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

#delphix_delete, #delphix_get, #delphix_post, #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

instance methods



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
78
79
80
81
82
83
84
85
# File 'lib/delphix/environment.rb', line 48

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

Instance Method Details

#base_endpointObject



32
33
34
# File 'lib/delphix/environment.rb', line 32

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

#deleteObject



22
23
24
# File 'lib/delphix/environment.rb', line 22

def delete
  delphix_delete("#{base_endpoint}/#{reference}", nil)['result']
end

#disableObject



18
19
20
# File 'lib/delphix/environment.rb', line 18

def disable
  delphix_post("#{base_endpoint}/#{reference}/disable", nil)['result']
end

#enableObject

basic operations



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

def enable
  delphix_post("#{base_endpoint}/#{reference}/enable", nil)['result']
end

#refresh_detailsObject

inherited operations



28
29
30
# File 'lib/delphix/environment.rb', line 28

def refresh_details
  @details = delphix_get("#{base_endpoint}/#{reference}", nil)['result']
end

#repositoriesObject

additional operations



37
38
39
40
41
42
43
44
# File 'lib/delphix/environment.rb', line 37

def repositories
  repos = Delphix::BaseArray.new
  result = get('/resources/json/delphix/repository', nil)['result']
  result.each do |o|
    repos << Delphix::Repository.new(connection, o) if o['environment'] == reference
  end
  repos
end