Class: Smplkit::ManagementClient::EnvironmentsNamespace
- Inherits:
-
Object
- Object
- Smplkit::ManagementClient::EnvironmentsNamespace
- Includes:
- HttpHelpers
- 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(http) ⇒ 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(http) ⇒ EnvironmentsNamespace
Returns a new instance of EnvironmentsNamespace.
266 267 268 |
# File 'lib/smplkit/management/client.rb', line 266 def initialize(http) @http = http end |
Instance Method Details
#_create_environment(env) ⇒ Object
295 296 297 298 |
# File 'lib/smplkit/management/client.rb', line 295 def _create_environment(env) resp = http_post("/api/environments/v1", body_for(env)) from_resource(resp["data"]) end |
#_update_environment(env) ⇒ Object
300 301 302 303 |
# File 'lib/smplkit/management/client.rb', line 300 def _update_environment(env) resp = http_put("/api/environments/v1/#{env.key}", body_for(env)) from_resource(resp["data"]) end |
#delete(key) ⇒ Object
280 281 282 |
# File 'lib/smplkit/management/client.rb', line 280 def delete(key) http_delete("/api/environments/v1/#{key}") end |
#get(key) ⇒ Object
275 276 277 278 |
# File 'lib/smplkit/management/client.rb', line 275 def get(key) resp = http_get("/api/environments/v1/#{key}") from_resource(resp["data"]) end |
#list ⇒ Object
270 271 272 273 |
# File 'lib/smplkit/management/client.rb', line 270 def list list_resp = http_list("/api/environments/v1") list_resp.map { |r| from_resource(r) } end |
#new(key, name: nil, color: nil, classification: Management::EnvironmentClassification::STANDARD, description: nil) ⇒ Object
284 285 286 287 288 289 290 291 292 293 |
# File 'lib/smplkit/management/client.rb', line 284 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 |