ibm-cloud-sdk 0.1.5 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/Gemfile +2 -0
  4. data/ibm-cloud-sdk.gemspec +1 -1
  5. data/lib/ibm/cloud/sdk.rb +3 -1
  6. data/lib/ibm/cloud/sdk/iam.rb +5 -0
  7. data/lib/ibm/cloud/sdk/logging.rb +21 -0
  8. data/lib/ibm/cloud/sdk/null_logger.rb +19 -0
  9. data/lib/ibm/cloud/sdk/power_iaas.rb +125 -10
  10. data/lib/ibm/cloud/sdk/resource_controller.rb +4 -0
  11. data/lib/ibm/cloud/sdk/tags.rb +28 -0
  12. data/lib/ibm/cloud/sdk/tags/http.rb +5 -0
  13. data/lib/ibm/cloud/sdk/tags/http/tag_collection.rb +99 -0
  14. data/lib/ibm/cloud/sdk/version.rb +1 -1
  15. data/lib/ibm/cloud/sdk/vpc.rb +8 -6
  16. data/lib/ibm/cloud/sdk/vpc/floatingips.rb +2 -2
  17. data/lib/ibm/cloud/sdk/vpc/flowlogcollectors.rb +2 -2
  18. data/lib/ibm/cloud/sdk/vpc/http.rb +7 -0
  19. data/lib/ibm/cloud/sdk/vpc/http/vpc_collection.rb +82 -0
  20. data/lib/ibm/cloud/sdk/vpc/http/vpc_http.rb +29 -0
  21. data/lib/ibm/cloud/sdk/vpc/http/vpc_instance.rb +30 -0
  22. data/lib/ibm/cloud/sdk/vpc/ike_policies.rb +2 -2
  23. data/lib/ibm/cloud/sdk/vpc/images.rb +2 -2
  24. data/lib/ibm/cloud/sdk/vpc/instance/actions.rb +2 -2
  25. data/lib/ibm/cloud/sdk/vpc/instance/floating_ips.rb +3 -3
  26. data/lib/ibm/cloud/sdk/vpc/instance/network_interfaces.rb +4 -29
  27. data/lib/ibm/cloud/sdk/vpc/instance/volume_attachments.rb +4 -27
  28. data/lib/ibm/cloud/sdk/vpc/instance_profiles.rb +3 -3
  29. data/lib/ibm/cloud/sdk/vpc/instances.rb +43 -3
  30. data/lib/ibm/cloud/sdk/vpc/ipsec_policies.rb +2 -2
  31. data/lib/ibm/cloud/sdk/vpc/keys.rb +2 -24
  32. data/lib/ibm/cloud/sdk/vpc/load_balancer.rb +1 -1
  33. data/lib/ibm/cloud/sdk/vpc/load_balancer/listeners.rb +2 -2
  34. data/lib/ibm/cloud/sdk/vpc/load_balancer/members.rb +2 -2
  35. data/lib/ibm/cloud/sdk/vpc/load_balancer/policies.rb +2 -2
  36. data/lib/ibm/cloud/sdk/vpc/load_balancer/pools.rb +2 -2
  37. data/lib/ibm/cloud/sdk/vpc/load_balancer/rules.rb +2 -2
  38. data/lib/ibm/cloud/sdk/vpc/load_balancers.rb +1 -1
  39. data/lib/ibm/cloud/sdk/vpc/network_acls.rb +4 -4
  40. data/lib/ibm/cloud/sdk/vpc/operating_systems.rb +2 -2
  41. data/lib/ibm/cloud/sdk/vpc/public_gateways.rb +2 -2
  42. data/lib/ibm/cloud/sdk/vpc/regions.rb +4 -4
  43. data/lib/ibm/cloud/sdk/vpc/security_groups.rb +6 -6
  44. data/lib/ibm/cloud/sdk/vpc/subnets.rb +2 -2
  45. data/lib/ibm/cloud/sdk/vpc/volume_profiles.rb +2 -2
  46. data/lib/ibm/cloud/sdk/vpc/volumes.rb +2 -2
  47. data/lib/ibm/cloud/sdk/vpc/vpcs.rb +6 -6
  48. data/lib/ibm/cloud/sdk/vpc/vpn_gateway/connections.rb +2 -2
  49. data/lib/ibm/cloud/sdk/vpc/vpn_gateway/local_cidrs.rb +2 -2
  50. data/lib/ibm/cloud/sdk/vpc/vpn_gateway/peer_cidrs.rb +2 -2
  51. data/lib/ibm/cloud/sdk/vpc/vpn_gateways.rb +2 -2
  52. data/lib/ibm/cloud/sdk_http.rb +16 -0
  53. data/lib/ibm/cloud/sdk_http/base_collection.rb +121 -0
  54. data/lib/ibm/cloud/sdk_http/base_http_mixin.rb +63 -0
  55. data/lib/ibm/cloud/sdk_http/base_instance.rb +55 -0
  56. data/lib/ibm/cloud/sdk_http/connection.rb +32 -0
  57. data/lib/ibm/cloud/sdk_http/exceptions.rb +31 -0
  58. data/lib/ibm/cloud/sdk_http/has_child.rb +23 -0
  59. data/lib/ibm/cloud/sdk_http/iam_token.rb +53 -0
  60. data/lib/ibm/cloud/sdk_http/sdk_response.rb +132 -0
  61. data/lib/ibm/cloud_sdk.rb +39 -0
  62. metadata +23 -11
  63. data/lib/ibm/cloud/sdk/vpc/base_collection.rb +0 -108
  64. data/lib/ibm/cloud/sdk/vpc/base_instance.rb +0 -23
  65. data/lib/ibm/cloud/sdk/vpc/base_vpc.rb +0 -61
  66. data/lib/ibm/cloud/sdk/vpc/cloud_sdk.rb +0 -33
  67. data/lib/ibm/cloud/sdk/vpc/helpers/connection.rb +0 -66
  68. data/lib/ibm/cloud/sdk/vpc/helpers/response.rb +0 -92
  69. data/lib/ibm/cloud/sdk/vpc/instance.rb +0 -35
