Class: SemaphoreClient::Api::ConfigFile
- Inherits:
-
Object
- Object
- SemaphoreClient::Api::ConfigFile
- Defined in:
- lib/semaphore_client/api/config_file.rb
Instance Method Summary collapse
- #attach_to_project(config_file_id, project_id) ⇒ Object
- #attach_to_project!(config_file_id, project_id) ⇒ Object
- #create_for_shared_config(shared_config_id, params) ⇒ Object
- #create_for_shared_config!(shared_config_id, params) ⇒ Object
- #delete(id) ⇒ Object
- #delete!(id) ⇒ Object
- #detach_from_project(config_file_id, project_id) ⇒ Object
- #detach_from_project!(config_file_id, project_id) ⇒ Object
- #get(id) ⇒ Object
- #get!(id) ⇒ Object
-
#initialize(http_client) ⇒ ConfigFile
constructor
A new instance of ConfigFile.
- #list_for_project(project_id) ⇒ Object
- #list_for_project!(project_id) ⇒ Object
- #list_for_shared_config(shared_config_id) ⇒ Object
- #list_for_shared_config!(shared_config_id) ⇒ Object
- #update(id, params) ⇒ Object
- #update!(id, params) ⇒ Object
Constructor Details
#initialize(http_client) ⇒ 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) ⇒ Object
13 14 15 16 |
# File 'lib/semaphore_client/api/config_file.rb', line 13 def attach_to_project(config_file_id, project_id) attach_to_project!(config_file_id, project_id) rescue SemaphoreClient::Exceptions::RequestFailed end |
#attach_to_project!(config_file_id, project_id) ⇒ Object
60 61 62 63 64 |
# File 'lib/semaphore_client/api/config_file.rb', line 60 def attach_to_project!(config_file_id, project_id) response = @http_client.post([:projects, project_id, :config_files, config_file_id]) assert_response_status(response, 204) end |
#create_for_shared_config(shared_config_id, params) ⇒ Object
28 29 30 31 |
# File 'lib/semaphore_client/api/config_file.rb', line 28 def create_for_shared_config(shared_config_id, params) create_for_shared_config!(shared_config_id, params) rescue SemaphoreClient::Exceptions::RequestFailed end |
#create_for_shared_config!(shared_config_id, params) ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/semaphore_client/api/config_file.rb', line 84 def create_for_shared_config!(shared_config_id, params) response = @http_client.post([:shared_configs, shared_config_id, :config_files], params.to_json) assert_response_status(response, 200) content = JSON.parse(response.body) SemaphoreClient::Model::ConfigFile.load(content) end |
#delete(id) ⇒ Object
38 39 40 41 |
# File 'lib/semaphore_client/api/config_file.rb', line 38 def delete(id) delete!(id) rescue SemaphoreClient::Exceptions::RequestFailed end |
#delete!(id) ⇒ Object
104 105 106 107 108 |
# File 'lib/semaphore_client/api/config_file.rb', line 104 def delete!(id) response = @http_client.delete([:config_files, id]) assert_response_status(response, 200) end |
#detach_from_project(config_file_id, project_id) ⇒ Object
18 19 20 21 |
# File 'lib/semaphore_client/api/config_file.rb', line 18 def detach_from_project(config_file_id, project_id) detach_from_project!(config_file_id, project_id) rescue SemaphoreClient::Exceptions::RequestFailed end |
#detach_from_project!(config_file_id, project_id) ⇒ Object
66 67 68 69 70 |
# File 'lib/semaphore_client/api/config_file.rb', line 66 def detach_from_project!(config_file_id, project_id) response = @http_client.delete([:projects, project_id, :config_files, config_file_id]) assert_response_status(response, 204) end |
#get(id) ⇒ Object
33 34 35 36 |
# File 'lib/semaphore_client/api/config_file.rb', line 33 def get(id) get!(id) rescue SemaphoreClient::Exceptions::RequestFailed end |
#get!(id) ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/semaphore_client/api/config_file.rb', line 94 def get!(id) response = @http_client.get([:config_files, id]) assert_response_status(response, 200) content = JSON.parse(response.body) SemaphoreClient::Model::ConfigFile.load(content) end |
#list_for_project(project_id) ⇒ Object
8 9 10 11 |
# File 'lib/semaphore_client/api/config_file.rb', line 8 def list_for_project(project_id) list_for_project!(project_id) rescue SemaphoreClient::Exceptions::RequestFailed end |
#list_for_project!(project_id) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/semaphore_client/api/config_file.rb', line 48 def list_for_project!(project_id) response = @http_client.get([:projects, project_id, :config_files]) assert_response_status(response, 200) content = JSON.parse(response.body) content.map do |entity| SemaphoreClient::Model::ConfigFile.load(entity) end end |
#list_for_shared_config(shared_config_id) ⇒ Object
23 24 25 26 |
# File 'lib/semaphore_client/api/config_file.rb', line 23 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
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/semaphore_client/api/config_file.rb', line 72 def list_for_shared_config!(shared_config_id) response = @http_client.get([:shared_configs, shared_config_id, :config_files]) assert_response_status(response, 200) content = JSON.parse(response.body) content.map do |entity| SemaphoreClient::Model::ConfigFile.load(entity) end end |
#update(id, params) ⇒ Object
43 44 45 46 |
# File 'lib/semaphore_client/api/config_file.rb', line 43 def update(id, params) update!(id, params) rescue SemaphoreClient::Exceptions::RequestFailed end |
#update!(id, params) ⇒ Object
110 111 112 113 114 115 116 117 118 |
# File 'lib/semaphore_client/api/config_file.rb', line 110 def update!(id, params) response = @http_client.patch([:config_files, id], params.to_json) assert_response_status(response, 200) content = JSON.parse(response.body) SemaphoreClient::Model::ConfigFile.load(content) end |