Class: Weavr::Service

Inherits:
Resource show all
Defined in:
lib/weavr/resource/service.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

child_resources, #connection, extract_class_params, load_definitions!, predefine_class, receive, #receive!, #refresh!, #resource_action

Class Method Details

.labelObject



3
# File 'lib/weavr/resource/service.rb', line 3

def self.label() 'ServiceInfo' ; end

Instance Method Details

#createObject



11
12
13
# File 'lib/weavr/resource/service.rb', line 11

def create
  resource_action(:post, self.class.label => { service_name: service_name })
end

#installObject



20
21
22
# File 'lib/weavr/resource/service.rb', line 20

def install
  to_state'INSTALLED'
end

#startObject



28
29
30
# File 'lib/weavr/resource/service.rb', line 28

def start
  to_state 'STARTED'
end

#stopObject



24
25
26
# File 'lib/weavr/resource/service.rb', line 24

def stop
  to_state 'INSTALLED'
end

#to_state(state) ⇒ Object



15
16
17
18
# File 'lib/weavr/resource/service.rb', line 15

def to_state state
  res = resource_action(:put, RequestInfo: { context: "Transition to #{state}" }, Body: { ServiceInfo: { state: state } })
  Request.receive(res || { })
end