@@ -5,39 +5,16 @@ module IBM
5
5
  module Cloud
6
6
  module SDK
7
7
  module VPC
8
- module INSTANCES
8
+ module INSTANCE
9
9
  # Get all attached volumes.
10
- class VolumeAttachments < BaseVPC
10
+ class VolumeAttachments < VPCCollection
11
11
  def initialize(parent)
12
- super(parent, 'volume_attachments')
13
- end
14
-
15
- def all
16
- get
17
- end
18
-
19
- def create(payload)
20
- post(payload)
21
- end
22
-
23
- def instance(id)
24
- VolumeAttachment.new(self, id)
12
+ super(parent, 'volume_attachments', child_class: VolumeAttachment)
25
13
  end
26
14
  end
27
15
 
28
16
  # A single attached volume.
29
- class VolumeAttachment < BaseVPC
30
- def details
31
- get
32
- end
33
-
34
- def update(payload)
35
- patch(payload)
36
- end
37
-
38
- def remove
39
- delete
40
- end
17
+ class VolumeAttachment < VPCInstance
41
18
  end
42
19
  end
43
20
  end
@@ -6,14 +6,14 @@ module IBM
6
6
  module SDK
7
7
  module VPC
8
8
  # Work with multiple profiles.
9
- class InstanceProfiles < BaseCollection
9
+ class InstanceProfiles < VPCCollection
10
10
  def initialize(parent)
11
- super(parent, 'instance/profiles', child_class: Profile, array_key: 'profiles')
11
+ super(parent, 'instance/profiles', child_class: InstanceProfile, array_key: 'profiles')
12
12
  end
13
13
  end
14
14
 
15
15
  # Get a single profile.
16
- class Profile < BaseInstance
16
+ class InstanceProfile < VPCInstance
17
17
  end
18
18
  end
19
19
  end
@@ -1,7 +1,9 @@
1
1
  # typed: true
2
2
  # frozen_string_literal: true
3
3
 
4
- require_relative('instance')
4
+ require_relative 'instance/actions'
5
+ require_relative 'instance/network_interfaces'
6
+ require_relative 'instance/volume_attachments'
5
7
 
6
8
  module IBM
7
9
  module Cloud
@@ -9,9 +11,47 @@ module IBM
9
11
  # Work with VPC instances.
10
12
  module VPC
11
13
  # Work with multiple VM instances.
12
- class Instances < BaseCollection
14
+ class Instances < VPCCollection
13
15
  def initialize(parent)
