Class: Puppet::Network::HTTP::API::Server::V3::Environments

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/network/http/api/server/v3/environments.rb

Instance Method Summary collapse

Constructor Details

#initialize(env_loader) ⇒ Environments

Returns a new instance of Environments.



12
13
14
# File 'lib/puppet/network/http/api/server/v3/environments.rb', line 12

def initialize(env_loader)
  @env_loader = env_loader
end

Instance Method Details

#call(request, response) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/puppet/network/http/api/server/v3/environments.rb', line 16

def call(request, response)
  response
    .respond_with(
      200,
      "application/json",
      Puppet::Util::Json
        .dump({
                "search_paths" => @env_loader.search_paths,
                "environments" => @env_loader.list.to_h do |env|
                  [env.name, {
                    "settings" => {
                      "modulepath" => env.full_modulepath,
                      "manifest" => env.manifest,
                      "environment_timeout" => timeout(env),
                      "config_version" => env.config_version || '',
                    }
                  }]
                end
              })
    )
end