Module: Delphix
- Defined in:
- lib/delphix.rb
Defined Under Namespace
Modules: Base, Error, Util
Classes: BaseArray, Connection, Database, Environment, Group, Repository
Class Method Summary
collapse
Class Method Details
.authenticate!(username, password) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/delphix.rb', line 17
def authenticate!(username,password)
case
when !username.is_a?(String)
raise ArgumentError, "Expected a String, got: '#{username}'"
when !password.is_a?(String)
raise ArgumentError, "Expected a String, got: '#{password}'"
end
reset_connection!
session = {
:type => 'APISession',
:version => {
:type => 'APIVersion', :major => 1,
:minor => 6,
:micro => 0
}
}
post('/resources/json/delphix/session', session.to_json)
auth = {
:type => 'LoginRequest',
:username => username,
:password => password
}
post('/resources/json/delphix/login', auth.to_json)
end
|
.connection ⇒ Object
99
100
101
|
# File 'lib/delphix.rb', line 99
def connection
@connection ||= Connection.new(url, options)
end
|
.debug ⇒ Object
89
90
91
|
# File 'lib/delphix.rb', line 89
def debug
@debug || false
end
|
.debug=(new_value) ⇒ Object
93
94
95
|
# File 'lib/delphix.rb', line 93
def debug=(new_value)
@debug = new_value
end
|
.default_url ⇒ Object
111
112
113
|
# File 'lib/delphix.rb', line 111
def default_url
'http://localhost'
end
|
.delete(endpoint, payload = nil) ⇒ Object
a generic delete method, used when there is not specialized method to invoke an API call
66
67
68
|
# File 'lib/delphix.rb', line 66
def delete(endpoint, payload=nil)
connection.delete( endpoint, {}, :body => payload)
end
|
.env_options ⇒ Object
115
116
117
|
# File 'lib/delphix.rb', line 115
def env_options
{}
end
|
.env_url ⇒ Object
107
108
109
|
# File 'lib/delphix.rb', line 107
def env_url
ENV['DELPHIX_URL'] || default_url
end
|
.get(endpoint, payload = nil) ⇒ Object
a generic get method, used when there is not specialized method to invoke an API call
51
52
53
|
# File 'lib/delphix.rb', line 51
def get(endpoint, payload=nil)
connection.get( endpoint, {}, :body => payload)
end
|
.options ⇒ Object
80
81
82
|
# File 'lib/delphix.rb', line 80
def options
@options ||= env_options
end
|
.options=(new_options) ⇒ Object
84
85
86
87
|
# File 'lib/delphix.rb', line 84
def options=(new_options)
@options = env_options.merge(new_options || {})
reset_connection!
end
|
.post(endpoint, payload = nil) ⇒ Object
a generic post method, used when there is not specialized method to invoke an API call
56
57
58
|
# File 'lib/delphix.rb', line 56
def post(endpoint, payload=nil)
connection.post( endpoint, {}, :body => payload)
end
|
.put(endpoint, payload = nil) ⇒ Object
a generic put method, used when there is not specialized method to invoke an API call
61
62
63
|
# File 'lib/delphix.rb', line 61
def put(endpoint, payload=nil)
connection.put( endpoint, {}, :body => payload)
end
|
.reset_connection! ⇒ Object
103
104
105
|
# File 'lib/delphix.rb', line 103
def reset_connection!
@connection = nil
end
|
.url ⇒ Object
70
71
72
73
|
# File 'lib/delphix.rb', line 70
def url
@url ||= env_url
@url
end
|
.url=(new_url) ⇒ Object
75
76
77
78
|
# File 'lib/delphix.rb', line 75
def url=(new_url)
@url = new_url
reset_connection!
end
|