sem 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/sem/api/base.rb +7 -5
- data/lib/sem/api/env_vars.rb +12 -10
- data/lib/sem/api/files.rb +11 -9
- data/lib/sem/api/orgs.rb +27 -39
- data/lib/sem/api/projects.rb +27 -18
- data/lib/sem/api/shared_configs.rb +73 -45
- data/lib/sem/api/teams.rb +48 -33
- data/lib/sem/api/traits/associated_with_org.rb +6 -2
- data/lib/sem/api/traits/associated_with_project.rb +29 -0
- data/lib/sem/api/traits/associated_with_shared_config.rb +9 -7
- data/lib/sem/api/traits/associated_with_team.rb +12 -12
- data/lib/sem/api/traits.rb +1 -0
- data/lib/sem/api/users.rb +30 -12
- data/lib/sem/api.rb +0 -1
- data/lib/sem/cli/orgs.rb +11 -28
- data/lib/sem/cli/projects.rb +46 -3
- data/lib/sem/cli/shared_configs.rb +57 -30
- data/lib/sem/cli/teams.rb +101 -45
- data/lib/sem/cli.rb +21 -4
- data/lib/sem/configuration.rb +48 -0
- data/lib/sem/errors.rb +33 -0
- data/lib/sem/pagination.rb +29 -0
- data/lib/sem/srn.rb +42 -0
- data/lib/sem/version.rb +1 -1
- data/lib/sem/views/base.rb +8 -3
- data/lib/sem/views/orgs.rb +9 -0
- data/lib/sem/views/projects.rb +31 -14
- data/lib/sem/views/shared_configs.rb +11 -0
- data/lib/sem/views/teams.rb +68 -16
- data/lib/sem/views/users.rb +5 -7
- data/lib/sem.rb +35 -2
- data/sem.gemspec +4 -3
- metadata +28 -13
- data/lib/sem/api/users_with_permissions.rb +0 -57
- data/lib/sem/credentials.rb +0 -19
- data/lib/sem/views/users_with_permissions.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccd122f3ce04fc09324bb135463966fd91fe5d90
|
4
|
+
data.tar.gz: aff41dee6b2352c2844beb298c8a0ed5268ff5d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa93e1e6a31b3f5faf0ea12a32e1178acf2c3fa041105d403b95659b1321d75819b1862f3524fbcd64015f506a6736bf10ab50b82dab69097b85d030f2010448
|
7
|
+
data.tar.gz: a59bc4d8e6248700231099d8f36bac604bd7f0bfc6a15817addb1774b2b7b6082e58b7b2c784cb200a58d83785da1dffebc7279d90f77b086a679dc83ddc5d07
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Semaphore CLI
|
2
2
|
|
3
3
|
[![Build Status](https://semaphoreci.com/api/v1/renderedtext/cli/branches/master/badge.svg)](https://semaphoreci.com/renderedtext/cli)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/sem.svg)](https://badge.fury.io/rb/sem)
|
4
5
|
|
5
6
|
![Semaphore logo](https://d1dkupr86d302v.cloudfront.net/assets/application_bootstrap/layout/semaphore-logo-a6d954e176b6975b511f314a0cc808dc94a8030210077e3a6e904fbe69dc5354.svg)
|
6
7
|
|
@@ -10,6 +11,22 @@ The Semaphore CLI is used to manage Semaphore projects from the command line.
|
|
10
11
|
|
11
12
|
For more info about Semaphore see <https://www.semaphoreci.com>
|
12
13
|
|
14
|
+
## Semaphore Resource Name (SRN)
|
15
|
+
|
16
|
+
SRN is a way of identifying Semaphore resources. This CLI uses SRNs as arguments
|
17
|
+
for all actions.
|
18
|
+
|
19
|
+
Formats for individual resources are the following:
|
20
|
+
|
21
|
+
- Organization: `organization_name`
|
22
|
+
- Team: `organization_name/team_name`
|
23
|
+
- Project: `organization_name/project_name`
|
24
|
+
- Shared Configuration: `organization_name/shared_configuration_name`
|
25
|
+
|
26
|
+
## Using custom API URL
|
27
|
+
|
28
|
+
Create a file at `~/.sem/api_url` containing only the custom url.
|
29
|
+
|
13
30
|
## Issues
|
14
31
|
|
15
32
|
For problems directly related to the CLI, [add an issue on GitHub](https://github.com/renderedtext/cli/issues/new).
|
data/lib/sem/api/base.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
module Sem
|
2
2
|
module API
|
3
3
|
class Base
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
class << self
|
5
|
+
def client
|
6
|
+
@client ||= SemaphoreClient.new(
|
7
|
+
Sem::Configuration.auth_token,
|
8
|
+
:api_url => Sem::Configuration.api_url,
|
9
|
+
:verbose => (Sem.log_level == Sem::LOG_LEVEL_TRACE)
|
10
|
+
)
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
data/lib/sem/api/env_vars.rb
CHANGED
@@ -3,17 +3,19 @@ module Sem
|
|
3
3
|
class EnvVars < Base
|
4
4
|
extend Traits::AssociatedWithSharedConfig
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
class << self
|
7
|
+
def api
|
8
|
+
client.env_vars
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
def to_hash(env_var)
|
12
|
+
{
|
13
|
+
:id => env_var.id,
|
14
|
+
:name => env_var.name,
|
15
|
+
:encrypted? => env_var.encrypted,
|
16
|
+
:content => env_var.content
|
17
|
+
}
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
data/lib/sem/api/files.rb
CHANGED
@@ -3,16 +3,18 @@ module Sem
|
|
3
3
|
class Files < Base
|
4
4
|
extend Traits::AssociatedWithSharedConfig
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
class << self
|
7
|
+
def api
|
8
|
+
client.config_files
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
def to_hash(file)
|
12
|
+
{
|
13
|
+
:id => file.id,
|
14
|
+
:name => file.path,
|
15
|
+
:encrypted? => file.encrypted
|
16
|
+
}
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
data/lib/sem/api/orgs.rb
CHANGED
@@ -1,53 +1,41 @@
|
|
1
1
|
module Sem
|
2
2
|
module API
|
3
3
|
class Orgs < Base
|
4
|
-
|
5
|
-
|
4
|
+
class << self
|
5
|
+
def list
|
6
|
+
orgs = api.list
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def self.info(name)
|
11
|
-
org = api.get(name)
|
12
|
-
|
13
|
-
to_hash(org)
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.list_teams(org_name)
|
17
|
-
Sem::API::Teams.list_for_org(org_name)
|
18
|
-
end
|
8
|
+
orgs.map { |org| to_hash(org) }
|
9
|
+
end
|
19
10
|
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.list_admins(org_name)
|
25
|
-
admin_teams = list_teams(org_name).select { |team| team[:permission] == "admin" }
|
26
|
-
|
27
|
-
admins = admin_teams.map { |team| client.users.list_for_team(team[:id]) }.flatten
|
11
|
+
def info(name)
|
12
|
+
org = api.get(name)
|
28
13
|
|
29
|
-
|
30
|
-
end
|
14
|
+
raise Sem::Errors::ResourceNotFound.new("Organization", [name]) if org.nil?
|
31
15
|
|
32
|
-
|
33
|
-
|
16
|
+
to_hash(org)
|
17
|
+
end
|
34
18
|
|
35
|
-
|
19
|
+
def list_teams(name)
|
20
|
+
Sem::API::Teams.list_for_org(name)
|
21
|
+
end
|
36
22
|
|
37
|
-
|
38
|
-
|
23
|
+
def list_users(name)
|
24
|
+
Sem::API::Users.list_for_org(name)
|
25
|
+
end
|
39
26
|
|
40
|
-
|
41
|
-
|
42
|
-
|
27
|
+
def api
|
28
|
+
client.orgs
|
29
|
+
end
|
43
30
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
31
|
+
def to_hash(org)
|
32
|
+
{
|
33
|
+
:id => org.id,
|
34
|
+
:username => org.username,
|
35
|
+
:created_at => org.created_at,
|
36
|
+
:updated_at => org.updated_at
|
37
|
+
}
|
38
|
+
end
|
51
39
|
end
|
52
40
|
end
|
53
41
|
end
|
data/lib/sem/api/projects.rb
CHANGED
@@ -4,29 +4,38 @@ module Sem
|
|
4
4
|
extend Traits::AssociatedWithOrg
|
5
5
|
extend Traits::AssociatedWithTeam
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
class << self
|
8
|
+
def name_to_id(org_name, project_name)
|
9
|
+
info(org_name, project_name)[:id]
|
10
|
+
end
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
+
def list
|
13
|
+
org_names = Orgs.list.map { |org| org[:username] }
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
+
org_names.pmap { |name| list_for_org(name) }.flatten
|
16
|
+
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
+
def info(org_name, project_name)
|
19
|
+
project = api.list_for_org(org_name, :name => project_name).first
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
raise Sem::Errors::ResourceNotFound.new("Project", [org_name, project_name]) if project.nil?
|
22
|
+
|
23
|
+
to_hash(project, org_name)
|
24
|
+
end
|
25
|
+
|
26
|
+
def api
|
27
|
+
client.projects
|
28
|
+
end
|
22
29
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
def to_hash(project, org)
|
31
|
+
{
|
32
|
+
:id => project.id,
|
33
|
+
:name => project.name,
|
34
|
+
:org => org,
|
35
|
+
:created_at => project.created_at,
|
36
|
+
:updated_at => project.updated_at
|
37
|
+
}
|
38
|
+
end
|
30
39
|
end
|
31
40
|
end
|
32
41
|
end
|
@@ -3,71 +3,99 @@ module Sem
|
|
3
3
|
class SharedConfigs < Base
|
4
4
|
extend Traits::AssociatedWithTeam
|
5
5
|
extend Traits::AssociatedWithOrg
|
6
|
+
extend Traits::AssociatedWithProject
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
class << self
|
9
|
+
def name_to_id(org_name, shared_config_name)
|
10
|
+
info(org_name, shared_config_name)[:id]
|
11
|
+
end
|
9
12
|
|
10
|
-
|
11
|
-
|
13
|
+
def list
|
14
|
+
org_names = Orgs.list.map { |org| org[:username] }
|
12
15
|
|
13
|
-
|
14
|
-
|
16
|
+
org_names.pmap { |name| list_for_org(name) }.flatten
|
17
|
+
end
|
15
18
|
|
16
|
-
|
17
|
-
|
19
|
+
def info(org_name, shared_config_name)
|
20
|
+
selected_shared_config = list_for_org(org_name).find do |shared_config|
|
21
|
+
shared_config[:name] == shared_config_name
|
22
|
+
end
|
18
23
|
|
19
|
-
|
20
|
-
|
24
|
+
if selected_shared_config.nil?
|
25
|
+
raise Sem::Errors::ResourceNotFound.new("Shared Configuration", [org_name, shared_config_name])
|
26
|
+
end
|
21
27
|
|
22
|
-
|
23
|
-
|
28
|
+
selected_shared_config
|
29
|
+
end
|
24
30
|
|
25
|
-
|
26
|
-
|
31
|
+
def create(org_name, args)
|
32
|
+
shared_config = api.create_for_org(org_name, args)
|
27
33
|
|
28
|
-
|
34
|
+
if shared_config.nil?
|
35
|
+
raise Sem::Errors::ResourceNotCreated.new("Shared Configuration", [org_name, args[:name]])
|
36
|
+
end
|
29
37
|
|
30
|
-
|
31
|
-
|
38
|
+
to_hash(shared_config, org_name)
|
39
|
+
end
|
32
40
|
|
33
|
-
|
34
|
-
|
41
|
+
def update(org_name, shared_config_name, args)
|
42
|
+
shared_config = info(org_name, shared_config_name)
|
35
43
|
|
36
|
-
|
37
|
-
end
|
44
|
+
shared_config = api.update(shared_config[:id], args)
|
38
45
|
|
39
|
-
|
40
|
-
|
41
|
-
|
46
|
+
if shared_config.nil?
|
47
|
+
raise Sem::Errors::ResourceNotUpdated.new("Shared Configuration", [org_name, shared_config_name])
|
48
|
+
end
|
42
49
|
|
43
|
-
|
44
|
-
|
45
|
-
end
|
50
|
+
to_hash(shared_config, org_name)
|
51
|
+
end
|
46
52
|
|
47
|
-
|
48
|
-
|
49
|
-
end
|
53
|
+
def delete(org_name, shared_config_name)
|
54
|
+
shared_config = info(org_name, shared_config_name)
|
50
55
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
56
|
+
api.delete!(shared_config[:id])
|
57
|
+
rescue SemaphoreClient::Exceptions::RequestFailed
|
58
|
+
raise Sem::Errors::ResourceNotDeleted.new("Shared Configuration", [org_name, shared_config_name])
|
59
|
+
end
|
60
|
+
|
61
|
+
def list_env_vars(org_name, shared_config_name)
|
62
|
+
Sem::API::EnvVars.list_for_shared_config(org_name, shared_config_name)
|
63
|
+
end
|
64
|
+
|
65
|
+
def list_files(org_name, shared_config_name)
|
66
|
+
Sem::API::Files.list_for_shared_config(org_name, shared_config_name)
|
67
|
+
end
|
68
|
+
|
69
|
+
def api
|
70
|
+
client.shared_configs
|
71
|
+
end
|
72
|
+
|
73
|
+
def to_hash(shared_config, org)
|
74
|
+
network_actions = [:config_files_count, :env_vars_count]
|
75
|
+
|
76
|
+
config_files, env_vars = network_actions.pmap do |action|
|
77
|
+
send(action, shared_config.id)
|
78
|
+
end
|
79
|
+
|
80
|
+
{
|
81
|
+
:id => shared_config.id,
|
82
|
+
:name => shared_config.name,
|
83
|
+
:org => org,
|
84
|
+
:config_files => config_files,
|
85
|
+
:env_vars => env_vars,
|
86
|
+
:created_at => shared_config.created_at,
|
87
|
+
:updated_at => shared_config.updated_at
|
88
|
+
}
|
89
|
+
end
|
61
90
|
|
62
|
-
class << self
|
63
91
|
private
|
64
92
|
|
65
|
-
def config_files_count(
|
66
|
-
client.config_files.list_for_shared_config(
|
93
|
+
def config_files_count(shared_config_id)
|
94
|
+
client.config_files.list_for_shared_config(shared_config_id).to_a.size
|
67
95
|
end
|
68
96
|
|
69
|
-
def env_vars_count(
|
70
|
-
client.env_vars.list_for_shared_config(
|
97
|
+
def env_vars_count(shared_config_id)
|
98
|
+
client.env_vars.list_for_shared_config(shared_config_id).to_a.size
|
71
99
|
end
|
72
100
|
end
|
73
101
|
end
|
data/lib/sem/api/teams.rb
CHANGED
@@ -3,51 +3,66 @@ module Sem
|
|
3
3
|
class Teams < Base
|
4
4
|
extend Traits::AssociatedWithOrg
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
class << self
|
7
|
+
def name_to_id(org_name, team_name)
|
8
|
+
info(org_name, team_name)[:id]
|
9
|
+
end
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
+
def list
|
12
|
+
org_names = Sem::API::Orgs.list.map { |org| org[:username] }
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
org_names.pmap { |name| list_for_org(name) }.flatten
|
15
|
+
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
+
def info(org_name, team_name)
|
18
|
+
selected_team = list_for_org(org_name).find { |team| team[:name] == team_name }
|
17
19
|
|
18
|
-
|
19
|
-
team = api.create_for_org(org_name, args)
|
20
|
+
raise Sem::Errors::ResourceNotFound.new("Team", [org_name, team_name]) if selected_team.nil?
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
selected_team
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
def create(org_name, args)
|
26
|
+
team = api.create_for_org(org_name, args)
|
26
27
|
|
27
|
-
|
28
|
+
raise Sem::Errors::ResourceNotCreated.new("Team", [org_name, args[:name]]) if team.nil?
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
to_hash(team, org_name)
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
def update(org_name, team_name, args)
|
34
|
+
team = info(org_name, team_name)
|
34
35
|
|
35
|
-
|
36
|
-
end
|
36
|
+
team = api.update(team[:id], args)
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
raise Sem::Errors::ResourceNotUpdated.new("Team", [org_name, team_name]) if team.nil?
|
39
|
+
|
40
|
+
to_hash(team, org_name)
|
41
|
+
end
|
42
|
+
|
43
|
+
def delete(org_name, team_name)
|
44
|
+
team = info(org_name, team_name)
|
45
|
+
|
46
|
+
api.delete!(team[:id])
|
47
|
+
rescue SemaphoreClient::Exceptions::RequestFailed
|
48
|
+
raise Sem::Errors::ResourceNotDeleted.new("Team", [org_name, team_name])
|
49
|
+
end
|
50
|
+
|
51
|
+
def api
|
52
|
+
client.teams
|
53
|
+
end
|
41
54
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
55
|
+
def to_hash(team, org)
|
56
|
+
{
|
57
|
+
:id => team.id,
|
58
|
+
:name => team.name,
|
59
|
+
:org => org,
|
60
|
+
:permission => team.permission,
|
61
|
+
:members => client.users.list_for_team(team.id).to_a.size.to_s,
|
62
|
+
:created_at => team.created_at,
|
63
|
+
:updated_at => team.updated_at
|
64
|
+
}
|
65
|
+
end
|
51
66
|
end
|
52
67
|
end
|
53
68
|
end
|
@@ -2,10 +2,14 @@ module Sem
|
|
2
2
|
module API
|
3
3
|
module Traits
|
4
4
|
module AssociatedWithOrg
|
5
|
+
PAGES_PER_CALL = 3
|
6
|
+
|
5
7
|
def list_for_org(org_name)
|
6
|
-
|
8
|
+
pages = Sem::Pagination.pages(PAGES_PER_CALL) do |page_index|
|
9
|
+
api.list_for_org(org_name, :page => page_index).to_a
|
10
|
+
end
|
7
11
|
|
8
|
-
|
12
|
+
pages.flatten.pmap { |instance| to_hash(instance, org_name) }
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Sem
|
2
|
+
module API
|
3
|
+
module Traits
|
4
|
+
module AssociatedWithProject
|
5
|
+
def list_for_project(org_name, project_name)
|
6
|
+
project = Projects.info(org_name, project_name)
|
7
|
+
|
8
|
+
instances = api.list_for_project(project[:id]).to_a
|
9
|
+
|
10
|
+
instances.map { |instance| to_hash(instance, org_name) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_to_project(org_name, project_name, instance_name)
|
14
|
+
instance = info(org_name, instance_name)
|
15
|
+
project = Projects.info(org_name, project_name)
|
16
|
+
|
17
|
+
api.attach_to_project(instance[:id], project[:id])
|
18
|
+
end
|
19
|
+
|
20
|
+
def remove_from_project(org_name, project_name, instance_name)
|
21
|
+
instance = info(org_name, instance_name)
|
22
|
+
project = Projects.info(org_name, project_name)
|
23
|
+
|
24
|
+
api.detach_from_project(instance[:id], project[:id])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -2,25 +2,27 @@ module Sem
|
|
2
2
|
module API
|
3
3
|
module Traits
|
4
4
|
module AssociatedWithSharedConfig
|
5
|
-
def list_for_shared_config(
|
6
|
-
shared_config = SharedConfigs.info(
|
5
|
+
def list_for_shared_config(org_name, shared_config_name)
|
6
|
+
shared_config = SharedConfigs.info(org_name, shared_config_name)
|
7
7
|
|
8
|
-
instances = api.list_for_shared_config(shared_config[:id])
|
8
|
+
instances = api.list_for_shared_config(shared_config[:id]).to_a
|
9
9
|
|
10
10
|
instances.map { |instance| to_hash(instance) }
|
11
11
|
end
|
12
12
|
|
13
|
-
def add_to_shared_config(
|
14
|
-
shared_config = SharedConfigs.info(
|
13
|
+
def add_to_shared_config(org_name, shared_config_name, params)
|
14
|
+
shared_config = SharedConfigs.info(org_name, shared_config_name)
|
15
15
|
|
16
16
|
api.create_for_shared_config(shared_config[:id], params)
|
17
17
|
end
|
18
18
|
|
19
|
-
def remove_from_shared_config(
|
20
|
-
instances = list_for_shared_config(
|
19
|
+
def remove_from_shared_config(org_name, shared_config_name, instance_name)
|
20
|
+
instances = list_for_shared_config(org_name, shared_config_name)
|
21
21
|
|
22
22
|
selected_instance = instances.find { |instance| instance[:name] == instance_name }
|
23
23
|
|
24
|
+
raise Sem::Errors::ResourceNotFound.new("Resource", [org_name, instance_name]) if selected_instance.nil?
|
25
|
+
|
24
26
|
api.delete(selected_instance[:id])
|
25
27
|
end
|
26
28
|
end
|
@@ -2,26 +2,26 @@ module Sem
|
|
2
2
|
module API
|
3
3
|
module Traits
|
4
4
|
module AssociatedWithTeam
|
5
|
-
def list_for_team(
|
6
|
-
|
5
|
+
def list_for_team(org_name, team_name)
|
6
|
+
team_id = Teams.name_to_id(org_name, team_name)
|
7
7
|
|
8
|
-
instances = api.list_for_team(
|
8
|
+
instances = api.list_for_team(team_id).to_a
|
9
9
|
|
10
|
-
instances.map { |instance| to_hash(instance) }
|
10
|
+
instances.map { |instance| to_hash(instance, org_name) }
|
11
11
|
end
|
12
12
|
|
13
|
-
def add_to_team(
|
14
|
-
|
15
|
-
|
13
|
+
def add_to_team(org_name, team_name, instance_name)
|
14
|
+
instance_id = name_to_id(org_name, instance_name)
|
15
|
+
team_id = Teams.name_to_id(org_name, team_name)
|
16
16
|
|
17
|
-
api.attach_to_team(
|
17
|
+
api.attach_to_team(instance_id, team_id)
|
18
18
|
end
|
19
19
|
|
20
|
-
def remove_from_team(
|
21
|
-
|
22
|
-
|
20
|
+
def remove_from_team(org_name, team_name, instance_name)
|
21
|
+
instance_id = name_to_id(org_name, instance_name)
|
22
|
+
team_id = Teams.name_to_id(org_name, team_name)
|
23
23
|
|
24
|
-
api.detach_from_team(
|
24
|
+
api.detach_from_team(instance_id, team_id)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/lib/sem/api/traits.rb
CHANGED