ibm-cloud-sdk 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49b6c34b47c964d6025eb8ca01efc3221fe33603c1c56b3e86167925f6132f60
4
- data.tar.gz: df5e08b1f01c0e05fbec5e8f5887139dde7210be53b2cf538b0357b7efe5f0a1
3
+ metadata.gz: 3e549ed1f265dba2b7b112602e225a10509451bffd348c7b04e0aefefe11a712
4
+ data.tar.gz: d342b3a1382bd87a650010b8558a1ce183eb9eb0f52081f8bfdbf4ec1ecf3bec
5
5
  SHA512:
6
- metadata.gz: afe2bfaae5cb2a853cd7ba2523a2aed7f0da6f6c319d1c2d730993ab5dc93613e928a423a0a7e0310023e96ad71aaa2f8129b5908d0c767e3679fdae8fa063ec
7
- data.tar.gz: 91d9e41682d13a1671d63c57fb2a4620b8b5f4d001c055036b7942b60a1e57b9e8a348a4615866851ff09389f6ed868ce7a62eff15b85c7bc8d564559f1180c2
6
+ metadata.gz: 689e9dd7cbb37ebea1f48f04fd587560d7b9ed39dd625e860845aee646d02fb0077ea233c2e3d88ed99a4051d22b52c485c5ebc186c190b44875ecef8c1a8862
7
+ data.tar.gz: 5ee30dca7e7d6e7a141e44094f2de5f181b50cbeecc941b81da8589e639d07bb0f39555e1fd8be1dca2263ad46dcbac7eb4c80b5164ef60b6d5005126aaf1887
@@ -1,6 +1,9 @@
1
1
  # Changelog
2
2
  All notable changes to the gem ibm-cloud-sdk-ruby will be documented here.
3
3
 
4
+ ## v0.1.8 - 2020-10-01
5
+ - Add second level instances
6
+
4
7
  ## v0.1.7 - 2020-09-28
5
8
  - Added Logging in IBM Cloud
6
9
  - Add VCR to vpc spec
@@ -1,7 +1,7 @@
1
1
  module IBM
2
2
  module Cloud
3
3
  module SDK
4
- VERSION = "0.1.7"
4
+ VERSION = "0.1.8"
5
5
  end
6
6
  end
7
7
  end
@@ -1,6 +1,8 @@
1
1
  # typed: true
2
2
  # frozen_string_literal: true
3
3
 
4
+ require_relative('base_mixins/has_child')
5
+
4
6
  module IBM
5
7
  module Cloud
6
8
  module SDK
@@ -21,6 +23,8 @@ module IBM
21
23
  @array_key ||= array_key
22
24
  @instance ||= child_class
23
25
 
26
+ (class << self; include ChildMixin; end) if child_class
27
+
24
28
  super(parent, endpoint)
25
29
  end
26
30
 
@@ -66,7 +70,7 @@ module IBM
66
70
  # Get the total count if it exists in the response. Returns nil otherwise.
67
71
  # @return [Integer] The total count reuturned by the server.
68
72
  def count
69
- fetch.json&.fetch(:total_count)
73
+ fetch.json&.fetch(:total_count, nil)
70
74
  end
71
75
 
72
76
  # A generic post method to create a resource on the collection.
@@ -77,11 +81,6 @@ module IBM
77
81
  adhoc(method: 'post', payload_type: payload_type, payload: payload)
78
82
  end
79
83
 
80
- # Access a specific instance by either id or name depending on API.
81
- def instance(id)
82
- @instance.new(self, id)
83
- end
84
-
85
84
  private
86
85
 
87
86
  # Create a generator that removes the need for pagination.
@@ -0,0 +1,27 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module IBM
5
+ module Cloud
6
+ module SDK
7
+ # Access a specific instance by either id or name depending on API.
8
+ module ChildMixin
9
+ # Get an instance of the collection object.
10
+ # @param id [String] ID of Name to search on depending on API.
11
+ # @return [] The instance object.
12
+ def instance(id)
13
+ @instance.new(self, id)
14
+ end
15
+
16
+ # Return the first_instance returned from a collection get.
17
+ def first_instance
18
+ result = params(limit: 1).all.first
19
+ return nil unless result
20
+ return nil unless result.key?(:id)
21
+
22
+ instance(result.fetch(:id))
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -5,7 +5,7 @@ module IBM
5
5
  module Cloud
6
6
  module SDK
7
7
  module VPC
8
- module INSTANCES
8
+ module INSTANCE
9
9
  # Actions for an instance.
10
10
  class Actions < BaseCollection
11
11
  def initialize(parent)
@@ -5,7 +5,7 @@ module IBM
5
5
  module Cloud
6
6
  module SDK
7
7
  module VPC
8
- module INSTANCES
8
+ module INSTANCE
9
9
  # Get a Floating IP.
10
10
  class FloatingIps < BaseCollection
11
11
  def initialize(parent)
@@ -7,7 +7,7 @@ module IBM
7
7
  module Cloud
8
8
  module SDK
9
9
  module VPC
10
- module INSTANCES
10
+ module INSTANCE
11
11
  # All netowrk interfaces.
12
12
  class NetworkInterfaces < BaseCollection
13
13
  def initialize(parent)
@@ -5,7 +5,7 @@ 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
10
  class VolumeAttachments < BaseCollection
11
11
  def initialize(parent)
@@ -50,10 +50,6 @@ module IBM
50
50
  INSTANCE::VolumeAttachments.new(self)
51
51
  end
52
52
 
53
- def profiles
54
- INSTANCE::Profiles.new(self)
55
- end
56
-
57
53
  def initialization
58
54
  adhoc(method: 'get', path: 'initialization').json
59
55
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibm-cloud-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - IBM Cloud Developers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-29 00:00:00.000000000 Z
11
+ date: 2020-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -69,6 +69,7 @@ files:
69
69
  - lib/ibm/cloud/sdk/vpc.rb
70
70
  - lib/ibm/cloud/sdk/vpc/base_collection.rb
71
71
  - lib/ibm/cloud/sdk/vpc/base_instance.rb
72
+ - lib/ibm/cloud/sdk/vpc/base_mixins/has_child.rb
72
73
  - lib/ibm/cloud/sdk/vpc/base_vpc.rb
73
74
  - lib/ibm/cloud/sdk/vpc/cloud_sdk.rb
74
75
  - lib/ibm/cloud/sdk/vpc/exceptions.rb
@@ -111,7 +112,7 @@ licenses:
111
112
  - '"Apache-2.0"'
112
113
  metadata:
113
114
  homepage_uri: https://github.com/IBM-Cloud/ibm-cloud-sdk-ruby
114
- changelog_uri: https://github.com/IBM-Cloud/ibm-cloud-sdk-ruby/blob/v0.1.7/CHANGELOG.md
115
+ changelog_uri: https://github.com/IBM-Cloud/ibm-cloud-sdk-ruby/blob/v0.1.8/CHANGELOG.md
115
116
  post_install_message:
116
117
  rdoc_options: []
117
118
  require_paths: