Class: SemaphoreClient::Api::Secret

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

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ Secret

Returns a new instance of Secret.



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

def initialize(http_client)
  @http_client = http_client
end

Instance Method Details

#attach_to_project(secret_id, project_id, params = nil, options = {}) ⇒ Object



88
89
90
91
# File 'lib/semaphore_client/api/secret.rb', line 88

def attach_to_project(secret_id, project_id, params = nil, options = {})
  attach_to_project!(secret_id, project_id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#attach_to_project!(secret_id, project_id, params = nil, options = {}) ⇒ Object



93
94
95
96
97
# File 'lib/semaphore_client/api/secret.rb', line 93

def attach_to_project!(secret_id, project_id, params = nil, options = {})
  path = "/projects/#{project_id}/secrets/#{secret_id}"

  @http_client.post(path, params, options)
end

#attach_to_team(secret_id, team_id, params = nil, options = {}) ⇒ Object



49
50
51
52
# File 'lib/semaphore_client/api/secret.rb', line 49

def attach_to_team(secret_id, team_id, params = nil, options = {})
  attach_to_team!(secret_id, team_id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#attach_to_team!(secret_id, team_id, params = nil, options = {}) ⇒ Object



54
55
56
57
58
# File 'lib/semaphore_client/api/secret.rb', line 54

def attach_to_team!(secret_id, team_id, params = nil, options = {})
  path = "/teams/#{team_id}/secrets/#{secret_id}"

  @http_client.post(path, params, options)
end

#create_for_org(org_id, params = nil, options = {}) ⇒ Object



22
23
24
25
# File 'lib/semaphore_client/api/secret.rb', line 22

def create_for_org(org_id, params = nil, options = {})
  create_for_org!(org_id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#create_for_org!(org_id, params = nil, options = {}) ⇒ Object



27
28
29
30
31
32
# File 'lib/semaphore_client/api/secret.rb', line 27

def create_for_org!(org_id, params = nil, options = {})
  path = "/orgs/#{org_id}/secrets"
  response = @http_client.post(path, params, options)

  SemaphoreClient::Model::Secret.load(response.body)
end

#delete(id, params = nil, options = {}) ⇒ Object



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

def delete(id, params = nil, options = {})
  delete!(id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#delete!(id, params = nil, options = {}) ⇒ Object



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

def delete!(id, params = nil, options = {})
  path = "/secrets/#{id}"

  @http_client.delete(path, params)
end

#detach_from_project(secret_id, project_id, params = nil, options = {}) ⇒ Object



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

def detach_from_project(secret_id, project_id, params = nil, options = {})
  detach_from_project!(secret_id, project_id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#detach_from_project!(secret_id, project_id, params = nil, options = {}) ⇒ Object



106
107
108
109
110
# File 'lib/semaphore_client/api/secret.rb', line 106

def detach_from_project!(secret_id, project_id, params = nil, options = {})
  path = "/projects/#{project_id}/secrets/#{secret_id}"

  @http_client.delete(path, params, options)
end

#detach_from_team(secret_id, team_id, params = nil, options = {}) ⇒ Object



62
63
64
65
# File 'lib/semaphore_client/api/secret.rb', line 62

def detach_from_team(secret_id, team_id, params = nil, options = {})
  detach_from_team!(secret_id, team_id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#detach_from_team!(secret_id, team_id, params = nil, options = {}) ⇒ Object



67
68
69
70
71
# File 'lib/semaphore_client/api/secret.rb', line 67

def detach_from_team!(secret_id, team_id, params = nil, options = {})
  path = "/teams/#{team_id}/secrets/#{secret_id}"

  @http_client.delete(path, params, options)
end

#get(id, params = nil, options = {}) ⇒ Object



114
115
116
117
# File 'lib/semaphore_client/api/secret.rb', line 114

def get(id, params = nil, options = {})
  get!(id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#get!(id, params = nil, options = {}) ⇒ Object



119
120
121
122
123
124
# File 'lib/semaphore_client/api/secret.rb', line 119

def get!(id, params = nil, options = {})
  path = "/secrets/#{id}"
  response = @http_client.get(path, params = {})

  SemaphoreClient::Model::Secret.load(response.body)
end

#list_for_org(org_id, params = nil, options = {}) ⇒ Object



9
10
11
12
# File 'lib/semaphore_client/api/secret.rb', line 9

def list_for_org(org_id, params = nil, options = {})
  list_for_org!(org_id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#list_for_org!(org_id, params = nil, options = {}) ⇒ Object



14
15
16
17
18
# File 'lib/semaphore_client/api/secret.rb', line 14

def list_for_org!(org_id, params = nil, options = {})
  path = "/orgs/#{org_id}/secrets"

  @http_client.get(path, params, options = {}).body.map { |e| SemaphoreClient::Model::Secret.load(e) }
end

#list_for_project(project_id, params = nil, options = {}) ⇒ Object



75
76
77
78
# File 'lib/semaphore_client/api/secret.rb', line 75

def list_for_project(project_id, params = nil, options = {})
  list_for_project!(project_id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#list_for_project!(project_id, params = nil, options = {}) ⇒ Object



80
81
82
83
84
# File 'lib/semaphore_client/api/secret.rb', line 80

def list_for_project!(project_id, params = nil, options = {})
  path = "/projects/#{project_id}/secrets"

  @http_client.get(path, params, options = {}).body.map { |e| SemaphoreClient::Model::Secret.load(e) }
end

#list_for_team(team_id, params = nil, options = {}) ⇒ Object



36
37
38
39
# File 'lib/semaphore_client/api/secret.rb', line 36

def list_for_team(team_id, params = nil, options = {})
  list_for_team!(team_id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#list_for_team!(team_id, params = nil, options = {}) ⇒ Object



41
42
43
44
45
# File 'lib/semaphore_client/api/secret.rb', line 41

def list_for_team!(team_id, params = nil, options = {})
  path = "/teams/#{team_id}/secrets"

  @http_client.get(path, params, options = {}).body.map { |e| SemaphoreClient::Model::Secret.load(e) }
end

#update(id, params = nil, options = {}) ⇒ Object



141
142
143
144
# File 'lib/semaphore_client/api/secret.rb', line 141

def update(id, params = nil, options = {})
  update!(id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#update!(id, params = nil, options = {}) ⇒ Object



146
147
148
149
150
151
# File 'lib/semaphore_client/api/secret.rb', line 146

def update!(id, params = nil, options = {})
  path = "/secrets/#{id}"
  response = @http_client.patch(path, params)

  SemaphoreClient::Model::Secret.load(response.body)
end