Module: Delphix

Includes:
Utils
Defined in:
lib/delphix.rb,
lib/delphix/utils.rb,
lib/delphix/client.rb,
lib/delphix/request.rb,
lib/delphix/version.rb,
lib/delphix/response.rb

Overview

The version number of the Delphix Gem

Defined Under Namespace

Modules: Utils, Version Classes: Client, Request, Response

Constant Summary collapse

API_ENDPOINT =
'/resources/json/delphix'
HTTP_HEADERS =
{
  'Accept'       =>  'application/json; charset=UTF-8',
  'Content-Type' =>  'application/json; charset=UTF-8',
  'User-Agent'   =>  'Delphix-Ruby-Client/1.0.0'
}
VERSION =
Delphix::Version.string
@@timeout =

Default timeout value in seconds.

10
@@default_headers =

Default headers

{}

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

#request_id, #utc_httpdate

Class Attribute Details

.api_passwdString



91
92
93
# File 'lib/delphix.rb', line 91

def api_passwd
  @api_passwd
end

.api_userString



88
89
90
# File 'lib/delphix.rb', line 88

def api_user
  @api_user
end

.api_versionHash



82
83
84
# File 'lib/delphix.rb', line 82

def api_version
  @api_version
end

.last_requestHash



69
70
71
# File 'lib/delphix.rb', line 69

def last_request
  @last_request
end

.last_responseHash



72
73
74
# File 'lib/delphix.rb', line 72

def last_response
  @last_response
end

.serverString



85
86
87
# File 'lib/delphix.rb', line 85

def server
  @server
end

.sessionHash, ...



79
80
81
# File 'lib/delphix.rb', line 79

def session
  @session
end

.verboseNothing



94
95
96
# File 'lib/delphix.rb', line 94

def verbose
  @verbose
end

Class Method Details

.api_url(resource = nil) ⇒ URL

Returns the API endpoint for a given resource namespace by combining the server address with the appropriate HTTP headers.



105
106
107
# File 'lib/delphix.rb', line 105

def self.api_url(resource = nil)
  'http://' + @server + resource
end

.clear_default_headersHash



104
105
106
# File 'lib/delphix/client.rb', line 104

def self.clear_default_headers
  @@default_headers = {}
end

.cookiesHash

Establish a session with the Delphix engine and return an identifier through browser cookies. This session will be reused in subsequent calls, the same session credentials and state are preserved without requiring a re-authentication call. Sessions do not persisit between incovations.



123
124
125
126
127
# File 'lib/delphix.rb', line 123

def self.cookies
  @resp ||= Delphix.post session_url,
    type: 'APISession', version: @api_version
  @resp.cookies
end

.default_header(name, value) ⇒ Hash



97
98
99
# File 'lib/delphix/client.rb', line 97

def self.default_header(name, value)
  @@default_headers[name] = value
end

.login(user = @api_user, passwd = @api_passwd) ⇒ Fixnum, ...

Authenticates the session so that API calls can be made. Only supports basic password authentication.



148
149
150
151
# File 'lib/delphix.rb', line 148

def self.(user = @api_user, passwd = @api_passwd)
  Delphix.post ,
    type: 'LoginRequest', username: user, password: passwd
end

.timeout(seconds) ⇒ undefined



113
114
115
# File 'lib/delphix/client.rb', line 113

def self.timeout(seconds)
  @@timeout = seconds
end

Instance Method Details

#alertString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end

#containerString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end

#databaseString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end

#deleteFixnum, ...

Delete an object on the system. For languages that don’t provide a native wrapper for DELETE, or for delete operations with optional input, all delete operations can also be invoked as POST to the same URL with /delete appended to it.



160
161
162
163
164
165
# File 'lib/delphix/client.rb', line 160

[:get, :post, :delete].each do |method|
  define_singleton_method(method) do |url, parameters = {}, &callback|
    Client.request(method.to_sym, url, @@default_headers,
      parameters.to_json, @@timeout, &callback)
  end
end

#environmentString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end

#getFixnum, ...

Retrieve data from the server where complex input is not needed. All GET requests are guaranteed to be read-only, but not all read-only requests are required to use GET. Simple input (strings, number, boolean values) can be passed as query parameters.



160
161
162
163
164
165
# File 'lib/delphix/client.rb', line 160

[:get, :post, :delete].each do |method|
  define_singleton_method(method) do |url, parameters = {}, &callback|
    Client.request(method.to_sym, url, @@default_headers,
      parameters.to_json, @@timeout, &callback)
  end
end

#groupString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end

#hostString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end

#jobString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end

#loginString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end

#policyString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end

#postFixnum, ...

Issue a read/write operation, or make a read-only call that requires complex input. The optional body of the call is expressed as JSON.



160
161
162
163
164
165
# File 'lib/delphix/client.rb', line 160

[:get, :post, :delete].each do |method|
  define_singleton_method(method) do |url, parameters = {}, &callback|
    Client.request(method.to_sym, url, @@default_headers,
      parameters.to_json, @@timeout, &callback)
  end
end

#repositoryString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end

#sessionString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end

#snapshotString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end

#sourceString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end

#sourceconfigString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end

#timeflowString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end

#userString

A helper method to return the URL for the resource by using the resource_url shorthand.



233
234
235
236
237
238
239
240
# File 'lib/delphix.rb', line 233

[ :alert, :container, :database, :environment, :group, :host, :job,
  :login, :policy, :repository, :session, :snapshot, :source,
  :sourceconfig, :timeflow, :user
].each do |name|
  define_singleton_method(name.to_s + '_url') do
    api_url('/resources/json/delphix/' + name.to_s)
  end
end