Class: Sem::API::Team
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Sem::API::Team
show all
- Extended by:
- Base
- Defined in:
- lib/sem/api/team.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Base
api_logger, client, create_new_api_client
Constructor Details
#initialize(org_name, team) ⇒ Team
Returns a new instance of Team.
32
33
34
35
36
|
# File 'lib/sem/api/team.rb', line 32
def initialize(org_name, team)
@org_name = org_name
super(team)
end
|
Instance Attribute Details
#org_name ⇒ Object
Returns the value of attribute org_name.
30
31
32
|
# File 'lib/sem/api/team.rb', line 30
def org_name
@org_name
end
|
Class Method Details
.all ⇒ Object
4
5
6
7
8
|
# File 'lib/sem/api/team.rb', line 4
def self.all
Sem::API::Org.all.pmap do |org|
client.teams.list_for_org(org.username).map { |team| new(org.username, team) }
end.flatten
end
|
.create!(team_srn, args) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/sem/api/team.rb', line 20
def self.create!(team_srn, args)
org_name, team_name = Sem::SRN.parse_team(team_srn)
team = client.teams.create_for_org(org_name, args.merge(:name => team_name))
raise Sem::Errors::ResourceNotCreated.new("Team", [org_name, team_name]) if team.nil?
new(org_name, team)
end
|
.find!(team_srn) ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/sem/api/team.rb', line 10
def self.find!(team_srn)
org_name, team_name = Sem::SRN.parse_team(team_srn)
team = client.teams.list_for_org(org_name).find { |t| t.name == team_name }
raise Sem::Errors::ResourceNotFound.new("Team", [org_name, team_name]) if team.nil?
new(org_name, team)
end
|
Instance Method Details
#add_project(project) ⇒ Object
58
59
60
|
# File 'lib/sem/api/team.rb', line 58
def add_project(project)
Sem::API::Base.client.projects.attach_to_team(project.id, id)
end
|
#add_shared_config(config) ⇒ Object
66
67
68
|
# File 'lib/sem/api/team.rb', line 66
def add_shared_config(config)
Sem::API::Base.client.shared_configs.attach_to_team(config.id, id)
end
|
#add_user(username) ⇒ Object
50
51
52
|
# File 'lib/sem/api/team.rb', line 50
def add_user(username)
Sem::API::Base.client.users.attach_to_team(username, id)
end
|
#delete! ⇒ Object
74
75
76
|
# File 'lib/sem/api/team.rb', line 74
def delete!
Sem::API::Base.client.teams.delete(id)
end
|
#full_name ⇒ Object
38
39
40
|
# File 'lib/sem/api/team.rb', line 38
def full_name
"#{org_name}/#{name}"
end
|
#projects ⇒ Object
82
83
84
|
# File 'lib/sem/api/team.rb', line 82
def projects
Sem::API::Base.client.projects.list_for_team(id).map { |project| Sem::API::Project.new(org_name, project) }
end
|
#remove_project(project) ⇒ Object
62
63
64
|
# File 'lib/sem/api/team.rb', line 62
def remove_project(project)
Sem::API::Base.client.projects.detach_from_team(project.id, id)
end
|
#remove_shared_config(config) ⇒ Object
70
71
72
|
# File 'lib/sem/api/team.rb', line 70
def remove_shared_config(config)
Sem::API::Base.client.shared_configs.detach_from_team(config.id, id)
end
|
#remove_user(username) ⇒ Object
54
55
56
|
# File 'lib/sem/api/team.rb', line 54
def remove_user(username)
Sem::API::Base.client.users.detach_from_team(username, id)
end
|
#shared_configs ⇒ Object
86
87
88
|
# File 'lib/sem/api/team.rb', line 86
def shared_configs
Sem::API::Base.client.shared_configs.list_for_team(id).map { |config| Sem::API::SharedConfig.new(org_name, config) }
end
|
#update(args) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/sem/api/team.rb', line 42
def update(args)
new_team = Sem::API::Base.client.teams.update(id, args)
raise Sem::Errors::ResourceNotUpdated.new("Team", [@org_name, name]) unless new_team
self.class.new(@org_name, new_team)
end
|
#users ⇒ Object
78
79
80
|
# File 'lib/sem/api/team.rb', line 78
def users
Sem::API::Base.client.users.list_for_team(id).map { |user| Sem::API::User.new(user) }
end
|