14
- super(parent, 'instances', child_class: INSTANCES::Instance)
16
+ super(parent, 'instances', child_class: Instance)
17
+ end
18
+
19
+ # A chainable method to set query filters on the collection.
20
+ # @example vpc.images.params(limit: 1).all
21
+ #
22
+ # @param start [String] A server-supplied token determining what resource to start the page on.
23
+ # @param limit [Integer] The number of resources to return on a page allowed values are between 1 and 100
24
+ # @param name [String] Filters the collection to resources with the exact specified name
25
+ # @param vpc_id [String] Filters the collection to resources in the VPC with the specified identifier
26
+ # @param vpc_crn [String] Filters the collection to resources in the VPC with the specified CRN
27
+ # @param vpc_name [String] Filters the collection to resources in the VPC with the exact specified name
28
+ # @return [BaseCollection] This class with the param instance variable set.
29
+ def params(start: nil, limit: nil, name: nil, vpc_id: nil, vpc_crn: nil, vpc_name: nil)
30
+ super(start: start, limit: limit)
31
+ @params['name'] = name if name
32
+ @params['vpc.id'] = vpc_id if vpc_id
33
+ @params['vpc.crn'] = vpc_crn if vpc_crn
34
+ @params['vpc.name'] = vpc_name if vpc_name
35
+ self
36
+ end
37
+ end
38
+
39
+ # Work with a single instance.
40
+ class Instance < VPCInstance
41
+ def actions
42
+ INSTANCE::Actions.new(self)
43
+ end
44
+
45
+ def network_interfaces
46
+ INSTANCE::NetworkInterfaces.new(self)
47
+ end
48
+
49
+ def volume_attachments
50
+ INSTANCE::VolumeAttachments.new(self)
51
+ end
52
+
53
+ def initialization
54
+ adhoc(method: 'get', path: 'initialization').json
15
55
  end
16
56
  end
17
57
  end
@@ -6,14 +6,14 @@ module IBM
6
6
  module SDK
7
7
  module VPC
8
8
  # A list of IPSecPolicy
9
- class IPSecPolicies < BaseCollection
9
+ class IPSecPolicies < VPCCollection
10
10
  def initialize(parent)
11
11
  super(parent, 'ike_policies', child_class: IPSecPolicy)
12
12
  end
13
13
  end
14
14
 
15
15
  # A single IPSecPolicy
16
- class IPSecPolicy < BaseInstance
16
+ class IPSecPolicy < VPCInstance
17
17
  def connections
18
18
  get('connections')
19
19
  end
@@ -6,36 +6,14 @@ module IBM
6
6
  module SDK
7
7
  module VPC
8
8
  # A collection of SSH keys.
9
- class Keys < BaseCollection
9
+ class Keys < VPCCollection
10
10
  def initialize(parent)
11
11
  super(parent, 'keys', child_class: Key)
12
12
  end
13
-
14
- def fetch(resource_id: nil)
15
- params = {}
16
- params['resource_group.id'] = resource_id if resource_id
17
- get(params: params)
18
- end
19
-
20
- def all(resource_id = nil)
21
- fetch(resource_id: resource_id).subkey(@array_key)
22
- end
23
-
24
- # :reek:FeatureEnvy
25
- def create(name, public_key, resource_group: nil, type: nil)
26
- payload = { name: name, public_key: public_key }
27
- payload[:resource_group] = resource_group if resource_group
28
- payload[:type] = type if type
29
- post(payload)
30
- end
31
-
32
- def key(id)
33
- Key.new(self, id)
34
- end
35
13
  end
36
14
 
37
15
  # A single key.
38
- class Key < BaseInstance
16
+ class Key < VPCInstance
39
17
  end
40
18
  end
41
19
  end
@@ -8,7 +8,7 @@ module IBM
8
8
  module SDK
9
9
  module VPC
10
10
  # A single LoadBalancer
11
- class LoadBalancer < BaseInstance
11
+ class LoadBalancer < VPCInstance
12
12
  def statistics
13
13
  get('statistics')
14
14
  end
@@ -9,7 +9,7 @@ module IBM
9
9
  module VPC
10
10
  module LOADBALANCER
11
11
  # A list of Listener
12
- class Listeners < BaseCollection
12
+ class Listeners < VPCCollection
13
13
  def initialize(parent)
14
14
  @array_key = 'listeners'
15
15
  @instance = Listener
