Class: Etna::Clients::Magma

Inherits:
Object
  • Object
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/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/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

Defined Under Namespace

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host:, token:, persistent: true, ignore_ssl: false) ⇒ Magma

Returns a new instance of Magma.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/etna/clients/magma/client.rb', line 11

def initialize(host:, token:, persistent: true, ignore_ssl: false)
  raise 'Magma client configuration is missing host.' unless host
  raise 'Magma client configuration is missing token.' unless token
  @etna_client = ::Etna::Client.new(
    host,
    token,
    routes_available: false,
    persistent: persistent,
    ignore_ssl: ignore_ssl)
  @host = host
  @token = token
  @ignore_ssl = ignore_ssl
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



10
11
12
# File 'lib/etna/clients/magma/client.rb', line 10

def host
  @host
end

#ignore_sslObject (readonly)

Returns the value of attribute ignore_ssl.



10
11
12
# File 'lib/etna/clients/magma/client.rb', line 10

def ignore_ssl
  @ignore_ssl
end

#tokenObject (readonly)

Returns the value of attribute token.



10
11
12
# File 'lib/etna/clients/magma/client.rb', line 10

def token
  @token
end

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



43
44
45
46
47
48
49
50
# File 'lib/etna/clients/magma/client.rb', line 43

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"



32
33
34
35
36
37
38
39
# File 'lib/etna/clients/magma/client.rb', line 32

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



52
53
54
55
56
57
58
59
# File 'lib/etna/clients/magma/client.rb', line 52

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



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

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



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

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