Class: SemaphoreClient::Api::EnvVar

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

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ EnvVar

Returns a new instance of EnvVar.



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

def initialize(http_client)
  @http_client = http_client
end

Instance Method Details

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



35
36
37
38
# File 'lib/semaphore_client/api/env_var.rb', line 35

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

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



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

def create_for_secret!(secret_id, params = nil, options = {})
  path = "/secrets/#{secret_id}/env_vars"
  response = @http_client.post(path, params, options)

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

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



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

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

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



68
69
70
71
72
# File 'lib/semaphore_client/api/env_var.rb', line 68

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

  @http_client.delete(path, params)
end

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



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

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

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



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

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

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

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



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

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



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

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

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

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



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

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

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



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

def list_for_secret!(secret_id, params = nil, options = {})
  path = "/secrets/#{secret_id}/env_vars"

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

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



76
77
78
79
# File 'lib/semaphore_client/api/env_var.rb', line 76

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

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



81
82
83
84
85
86
# File 'lib/semaphore_client/api/env_var.rb', line 81

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

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