Class: IBM::Cloud::SDK::VPC::INSTANCE::Actions

Inherits:
VPCCollection show all
Defined in:
lib/ibm/cloud/sdk/vpc/instance/actions.rb

Overview

Actions for an instance.

Instance Attribute Summary

Attributes included from IBM::Cloud::SDKHTTP::BaseHTTPMixin

#endpoint

Attributes inherited from IBM::Cloud::SDKHTTP::BaseCollection

#connection, #endpoint, #logger, #token

Instance Method Summary collapse

Methods inherited from VPCCollection

#count, #has_count?, #params

Methods included from VpcHTTP

#metadata

Methods included from IBM::Cloud::SDKHTTP::BaseHTTPMixin

#adhoc, #delete, #get, #metadata, #patch, #post, #put, #unchecked_response, #url

Methods inherited from IBM::Cloud::SDKHTTP::BaseCollection

#all, #data, #fetch, #params, #reset_params

Constructor Details

#initialize(parent) ⇒ Actions



14
15
16
# File 'lib/ibm/cloud/sdk/vpc/instance/actions.rb', line 14

def initialize(parent)
  super(parent, 'actions')
end

Instance Method Details

#create(action, force: false) ⇒ Object

Send a custom action request.



38
39
40
41
42
43
44
# File 'lib/ibm/cloud/sdk/vpc/instance/actions.rb', line 38

def create(action, force: false)
  @logger.info("Sending action request for #{action} with force #{force}.")
  payload = { type: action }
  payload[:force] = force if force
  response = post(payload: payload)
  Action.new(response)
end

#reboot(force: false) ⇒ Object

Send an action request to reboot the instance.



31
32
33
# File 'lib/ibm/cloud/sdk/vpc/instance/actions.rb', line 31

def reboot(force: false)
  create('reboot', force: force)
end

#startObject

Send an action request to start the instance.



19
20
21
# File 'lib/ibm/cloud/sdk/vpc/instance/actions.rb', line 19

def start
  create('start')
end

#stop(force: false) ⇒ Object

Send an action request to stop the instance.



25
26
27
# File 'lib/ibm/cloud/sdk/vpc/instance/actions.rb', line 25

def stop(force: false)
  create('stop', force: force)
end