Class: Smplkit::ManagementClient::EnvironmentsNamespace
- Inherits:
-
Object
- Object
- Smplkit::ManagementClient::EnvironmentsNamespace
- Defined in:
- lib/smplkit/management/client.rb
Instance Method Summary collapse
- #_create_environment(env) ⇒ Object
- #_update_environment(env) ⇒ Object
- #delete(key) ⇒ Object
- #get(key) ⇒ Object
-
#initialize(api_client) ⇒ EnvironmentsNamespace
constructor
A new instance of EnvironmentsNamespace.
- #list(page_number: nil, page_size: nil) ⇒ Object
- #new(key, name: nil, color: nil, classification: Management::EnvironmentClassification::STANDARD, description: nil) ⇒ Object
Constructor Details
#initialize(api_client) ⇒ EnvironmentsNamespace
Returns a new instance of EnvironmentsNamespace.
334 335 336 |
# File 'lib/smplkit/management/client.rb', line 334 def initialize(api_client) @api = SmplkitGeneratedClient::App::EnvironmentsApi.new(api_client) end |
Instance Method Details
#_create_environment(env) ⇒ Object
367 368 369 370 |
# File 'lib/smplkit/management/client.rb', line 367 def _create_environment(env) response = ErrorMapping.call { @api.create_environment(body_for(env)) } from_resource(ResourceShim.from_model(response.data)) end |
#_update_environment(env) ⇒ Object
372 373 374 375 |
# File 'lib/smplkit/management/client.rb', line 372 def _update_environment(env) response = ErrorMapping.call { @api.update_environment(env.key, body_for(env)) } from_resource(ResourceShim.from_model(response.data)) end |
#delete(key) ⇒ Object
351 352 353 354 |
# File 'lib/smplkit/management/client.rb', line 351 def delete(key) ErrorMapping.call { @api.delete_environment(key) } true end |
#get(key) ⇒ Object
346 347 348 349 |
# File 'lib/smplkit/management/client.rb', line 346 def get(key) response = ErrorMapping.call { @api.get_environment(key) } from_resource(ResourceShim.from_model(response.data)) end |
#list(page_number: nil, page_size: nil) ⇒ Object
338 339 340 341 342 343 344 |
# File 'lib/smplkit/management/client.rb', line 338 def list(page_number: nil, page_size: nil) opts = {} opts[:page_number] = page_number unless page_number.nil? opts[:page_size] = page_size unless page_size.nil? response = ErrorMapping.call { @api.list_environments(opts) } (response.data || []).map { |r| from_resource(ResourceShim.from_model(r)) } end |
#new(key, name: nil, color: nil, classification: Management::EnvironmentClassification::STANDARD, description: nil) ⇒ Object
356 357 358 359 360 361 362 363 364 365 |
# File 'lib/smplkit/management/client.rb', line 356 def new(key, name: nil, color: nil, classification: Management::EnvironmentClassification::STANDARD, description: nil) color = Management::Color.new(color) if color.is_a?(String) Management::Environment.new( self, key: key, name: name || Smplkit::Helpers.key_to_display_name(key), color: color, classification: classification, description: description ) end |