pnap_rancher_api 1.0.6 → 2.0.1

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -4
  3. data/VERSION +1 -1
  4. data/docs/Cluster.md +3 -3
  5. data/docs/ClustersApi.md +6 -8
  6. data/docs/NodePool.md +2 -2
  7. data/docs/RancherClusterConfig.md +1 -1
  8. data/lib/pnap_rancher_api/api/clusters_api.rb +11 -7
  9. data/lib/pnap_rancher_api/api_client.rb +26 -23
  10. data/lib/pnap_rancher_api/api_error.rb +2 -1
  11. data/lib/pnap_rancher_api/configuration.rb +28 -9
  12. data/lib/pnap_rancher_api/models/cluster.rb +25 -24
  13. data/lib/pnap_rancher_api/models/delete_result.rb +18 -19
  14. data/lib/pnap_rancher_api/models/error.rb +16 -19
  15. data/lib/pnap_rancher_api/models/node.rb +14 -19
  16. data/lib/pnap_rancher_api/models/node_pool.rb +54 -20
  17. data/lib/pnap_rancher_api/models/rancher_cluster_certificates.rb +14 -19
  18. data/lib/pnap_rancher_api/models/rancher_cluster_config.rb +15 -20
  19. data/lib/pnap_rancher_api/models/rancher_server_metadata.rb +14 -19
  20. data/lib/pnap_rancher_api/models/ssh_config.rb +14 -19
  21. data/lib/pnap_rancher_api/models/workload_cluster_config.rb +16 -19
  22. data/lib/pnap_rancher_api/version.rb +1 -1
  23. data/lib/pnap_rancher_api.rb +1 -5
  24. data/pnap_rancher_api.gemspec +2 -2
  25. data/spec/api/clusters_api_spec.rb +7 -7
  26. data/spec/models/cluster_spec.rb +14 -12
  27. data/spec/models/delete_result_spec.rb +6 -4
  28. data/spec/models/error_spec.rb +6 -4
  29. data/spec/models/node_pool_spec.rb +9 -7
  30. data/spec/models/node_spec.rb +5 -3
  31. data/spec/models/rancher_cluster_certificates_spec.rb +7 -5
  32. data/spec/models/rancher_cluster_config_spec.rb +11 -9
  33. data/spec/models/rancher_server_metadata_spec.rb +7 -5
  34. data/spec/models/ssh_config_spec.rb +7 -5
  35. data/spec/models/workload_cluster_config_spec.rb +8 -6
  36. data/spec/spec_helper.rb +1 -1
  37. metadata +10 -30
  38. data/docs/ClusterConfiguration.md +0 -30
  39. data/docs/ClusterWorkloadConfiguration.md +0 -24
  40. data/docs/NodePoolSshConfig.md +0 -22
  41. data/docs/RancherClusterConfigCertificates.md +0 -22
  42. data/lib/pnap_rancher_api/models/cluster_configuration.rb +0 -290
  43. data/lib/pnap_rancher_api/models/cluster_workload_configuration.rb +0 -271
  44. data/lib/pnap_rancher_api/models/node_pool_ssh_config.rb +0 -253
  45. data/lib/pnap_rancher_api/models/rancher_cluster_config_certificates.rb +0 -247
  46. data/spec/api_client_spec.rb +0 -226
  47. data/spec/configuration_spec.rb +0 -42
  48. data/spec/models/cluster_configuration_spec.rb +0 -70
  49. data/spec/models/cluster_workload_configuration_spec.rb +0 -52
  50. data/spec/models/node_pool_ssh_config_spec.rb +0 -46
  51. data/spec/models/rancher_cluster_config_certificates_spec.rb +0 -46
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d1811b259151374d1b18fb602b9901d1cbb51cbf671d3124d04c5a60b578b0a
4
- data.tar.gz: 00af5779a3fdfad33e2c4253043e35ea7b9cae1f2cef650128393d40c43a6ce7
3
+ metadata.gz: ff82caa1a18507deffa96e60c2c296a224b9d672bebe2b01b25da7f20cda56aa
4
+ data.tar.gz: 0a27b1c04e52a13addd825dc2c15bb036f88ac6c8d6cc97c5c5d4b039a49648e
5
5
  SHA512:
