Class: Smplkit::ManagementClient::EnvironmentsNamespace

Inherits:
Object
  • Object
show all
Defined in:
lib/smplkit/management/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_client) ⇒ EnvironmentsNamespace

Returns a new instance of EnvironmentsNamespace.



299
300
301
# File 'lib/smplkit/management/client.rb', line 299

def initialize(api_client)
  @api = SmplkitGeneratedClient::App::EnvironmentsApi.new(api_client)
end

Instance Method Details

#_create_environment(env) ⇒ Object



329
330
331
332
# File 'lib/smplkit/management/client.rb', line 329

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



334
335
336
337
# File 'lib/smplkit/management/client.rb', line 334

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



313
314
315
316
# File 'lib/smplkit/management/client.rb', line 313

def delete(key)
  ErrorMapping.call { @api.delete_environment(key) }
  true
end

#get(key) ⇒ Object



308
309
310
311
# File 'lib/smplkit/management/client.rb', line 308

def get(key)
  response = ErrorMapping.call { @api.get_environment(key) }
  from_resource(ResourceShim.from_model(response.data))
end

#listObject



303
304
305
306
# File 'lib/smplkit/management/client.rb', line 303

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



318
319
320
321
322
323
324
325
326
327
# File 'lib/smplkit/management/client.rb', line 318

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