Class: Nahook::Resources::Environments
- Inherits:
-
Object
- Object
- Nahook::Resources::Environments
- Defined in:
- lib/nahook/resources/environments.rb
Overview
Resource for managing environments via the Management API.
Instance Method Summary collapse
-
#create(workspace_id, name:, slug:) ⇒ Hash
Create a new environment.
-
#delete(workspace_id, id) ⇒ nil
Delete an environment.
-
#get(workspace_id, id) ⇒ Hash
Get a single environment by ID.
-
#initialize(http) ⇒ Environments
constructor
private
A new instance of Environments.
-
#list(workspace_id) ⇒ Hash
List all environments in a workspace.
-
#list_event_type_visibility(workspace_id, env_id) ⇒ Hash
List event type visibility for an environment.
-
#set_event_type_visibility(workspace_id, env_id, event_type_id, published:) ⇒ Hash
Set event type visibility for an environment.
-
#update(workspace_id, id, name: nil) ⇒ Hash
Update an existing environment.
Constructor Details
#initialize(http) ⇒ Environments
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Environments.
16 17 18 |
# File 'lib/nahook/resources/environments.rb', line 16 def initialize(http) @http = http end |
Instance Method Details
#create(workspace_id, name:, slug:) ⇒ Hash
Create a new environment.
38 39 40 41 42 43 44 |
# File 'lib/nahook/resources/environments.rb', line 38 def create(workspace_id, name:, slug:) @http.request( method: :post, path: "/management/v1/workspaces/#{e(workspace_id)}/environments", body: { "name" => name, "slug" => slug } ) end |
#delete(workspace_id, id) ⇒ nil
Delete an environment.
79 80 81 82 83 84 |
# File 'lib/nahook/resources/environments.rb', line 79 def delete(workspace_id, id) @http.request( method: :delete, path: "/management/v1/workspaces/#{e(workspace_id)}/environments/#{e(id)}" ) end |
#get(workspace_id, id) ⇒ Hash
Get a single environment by ID.
51 52 53 54 55 56 |
# File 'lib/nahook/resources/environments.rb', line 51 def get(workspace_id, id) @http.request( method: :get, path: "/management/v1/workspaces/#{e(workspace_id)}/environments/#{e(id)}" ) end |
#list(workspace_id) ⇒ Hash
List all environments in a workspace.
24 25 26 27 28 29 30 |
# File 'lib/nahook/resources/environments.rb', line 24 def list(workspace_id) data = @http.request( method: :get, path: "/management/v1/workspaces/#{e(workspace_id)}/environments" ) { "data" => data } end |
#list_event_type_visibility(workspace_id, env_id) ⇒ Hash
List event type visibility for an environment.
91 92 93 94 95 96 97 |
# File 'lib/nahook/resources/environments.rb', line 91 def list_event_type_visibility(workspace_id, env_id) data = @http.request( method: :get, path: "/management/v1/workspaces/#{e(workspace_id)}/environments/#{e(env_id)}/event-types" ) { "data" => data } end |
#set_event_type_visibility(workspace_id, env_id, event_type_id, published:) ⇒ Hash
Set event type visibility for an environment.
106 107 108 109 110 111 112 |
# File 'lib/nahook/resources/environments.rb', line 106 def set_event_type_visibility(workspace_id, env_id, event_type_id, published:) @http.request( method: :put, path: "/management/v1/workspaces/#{e(workspace_id)}/environments/#{e(env_id)}/event-types/#{e(event_type_id)}/visibility", body: { "published" => published } ) end |
#update(workspace_id, id, name: nil) ⇒ Hash
Update an existing environment.
64 65 66 67 68 69 70 71 72 |
# File 'lib/nahook/resources/environments.rb', line 64 def update(workspace_id, id, name: nil) body = {} body["name"] = name unless name.nil? @http.request( method: :patch, path: "/management/v1/workspaces/#{e(workspace_id)}/environments/#{e(id)}", body: body ) end |