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, ParentLinkType, Project, ProjectValidator, QueryRequest, QueryResponse, RecordSynchronizationWorkflow, RenameAttributeAction, RenameAttributeActionValidator, RenamesValidator, RetrievalRequest, RetrievalResponse, RowBase, SetDateShiftRootAction, 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, #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



69
70
71
72
73
74
75
76
# File 'lib/etna/clients/magma/client.rb', line 69

def query(query_request = QueryRequest.new)
  json = nil
  @etna_client.post('/query', query_request) do |res|
    json = JSON.parse(res.body)
  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
# File 'lib/etna/clients/magma/client.rb', line 58

def retrieve(retrieval_request = RetrievalRequest.new)
  json = nil
  @etna_client.post('/retrieve', retrieval_request) do |res|
    json = JSON.parse(res.body)
  end

  RetrievalResponse.new(json)
end

#update(update_request = UpdateRequest.new) ⇒ Object



78
79
80
81
82
83
84
85
# File 'lib/etna/clients/magma/client.rb', line 78

def update(update_request = UpdateRequest.new)
  json = nil
  @etna_client.multipart_post('/update', update_request.encode_multipart_content) do |res|
    json = JSON.parse(res.body)
  end

  UpdateResponse.new(json)
end

#update_json(update_request = UpdateRequest.new) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/etna/clients/magma/client.rb', line 87

def update_json(update_request = UpdateRequest.new)
  json = nil
  @etna_client.post('/update', update_request) do |res|
    json = JSON.parse(res.body)
  end

  UpdateResponse.new(json)
end

#update_model(update_model_request = UpdateModelRequest.new) ⇒ Object



96
97
98
99
100
101
102
103
# File 'lib/etna/clients/magma/client.rb', line 96

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

  UpdateModelResponse.new(json)
end