Class: PEClient::Resource::NodeClassifierV1::Environments

Inherits:
Base
  • Object
show all
Defined in:
lib/pe_client/resources/node_classifier.v1/environments.rb

Overview

Use the environments endpoints to retrieve the node classifier’s environment data. The responses tell you which environments are available, whether a named environment exists, and which classes exist in a certain environment.

Constant Summary collapse

BASE_PATH =

The base path for Node Classifier API v1 environments endpoints.

"#{NodeClassifierV1::BASE_PATH}/environments".freeze

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from PEClient::Resource::Base

Instance Method Details

#classes(environment, name = nil) ⇒ Hash

Retrieve a list of all classes (that the node classifier knows about) or a specific class in a specific environment.

Parameters:

  • environment (String)
  • name (String) (defaults to: nil)

    The name of the class to retrieve. If nil, retrieves all classes in the environment.

Returns:

  • (Hash)


61
62
63
64
65
66
67
# File 'lib/pe_client/resources/node_classifier.v1/environments.rb', line 61

def classes(environment, name = nil)
  if name
    @client.get "#{BASE_PATH}/#{environment}/classes/#{name}"
  else
    @client.get "#{BASE_PATH}/#{environment}/classes"
  end
end

#create(name) ⇒ Hash

Create a new environment with a specific name.

Parameters:

  • name (String)

Returns:

  • (Hash)


50
51
52
# File 'lib/pe_client/resources/node_classifier.v1/environments.rb', line 50

def create(name)
  @client.put BASE_PATH, body: {name: name}
end

#get(name = nil) ⇒ Array<Hash>

Retrieve a list of all environments the node classifier knows about at the time of the request. Or Retrieve information about a specific environment.

Parameters:

  • name (String) (defaults to: nil)

    The name of the environment to retrieve. If nil, retrieves all environments.

Returns:

  • (Array<Hash>)


37
38
39
40
41
42
43
# File 'lib/pe_client/resources/node_classifier.v1/environments.rb', line 37

def get(name = nil)
  if name
    @client.get "#{BASE_PATH}/#{name}"
  else
    @client.get BASE_PATH
  end
end