Class: SemaphoreClient::Api::SharedConfig

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

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ SharedConfig

Returns a new instance of SharedConfig.



4
5
6
# File 'lib/semaphore_client/api/shared_config.rb', line 4

def initialize(http_client)
  @http_client = http_client
end

Instance Method Details

#attach_to_project(shared_config_id, project_id) ⇒ Object



38
39
40
41
# File 'lib/semaphore_client/api/shared_config.rb', line 38

def attach_to_project(shared_config_id, project_id)
  attach_to_project!(shared_config_id, project_id)
rescue SemaphoreClient::Exceptions::RequestFailed
end

#attach_to_project!(shared_config_id, project_id) ⇒ Object



127
128
129
130
131
# File 'lib/semaphore_client/api/shared_config.rb', line 127

def attach_to_project!(shared_config_id, project_id)
  response = @http_client.post([:projects, project_id, :shared_configs, shared_config_id])

  assert_response_status(response, 204)
end

#attach_to_team(shared_config_id, team_id) ⇒ Object



23
24
25
26
# File 'lib/semaphore_client/api/shared_config.rb', line 23

def attach_to_team(shared_config_id, team_id)
  attach_to_team!(shared_config_id, team_id)
rescue SemaphoreClient::Exceptions::RequestFailed
end

#attach_to_team!(shared_config_id, team_id) ⇒ Object



101
102
103
104
105
# File 'lib/semaphore_client/api/shared_config.rb', line 101

def attach_to_team!(shared_config_id, team_id)
  response = @http_client.post([:teams, team_id, :shared_configs, shared_config_id])

  assert_response_status(response, 204)
end

#create_for_org(org_id, params) ⇒ Object



13
14
15
16
# File 'lib/semaphore_client/api/shared_config.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



77
78
79
80
81
82
83
84
85
# File 'lib/semaphore_client/api/shared_config.rb', line 77

def create_for_org!(org_id, params)
  response = @http_client.post([:orgs, org_id, :shared_configs], params.to_json)

  assert_response_status(response, 200)

  content = JSON.parse(response.body)

  SemaphoreClient::Model::SharedConfig.load(content)
end

#delete(id) ⇒ Object



53
54
55
56
# File 'lib/semaphore_client/api/shared_config.rb', line 53

def delete(id)
  delete!(id)
rescue SemaphoreClient::Exceptions::RequestFailed
end

#delete!(id) ⇒ Object



149
150
151
152
153
# File 'lib/semaphore_client/api/shared_config.rb', line 149

def delete!(id)
  response = @http_client.delete([:shared_configs, id])

  assert_response_status(response, 200)
end

#detach_from_project(shared_config_id, project_id) ⇒ Object



43
44
45
46
# File 'lib/semaphore_client/api/shared_config.rb', line 43

def detach_from_project(shared_config_id, project_id)
  detach_from_project!(shared_config_id, project_id)
rescue SemaphoreClient::Exceptions::RequestFailed
end

#detach_from_project!(shared_config_id, project_id) ⇒ Object



133
134
135
136
137
# File 'lib/semaphore_client/api/shared_config.rb', line 133

def detach_from_project!(shared_config_id, project_id)
  response = @http_client.delete([:projects, project_id, :shared_configs, shared_config_id])

  assert_response_status(response, 204)
end

#detach_from_team(shared_config_id, team_id) ⇒ Object



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

def detach_from_team(shared_config_id, team_id)
  detach_from_team!(shared_config_id, team_id)
rescue SemaphoreClient::Exceptions::RequestFailed
end

#detach_from_team!(shared_config_id, team_id) ⇒ Object



107
108
109
110
111
# File 'lib/semaphore_client/api/shared_config.rb', line 107

def detach_from_team!(shared_config_id, team_id)
  response = @http_client.delete([:teams, team_id, :shared_configs, shared_config_id])

  assert_response_status(response, 204)
end

#get(id) ⇒ Object



48
49
50
51
# File 'lib/semaphore_client/api/shared_config.rb', line 48

def get(id)
  get!(id)
rescue SemaphoreClient::Exceptions::RequestFailed
end

#get!(id) ⇒ Object



139
140
141
142
143
144
145
146
147
# File 'lib/semaphore_client/api/shared_config.rb', line 139

def get!(id)
  response = @http_client.get([:shared_configs, id])

  assert_response_status(response, 200)

  content = JSON.parse(response.body)

  SemaphoreClient::Model::SharedConfig.load(content)
end

#list_for_org(org_id, query = nil) ⇒ Object



8
9
10
11
# File 'lib/semaphore_client/api/shared_config.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



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/semaphore_client/api/shared_config.rb', line 63

def list_for_org!(org_id, query = nil)
  query_string = query.nil? ? nil : "?#{query}"

  response = @http_client.get([:orgs, org_id, :shared_configs, query_string].compact)

  assert_response_status(response, 200)

  content = JSON.parse(response.body)

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

#list_for_project(project_id, query = nil) ⇒ Object



33
34
35
36
# File 'lib/semaphore_client/api/shared_config.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



113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/semaphore_client/api/shared_config.rb', line 113

def list_for_project!(project_id, query = nil)
  query_string = query.nil? ? nil : "?#{query}"

  response = @http_client.get([:projects, project_id, :shared_configs, query_string].compact)

  assert_response_status(response, 200)

  content = JSON.parse(response.body)

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

#list_for_team(team_id, query = nil) ⇒ Object



18
19
20
21
# File 'lib/semaphore_client/api/shared_config.rb', line 18

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



87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/semaphore_client/api/shared_config.rb', line 87

def list_for_team!(team_id, query = nil)
  query_string = query.nil? ? nil : "?#{query}"

  response = @http_client.get([:teams, team_id, :shared_configs, query_string].compact)

  assert_response_status(response, 200)

  content = JSON.parse(response.body)

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

#update(id, params) ⇒ Object



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

def update(id, params)
  update!(id, params)
rescue SemaphoreClient::Exceptions::RequestFailed
end

#update!(id, params) ⇒ Object



155
156
157
158
159
160
161
162
163
# File 'lib/semaphore_client/api/shared_config.rb', line 155

def update!(id, params)
  response = @http_client.patch([:shared_configs, id], params.to_json)

  assert_response_status(response, 200)

  content = JSON.parse(response.body)

  SemaphoreClient::Model::SharedConfig.load(content)
end