Class: Triglav::Model::Host

Inherits:
Base
  • Object
show all
Defined in:
lib/triglav/model.rb

Constant Summary

Constants inherited from Base

Base::API_ENDPOINT_MAP

Instance Attribute Summary

Attributes inherited from Base

#client, #info

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

build_params, create, #destroy, endpoint_for, #initialize, param, #revert, #show, #update

Constructor Details

This class inherits a constructor from Triglav::Model::Base

Class Method Details

.pathObject



101
102
103
# File 'lib/triglav/model.rb', line 101

def self.path
  'hosts'
end

Instance Method Details

#add_relation(service, role) ⇒ Object



105
106
107
108
109
110
111
112
113
114
# File 'lib/triglav/model.rb', line 105

def add_relation(service, role)
  endpoint = self.class.endpoint_for(:update, info.name)
  result   = client.dispatch_request(
    endpoint[:method],
    endpoint[:path],
    'host[host_relations_attributes][0][service_id]' => service.info.id,
    'host[host_relations_attributes][0][role_id]'    => role.info.id,
  )
  self.class.new(client: client, info: result[self.class.param])
end