Class: Environments
- Inherits:
-
Object
- Object
- Environments
- Defined in:
- lib/puppetclassify/environments.rb
Instance Method Summary collapse
- #create_environment(name) ⇒ Object
- #get_environment(name) ⇒ Object
- #get_environments ⇒ Object
-
#initialize(nc_api_url, puppet_https) ⇒ Environments
constructor
A new instance of Environments.
Constructor Details
#initialize(nc_api_url, puppet_https) ⇒ Environments
Returns a new instance of Environments.
4 5 6 7 |
# File 'lib/puppetclassify/environments.rb', line 4 def initialize(nc_api_url, puppet_https) @nc_api_url = nc_api_url @puppet_https = puppet_https end |
Instance Method Details
#create_environment(name) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/puppetclassify/environments.rb', line 19 def create_environment(name) env_res = @puppet_https.put("#{@nc_api_url}/v1/environments/#{name}") unless env_res.code.to_i == 201 STDERR.puts "An error occured saving the environment: HTTP #{env_res.code} #{env_res.}" STDERR.puts env_res.body end end |
#get_environment(name) ⇒ Object
14 15 16 17 |
# File 'lib/puppetclassify/environments.rb', line 14 def get_environment(name) env_res = @puppet_https.get("#{@nc_api_url}/v1/environments/#{name}") JSON.parse(env_res.body) end |
#get_environments ⇒ Object
9 10 11 12 |
# File 'lib/puppetclassify/environments.rb', line 9 def get_environments env_res = @puppet_https.get("#{@nc_api_url}/v1/environments") JSON.parse(env_res.body) end |