6
- metadata.gz: aaf0c71405af1383e88993185794291cf6f45ae9d9d0f942b14c8097f62c62637276b18846305fa8a8d289a402071f176c9497ddcc9e898ac99991db4b63c6de
7
- data.tar.gz: 3c24a17b44ac417a628a9c932e9e75ff0fb444d83c85a8ce082a2a208f0f614b752548b2980fc02850e80ffc3916eb6e493077efe90062a0a9e2fde584acb4e6
6
+ metadata.gz: 1df0984d885c107cbb5fb223fd19b4654ee620177fed0130a6debb3d8a0f860a027448a6c4e221afcf28dec26c65c98b91d5c2af856936a413b9b41aa7a67702
7
+ data.tar.gz: 4609a6e41db3fc7a0c4cb313fa19e735d704d6f5c52977e981ecca7105772ff3713c73979731639a76852d3c5547f6013b5f591bc11bc63e41ab625f52edb968
data/README.md CHANGED
@@ -74,6 +74,8 @@ require 'pnap_rancher_api'
74
74
  RancherApi.configure do |config|
75
75
  # Configure OAuth2 access token for authorization: OAuth2
76
76
  config.access_token = 'YOUR ACCESS TOKEN'
77
+ # Configure a proc to get access tokens in lieu of the static access_token configuration
78
+ config.access_token_getter = -> { 'YOUR TOKEN GETTER PROC' }
77
79
  end
78
80
 
79
81
  api_instance = RancherApi::ClustersApi.new
@@ -128,16 +130,12 @@ Class | Method | HTTP request | Description
128
130
  ## Documentation for Models
129
131
 
130
132
  - [RancherApi::Cluster](docs/Cluster.md)
131
- - [RancherApi::ClusterConfiguration](docs/ClusterConfiguration.md)
132
- - [RancherApi::ClusterWorkloadConfiguration](docs/ClusterWorkloadConfiguration.md)
133
133
  - [RancherApi::DeleteResult](docs/DeleteResult.md)
134
134
  - [RancherApi::Error](docs/Error.md)
135
135
  - [RancherApi::Node](docs/Node.md)
136
136
  - [RancherApi::NodePool](docs/NodePool.md)
137
- - [RancherApi::NodePoolSshConfig](docs/NodePoolSshConfig.md)
138
137
  - [RancherApi::RancherClusterCertificates](docs/RancherClusterCertificates.md)
139
138
  - [RancherApi::RancherClusterConfig](docs/RancherClusterConfig.md)
140
- - [RancherApi::RancherClusterConfigCertificates](docs/RancherClusterConfigCertificates.md)
141
139
  - [RancherApi::RancherServerMetadata](docs/RancherServerMetadata.md)
142
140
  - [RancherApi::SshConfig](docs/SshConfig.md)
143
141
  - [RancherApi::WorkloadClusterConfig](docs/WorkloadClusterConfig.md)
@@ -146,6 +144,7 @@ Class | Method | HTTP request | Description
146
144
  ## Documentation for Authorization
147
145
 
148
146
 
147
+ Authentication schemes defined for the API:
149
148
  ### OAuth2
150
149
 
151
150
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.6
1
+ 2.0.1
data/docs/Cluster.md CHANGED
@@ -10,10 +10,10 @@
10
10
  | **location** | **String** | Deployment location. Cannot be changed once a cluster is created. Currently this field should be set to `PHX`, `ASH`, `SGP`, `NLD`, `CHI`, `SEA` or `AUS`. | |
11
11
  | **initial_cluster_version** | **String** | (Read-only) The Rancher version that was installed on the cluster during the first creation process. | [optional][readonly] |
12
12
  | **node_pools** | [**Array<NodePool>**](NodePool.md) | The node pools associated with the cluster. | [optional] |
