Class: Confy::Api::Teams

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

Overview

Every organization will have a default team named __Owners__. Owner of the organization will be a default member for every team.

org - Name of the organization

Instance Method Summary collapse

Constructor Details

#initialize(org, client) ⇒ Teams

Returns a new instance of Teams.



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

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

Instance Method Details

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

Create a team for the given organization. Authenticated user should be the owner of the organization.

‘/orgs/:org/teams’ POST

name - Name of the team description - Description of the team



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

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

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

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

Delete the given team. Cannot delete the default team in the organization. Authenticated user should be the owner of the organization.

‘/orgs/:org/teams/:team’ DELETE

team - Name of the team



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

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

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

#list(options = {}) ⇒ Object

List teams of the given organization authenticated user is a member of.

‘/orgs/:org/teams’ GET



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

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

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

#projects(team, options = {}) ⇒ Object

Retrieve the list of projects the given team has access to. Authenticated user should be a member of the team.

‘/orgs/:org/teams/:team/projects’ GET

team - Name of the team



78
79
80
81
82
# File 'lib/confy/api/teams.rb', line 78

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

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

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

Get the given team in the given organization. Access only if the authenticated user is a member of the team.

‘/orgs/:org/teams/:team’ GET

team - Name of the team



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

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

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

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

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

‘/orgs/:org/teams/:team’ PATCH

team - Name of the team description - Description of the team



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

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

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