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.
293 294 295 |
# File 'lib/smplkit/management/client.rb', line 293 def initialize(api_client) @api = SmplkitGeneratedClient::App::EnvironmentsApi.new(api_client) end |
Instance Method Details
#_create_environment(env) ⇒ Object
323 324 325 326 |
# File 'lib/smplkit/management/client.rb', line 323 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
328 329 330 331 |
# File 'lib/smplkit/management/client.rb', line 328 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
307 308 309 310 |
# File 'lib/smplkit/management/client.rb', line 307 def delete(key) ErrorMapping.call { @api.delete_environment(key) } true end |
#get(key) ⇒ Object
302 303 304 305 |
# File 'lib/smplkit/management/client.rb', line 302 def get(key) response = ErrorMapping.call { @api.get_environment(key) } from_resource(ResourceShim.from_model(response.data)) end |
#list ⇒ Object
297 298 299 300 |
# File 'lib/smplkit/management/client.rb', line 297 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
312 313 314 315 316 317 318 319 320 321 |
# File 'lib/smplkit/management/client.rb', line 312 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 |