Class: Confy::Api::Projects

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

Overview

An organization can contain any number of projects.

org - Name of the organization

Instance Method Summary collapse

Constructor Details

#initialize(org, client) ⇒ Projects

Returns a new instance of Projects.



10
11
12
13
# File 'lib/confy/api/projects.rb', line 10

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

Instance Method Details

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

Create a project if the authenticated user is the owner of the given organization. Only the __owners__ team will be able to see the project initially.

‘/orgs/:org/projects’ POST

name - Name of the project description - Description of the project



30
31
32
33
34
35
36
# File 'lib/confy/api/projects.rb', line 30

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

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

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

Delete the given project. Authenticated user should be the owner of the organization.

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

project - Name of the project



67
68
69
70
71
# File 'lib/confy/api/projects.rb', line 67

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

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

#list(options = {}) ⇒ Object

List all the projects of the given organization which can be accessed by the authenticated user.

‘/orgs/:org/projects’ GET



18
19
20
21
22
# File 'lib/confy/api/projects.rb', line 18

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

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

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

Get the given project in the given organization. Works only if the authenticated user has access to the project.

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

project - Name of the project



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

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

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

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

Update the given project. __Description__ is the only thing which can be updated. Authenticated user should be the owner of the organization.

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

project - Name of the project description - Description of the project



55
56
57
58
59
60
# File 'lib/confy/api/projects.rb', line 55

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

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