Class: Confy::Api::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/confy/api/config.rb

Overview

Any member of the team which has access to the project can retrieve any of it’s environment’s configuration document or edit it.

org - Name of the organization project - Name of the project env - Name of the environment

Instance Method Summary collapse

Constructor Details

#initialize(org, project, env, client) ⇒ Config

Returns a new instance of Config.



12
13
14
15
16
17
# File 'lib/confy/api/config.rb', line 12

def initialize(org, project, env, client)
  @org = org
  @project = project
  @env = env
  @client = client
end

Instance Method Details

#retrieve(options = {}) ⇒ Object

Get an environment configuration

‘/orgs/:org/projects/:project/envs/:env/config’ GET



22
23
24
25
26
# File 'lib/confy/api/config.rb', line 22

def retrieve(options = {})
  body = options.fetch(:query, {})

  @client.get("/orgs/#{@org}/projects/#{@project}/envs/#{@env}/config", body, options)
end

#update(config, options = {}) ⇒ Object

Update the configuration document for the given environment of the project. We will patch the document recursively.

‘/orgs/:org/projects/:project/envs/:env/config’ PATCH

config - Configuration to update



33
34
35
36
37
38
# File 'lib/confy/api/config.rb', line 33

def update(config, options = {})
  body = options.fetch(:body, {})
  body[:config] = config

  @client.patch("/orgs/#{@org}/projects/#{@project}/envs/#{@env}/config", body, options)
end

#versions(options = {}) ⇒ Object

List the last 10 versions of the environment configuration

‘/orgs/:org/projects/:project/envs/:env/versions’ GET



43
44
45
46
47
# File 'lib/confy/api/config.rb', line 43

def versions(options = {})
  body = options.fetch(:query, {})

  @client.get("/orgs/#{@org}/projects/#{@project}/envs/#{@env}/versions", body, options)
end