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 ⇒ 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.
292 293 294 |
# File 'lib/smplkit/management/client.rb', line 292 def initialize(api_client) @api = SmplkitGeneratedClient::App::EnvironmentsApi.new(api_client) end |
Instance Method Details
#_create_environment(env) ⇒ Object
322 323 324 325 |
# File 'lib/smplkit/management/client.rb', line 322 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
327 328 329 330 |
# File 'lib/smplkit/management/client.rb', line 327 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
306 307 308 309 |
# File 'lib/smplkit/management/client.rb', line 306 def delete(key) ErrorMapping.call { @api.delete_environment(key) } true end |
#get(key) ⇒ Object
301 302 303 304 |
# File 'lib/smplkit/management/client.rb', line 301 def get(key) response = ErrorMapping.call { @api.get_environment(key) } from_resource(ResourceShim.from_model(response.data)) end |
#list ⇒ Object
296 297 298 299 |
# File 'lib/smplkit/management/client.rb', line 296 def list response = ErrorMapping.call { @api.list_environments } (response.data || []).map { |r| from_resource(ResourceShim.from_model(r)) } end |
#new(key, name: nil, color: nil, classification: Management::EnvironmentClassification::STANDARD, description: nil) ⇒ Object
311 312 313 314 315 316 317 318 319 320 |
# File 'lib/smplkit/management/client.rb', line 311 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 |