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.



295
296
297
# File 'lib/smplkit/management/client.rb', line 295

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

Instance Method Details

#_create_environment(env) ⇒ Object



325
326
327
328
# File 'lib/smplkit/management/client.rb', line 325

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



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

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



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

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

#get(key) ⇒ Object



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

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

#listObject



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

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



314
315
316
317
318
319
320
321
322
323
# File 'lib/smplkit/management/client.rb', line 314

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