Class: PEClient::Resource::NodeClassifierV1::Groups
- Defined in:
- lib/pe_client/resources/node_classifier.v1/groups.rb
Overview
The groups endpoints create, read, update, and delete groups.
Constant Summary collapse
- BASE_PATH =
The base path for Node Classifier API v1 groups endpoints.
"#{NodeClassifierV1::BASE_PATH}/groups".freeze
Instance Method Summary collapse
-
#create(name:, parent:, id: nil, environment: nil, environment_trumps: nil, description: nil, rule: nil, variables: nil, classes: {}, config_data: nil) ⇒ Hash
Create a node group with a randomly-generated ID or specific ID if supplied.
-
#delete(id) ⇒ Hash
Delete the node group with the given ID.
-
#get(id = nil) ⇒ Hash+
Retrieves one or more groups.
-
#nodes(id) ⇒ Hash
Resolve all the nodes associated with a node group.
-
#pin(id, nodes) ⇒ Hash
Pin specific nodes to a node group.
-
#rules(id) ⇒ Hash
Resolve the rules for a specific node group, and then translate those rules to work with the PuppetDB nodes and inventory endpoints.
-
#unpin(id, nodes) ⇒ Hash
Unpin specific nodes to a node group.
-
#update(id, attributes) ⇒ Hash
Edit the name, environment, parent node group, rules, classes, class parameters, configuration data, and variables for a specific node group.
Methods inherited from Base
Constructor Details
This class inherits a constructor from PEClient::Resource::Base
Instance Method Details
#create(name:, parent:, id: nil, environment: nil, environment_trumps: nil, description: nil, rule: nil, variables: nil, classes: {}, config_data: nil) ⇒ Hash
Create a node group with a randomly-generated ID or specific ID if supplied.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pe_client/resources/node_classifier.v1/groups.rb', line 74 def create(name:, parent:, id: nil, environment: nil, environment_trumps: nil, description: nil, rule: nil, variables: nil, classes: {}, config_data: nil) body = { name:, parent:, environment:, environment_trumps:, description:, rule:, variables:, classes:, config_data: }.compact if id @client.put "#{BASE_PATH}/#{id}", body: else @client.post BASE_PATH, body: end end |
#delete(id) ⇒ Hash
Delete the node group with the given ID.
111 112 113 |
# File 'lib/pe_client/resources/node_classifier.v1/groups.rb', line 111 def delete(id) @client.delete "#{BASE_PATH}/#{id}" end |
#get(id = nil) ⇒ Hash+
Retrieves one or more groups.
34 35 36 37 38 39 40 |
# File 'lib/pe_client/resources/node_classifier.v1/groups.rb', line 34 def get(id = nil) if id @client.get("#{BASE_PATH}/#{id}") else @client.get(BASE_PATH) end end |
#nodes(id) ⇒ Hash
Resolve all the nodes associated with a node group.
This endpoint combines all the rules for the group and queries PuppetDB for the result.
150 151 152 |
# File 'lib/pe_client/resources/node_classifier.v1/groups.rb', line 150 def nodes(id) @client.get "#{BASE_PATH}/#{id}/nodes" end |
#pin(id, nodes) ⇒ Hash
Pin specific nodes to a node group.
121 122 123 |
# File 'lib/pe_client/resources/node_classifier.v1/groups.rb', line 121 def pin(id, nodes) @client.post "#{BASE_PATH}/#{id}/pin", body: {nodes:} end |
#rules(id) ⇒ Hash
Resolve the rules for a specific node group, and then translate those rules to work with the PuppetDB nodes and inventory endpoints.
140 141 142 |
# File 'lib/pe_client/resources/node_classifier.v1/groups.rb', line 140 def rules(id) @client.get "#{BASE_PATH}/#{id}/rules" end |
#unpin(id, nodes) ⇒ Hash
Unpin specific nodes to a node group.
131 132 133 |
# File 'lib/pe_client/resources/node_classifier.v1/groups.rb', line 131 def unpin(id, nodes) @client.post "#{BASE_PATH}/#{id}/unpin", body: {nodes:} end |
#update(id, attributes) ⇒ Hash
Edit the name, environment, parent node group, rules, classes, class parameters, configuration data, and variables for a specific node group.
102 103 104 |
# File 'lib/pe_client/resources/node_classifier.v1/groups.rb', line 102 def update(id, attributes) @client.post "#{BASE_PATH}/#{id}", body: attributes end |