@@ -18,7 +18,7 @@ module IBM
18
18
  end
19
19
 
20
20
  # A single Listener
21
- class Listener < BaseInstance
21
+ class Listener < VPCInstance
22
22
  def policies
23
23
  LOADBALANCER::Policies.new(self)
24
24
  end
@@ -6,7 +6,7 @@ module IBM
6
6
  module SDK
7
7
  module VPC
8
8
  # A list of Member
9
- class Members < BaseCollection
9
+ class Members < VPCCollection
10
10
  def initialize(parent)
11
11
  @array_key = 'members'
12
12
  @instance = Member
@@ -15,7 +15,7 @@ module IBM
15
15
  end
16
16
 
17
17
  # A single Member
18
- class Member < BaseInstance
18
+ class Member < VPCInstance
19
19
  end
20
20
  end
21
21
  end
@@ -9,7 +9,7 @@ module IBM
9
9
  module VPC
10
10
  module LOADBALANCER
11
11
  # A list of Policies
12
- class Policies < BaseCollection
12
+ class Policies < VPCCollection
13
13
  def initialize(parent)
14
14
  @array_key = 'policies'
15
15
  @instance = Policy
@@ -18,7 +18,7 @@ module IBM
18
18
  end
19
19
 
20
20
  # A single Policy
21
- class Policy < BaseInstance
21
+ class Policy < VPCInstance
22
22
  def rules
23
23
  Rules.new(self)
24
24
  end
@@ -8,7 +8,7 @@ module IBM
8
8
  module SDK
9
9
  module VPC
10
10
  # A list of Pool
11
- class Pools < BaseCollection
11
+ class Pools < VPCCollection
12
12
  def initialize(parent)
13
13
  @array_key = 'pools'
14
14
  @instance = Pool
@@ -17,7 +17,7 @@ module IBM
17
17
  end
18
18
 
19
19
  # A single Pool
20
- class Pool < BaseInstance
20
+ class Pool < VPCInstance
21
21
  def members
22
22
  Members.new(self)
23
23
  end
@@ -7,7 +7,7 @@ module IBM
7
7
  module VPC
8
8
  module LOADBALANCER
9
9
  # A list of Rule
10
- class Rules < BaseCollection
10
+ class Rules < VPCCollection
11
11
  def initialize(parent)
12
12
  @array_key = 'rules'
13
13
  @instance = Rule
@@ -16,7 +16,7 @@ module IBM
16
16
  end
17
17
 
18
18
  # A single Rule
19
- class Rule < BaseInstance
19
+ class Rule < VPCInstance
20
20
  end
21
21
  end
22
22
  end
@@ -8,7 +8,7 @@ module IBM
8
8
  module SDK
9
9
  module VPC
10
10
  # A list of LoadBalancer
11
- class LoadBalancers < BaseCollection
11
+ class LoadBalancers < VPCCollection
12
12
  def initialize(parent)
13
13
  super(parent, 'load_balancers', child_class: LoadBalancer)
14
14
  end
@@ -6,14 +6,14 @@ module IBM
6
6
  module SDK
7
7
  module VPC
8
8
  # A list of NetworkACL
9
- class NetworkACLs < BaseCollection
9
+ class NetworkACLs < VPCCollection
10
10
  def initialize(parent)
11
11
  super(parent, 'network_acls', child_class: NetworkACL)
12
12
  end
13
13
  end
14
14
 
15
15
  # A single NetworkACL
16
- class NetworkACL < BaseInstance
16
+ class NetworkACL < VPCInstance
17
17
  def rules
18
18
  NETWORKACL::Rules.new(self)
19
19
  end
@@ -21,7 +21,7 @@ module IBM
21
21
 
22
22
  module NETWORKACL
23
23
  # A list of NetworkACL
24
- class Rules < BaseCollection
24
+ class Rules < VPCCollection
25
25
  def initialize(parent)
26
26
  @array_key = 'network_acls'
27
27
  @instance = NetworkACL
@@ -30,7 +30,7 @@ module IBM
30
30
  end
31
31
 
32
32
  # A single NetworkACL
33
- class Rule < BaseInstance
33
+ class Rule < VPCInstance
34
34
  end
35
35
  end
36
36
  end
@@ -6,14 +6,14 @@ module IBM
6
6
  module SDK
7
7
  module VPC