13
- | **configuration** | [**ClusterConfiguration**](ClusterConfiguration.md) | | [optional] |
13
+ | **configuration** | [**RancherClusterConfig**](RancherClusterConfig.md) | | [optional] |
14
14
  | **metadata** | [**RancherServerMetadata**](RancherServerMetadata.md) | | [optional][readonly] |
15
- | **workload_configuration** | [**ClusterWorkloadConfiguration**](ClusterWorkloadConfiguration.md) | | [optional] |
16
- | **status_description** | **String** | The cluster status | [optional][readonly] |
15
+ | **workload_configuration** | [**WorkloadClusterConfig**](WorkloadClusterConfig.md) | | [optional] |
16
+ | **status_description** | **String** | (Read-Only) The cluster status | [optional][readonly] |
17
17
 
18
18
  ## Example
19
19
 
data/docs/ClustersApi.md CHANGED
@@ -216,7 +216,7 @@ end
216
216
 
217
217
  ## clusters_post
218
218
 
219
- > <Cluster> clusters_post(opts)
219
+ > <Cluster> clusters_post(cluster)
220
220
 
221
221
  Create a Rancher Server Deployment.
222
222
 
@@ -234,13 +234,11 @@ RancherApi.configure do |config|
234
234
  end
235
235
 
236
236
  api_instance = RancherApi::ClustersApi.new
237
- opts = {
238
- cluster: RancherApi::Cluster.new({location: 'PHX'}) # Cluster |
239
- }
237
+ cluster = RancherApi::Cluster.new({location: 'PHX'}) # Cluster |
240
238
 
241
239
  begin
242
240
  # Create a Rancher Server Deployment.
243
- result = api_instance.clusters_post(opts)
241
+ result = api_instance.clusters_post(cluster)
244
242
  p result
245
243
  rescue RancherApi::ApiError => e
246
244
  puts "Error when calling ClustersApi->clusters_post: #{e}"
@@ -251,12 +249,12 @@ end
251
249
 
252
250
  This returns an Array which contains the response data, status code and headers.
253
251
 
254
- > <Array(<Cluster>, Integer, Hash)> clusters_post_with_http_info(opts)
252
+ > <Array(<Cluster>, Integer, Hash)> clusters_post_with_http_info(cluster)
255
253
 
