Class: SemaphoreClient::Api::ConfigFile

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

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ ConfigFile

Returns a new instance of ConfigFile.



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

def initialize(http_client)
  @http_client = http_client
end

Instance Method Details

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



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

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

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



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

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

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

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



61
62
63
64
# File 'lib/semaphore_client/api/config_file.rb', line 61

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



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

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

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

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



89
90
91
92
# File 'lib/semaphore_client/api/config_file.rb', line 89

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

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



94
95
96
97
98
# File 'lib/semaphore_client/api/config_file.rb', line 94

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

  @http_client.delete(path, params)
end

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



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

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

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



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

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

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

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



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

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

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



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

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

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

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



9
10
11
12
# File 'lib/semaphore_client/api/config_file.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/config_file.rb', line 14

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

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

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



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

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



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

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

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

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



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

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

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



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

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

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