Class: Etna::Clients::Magma

Inherits:
BaseClient show all
Defined in:
lib/etna/clients/magma/client.rb,
lib/etna/clients/magma/models.rb,
lib/etna/clients/magma/formatting/models_csv.rb,
lib/etna/clients/magma/workflows/crud_workflow.rb,
lib/etna/clients/magma/formatting/models_odm_xml.rb,
lib/etna/clients/magma/formatting/models_odm_xml.rb,
lib/etna/clients/magma/workflows/json_converters.rb,
lib/etna/clients/magma/workflows/json_validators.rb,
lib/etna/clients/magma/workflows/file_linking_workflow.rb,
lib/etna/clients/magma/workflows/create_project_workflow.rb,
lib/etna/clients/magma/workflows/walk_model_tree_workflow.rb,
lib/etna/clients/magma/workflows/add_project_models_workflow.rb,
lib/etna/clients/magma/workflows/file_attributes_blank_workflow.rb,
lib/etna/clients/magma/workflows/model_synchronization_workflow.rb,
lib/etna/clients/magma/workflows/record_synchronization_workflow.rb,
lib/etna/clients/magma/workflows/ensure_containing_record_workflow.rb,
lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb,
lib/etna/clients/magma/workflows/attribute_actions_from_json_workflow.rb,
lib/etna/clients/magma/workflows/materialize_magma_record_files_workflow.rb

Defined Under Namespace

Modules: ModelsCsv, ModelsOdmXml Classes: AddAttributeAction, AddAttributeActionValidator, AddLinkAction, AddLinkActionValidator, AddLinkDefinition, AddModelAction, AddModelValidator, AddProjectAction, AddProjectModelsWorkflow, Attribute, AttributeActionValidatorBase, AttributeActionsConverter, AttributeActionsFromJsonWorkflow, AttributeActionsValidator, AttributeType, AttributeValidation, AttributeValidationType, AttributeValidator, Attributes, ConverterBase, CreateProjectWorkflow, Dictionary, Documents, EnsureContainingRecordWorkflow, FileAttributesBlankWorkflow, FileLinkingWorkflow, MagmaCrudWorkflow, MaterializeDataWorkflow, Model, ModelSynchronizationWorkflow, Models, Pager, ParentLinkType, Project, ProjectValidator, QueryRequest, QueryResponse, RecordSynchronizationWorkflow, RenameAttributeAction, RenameAttributeActionValidator, RenamesValidator, RetrievalRequest, RetrievalResponse, RowBase, SetDateShiftRootAction, SetModelTemplateAction, SimpleFileLinkingWorkflow, Template, UpdateAttributeAction, UpdateAttributeActionValidator, UpdateAttributesFromCsvWorkflowBase, UpdateAttributesFromCsvWorkflowMultiModel, UpdateAttributesFromCsvWorkflowSingleModel, UpdateModelRequest, UpdateModelResponse, UpdateRequest, UpdateResponse, ValidatorBase, WalkModelTreeWorkflow

Instance Attribute Summary

Attributes inherited from BaseClient

#host, #ignore_ssl, #token

Instance Method Summary collapse

Methods inherited from BaseClient

#initialize, #safe_parse, #token_expired?, #token_will_expire?

Constructor Details

This class inherits a constructor from Etna::Clients::BaseClient

Instance Method Details

#query(query_request = QueryRequest.new) ⇒ Object

This 'query' end point is used to fetch data by graph query See question.rb for more detail



73
74
75
76
77
78
79
80
# File 'lib/etna/clients/magma/client.rb', line 73

def query(query_request = QueryRequest.new)
  json = nil
  @etna_client.post('/query', query_request) do |res|
    json = safe_parse(res)
  end

  QueryResponse.new(json)
end

#retrieve(retrieval_request = RetrievalRequest.new) ⇒ Object

This endpoint returns models and records by name: e.g. params: { model_name: "model_one", # or "all" record_names: [ "rn1", "rn2" ], # or "all", attribute_names: "all" }



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/etna/clients/magma/client.rb', line 58

def retrieve(retrieval_request = RetrievalRequest.new)
  if retrieval_request.is_a?(Hash)
    retrieval_request = RetrievalRequest.new(retrieval_request)
  end

  json = nil
  @etna_client.post('/retrieve', retrieval_request) do |res|
    json = safe_parse(res)
  end

  RetrievalResponse.new(json)
end

#set_flags(project_name:, flags:) ⇒ Object



216
217
218
219
220
221
222
223
# File 'lib/etna/clients/magma/client.rb', line 216

def set_flags(project_name:, flags:)
  json = nil
  @etna_client.post("/flags/#{project_name}", { flags: flags }) do |res|
    json = safe_parse(res)
  end

  json
end

#update(update_request = UpdateRequest.new) ⇒ Object



82
83
84
85
86
87
88
89
90
# File 'lib/etna/clients/magma/client.rb', line 82

def update(update_request = UpdateRequest.new)
  json = nil

  @etna_client.multipart_post('/update', update_request.encode_multipart_content) do |res|
    json = safe_parse(res)
  end

  UpdateResponse.new(json)
end

#update_json(update_request = UpdateRequest.new, page_size = nil) ⇒ Object



193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/etna/clients/magma/client.rb', line 193

def update_json(update_request = UpdateRequest.new, page_size=nil)
  json = nil

  if page_size
    return Etna::Clients::Magma::Pager.new(self, update_request, page_size).response
  end

  @etna_client.post('/update', update_request) do |res|
    json = safe_parse(res)
  end

  UpdateResponse.new(json)
end

#update_model(update_model_request = UpdateModelRequest.new) ⇒ Object



207
208
209
210
211
212
213
214
# File 'lib/etna/clients/magma/client.rb', line 207

def update_model(update_model_request = UpdateModelRequest.new)
  json = nil
  @etna_client.post('/update_model', update_model_request) do |res|
    json = safe_parse(res)
  end

  UpdateModelResponse.new(json)
end