Class: SemaphoreClient::Api::Project
- Inherits:
-
Object
- Object
- SemaphoreClient::Api::Project
- Defined in:
- lib/semaphore_client/api/project.rb
Instance Method Summary collapse
- #attach_to_team(project_id, team_id) ⇒ Object
- #attach_to_team!(project_id, team_id) ⇒ Object
- #detach_from_team(project_id, team_id) ⇒ Object
- #detach_from_team!(project_id, team_id) ⇒ Object
-
#initialize(http_client) ⇒ Project
constructor
A new instance of Project.
- #list_for_org(org_id, query = nil) ⇒ Object
- #list_for_org!(org_id, query = nil) ⇒ Object
- #list_for_shared_config(shared_config_id, query = nil) ⇒ Object
- #list_for_shared_config!(shared_config_id, query = nil) ⇒ Object
- #list_for_team(team_id, query = nil) ⇒ Object
- #list_for_team!(team_id, query = nil) ⇒ Object
Constructor Details
#initialize(http_client) ⇒ Project
Returns a new instance of Project.
4 5 6 |
# File 'lib/semaphore_client/api/project.rb', line 4 def initialize(http_client) @http_client = http_client end |
Instance Method Details
#attach_to_team(project_id, team_id) ⇒ Object
18 19 20 21 |
# File 'lib/semaphore_client/api/project.rb', line 18 def attach_to_team(project_id, team_id) attach_to_team!(project_id, team_id) rescue SemaphoreClient::Exceptions::RequestFailed end |
#attach_to_team!(project_id, team_id) ⇒ Object
61 62 63 64 65 |
# File 'lib/semaphore_client/api/project.rb', line 61 def attach_to_team!(project_id, team_id) response = @http_client.post([:teams, team_id, :projects, project_id]) assert_response_status(response, 204) end |
#detach_from_team(project_id, team_id) ⇒ Object
23 24 25 26 |
# File 'lib/semaphore_client/api/project.rb', line 23 def detach_from_team(project_id, team_id) detach_from_team!(project_id, team_id) rescue SemaphoreClient::Exceptions::RequestFailed end |
#detach_from_team!(project_id, team_id) ⇒ Object
67 68 69 70 71 |
# File 'lib/semaphore_client/api/project.rb', line 67 def detach_from_team!(project_id, team_id) response = @http_client.delete([:teams, team_id, :projects, project_id]) assert_response_status(response, 204) end |
#list_for_org(org_id, query = nil) ⇒ Object
8 9 10 11 |
# File 'lib/semaphore_client/api/project.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
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/semaphore_client/api/project.rb', line 33 def list_for_org!(org_id, query = nil) query_string = query.nil? ? nil : "?#{query}" response = @http_client.get([:orgs, org_id, :projects, query_string].compact) assert_response_status(response, 200) content = JSON.parse(response.body) content.map do |entity| SemaphoreClient::Model::Project.load(entity) end end |
#list_for_shared_config(shared_config_id, query = nil) ⇒ Object
28 29 30 31 |
# File 'lib/semaphore_client/api/project.rb', line 28 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
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/semaphore_client/api/project.rb', line 73 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, :projects, query_string].compact) assert_response_status(response, 200) content = JSON.parse(response.body) content.map do |entity| SemaphoreClient::Model::Project.load(entity) end end |
#list_for_team(team_id, query = nil) ⇒ Object
13 14 15 16 |
# File 'lib/semaphore_client/api/project.rb', line 13 def list_for_team(team_id, query = nil) list_for_team!(team_id, query) rescue SemaphoreClient::Exceptions::RequestFailed end |
#list_for_team!(team_id, query = nil) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/semaphore_client/api/project.rb', line 47 def list_for_team!(team_id, query = nil) query_string = query.nil? ? nil : "?#{query}" response = @http_client.get([:teams, team_id, :projects, query_string].compact) assert_response_status(response, 200) content = JSON.parse(response.body) content.map do |entity| SemaphoreClient::Model::Project.load(entity) end end |