semaphore_client 2.3.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/semaphore_client.rb +7 -5
- data/lib/semaphore_client/api/config_file.rb +59 -81
- data/lib/semaphore_client/api/env_var.rb +59 -81
- data/lib/semaphore_client/api/org.rb +15 -27
- data/lib/semaphore_client/api/project.rb +42 -73
- data/lib/semaphore_client/api/shared_config.rb +81 -108
- data/lib/semaphore_client/api/team.rb +50 -85
- data/lib/semaphore_client/api/user.rb +34 -64
- data/lib/semaphore_client/exceptions.rb +34 -2
- data/lib/semaphore_client/http_client.rb +73 -53
- data/lib/semaphore_client/version.rb +1 -1
- data/semaphore_client.gemspec +3 -1
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d4ea7977e94aa5c80b02123679165c5cc3f6720
|
4
|
+
data.tar.gz: 147e7c0565697549c42bf2b4193e98e8045a525c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7c4bf97917f9d10322bf30dddee91be955aff962ce42baa3214c821b80a8b62b94a9a9ce1d95852884822ce225b237b842f1bcdf284ddd4ca480cb2440402d8
|
7
|
+
data.tar.gz: 9b654def04a757c7b531dbbbe85ae4faebb547ff9c545bfbb026d47285178e508e92e3513dfea2ea681dc6b8066c3cd329c8e0cb5e19d17f0231d871404be78b
|
data/Gemfile.lock
CHANGED
data/lib/semaphore_client.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "json"
|
2
2
|
require "securerandom"
|
3
3
|
require "faraday"
|
4
|
+
require "faraday_middleware"
|
4
5
|
require "logger"
|
5
6
|
|
6
7
|
require "semaphore_client/version"
|
@@ -28,10 +29,11 @@ class SemaphoreClient
|
|
28
29
|
def initialize(auth_token, options = {})
|
29
30
|
@auth_token = auth_token
|
30
31
|
|
31
|
-
@api_url
|
32
|
-
@api_version
|
33
|
-
@verbose
|
34
|
-
@logger
|
32
|
+
@api_url = options.fetch(:api_url, API_URL)
|
33
|
+
@api_version = options.fetch(:api_version, API_VERSION)
|
34
|
+
@verbose = options.fetch(:verbose, false)
|
35
|
+
@logger = options.fetch(:logger, Logger.new(STDOUT))
|
36
|
+
@auto_paginate = options.fetch(:auto_paginate, false)
|
35
37
|
end
|
36
38
|
|
37
39
|
def users
|
@@ -65,6 +67,6 @@ class SemaphoreClient
|
|
65
67
|
private
|
66
68
|
|
67
69
|
def http_client
|
68
|
-
@http_client ||= SemaphoreClient::HttpClient.new(@auth_token, @api_url, @api_version, @verbose, @logger)
|
70
|
+
@http_client ||= SemaphoreClient::HttpClient.new(@auth_token, @api_url, @api_version, @verbose, @logger, @auto_paginate)
|
69
71
|
end
|
70
72
|
end
|
@@ -5,135 +5,113 @@ class SemaphoreClient
|
|
5
5
|
@http_client = http_client
|
6
6
|
end
|
7
7
|
|
8
|
-
def list_for_project(project_id, query = nil)
|
9
|
-
list_for_project!(project_id, query)
|
10
|
-
rescue SemaphoreClient::Exceptions::RequestFailed
|
11
|
-
end
|
12
8
|
|
13
|
-
def
|
14
|
-
|
15
|
-
rescue SemaphoreClient::Exceptions::
|
9
|
+
def list_for_project(project_id, params = nil, options = {})
|
10
|
+
list_for_project!(project_id, params, options)
|
11
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
16
12
|
end
|
17
13
|
|
18
|
-
def
|
19
|
-
|
20
|
-
rescue SemaphoreClient::Exceptions::RequestFailed
|
21
|
-
end
|
14
|
+
def list_for_project!(project_id, params = nil, options = {})
|
15
|
+
path = "/projects/#{project_id}/config_files"
|
22
16
|
|
23
|
-
|
24
|
-
list_for_shared_config!(shared_config_id, query)
|
25
|
-
rescue SemaphoreClient::Exceptions::RequestFailed
|
17
|
+
@http_client.get(path, params, options = {}).body.map { |e| SemaphoreClient::Model::ConfigFile.load(e) }
|
26
18
|
end
|
27
19
|
|
28
|
-
def create_for_shared_config(shared_config_id, params)
|
29
|
-
create_for_shared_config!(shared_config_id, params)
|
30
|
-
rescue SemaphoreClient::Exceptions::RequestFailed
|
31
|
-
end
|
32
20
|
|
33
|
-
def get(id)
|
34
|
-
get!(id)
|
35
|
-
rescue SemaphoreClient::Exceptions::RequestFailed
|
36
|
-
end
|
37
21
|
|
38
|
-
def
|
39
|
-
|
40
|
-
rescue SemaphoreClient::Exceptions::
|
22
|
+
def attach_to_project(config_file_id, project_id, params = nil, options = {})
|
23
|
+
attach_to_project!(config_file_id, project_id, params, options)
|
24
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
41
25
|
end
|
42
26
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
27
|
+
def attach_to_project!(config_file_id, project_id, params = nil, options = {})
|
28
|
+
path = "/projects/#{project_id}/config_files/#{config_file_id}"
|
29
|
+
|
30
|
+
@http_client.post(path, params, options)
|
46
31
|
end
|
47
32
|
|
48
|
-
def list_for_project!(project_id, query = nil)
|
49
|
-
query_string =
|
50
|
-
unless query.nil? || query.empty?
|
51
|
-
"?" + query.map { |key, value| "#{key}=#{value}" }.join("&")
|
52
|
-
end
|
53
33
|
|
54
|
-
response = @http_client.get([:projects, project_id, :config_files, query_string].compact)
|
55
34
|
|
56
|
-
|
35
|
+
def detach_from_project(config_file_id, project_id, params = nil, options = {})
|
36
|
+
detach_from_project!(config_file_id, project_id, params, options)
|
37
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
38
|
+
end
|
57
39
|
|
58
|
-
|
40
|
+
def detach_from_project!(config_file_id, project_id, params = nil, options = {})
|
41
|
+
path = "/projects/#{project_id}/config_files/#{config_file_id}"
|
59
42
|
|
60
|
-
|
61
|
-
SemaphoreClient::Model::ConfigFile.load(entity)
|
62
|
-
end
|
43
|
+
@http_client.delete(path, params, options)
|
63
44
|
end
|
64
45
|
|
65
|
-
def attach_to_project!(config_file_id, project_id)
|
66
|
-
response = @http_client.post([:projects, project_id, :config_files, config_file_id])
|
67
46
|
|
68
|
-
|
47
|
+
|
48
|
+
def list_for_shared_config(shared_config_id, params = nil, options = {})
|
49
|
+
list_for_shared_config!(shared_config_id, params, options)
|
50
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
69
51
|
end
|
70
52
|
|
71
|
-
def
|
72
|
-
|
53
|
+
def list_for_shared_config!(shared_config_id, params = nil, options = {})
|
54
|
+
path = "/shared_configs/#{shared_config_id}/config_files"
|
73
55
|
|
74
|
-
|
56
|
+
@http_client.get(path, params, options = {}).body.map { |e| SemaphoreClient::Model::ConfigFile.load(e) }
|
75
57
|
end
|
76
58
|
|
77
|
-
def list_for_shared_config!(shared_config_id, query = nil)
|
78
|
-
query_string =
|
79
|
-
unless query.nil? || query.empty?
|
80
|
-
"?" + query.map { |key, value| "#{key}=#{value}" }.join("&")
|
81
|
-
end
|
82
59
|
|
83
|
-
response = @http_client.get([:shared_configs, shared_config_id, :config_files, query_string].compact)
|
84
60
|
|
85
|
-
|
61
|
+
def create_for_shared_config(shared_config_id, params = nil, options = {})
|
62
|
+
create_for_shared_config!(shared_config_id, params, options)
|
63
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
64
|
+
end
|
86
65
|
|
87
|
-
|
66
|
+
def create_for_shared_config!(shared_config_id, params = nil, options = {})
|
67
|
+
path = "/shared_configs/#{shared_config_id}/config_files"
|
68
|
+
response = @http_client.post(path, params, options)
|
88
69
|
|
89
|
-
|
90
|
-
SemaphoreClient::Model::ConfigFile.load(entity)
|
91
|
-
end
|
70
|
+
SemaphoreClient::Model::ConfigFile.load(response.body)
|
92
71
|
end
|
93
72
|
|
94
|
-
def create_for_shared_config!(shared_config_id, params)
|
95
|
-
response = @http_client.post([:shared_configs, shared_config_id, :config_files], params.to_json)
|
96
73
|
|
97
|
-
assert_response_status(response, 200)
|
98
74
|
|
99
|
-
|
100
|
-
|
101
|
-
|
75
|
+
def get(id, params = nil, options = {})
|
76
|
+
get!(id, params, options)
|
77
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
102
78
|
end
|
103
79
|
|
104
|
-
def get!(id)
|
105
|
-
|
80
|
+
def get!(id, params = nil, options = {})
|
81
|
+
path = "/config_files/#{id}"
|
82
|
+
response = @http_client.get(path, params = {})
|
83
|
+
|
84
|
+
SemaphoreClient::Model::ConfigFile.load(response.body)
|
85
|
+
end
|
106
86
|
|
107
|
-
assert_response_status(response, 200)
|
108
87
|
|
109
|
-
content = JSON.parse(response.body)
|
110
88
|
|
111
|
-
|
89
|
+
def delete(id, params = nil, options = {})
|
90
|
+
delete!(id, params, options)
|
91
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
112
92
|
end
|
113
93
|
|
114
|
-
def delete!(id)
|
115
|
-
|
94
|
+
def delete!(id, params = nil, options = {})
|
95
|
+
path = "/config_files/#{id}"
|
116
96
|
|
117
|
-
|
97
|
+
@http_client.delete(path, params)
|
118
98
|
end
|
119
99
|
|
120
|
-
def update!(id, params)
|
121
|
-
response = @http_client.patch([:config_files, id], params.to_json)
|
122
|
-
|
123
|
-
assert_response_status(response, 200)
|
124
100
|
|
125
|
-
content = JSON.parse(response.body)
|
126
101
|
|
127
|
-
|
102
|
+
def update(id, params = nil, options = {})
|
103
|
+
update!(id, params, options)
|
104
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
128
105
|
end
|
129
106
|
|
130
|
-
|
107
|
+
def update!(id, params = nil, options = {})
|
108
|
+
path = "/config_files/#{id}"
|
109
|
+
response = @http_client.patch(path, params)
|
131
110
|
|
132
|
-
|
133
|
-
return if response.status == expected_status
|
134
|
-
|
135
|
-
raise SemaphoreClient::Exceptions::RequestFailed, response.status
|
111
|
+
SemaphoreClient::Model::ConfigFile.load(response.body)
|
136
112
|
end
|
113
|
+
|
114
|
+
|
137
115
|
end
|
138
116
|
end
|
139
117
|
end
|
@@ -5,135 +5,113 @@ class SemaphoreClient
|
|
5
5
|
@http_client = http_client
|
6
6
|
end
|
7
7
|
|
8
|
-
def list_for_project(project_id, query = nil)
|
9
|
-
list_for_project!(project_id, query)
|
10
|
-
rescue SemaphoreClient::Exceptions::RequestFailed
|
11
|
-
end
|
12
8
|
|
13
|
-
def
|
14
|
-
|
15
|
-
rescue SemaphoreClient::Exceptions::
|
9
|
+
def list_for_project(project_id, params = nil, options = {})
|
10
|
+
list_for_project!(project_id, params, options)
|
11
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
16
12
|
end
|
17
13
|
|
18
|
-
def
|
19
|
-
|
20
|
-
rescue SemaphoreClient::Exceptions::RequestFailed
|
21
|
-
end
|
14
|
+
def list_for_project!(project_id, params = nil, options = {})
|
15
|
+
path = "/projects/#{project_id}/env_vars"
|
22
16
|
|
23
|
-
|
24
|
-
list_for_shared_config!(shared_config_id, query)
|
25
|
-
rescue SemaphoreClient::Exceptions::RequestFailed
|
17
|
+
@http_client.get(path, params, options = {}).body.map { |e| SemaphoreClient::Model::EnvVar.load(e) }
|
26
18
|
end
|
27
19
|
|
28
|
-
def create_for_shared_config(shared_config_id, params)
|
29
|
-
create_for_shared_config!(shared_config_id, params)
|
30
|
-
rescue SemaphoreClient::Exceptions::RequestFailed
|
31
|
-
end
|
32
20
|
|
33
|
-
def get(id)
|
34
|
-
get!(id)
|
35
|
-
rescue SemaphoreClient::Exceptions::RequestFailed
|
36
|
-
end
|
37
21
|
|
38
|
-
def
|
39
|
-
|
40
|
-
rescue SemaphoreClient::Exceptions::
|
22
|
+
def attach_to_project(env_var_id, project_id, params = nil, options = {})
|
23
|
+
attach_to_project!(env_var_id, project_id, params, options)
|
24
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
41
25
|
end
|
42
26
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
27
|
+
def attach_to_project!(env_var_id, project_id, params = nil, options = {})
|
28
|
+
path = "/projects/#{project_id}/env_vars/#{env_var_id}"
|
29
|
+
|
30
|
+
@http_client.post(path, params, options)
|
46
31
|
end
|
47
32
|
|
48
|
-
def list_for_project!(project_id, query = nil)
|
49
|
-
query_string =
|
50
|
-
unless query.nil? || query.empty?
|
51
|
-
"?" + query.map { |key, value| "#{key}=#{value}" }.join("&")
|
52
|
-
end
|
53
33
|
|
54
|
-
response = @http_client.get([:projects, project_id, :env_vars, query_string].compact)
|
55
34
|
|
56
|
-
|
35
|
+
def detach_from_project(env_var_id, project_id, params = nil, options = {})
|
36
|
+
detach_from_project!(env_var_id, project_id, params, options)
|
37
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
38
|
+
end
|
57
39
|
|
58
|
-
|
40
|
+
def detach_from_project!(env_var_id, project_id, params = nil, options = {})
|
41
|
+
path = "/projects/#{project_id}/env_vars/#{env_var_id}"
|
59
42
|
|
60
|
-
|
61
|
-
SemaphoreClient::Model::EnvVar.load(entity)
|
62
|
-
end
|
43
|
+
@http_client.delete(path, params, options)
|
63
44
|
end
|
64
45
|
|
65
|
-
def attach_to_project!(env_var_id, project_id)
|
66
|
-
response = @http_client.post([:projects, project_id, :env_vars, env_var_id])
|
67
46
|
|
68
|
-
|
47
|
+
|
48
|
+
def list_for_shared_config(shared_config_id, params = nil, options = {})
|
49
|
+
list_for_shared_config!(shared_config_id, params, options)
|
50
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
69
51
|
end
|
70
52
|
|
71
|
-
def
|
72
|
-
|
53
|
+
def list_for_shared_config!(shared_config_id, params = nil, options = {})
|
54
|
+
path = "/shared_configs/#{shared_config_id}/env_vars"
|
73
55
|
|
74
|
-
|
56
|
+
@http_client.get(path, params, options = {}).body.map { |e| SemaphoreClient::Model::EnvVar.load(e) }
|
75
57
|
end
|
76
58
|
|
77
|
-
def list_for_shared_config!(shared_config_id, query = nil)
|
78
|
-
query_string =
|
79
|
-
unless query.nil? || query.empty?
|
80
|
-
"?" + query.map { |key, value| "#{key}=#{value}" }.join("&")
|
81
|
-
end
|
82
59
|
|
83
|
-
response = @http_client.get([:shared_configs, shared_config_id, :env_vars, query_string].compact)
|
84
60
|
|
85
|
-
|
61
|
+
def create_for_shared_config(shared_config_id, params = nil, options = {})
|
62
|
+
create_for_shared_config!(shared_config_id, params, options)
|
63
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
64
|
+
end
|
86
65
|
|
87
|
-
|
66
|
+
def create_for_shared_config!(shared_config_id, params = nil, options = {})
|
67
|
+
path = "/shared_configs/#{shared_config_id}/env_vars"
|
68
|
+
response = @http_client.post(path, params, options)
|
88
69
|
|
89
|
-
|
90
|
-
SemaphoreClient::Model::EnvVar.load(entity)
|
91
|
-
end
|
70
|
+
SemaphoreClient::Model::EnvVar.load(response.body)
|
92
71
|
end
|
93
72
|
|
94
|
-
def create_for_shared_config!(shared_config_id, params)
|
95
|
-
response = @http_client.post([:shared_configs, shared_config_id, :env_vars], params.to_json)
|
96
73
|
|
97
|
-
assert_response_status(response, 200)
|
98
74
|
|
99
|
-
|
100
|
-
|
101
|
-
|
75
|
+
def get(id, params = nil, options = {})
|
76
|
+
get!(id, params, options)
|
77
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
102
78
|
end
|
103
79
|
|
104
|
-
def get!(id)
|
105
|
-
|
80
|
+
def get!(id, params = nil, options = {})
|
81
|
+
path = "/env_vars/#{id}"
|
82
|
+
response = @http_client.get(path, params = {})
|
83
|
+
|
84
|
+
SemaphoreClient::Model::EnvVar.load(response.body)
|
85
|
+
end
|
106
86
|
|
107
|
-
assert_response_status(response, 200)
|
108
87
|
|
109
|
-
content = JSON.parse(response.body)
|
110
88
|
|
111
|
-
|
89
|
+
def delete(id, params = nil, options = {})
|
90
|
+
delete!(id, params, options)
|
91
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
112
92
|
end
|
113
93
|
|
114
|
-
def delete!(id)
|
115
|
-
|
94
|
+
def delete!(id, params = nil, options = {})
|
95
|
+
path = "/env_vars/#{id}"
|
116
96
|
|
117
|
-
|
97
|
+
@http_client.delete(path, params)
|
118
98
|
end
|
119
99
|
|
120
|
-
def update!(id, params)
|
121
|
-
response = @http_client.patch([:env_vars, id], params.to_json)
|
122
|
-
|
123
|
-
assert_response_status(response, 200)
|
124
100
|
|
125
|
-
content = JSON.parse(response.body)
|
126
101
|
|
127
|
-
|
102
|
+
def update(id, params = nil, options = {})
|
103
|
+
update!(id, params, options)
|
104
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
128
105
|
end
|
129
106
|
|
130
|
-
|
107
|
+
def update!(id, params = nil, options = {})
|
108
|
+
path = "/env_vars/#{id}"
|
109
|
+
response = @http_client.patch(path, params)
|
131
110
|
|
132
|
-
|
133
|
-
return if response.status == expected_status
|
134
|
-
|
135
|
-
raise SemaphoreClient::Exceptions::RequestFailed, response.status
|
111
|
+
SemaphoreClient::Model::EnvVar.load(response.body)
|
136
112
|
end
|
113
|
+
|
114
|
+
|
137
115
|
end
|
138
116
|
end
|
139
117
|
end
|
@@ -5,45 +5,33 @@ class SemaphoreClient
|
|
5
5
|
@http_client = http_client
|
6
6
|
end
|
7
7
|
|
8
|
-
def list
|
9
|
-
list!
|
10
|
-
rescue SemaphoreClient::Exceptions::RequestFailed
|
11
|
-
end
|
12
8
|
|
13
|
-
def
|
14
|
-
|
15
|
-
rescue SemaphoreClient::Exceptions::
|
9
|
+
def list(params = nil, options = {})
|
10
|
+
list!(params, options)
|
11
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
16
12
|
end
|
17
13
|
|
18
|
-
def list!
|
19
|
-
|
20
|
-
|
21
|
-
assert_response_status(response, 200)
|
14
|
+
def list!(params = nil, options = {})
|
15
|
+
path = "/orgs"
|
22
16
|
|
23
|
-
|
24
|
-
|
25
|
-
content.map do |entity|
|
26
|
-
SemaphoreClient::Model::Org.load(entity)
|
27
|
-
end
|
17
|
+
@http_client.get(path, params, options).body.map { |e| SemaphoreClient::Model::Org.load(e) }
|
28
18
|
end
|
29
19
|
|
30
|
-
def get!(id)
|
31
|
-
response = @http_client.get([:orgs, id])
|
32
|
-
|
33
|
-
assert_response_status(response, 200)
|
34
20
|
|
35
|
-
content = JSON.parse(response.body)
|
36
21
|
|
37
|
-
|
22
|
+
def get(id, params = nil, options = {})
|
23
|
+
get!(id, params, options)
|
24
|
+
rescue SemaphoreClient::Exceptions::ResponseError
|
38
25
|
end
|
39
26
|
|
40
|
-
|
27
|
+
def get!(id, params = nil, options = {})
|
28
|
+
path = "/orgs/#{id}"
|
29
|
+
response = @http_client.get(path, params = {})
|
41
30
|
|
42
|
-
|
43
|
-
return if response.status == expected_status
|
44
|
-
|
45
|
-
raise SemaphoreClient::Exceptions::RequestFailed, response.status
|
31
|
+
SemaphoreClient::Model::Org.load(response.body)
|
46
32
|
end
|
33
|
+
|
34
|
+
|
47
35
|
end
|
48
36
|
end
|
49
37
|
end
|