8
8
  # A list of OperatingSystem
9
- class OperatingSystems < BaseCollection
9
+ class OperatingSystems < VPCCollection
10
10
  def initialize(parent)
11
11
  super(parent, 'operating_systems', child_class: OperatingSystem)
12
12
  end
13
13
  end
14
14
 
15
15
  # A single OperatingSystem
16
- class OperatingSystem < BaseInstance
16
+ class OperatingSystem < VPCInstance
17
17
  end
18
18
  end
19
19
  end
@@ -6,14 +6,14 @@ module IBM
6
6
  module SDK
7
7
  module VPC
8
8
  # A list of PublicGateway
9
- class PublicGateways < BaseCollection
9
+ class PublicGateways < VPCCollection
10
10
  def initialize(parent)
11
11
  super(parent, 'public_gateways', child_class: PublicGateway)
12
12
  end
13
13
  end
14
14
 
15
15
  # A single PublicGateway
16
- class PublicGateway < BaseInstance
16
+ class PublicGateway < VPCInstance
17
17
  end
18
18
  end
19
19
  end
@@ -6,28 +6,28 @@ module IBM
6
6
  module SDK
7
7
  module VPC
8
8
  # Work with VPC reqions
9
- class Regions < BaseCollection
9
+ class Regions < VPCCollection
10
10
  def initialize(parent)
11
11
  super(parent, 'regions', child_class: Region)
12
12
  end
13
13
  end
14
14
 
15
15
  # Work with a single region
16
- class Region < BaseInstance
16
+ class Region < VPCInstance
17
17
  def zones
18
18
  Zones.new(self)
19
19
  end
20
20
  end
21
21
 
22
22
  # Zones are included within a region.
23
- class Zones < BaseCollection
23
+ class Zones < VPCCollection
24
24
  def initialize(parent)
25
25
  super(parent, 'zones', child_class: Zone)
26
26
  end
27
27
  end
28
28
 
29
29
  # A single zone.
30
- class Zone < BaseVPC
30
+ class Zone < VPCInstance
31
31
  end
32
32
  end
33
33
  end
@@ -6,14 +6,14 @@ module IBM
6
6
  module SDK
7
7
  module VPC
8
8
  # Work with VPC reqions
9
- class SecurityGroups < BaseCollection
9
+ class SecurityGroups < VPCCollection
10
10
  def initialize(parent)
11
11
  super(parent, 'security_groups', child_class: SecurityGroup)
12
12
  end
13
13
  end
14
14
 
15
15
  # Work with VPC reqions
16
- class SecurityGroup < BaseCollection
16
+ class SecurityGroup < VPCInstance
17
17
  def network_interfaces
18
18
  SECURITYGROUP::NetworkInterfaces.new(self)
19
19
  end
@@ -21,25 +21,25 @@ module IBM
21
21
 
22
22
  module SECURITYGROUP
23
23
  # Work with interfaces associated with parent group.
24
- class NetworkInterfaces < BaseCollection
24
+ class NetworkInterfaces < VPCCollection
25
25
  def initialize(parent)
26
26
  super(parent, 'network_interfaces', child_class: NetworkInterface)
27
27
  end
28
28
  end
29
29
 
30
30
  # Work with a single rule.
31
- class NetworkInterface < BaseInstance
31
+ class NetworkInterface < VPCInstance
32
32
  end
33
33
 
34
34
  # Work with rules associated with parent group.
35
- class Rules < BaseCollection
35
+ class Rules < VPCCollection
36
36
  def initialize(parent)
37
37
  super(parent, 'rules', child_class: Rule)
38
38
  end
39
39
  end
40
40
 
41
41
  # Work with a single rule.
42
- class Rule < BaseInstance
42
+ class Rule < VPCInstance
43
43
  end
44
44
  end
45
45
  end
@@ -6,14 +6,14 @@ module IBM
6
6
  module SDK
7
7
  module VPC
8
8
  # A list of submetes
9
- class Subnets < BaseCollection
9
+ class Subnets < VPCCollection
10
10
  def initialize(parent)
11
11
  super(parent, 'subnets', child_class: Subnet)
12
12
  end
13
13
  end
14
14
 
15
15
  # A single subnet
16
- class Subnet < BaseInstance
16
+ class Subnet < VPCInstance
17
17
  end
18
18
  end
19
19
  end