Class: Delphix::Environment

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/delphix/environment.rb

Instance Attribute Summary

Attributes included from Base

#details

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

#name, #reference, #to_s, #type

Constructor Details

#initialize(reference, details = nil) ⇒ Environment

Returns a new instance of Environment.


8
9
10
# File 'lib/delphix/environment.rb', line 8

def initialize(reference, details=nil)
  super(reference, details)
end

Class Method Details

.create(name, address, port, toolkit_path, username, password) ⇒ Object

class methods


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/delphix/environment.rb', line 40

def self.create(name, address, port, toolkit_path, username, password)
  body = {
    :type => 'HostEnvironmentCreateParameters',
    :primaryUser => {
      :type => 'EnvironmentUser',
      :name => username,
      :credential => {
        :type => 'PasswordCredential',
        :password => password
      }
    },
    :hostEnvironment => {
      :type => 'UnixHostEnvironment',
      :name => name
    },
    :hostParameters => {
      :type => 'UnixHostCreateParameters',
      :host => {
        :type => 'UnixHost',
        :address => address,
        :sshPort => port,
        :toolkitPath => toolkit_path
      }
    }
  }
  response = Delphix.post('/resources/json/delphix/environment', body.to_json)

  ref = response['result']
  job = response['job']

  # create a new skeleton group object
  env = Delphix::Environment.new ref

  # refresh the object from the DE
  env.refresh_details

  env
end

.listObject


79
80
81
82
83
84
85
86
# File 'lib/delphix/environment.rb', line 79

def self.list
  envs = Delphix::BaseArray.new
  result = Delphix.get('/resources/json/delphix/environment')['result']
  result.each do |env|
    envs << Delphix::Environment.new(env['reference'],env)
  end
  envs
end

Instance Method Details

#base_endpointObject


34
35
36
# File 'lib/delphix/environment.rb', line 34

def base_endpoint
  '/resources/json/delphix/environment'
end

#deleteObject

basic operations


14
15
16
# File 'lib/delphix/environment.rb', line 14

def delete
  Delphix.delete("#{base_endpoint}/#{reference}")['result']
end

#disableObject


24
25
26
# File 'lib/delphix/environment.rb', line 24

def disable
  Delphix.post("#{base_endpoint}/#{reference}/disable")['result']
end

#enableObject

specific operations


20
21
22
# File 'lib/delphix/environment.rb', line 20

def enable
  Delphix.post("#{base_endpoint}/#{reference}/enable")['result']
end

#refresh_detailsObject

inherited operations


30
31
32
# File 'lib/delphix/environment.rb', line 30

def refresh_details
  @details = Delphix.get("#{base_endpoint}/#{reference}")['result']
end