Class: Confy::Api::Envs

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

Overview

Every project has a default environment named Production. Each environment has __one__ configuration document which can have many keys and values.

org - Name of the organization project - Name of the project

Instance Method Summary collapse

Constructor Details

#initialize(org, project, client) ⇒ Envs

Returns a new instance of Envs.



11
12
13
14
15
# File 'lib/confy/api/envs.rb', line 11

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

Instance Method Details

#create(name, description, options = {}) ⇒ Object

Create an environment. The authenticated user should have access to the project.

‘/orgs/:org/projects/:project/envs’ POST

name - Name of the environment description - Description of the environment



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

def create(name, description, options = {})
  body = options.fetch(:body, {})
  body[:name] = name
  body[:description] = description

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

#destroy(env, options = {}) ⇒ Object

Delete the given environment. Authenticated user should have access to the project. Cannot delete the default environment.

‘/orgs/:org/projects/:project/envs/:env’ DELETE

env - Name of the environment



69
70
71
72
73
# File 'lib/confy/api/envs.rb', line 69

def destroy(env, options = {})
  body = options.fetch(:body, {})

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

#list(options = {}) ⇒ Object

List all the environmens of the project. The authenticated user should have access to the project.

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



20
21
22
23
24
# File 'lib/confy/api/envs.rb', line 20

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

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

#retrieve(env, options = {}) ⇒ Object

Get the given environment in the given project. The authenticated user should have access to the project.

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

env - Name of the environment



45
46
47
48
49
# File 'lib/confy/api/envs.rb', line 45

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

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

#update(env, description, options = {}) ⇒ Object

Update the given environment. __Description__ is the only thing which can be updated. Authenticated user should have access to the project.

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

env - Name of the environment description - Description of the environment



57
58
59
60
61
62
# File 'lib/confy/api/envs.rb', line 57

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

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