Class: SemaphoreClient::Api::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/semaphore_client/api/project.rb

Instance Method Summary collapse

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



57
58
59
60
61
# File 'lib/semaphore_client/api/project.rb', line 57

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



63
64
65
66
67
# File 'lib/semaphore_client/api/project.rb', line 63

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) ⇒ Object



8
9
10
11
# File 'lib/semaphore_client/api/project.rb', line 8

def list_for_org(org_id)
  list_for_org!(org_id)
rescue SemaphoreClient::Exceptions::RequestFailed
end

#list_for_org!(org_id) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/semaphore_client/api/project.rb', line 33

def list_for_org!(org_id)
  response = @http_client.get([:orgs, org_id, :projects])

  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) ⇒ Object



28
29
30
31
# File 'lib/semaphore_client/api/project.rb', line 28

def list_for_shared_config(shared_config_id)
  list_for_shared_config!(shared_config_id)
rescue SemaphoreClient::Exceptions::RequestFailed
end

#list_for_shared_config!(shared_config_id) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/semaphore_client/api/project.rb', line 69

def list_for_shared_config!(shared_config_id)
  response = @http_client.get([:shared_configs, shared_config_id, :projects])

  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) ⇒ Object



13
14
15
16
# File 'lib/semaphore_client/api/project.rb', line 13

def list_for_team(team_id)
  list_for_team!(team_id)
rescue SemaphoreClient::Exceptions::RequestFailed
end

#list_for_team!(team_id) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/semaphore_client/api/project.rb', line 45

def list_for_team!(team_id)
  response = @http_client.get([:teams, team_id, :projects])

  assert_response_status(response, 200)

  content = JSON.parse(response.body)

  content.map do |entity|
    SemaphoreClient::Model::Project.load(entity)
  end
end