Class: IBM::Cloud::SDK::VPC::Keys

Inherits:
BaseCollection show all
Defined in:
lib/ibm/cloud/sdk/vpc/keys.rb

Overview

A collection of SSH keys.

Instance Attribute Summary

Attributes inherited from BaseVPC

#connection, #endpoint, #logger

Instance Method Summary collapse

Methods inherited from BaseCollection

#count, #data, #has_count?, #params

Methods inherited from BaseVPC

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

Constructor Details

#initialize(parent) ⇒ Keys

Returns a new instance of Keys.



10
11
12
# File 'lib/ibm/cloud/sdk/vpc/keys.rb', line 10

def initialize(parent)
  super(parent, 'keys', child_class: Key)
end

Instance Method Details

#all(resource_id = nil) ⇒ Object



20
21
22
# File 'lib/ibm/cloud/sdk/vpc/keys.rb', line 20

def all(resource_id = nil)
  fetch(resource_id: resource_id).subkey(@array_key)
end

#create(name, public_key, resource_group: nil, type: nil) ⇒ Object

:reek:FeatureEnvy



25
26
27
28
29
30
# File 'lib/ibm/cloud/sdk/vpc/keys.rb', line 25

def create(name, public_key, resource_group: nil, type: nil)
  payload = { name: name, public_key: public_key }
  payload[:resource_group] = resource_group if resource_group
  payload[:type] = type if type
  post(payload)
end

#fetch(resource_id: nil) ⇒ Object



14
15
16
17
18
# File 'lib/ibm/cloud/sdk/vpc/keys.rb', line 14

def fetch(resource_id: nil)
  params = {}
  params['resource_group.id'] = resource_id if resource_id
  get(params: params)
end

#key(id) ⇒ Object



32
33
34
# File 'lib/ibm/cloud/sdk/vpc/keys.rb', line 32

def key(id)
  Key.new(self, id)
end