Class: Smplkit::ManagementClient::ConfigNamespace
- Inherits:
-
Object
- Object
- Smplkit::ManagementClient::ConfigNamespace
- Includes:
- HttpHelpers
- Defined in:
- lib/smplkit/management/client.rb
Instance Method Summary collapse
- #_create_config(config) ⇒ Object
- #_update_config(config) ⇒ Object
- #delete(key) ⇒ Object
- #fetch_chain(key) ⇒ Object
- #get(key) ⇒ Object
-
#initialize(http) ⇒ ConfigNamespace
constructor
A new instance of ConfigNamespace.
- #list ⇒ Object
- #new_config(key, name: nil, description: nil, parent: nil) ⇒ Object
Constructor Details
#initialize(http) ⇒ ConfigNamespace
Returns a new instance of ConfigNamespace.
383 384 385 |
# File 'lib/smplkit/management/client.rb', line 383 def initialize(http) @http = http end |
Instance Method Details
#_create_config(config) ⇒ Object
408 409 410 411 412 |
# File 'lib/smplkit/management/client.rb', line 408 def _create_config(config) body = Smplkit::Config::Helpers.build_config_request_body(config) resp = http_post("/api/configs/v1", body) Smplkit::Config::Helpers.config_from_json(self, resp["data"]) end |
#_update_config(config) ⇒ Object
414 415 416 417 418 |
# File 'lib/smplkit/management/client.rb', line 414 def _update_config(config) body = Smplkit::Config::Helpers.build_config_request_body(config) resp = http_put("/api/configs/v1/#{config.key}", body) Smplkit::Config::Helpers.config_from_json(self, resp["data"]) end |
#delete(key) ⇒ Object
397 398 399 |
# File 'lib/smplkit/management/client.rb', line 397 def delete(key) http_delete("/api/configs/v1/#{key}") end |
#fetch_chain(key) ⇒ Object
420 421 422 423 |
# File 'lib/smplkit/management/client.rb', line 420 def fetch_chain(key) resp = http_get("/api/configs/v1/#{key}/chain") (resp["data"] || []).map { |r| r["attributes"] || {} } end |
#get(key) ⇒ Object
392 393 394 395 |
# File 'lib/smplkit/management/client.rb', line 392 def get(key) resp = http_get("/api/configs/v1/#{key}") Smplkit::Config::Helpers.config_from_json(self, resp["data"]) end |
#list ⇒ Object
387 388 389 390 |
# File 'lib/smplkit/management/client.rb', line 387 def list list_resp = http_list("/api/configs/v1") list_resp.map { |r| Smplkit::Config::Helpers.config_from_json(self, r) } end |
#new_config(key, name: nil, description: nil, parent: nil) ⇒ Object
401 402 403 404 405 406 |
# File 'lib/smplkit/management/client.rb', line 401 def new_config(key, name: nil, description: nil, parent: nil) Smplkit::Config::Config.new( self, key: key, name: name, description: description, parent_id: parent.is_a?(Smplkit::Config::Config) ? parent.key : parent ) end |