256
254
  ```ruby
257
255
  begin
258
256
  # Create a Rancher Server Deployment.
259
- data, status_code, headers = api_instance.clusters_post_with_http_info(opts)
257
+ data, status_code, headers = api_instance.clusters_post_with_http_info(cluster)
260
258
  p status_code # => 2xx
261
259
  p headers # => { ... }
262
260
  p data # => <Cluster>
@@ -269,7 +267,7 @@ end
269
267
 
270
268
  | Name | Type | Description | Notes |
271
269
  | ---- | ---- | ----------- | ----- |
272
- | **cluster** | [**Cluster**](Cluster.md) | | [optional] |
270
+ | **cluster** | [**Cluster**](Cluster.md) | | |
273
271
 
274
272
  ### Return type
275
273
 
data/docs/NodePool.md CHANGED
@@ -7,7 +7,7 @@
7
7
  | **name** | **String** | The name of the node pool. | [optional] |
8
8
  | **node_count** | **Integer** | Number of configured nodes, currently only node counts of 1 and 3 are possible. | [optional] |
9
9
  | **server_type** | **String** | Node server type. Cannot be changed once a server is created. Currently this field should be set to either &#x60;s0.d1.small&#x60;, &#x60;s0.d1.medium&#x60;, &#x60;s1.c1.small&#x60;, &#x60;s1.c1.medium&#x60;, &#x60;s1.c2.medium&#x60;, &#x60;s1.c2.large&#x60;, &#x60;s2.c1.small&#x60;, &#x60;s2.c1.medium&#x60;, &#x60;s2.c1.large&#x60;, &#x60;s2.c2.small&#x60;, &#x60;s2.c2.medium&#x60;, &#x60;s2.c2.large&#x60;, &#x60;s1.e1.small&#x60;, &#x60;s1.e1.medium&#x60;, &#x60;s1.e1.large&#x60;. | [optional][default to &#39;s0.d1.small&#39;] |
10
- | **ssh_config** | [**NodePoolSshConfig**](NodePoolSshConfig.md) | | [optional] |
10
+ | **ssh_config** | [**SshConfig**](SshConfig.md) | | [optional] |
11
11
  | **nodes** | [**Array&lt;Node&gt;**](Node.md) | (Read-only) The nodes associated with this node pool. | [optional][readonly] |
12
12
 
13
13
  ## Example
@@ -16,7 +16,7 @@
16
16
  require 'pnap_rancher_api'
17
17
 
18
18
  instance = RancherApi::NodePool.new(
19
- name: Rancher Server node pool.,
19
+ name: rancher-server-node-pool,
20
20
  node_count: null,
21
21
  server_type: s0.d1.small,
22
22
  ssh_config: null,
@@ -10,7 +10,7 @@
10
10
  | **etcd_snapshot_retention** | **Integer** | This maps to ranchers &#x60;etcd-snapshot-retention&#x60;. Number of snapshots to retain. | [optional][default to 5] |
11
11
  | **node_taint** | **String** | This maps to ranchers &#x60;node-taint&#x60;. Registering kubelet with set of taints. By default, server nodes will be schedulable and thus your workloads can get launched on them. If you wish to have a dedicated control plane where no user workloads will run, you can use taints. | [optional] |
12
12
  | **cluster_domain** | **String** | This maps to ranchers &#x60;cluster-domain&#x60;. Cluster Domain. | [optional] |
13
- | **certificates** | [**RancherClusterConfigCertificates**](RancherClusterConfigCertificates.md) | | [optional] |
13
+ | **certificates** | [**RancherClusterCertificates**](RancherClusterCertificates.md) | | [optional] |
14
14
 
15
15
  ## Example
16
16
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.1
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -204,23 +204,27 @@ module RancherApi
204
204
 
205
205
  # Create a Rancher Server Deployment.
206
206
  # Create a Rancher Server Deployment as described in <a href='https://rancher.com/docs/rancher/v2.5/en/overview/architecture/#rancher-server-architecture' target='_blank'>Rancher Docs Architecture</a>. Rancher Server allows the creation, import and management of multiple Downstream User Kubernetes Clusters. <b>This is not a Downstream User Cluster</b>. Knowledge base article to help you can be found <a href='https://phoenixnap.com/kb/bmc-rancher-workload-cluster#ftoc-heading-5' target='_blank'>here</a>.
207
+ # @param cluster [Cluster]
207
208
  # @param [Hash] opts the optional parameters
208
- # @option opts [Cluster] :cluster
209
209
  # @return [Cluster]
210
- def clusters_post(opts = {})
211
- data, _status_code, _headers = clusters_post_with_http_info(opts)
210
+ def clusters_post(cluster, opts = {})
211
+ data, _status_code, _headers = clusters_post_with_http_info(cluster, opts)
212
212
  data
213
213
  end
214
214
 
215
215
  # Create a Rancher Server Deployment.
216
216
  # Create a Rancher Server Deployment as described in &lt;a href&#x3D;&#39;https://rancher.com/docs/rancher/v2.5/en/overview/architecture/#rancher-server-architecture&#39; target&#x3D;&#39;_blank&#39;&gt;Rancher Docs Architecture&lt;/a&gt;. Rancher Server allows the creation, import and management of multiple Downstream User Kubernetes Clusters. &lt;b&gt;This is not a Downstream User Cluster&lt;/b&gt;. Knowledge base article to help you can be found &lt;a href&#x3D;&#39;https://phoenixnap.com/kb/bmc-rancher-workload-cluster#ftoc-heading-5&#39; target&#x3D;&#39;_blank&#39;&gt;here&lt;/a&gt;.
217
+ # @param cluster [Cluster]
217
218
  # @param [Hash] opts the optional parameters
218
- # @option opts [Cluster] :cluster
219
219
  # @return [Array<(Cluster, Integer, Hash)>] Cluster data, response status code and response headers
220
- def clusters_post_with_http_info(opts = {})
220
+ def clusters_post_with_http_info(cluster, opts = {})
221
221
  if @api_client.config.debugging
222
222
  @api_client.config.logger.debug 'Calling API: ClustersApi.clusters_post ...'
223
223
  end
224
+ # verify the required parameter 'cluster' is set
225
+ if @api_client.config.client_side_validation && cluster.nil?
226
+ fail ArgumentError, "Missing the required parameter 'cluster' when calling ClustersApi.clusters_post"
227
+ end
224
228
  # resource path
225
229
  local_var_path = '/clusters'
226
230
 
@@ -241,7 +245,7 @@ module RancherApi
241
245
  form_params = opts[:form_params] || {}
242
246
 
243
247
  # http body (model)
244
- post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'cluster'])
248
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(cluster)
245
249
 
246
250
  # return_type
247
251
  return_type = opts[:debug_return_type] || 'Cluster'
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.1
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -17,6 +17,7 @@ require 'tempfile'
17
17
  require 'time'
18
18
  require 'typhoeus'
19
19
 
20
+
20
21
  module RancherApi
21
22
  class ApiClient
22
23
  # The Configuration object holding settings to be used in the API client.
@@ -31,8 +32,9 @@ module RancherApi
31
32
  # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
32
33
  def initialize(config = Configuration.default)
33
34
  @config = config
34
- @user_agent = "PNAP-ruby-sdk-bmc/#{ RancherApi::VERSION }"
35
- @powered_by = "PNAP-ruby-sdk-bmc/#{ RancherApi::VERSION }"
35
+ @config.params_encoding = :multi
36
+ @user_agent = "PNAP-ruby-sdk-bmc/RancherApi/#{ RancherApi::VERSION }"
37
+ @powered_by = "PNAP-ruby-sdk-bmc/RancherApi/#{ RancherApi::VERSION }"
36
38
  @default_headers = {
37
39
  'Content-Type' => 'application/json',
38
40
  'User-Agent' => @user_agent,
@@ -47,9 +49,10 @@ module RancherApi
47
49
  # Call an API with given options.
48
50
  #
49
51
  # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
50
- # the data deserialized from response body (could be nil), response status code and response headers.
52
+ # the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
51
53
  def call_api(http_method, path, opts = {})
52
54
  request = build_request(http_method, path, opts)
55
+ tempfile = download_file(request) if opts[:return_type] == 'File'
53
56
  response = request.run
54
57
 
55
58
  if @config.debugging
@@ -71,7 +74,9 @@ module RancherApi
71
74
  end
72
75
  end
73
76
 
74
- if opts[:return_type]
77
+ if opts[:return_type] == 'File'
78
+ data = tempfile
79
+ elsif opts[:return_type]
75
80
  data = deserialize(response, opts[:return_type])
76
81
  else
77
82
  data = nil
@@ -127,9 +132,7 @@ module RancherApi
127
132
  end
128
133
  end
129
134
 
130
- request = Typhoeus::Request.new(url, req_opts)
131
- download_file(request) if opts[:return_type] == 'File'
132
- request
135
+ Typhoeus::Request.new(url, req_opts)
133
136
  end
134
137
 
135
138
  # Builds the HTTP request body
@@ -167,6 +170,8 @@ module RancherApi
167
170
  # process can use.
168
171
  #
169
172
  # @see Configuration#temp_folder_path
173
+ #
174
+ # @return [Tempfile] the tempfile generated
170
175
  def download_file(request)
171
176
  tempfile = nil
172
177
  encoding = nil
@@ -181,21 +186,24 @@ module RancherApi
181
186
  prefix = prefix + '-' unless prefix.end_with?('-')
182
187
  encoding = response.body.encoding
183
188
  tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
184
- @tempfile = tempfile
185
189
  end
186
190
  request.on_body do |chunk|
187
191
  chunk.force_encoding(encoding)
188
192
  tempfile.write(chunk)
189
193
  end
190
- request.on_complete do |response|
191
- if tempfile
192
- tempfile.close
193
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
194
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
195
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
196
- "explicitly with `tempfile.delete`"
197
- end
194
+ # run the request to ensure the tempfile is created successfully before returning it
195
+ request.run
196
+ if tempfile
197
+ tempfile.close
198
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
199
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
200
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
201
+ "explicitly with `tempfile.delete`"
202
+ else
203
+ fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}")
198
204
  end
205
+
206
+ tempfile
199
207
  end
200
208
 
201
209
  # Check if the given MIME is a JSON MIME.
@@ -216,15 +224,10 @@ module RancherApi
216
224
  # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
217
225
  def deserialize(response, return_type)
218
226
  body = response.body
219
-
220
- # handle file downloading - return the File instance processed in request callbacks
221
- # note that response body is empty when the file is written in chunks in request on_body callback
222
- return @tempfile if return_type == 'File'
223
-
224
227
  return nil if body.nil? || body.empty?
225
228
 
226
229
  # return response body directly for String return type
227
- return body if return_type == 'String'
230
+ return body.to_s if return_type == 'String'
228
231
 
229
232
  # ensuring a default content type
230
233
  content_type = response.headers['Content-Type'] || 'application/json'
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.1
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -32,6 +32,7 @@ module RancherApi
32
32
  end
33
33
  else
34
34
  super arg
35
+ @message = arg
35
36
  end
36
37
  end
37
38
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.1
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -62,6 +62,16 @@ module RancherApi
62
62
  # Defines the access token (Bearer) used with OAuth2.
63
63
  attr_accessor :access_token
64
64
 
65
+ # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
66
+ # Overrides the access_token if set
67
+ # @return [Proc]
68
+ attr_accessor :access_token_getter
69
+
70
+ # Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
71
+ # HTTP responses with return type `File` will be returned as a stream of binary data.
72
+ # Default to false.
73
+ attr_accessor :return_binary_data
74
+
65
75
  # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
66
76
  # details will be logged with `logger.debug` (see the `logger` attribute).
67
77
  # Default to false.
@@ -142,7 +152,7 @@ module RancherApi
142
152
  @scheme = 'https'
143
153
  @host = 'api.phoenixnap.com'
144
154
  @base_path = '/solutions/rancher/v1beta'
145
- @server_index = 0
155
+ @server_index = nil
146
156
  @server_operation_index = {}
147
157
  @server_variables = {}
148
158
  @server_operation_variables = {}
@@ -190,10 +200,12 @@ module RancherApi
190
200
 
191
201
  # Returns base URL for specified operation based on server settings
192
202
  def base_url(operation = nil)
193
- index = server_operation_index.fetch(operation, server_index)
194
- return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
195
-
196
- server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
203
+ if operation_server_settings.key?(operation) then
204
+ index = server_operation_index.fetch(operation, server_index)
205
+ server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
206
+ else
207
+ server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
208
+ end
197
209
  end
198
210
 
199
211
  # Gets API key (with prefix if set).
@@ -208,6 +220,12 @@ module RancherApi
208
220
  end
209
221
  end
210
222
 
223
+ # Gets access_token using access_token_getter or uses the static access_token
224
+ def access_token_with_refresh
225
+ return access_token if access_token_getter.nil?
226
+ access_token_getter.call
227
+ end
228
+
211
229
  # Gets Basic Auth token string
212
230
  def basic_auth_token
213
231
  'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
@@ -221,7 +239,7 @@ module RancherApi
221
239
  type: 'oauth2',
222
240
  in: 'header',
223
241
  key: 'Authorization',
224
- value: "Bearer #{access_token}"
242
+ value: "Bearer #{access_token_with_refresh}"
225
243
  },
226
244
  }
227
245
  end
@@ -249,8 +267,8 @@ module RancherApi
249
267
  servers = server_settings if servers == nil
250
268
 
251
269
  # check array index out of bound
252
- if (index < 0 || index >= servers.size)
253
- fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
270
+ if (index.nil? || index < 0 || index >= servers.size)
271
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
254
272
  end
255
273
 
256
274
  server = servers[index]
@@ -275,5 +293,6 @@ module RancherApi
275
293
  url
276
294
  end
277
295
 
296
+
278
297
  end
279
298
  end
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.1
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -40,7 +40,7 @@ module RancherApi
40
40
 
41
41
  attr_accessor :workload_configuration
42
42
 
43
- # The cluster status
43
+ # (Read-Only) The cluster status
44
44
  attr_accessor :status_description
45
45
 
46
46
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -73,9 +73,9 @@ module RancherApi
73
73
  :'location' => :'String',
74
74
  :'initial_cluster_version' => :'String',
75
75
  :'node_pools' => :'Array<NodePool>',
76
- :'configuration' => :'ClusterConfiguration',
76
+ :'configuration' => :'RancherClusterConfig',
77
77
  :'metadata' => :'RancherServerMetadata',
78
- :'workload_configuration' => :'ClusterWorkloadConfiguration',
78
+ :'workload_configuration' => :'WorkloadClusterConfig',
79
79
  :'status_description' => :'String'
80
80
  }
81
81
  end
@@ -115,6 +115,8 @@ module RancherApi
115
115
 
116
116
  if attributes.key?(:'location')
117
117
  self.location = attributes[:'location']
118
+ else
119
+ self.location = nil
118
120
  end
119
121
 
120
122
  if attributes.key?(:'initial_cluster_version')
@@ -147,6 +149,7 @@ module RancherApi
147
149
  # Show invalid properties with the reasons. Usually used together with valid?
148
150
  # @return Array for valid properties with the reasons
149
151
  def list_invalid_properties
152
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
150
153
  invalid_properties = Array.new
151
154
  if @location.nil?
152
155
  invalid_properties.push('invalid value for "location", location cannot be nil.')
@@ -166,6 +169,7 @@ module RancherApi
166
169
  # Check to see if the all the properties in the model are valid
167
170
  # @return true if the model is valid
168
171
  def valid?
172
+ warn '[DEPRECATED] the `valid?` method is obsolete'
169
173
  return false if @location.nil?
170
174
  return false if !@node_pools.nil? && @node_pools.length > 1
171
175
  return false if !@node_pools.nil? && @node_pools.length < 1
@@ -175,11 +179,15 @@ module RancherApi
175
179
  # Custom attribute writer method with validation
176
180
  # @param [Object] node_pools Value to be assigned
177
181
  def node_pools=(node_pools)
178
- if !node_pools.nil? && node_pools.length > 1
182
+ if node_pools.nil?
183
+ fail ArgumentError, 'node_pools cannot be nil'
184
+ end
185
+
186
+ if node_pools.length > 1
179
187
  fail ArgumentError, 'invalid value for "node_pools", number of items must be less than or equal to 1.'
180
188
  end
181
189
 
182
- if !node_pools.nil? && node_pools.length < 1
190
+ if node_pools.length < 1
183
191
  fail ArgumentError, 'invalid value for "node_pools", number of items must be greater than or equal to 1.'
184
192
  end
185
193
 
@@ -219,37 +227,30 @@ module RancherApi
219
227
  # @param [Hash] attributes Model attributes in the form of hash
220
228
  # @return [Object] Returns the model itself
221
229
  def self.build_from_hash(attributes)
222
- new.build_from_hash(attributes)
223
- end
224
-
225
- # Builds the object from hash
226
- # @param [Hash] attributes Model attributes in the form of hash
227
- # @return [Object] Returns the model itself
228
- def build_from_hash(attributes)
229
230
  return nil unless attributes.is_a?(Hash)
230
231
  attributes = attributes.transform_keys(&:to_sym)
231
- self.class.openapi_types.each_pair do |key, type|
232
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
233
- self.send("#{key}=", nil)
232
+ transformed_hash = {}
233
+ openapi_types.each_pair do |key, type|
234
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
235
+ transformed_hash["#{key}"] = nil
234
236
  elsif type =~ /\AArray<(.*)>/i
235
237
  # check to ensure the input is an array given that the attribute
236
238
  # is documented as an array but the input is not
237
- if attributes[self.class.attribute_map[key]].is_a?(Array)
238
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
239
+ if attributes[attribute_map[key]].is_a?(Array)
240
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
239
241
  end
240
- elsif !attributes[self.class.attribute_map[key]].nil?
241
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
242
+ elsif !attributes[attribute_map[key]].nil?
243
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
242
244
  end
243
245
  end
244
-
245
- self
246
+ new(transformed_hash)
246
247
  end
247
248
 
248
249
  # Deserializes the data based on type
249
250
  # @param string type Data type
250
251
  # @param string value Value to be deserialized
251
252
  # @return [Object] Deserialized data
252
- def _deserialize(type, value)
253
+ def self._deserialize(type, value)
253
254
  case type.to_sym
254
255
  when :Time
255
256
  Time.parse(value)
@@ -284,7 +285,7 @@ module RancherApi
284
285
  else # model
285
286
  # models (e.g. Pet) or oneOf
286
287
  klass = RancherApi.const_get(type)
287
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
288
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
288
289
  end
289
290
  end
290
291
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 0.1
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -66,16 +66,21 @@ module RancherApi
66
66
 
67
67
  if attributes.key?(:'result')
68
68
  self.result = attributes[:'result']
69
+ else
70
+ self.result = nil
69
71
  end
70
72
 
71
73
  if attributes.key?(:'cluster_id')
72
74
  self.cluster_id = attributes[:'cluster_id']
75
+ else
76
+ self.cluster_id = nil
73
77
  end
74
78
  end
75
79
 
76
80
  # Show invalid properties with the reasons. Usually used together with valid?
77
81
  # @return Array for valid properties with the reasons
78
82
  def list_invalid_properties
83
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
79
84
  invalid_properties = Array.new
80
85
  if @result.nil?
81
86
  invalid_properties.push('invalid value for "result", result cannot be nil.')
@@ -91,6 +96,7 @@ module RancherApi
91
96
  # Check to see if the all the properties in the model are valid
92
97
  # @return true if the model is valid
93
98
  def valid?
99
+ warn '[DEPRECATED] the `valid?` method is obsolete'
94
100
  return false if @result.nil?
95
101
  return false if @cluster_id.nil?
96
102
  true
@@ -121,37 +127,30 @@ module RancherApi
121
127
  # @param [Hash] attributes Model attributes in the form of hash
122
128
  # @return [Object] Returns the model itself
123
129
  def self.build_from_hash(attributes)
124
- new.build_from_hash(attributes)
125
- end
126
-
127
- # Builds the object from hash
128
- # @param [Hash] attributes Model attributes in the form of hash
129
- # @return [Object] Returns the model itself
130
- def build_from_hash(attributes)
131
130
  return nil unless attributes.is_a?(Hash)
132
131
  attributes = attributes.transform_keys(&:to_sym)
133
- self.class.openapi_types.each_pair do |key, type|
134
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
135
- self.send("#{key}=", nil)
132
+ transformed_hash = {}
133
+ openapi_types.each_pair do |key, type|
134
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
135
+ transformed_hash["#{key}"] = nil
136
136
  elsif type =~ /\AArray<(.*)>/i
137
137
  # check to ensure the input is an array given that the attribute
138
138
  # is documented as an array but the input is not
139
- if attributes[self.class.attribute_map[key]].is_a?(Array)
140
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
139
+ if attributes[attribute_map[key]].is_a?(Array)
140
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
141
141
  end
142
- elsif !attributes[self.class.attribute_map[key]].nil?
143
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
142
+ elsif !attributes[attribute_map[key]].nil?
143
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
144
144
  end
145
145
  end
146
-
147
- self
146
+ new(transformed_hash)
148
147
  end
149
148
 
150
149
  # Deserializes the data based on type
151
150
  # @param string type Data type
152
151
  # @param string value Value to be deserialized
153
152
  # @return [Object] Deserialized data
154
- def _deserialize(type, value)
153
+ def self._deserialize(type, value)
155
154
  case type.to_sym
156
155
  when :Time
157
156
  Time.parse(value)
@@ -186,7 +185,7 @@ module RancherApi
186
185
  else # model
187
186
  # models (e.g. Pet) or oneOf
188
187
  klass = RancherApi.const_get(type)
189
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
188
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
190
189
  end
191
190
  end
192
191