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
-
.api_passwd ⇒ String
Password for authentication.
-
.api_user ⇒ String
Username to authenticate with.
-
.api_version ⇒ Hash
Containing the major, minor and micro version numbers.
-
.last_request ⇒ Hash
Retruns the last request.
-
.last_response ⇒ Hash
Retruns the last response.
-
.server ⇒ String
Delphix server address.
- .session ⇒ Hash, ...
-
.verbose ⇒ Nothing
Enables verbosity.
Class Method Summary collapse
-
.api_url(resource = nil) ⇒ URL
Returns the API endpoint for a given resource namespace by combining the server address with the appropriate HTTP headers.
-
.clear_default_headers ⇒ Hash
The HTTP headers sent with a POST/GET/DELETE.
-
.cookies ⇒ Hash
Establish a session with the Delphix engine and return an identifier through browser cookies.
-
.default_header(name, value) ⇒ Hash
The result of the key/value pair.
-
.login(user = @api_user, passwd = @api_passwd) ⇒ Fixnum, ...
Authenticates the session so that API calls can be made.
- .timeout(seconds) ⇒ undefined
Instance Method Summary collapse
-
#alert ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
-
#container ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
-
#database ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
-
#delete ⇒ Fixnum, ...
Delete an object on the system.
-
#environment ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
-
#get ⇒ Fixnum, ...
Retrieve data from the server where complex input is not needed.
-
#group ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
-
#host ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
-
#job ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
-
#login ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
-
#policy ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
-
#post ⇒ Fixnum, ...
Issue a read/write operation, or make a read-only call that requires complex input.
-
#repository ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
-
#session ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
-
#snapshot ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
-
#source ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
-
#sourceconfig ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
-
#timeflow ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
-
#user ⇒ String
A helper method to return the URL for the resource by using the resource_url shorthand.
Methods included from Utils
Class Attribute Details
.api_passwd ⇒ String
Returns password for authentication.
91 92 93 |
# File 'lib/delphix.rb', line 91 def api_passwd @api_passwd end |
.api_user ⇒ String
Returns username to authenticate with.
88 89 90 |
# File 'lib/delphix.rb', line 88 def api_user @api_user end |
.api_version ⇒ Hash
Returns containing the major, minor and micro version numbers.
82 83 84 |
# File 'lib/delphix.rb', line 82 def api_version @api_version end |
.last_request ⇒ Hash
Returns retruns the last request.
69 70 71 |
# File 'lib/delphix.rb', line 69 def last_request @last_request end |
.last_response ⇒ Hash
Returns retruns the last response.
72 73 74 |
# File 'lib/delphix.rb', line 72 def last_response @last_response end |
.server ⇒ String
Returns Delphix server address.
85 86 87 |
# File 'lib/delphix.rb', line 85 def server @server end |
.session ⇒ Hash, ...
79 80 81 |
# File 'lib/delphix.rb', line 79 def session @session end |
.verbose ⇒ Nothing
Returns enables verbosity.
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_headers ⇒ Hash
Returns The HTTP headers sent with a POST/GET/DELETE.
104 105 106 |
# File 'lib/delphix/client.rb', line 104 def self.clear_default_headers @@default_headers = {} end |
.cookies ⇒ Hash
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. @resp ||= Delphix.post session_url, type: 'APISession', version: @api_version @resp. end |
.default_header(name, value) ⇒ Hash
Returns The result of the key/value pair.
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.login(user = @api_user, passwd = @api_passwd) Delphix.post login_url, 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
#alert ⇒ String
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 |
#container ⇒ String
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 |
#database ⇒ String
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 |
#delete ⇒ Fixnum, ...
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 |
#environment ⇒ String
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 |
#get ⇒ Fixnum, ...
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 |
#group ⇒ String
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 |
#host ⇒ String
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 |
#job ⇒ String
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 |
#login ⇒ String
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 |
#policy ⇒ String
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 |
#post ⇒ Fixnum, ...
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 |
#repository ⇒ String
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 |
#session ⇒ String
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 |
#snapshot ⇒ String
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 |
#source ⇒ String
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 |
#sourceconfig ⇒ String
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 |
#timeflow ⇒ String
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 |
#user ⇒ String
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 |