Class: PEClient::Resource::PuppetDB::QueryV4::Nodes
- Defined in:
- lib/pe_client/resources/puppet_db/query.v4/nodes.rb
Overview
Nodes can be queried by making requests through these endpoints.
Constant Summary collapse
- BASE_PATH =
The base path for PuppetDB Query v4 Nodes endpoints.
"#{QueryV4::BASE_PATH}/nodes".freeze
Instance Method Summary collapse
-
#facts(node:, name: nil, value: nil, query: nil, **kwargs) ⇒ Hash+
This will return the facts for the given node.
-
#get(node: nil, query: nil, **kwargs) ⇒ Hash+
This will return all nodes matching the given query.
-
#resources(node:, type: nil, title: nil, query: nil, **kwargs) ⇒ Hash+
This will return the resources for the given node.
Methods inherited from Base
Constructor Details
This class inherits a constructor from PEClient::Resource::Base
Instance Method Details
#facts(node:, name: nil, value: nil, query: nil, **kwargs) ⇒ Hash+
This will return the facts for the given node. Facts from deactivated and expired nodes aren’t included in the response. This is a shortcut to the PEClient::Resource::PuppetDB::QueryV4#facts endpoint. It behaves the same as a call to PEClient::Resource::PuppetDB::QueryV4#facts with a query string of [“=”, “certname”, “<NODE>”]. Facts from deactivated and expired nodes aren’t included in the response.
Most of PuppetDB’s query endpoints support a general set of HTTP URL parameters that can be used for paging results. PuppetDB also supports paging via query operators, as described in the AST documentation.
63 64 65 66 67 68 |
# File 'lib/pe_client/resources/puppet_db/query.v4/nodes.rb', line 63 def facts(node:, name: nil, value: nil, query: nil, **kwargs) uri = "#{BASE_PATH}/#{node}/facts" uri += "/#{name}" if name uri += "/#{value}" if name && value @client.get uri, params: {query: query&.to_json}.merge!(QueryV4.query_paging(**kwargs)).compact end |
#get(node: nil, query: nil, **kwargs) ⇒ Hash+
This will return all nodes matching the given query. Deactivated and expired nodes aren’t included in the response.
Most of PuppetDB’s query endpoints support a general set of HTTP URL parameters that can be used for paging results. PuppetDB also supports paging via query operators, as described in the AST documentation.
42 43 44 45 |
# File 'lib/pe_client/resources/puppet_db/query.v4/nodes.rb', line 42 def get(node: nil, query: nil, **kwargs) @client.get node ? "#{BASE_PATH}/#{node}" : BASE_PATH, params: {query: query&.to_json}.merge!(QueryV4.query_paging(**kwargs)).compact end |
#resources(node:, type: nil, title: nil, query: nil, **kwargs) ⇒ Hash+
This will return the resources for the given node. Resources from deactivated and expired nodes aren’t included in the response. This is a shortcut to the PEClient::Resource::PuppetDB::QueryV4#resources endpoint. It behaves the same as a call to PEClient::Resource::PuppetDB::QueryV4#resources with a query string of [“=”, “certname”, “<NODE>”].
Most of PuppetDB’s query endpoints support a general set of HTTP URL parameters that can be used for paging results. PuppetDB also supports paging via query operators, as described in the AST documentation.
86 87 88 89 90 91 |
# File 'lib/pe_client/resources/puppet_db/query.v4/nodes.rb', line 86 def resources(node:, type: nil, title: nil, query: nil, **kwargs) uri = "#{BASE_PATH}/#{node}/resources" uri += "/#{type}" if type uri += "/#{title}" if type && title @client.get uri, params: {query: query&.to_json}.merge!(QueryV4.query_paging(**kwargs)).compact end |