Class: Ey::Core::Client::ClusterComponent

Inherits:
Model
  • Object
show all
Extended by:
Associations
Defined in:
lib/vendor/core/ey-core/models/cluster_component.rb

Instance Method Summary collapse

Methods included from Associations

assoc_accessor, assoc_coverage, assoc_reader, assoc_writer, associations, collection_reader

Methods inherited from Model

#destroy, range_parser, #save, #update!, #url

Instance Method Details

#connect(destination, configuration = {}) ⇒ Object

Parameters:



23
24
25
26
27
# File 'lib/vendor/core/ey-core/models/cluster_component.rb', line 23

def connect(destination, configuration={})
  requires :identity

  self.connection.connectors.create(source: self, destination: destination, configuration: configuration)
end

#run(action, params = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/vendor/core/ey-core/models/cluster_component.rb', line 29

def run(action, params={})
  requires :identity

  response = self.connection.run_cluster_component_action(
    "action"            => action,
    "cluster_component" => self.identity,
    "task"              => params,
  )
  connection.requests.new(response.body["request"])
end

#save!Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/vendor/core/ey-core/models/cluster_component.rb', line 40

def save!
  params = {
    "url"               => self.collection.url,
    "component"         => self.component_id,
    "cluster"           => self.cluster_id,
    "cluster_component" => {
      "configuration" => configuration,
    },
  }

  if new_record?
    merge_attributes(self.connection.create_cluster_component(params).body["cluster_component"])
  else
    params = {
      "id" => id,
      "cluster_component" => {
        "configuration" => configuration,
      }
    }
    merge_attributes(self.connection.update_cluster_component(params).body["cluster_component"])
  end
end