Class: SemaphoreClient::Api::Team
- Inherits:
-
Object
- Object
- SemaphoreClient::Api::Team
- Defined in:
- lib/semaphore_client/api/team.rb
Instance Method Summary collapse
- #create_for_org(org_id, params) ⇒ Object
- #create_for_org!(org_id, params) ⇒ Object
- #delete(id) ⇒ Object
- #delete!(id) ⇒ Object
- #get(id) ⇒ Object
- #get!(id) ⇒ Object
-
#initialize(http_client) ⇒ Team
constructor
A new instance of Team.
- #list_for_org(org_id, query = nil) ⇒ Object
- #list_for_org!(org_id, query = nil) ⇒ Object
- #list_for_project(project_id, query = nil) ⇒ Object
- #list_for_project!(project_id, query = nil) ⇒ Object
- #list_for_shared_config(shared_config_id, query = nil) ⇒ Object
- #list_for_shared_config!(shared_config_id, query = nil) ⇒ Object
- #update(id, params) ⇒ Object
- #update!(id, params) ⇒ Object
Constructor Details
#initialize(http_client) ⇒ Team
Returns a new instance of Team.
4 5 6 |
# File 'lib/semaphore_client/api/team.rb', line 4 def initialize(http_client) @http_client = http_client end |
Instance Method Details
#create_for_org(org_id, params) ⇒ Object
13 14 15 16 |
# File 'lib/semaphore_client/api/team.rb', line 13 def create_for_org(org_id, params) create_for_org!(org_id, params) rescue SemaphoreClient::Exceptions::RequestFailed end |
#create_for_org!(org_id, params) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/semaphore_client/api/team.rb', line 57 def create_for_org!(org_id, params) response = @http_client.post([:orgs, org_id, :teams], params.to_json) assert_response_status(response, 200) content = JSON.parse(response.body) SemaphoreClient::Model::Team.load(content) end |
#delete(id) ⇒ Object
23 24 25 26 |
# File 'lib/semaphore_client/api/team.rb', line 23 def delete(id) delete!(id) rescue SemaphoreClient::Exceptions::RequestFailed end |
#delete!(id) ⇒ Object
77 78 79 80 81 |
# File 'lib/semaphore_client/api/team.rb', line 77 def delete!(id) response = @http_client.delete([:teams, id]) assert_response_status(response, 200) end |
#get(id) ⇒ Object
18 19 20 21 |
# File 'lib/semaphore_client/api/team.rb', line 18 def get(id) get!(id) rescue SemaphoreClient::Exceptions::RequestFailed end |
#get!(id) ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/semaphore_client/api/team.rb', line 67 def get!(id) response = @http_client.get([:teams, id]) assert_response_status(response, 200) content = JSON.parse(response.body) SemaphoreClient::Model::Team.load(content) end |
#list_for_org(org_id, query = nil) ⇒ Object
8 9 10 11 |
# File 'lib/semaphore_client/api/team.rb', line 8 def list_for_org(org_id, query = nil) list_for_org!(org_id, query) rescue SemaphoreClient::Exceptions::RequestFailed end |
#list_for_org!(org_id, query = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/semaphore_client/api/team.rb', line 43 def list_for_org!(org_id, query = nil) query_string = query.nil? ? nil : "?#{query}" response = @http_client.get([:orgs, org_id, :teams, query_string].compact) assert_response_status(response, 200) content = JSON.parse(response.body) content.map do |entity| SemaphoreClient::Model::Team.load(entity) end end |
#list_for_project(project_id, query = nil) ⇒ Object
33 34 35 36 |
# File 'lib/semaphore_client/api/team.rb', line 33 def list_for_project(project_id, query = nil) list_for_project!(project_id, query) rescue SemaphoreClient::Exceptions::RequestFailed end |
#list_for_project!(project_id, query = nil) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/semaphore_client/api/team.rb', line 93 def list_for_project!(project_id, query = nil) query_string = query.nil? ? nil : "?#{query}" response = @http_client.get([:projects, project_id, :teams, query_string].compact) assert_response_status(response, 200) content = JSON.parse(response.body) content.map do |entity| SemaphoreClient::Model::Team.load(entity) end end |
#list_for_shared_config(shared_config_id, query = nil) ⇒ Object
38 39 40 41 |
# File 'lib/semaphore_client/api/team.rb', line 38 def list_for_shared_config(shared_config_id, query = nil) list_for_shared_config!(shared_config_id, query) rescue SemaphoreClient::Exceptions::RequestFailed end |
#list_for_shared_config!(shared_config_id, query = nil) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/semaphore_client/api/team.rb', line 107 def list_for_shared_config!(shared_config_id, query = nil) query_string = query.nil? ? nil : "?#{query}" response = @http_client.get([:shared_configs, shared_config_id, :teams, query_string].compact) assert_response_status(response, 200) content = JSON.parse(response.body) content.map do |entity| SemaphoreClient::Model::Team.load(entity) end end |
#update(id, params) ⇒ Object
28 29 30 31 |
# File 'lib/semaphore_client/api/team.rb', line 28 def update(id, params) update!(id, params) rescue SemaphoreClient::Exceptions::RequestFailed end |
#update!(id, params) ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/semaphore_client/api/team.rb', line 83 def update!(id, params) response = @http_client.patch([:teams, id], params.to_json) assert_response_status(response, 200) content = JSON.parse(response.body) SemaphoreClient::Model::Team.load(content) end |