ultrasoap 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +36 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +90 -0
- data/lib/constants.rb +19 -0
- data/lib/settings.rb +7 -0
- data/lib/ultrasoap.rb +199 -0
- data/support/ultrasoap.yaml.sample +11 -0
- data/ultrasoap-ruby.gemspec +22 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ba939da1c7f279494a0088b419718a9b7f15982e
|
4
|
+
data.tar.gz: ef70972332257c84824a87fd2f0e3cb9ee47eeaa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0a6e5a79638ff07d3855c7b63d42cf3985c55a94d868696a48b07f19422af0134dbce15fdf2aa699bfac7939704a8af72300f985fd15d56f85a6f479484ad381
|
7
|
+
data.tar.gz: 97c4eab1a249951a82787855eea743a934d322fe23de6df551e59f4bef3103a8ccf17aa74af4bf160c4c0f39d792a3f2aca2be9e055b524be784dfa593e8a052
|
data/.gitignore
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
35
|
+
|
36
|
+
Gemfile.lock
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 chrean
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
ultrasoap-ruby
|
2
|
+
==============
|
3
|
+
|
4
|
+
Ruby gem to interact with UltraDNS SOAP API.
|
5
|
+
This gem is still in a very early version, so don't expect it to do miracles.
|
6
|
+
It just works, basically.
|
7
|
+
I plan to extend it, in the future, adding wrappers for the most important UltraDNS functions.
|
8
|
+
|
9
|
+
Install
|
10
|
+
-------
|
11
|
+
|
12
|
+
Just run:
|
13
|
+
|
14
|
+
```
|
15
|
+
gem install ultrasoap
|
16
|
+
```
|
17
|
+
|
18
|
+
Add it to your Gemfile:
|
19
|
+
|
20
|
+
```
|
21
|
+
gem 'ultrasoap'
|
22
|
+
```
|
23
|
+
|
24
|
+
Finally, require it into your source code:
|
25
|
+
|
26
|
+
```
|
27
|
+
require 'ultrasoap'
|
28
|
+
```
|
29
|
+
|
30
|
+
Then create the file ~/.ultrasoap, which has to be in **YAML format**.
|
31
|
+
Fill the file with your Neustar credentials, like this:
|
32
|
+
|
33
|
+
```yaml
|
34
|
+
username: johndoe
|
35
|
+
password: secret
|
36
|
+
```
|
37
|
+
|
38
|
+
You can tune other settings as well, though only credentials are mandatory.
|
39
|
+
|
40
|
+
Example:
|
41
|
+
|
42
|
+
```yaml
|
43
|
+
log_file : 'ultrasoap.log'
|
44
|
+
log : false
|
45
|
+
log_level : 'error'
|
46
|
+
test_wsdl : 'https://testapi.ultradns.com/UltraDNS_WS/v01?wsdl'
|
47
|
+
prod_wsdl : 'https://ultra-api.ultradns.com/UltraDNS_WS/v01?wsdl'
|
48
|
+
transactions: false
|
49
|
+
```
|
50
|
+
|
51
|
+
So basically you can tune log_file's path, logging level, test and production WSDL, and whether or not your client will use transactions.
|
52
|
+
|
53
|
+
Usage
|
54
|
+
-----
|
55
|
+
|
56
|
+
First off, instantiate UltraSOAP::Client:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
dl = UltraSOAP::Client.new()
|
60
|
+
```
|
61
|
+
|
62
|
+
Secondly, form the message and send it to the API server:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
# See SOAP API reference for explanations on parameters and calls
|
66
|
+
probes_message = {
|
67
|
+
:pool_record_ID => pool_record_id.to_s,
|
68
|
+
:sort_by => 'PROBEDATA'
|
69
|
+
}
|
70
|
+
```
|
71
|
+
|
72
|
+
Now you are ready to send the call:
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
probes_response = dl.send_request :get_probes_of_pool_record, probes_message
|
76
|
+
```
|
77
|
+
|
78
|
+
For those who didn't get it, the method *send_request* takes 2 parameters:
|
79
|
+
1) The symbol of the function to call.
|
80
|
+
2) The message containing the parameters for the function, as stated in the reference.
|
81
|
+
|
82
|
+
The response is an XML Nodeset, therefore you can perform XPath queries and everything:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
probes_response.xpath("//ProbeData").each |probe|
|
86
|
+
# Put your loop code here
|
87
|
+
...
|
88
|
+
...
|
89
|
+
end
|
90
|
+
```
|
data/lib/constants.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module UltraSOAP
|
4
|
+
class Constants
|
5
|
+
include Singleton
|
6
|
+
|
7
|
+
attr_accessor :lb_pool_modes
|
8
|
+
|
9
|
+
def initialize()
|
10
|
+
@lb_pool_modes = {
|
11
|
+
"force_active_test" => "ForceActive-Test",
|
12
|
+
"force_active_notest" => "ForceActive-NoTest",
|
13
|
+
"force_fail_test" => "ForceFail-Test",
|
14
|
+
"force_fail_notest" => "ForceFail-NoTest",
|
15
|
+
"normal" => "Normal"
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/settings.rb
ADDED
data/lib/ultrasoap.rb
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
require 'savon'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
module UltraSOAP
|
5
|
+
|
6
|
+
class Client
|
7
|
+
|
8
|
+
# Class variables
|
9
|
+
@logger
|
10
|
+
|
11
|
+
@logdest = './ultrasoap.log'
|
12
|
+
@logging = false
|
13
|
+
@log_level = 'error'
|
14
|
+
@test_wsdl = 'https://testapi.ultradns.com/UltraDNS_WS/v01?wsdl'
|
15
|
+
@prod_wsdl = 'https://ultra-api.ultradns.com/UltraDNS_WS/v01?wsdl'
|
16
|
+
@environment = 'production'
|
17
|
+
@transaction_id = nil
|
18
|
+
@use_transactions = false
|
19
|
+
|
20
|
+
class << self
|
21
|
+
attr_accessor :logdest
|
22
|
+
attr_accessor :logging
|
23
|
+
attr_accessor :log_level
|
24
|
+
attr_accessor :transaction_id
|
25
|
+
attr_accessor :test_wsdl
|
26
|
+
attr_accessor :prod_wsdl
|
27
|
+
attr_accessor :environment
|
28
|
+
attr_accessor :use_transactions
|
29
|
+
end
|
30
|
+
|
31
|
+
# Instance variables
|
32
|
+
attr_accessor :logging
|
33
|
+
attr_accessor :loglevel
|
34
|
+
|
35
|
+
# Constructor
|
36
|
+
def initialize()
|
37
|
+
# Exits if username or password aren't specified.
|
38
|
+
return nil unless !(Settings.username.nil? or Settings.password.nil?)
|
39
|
+
|
40
|
+
username = Settings.username
|
41
|
+
password = Settings.password
|
42
|
+
|
43
|
+
@environment = Settings['environment'] || Client.environment
|
44
|
+
|
45
|
+
# We don't need the following to be instance variables
|
46
|
+
ultra_wsdl = (@environment == 'test' ? (Settings['test_wsdl'] || Client.test_wsdl) : (Settings['prod_wsdl'] || Client.prod_wsdl))
|
47
|
+
|
48
|
+
# Setting up parameter values, if provided. If not, defaults are assumed
|
49
|
+
|
50
|
+
@use_transactions = Settings['use_transactions'] || Client.use_transactions
|
51
|
+
@logdest = Settings['logfile'] || Client.logdest
|
52
|
+
|
53
|
+
@logger = Logger.new(@logdest)
|
54
|
+
|
55
|
+
logging = Settings['logging'] || Client.logging
|
56
|
+
|
57
|
+
log_lev = Settings['log_level'] || Client.log_level
|
58
|
+
|
59
|
+
begin
|
60
|
+
# For some reason, if I use the instance variable, Savon.client doesn't work properly
|
61
|
+
|
62
|
+
@client = Savon.client do
|
63
|
+
wsdl ultra_wsdl
|
64
|
+
env_namespace 'soapenv'
|
65
|
+
wsse_auth(username, password)
|
66
|
+
element_form_default :unqualified
|
67
|
+
log logging
|
68
|
+
log_level log_lev.to_sym
|
69
|
+
pretty_print_xml true
|
70
|
+
end
|
71
|
+
rescue Exception => e
|
72
|
+
@logger.error("Error in ultrasoap.initialize: " + e.message)
|
73
|
+
raise 'Error in ultrasoap initialization, check log file'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Main method to send SOAP requests
|
78
|
+
#
|
79
|
+
# Parameters:
|
80
|
+
# * method: the SOAP send_request
|
81
|
+
# * message: the message hash
|
82
|
+
def send_request(method, message, strip_namespaces=true)
|
83
|
+
# If the client is using transactions, append the transaction id to the message hash
|
84
|
+
if @use_transactions == true
|
85
|
+
transaction_hash = { :transaction_id => @transaction_id }
|
86
|
+
message.merge(transaction_hash)
|
87
|
+
end
|
88
|
+
|
89
|
+
begin
|
90
|
+
@response = @client.call method, message: message
|
91
|
+
return Nokogiri::XML(@response.to_xml).remove_namespaces!
|
92
|
+
rescue Exception => e
|
93
|
+
@logger.error("Error in ultrasoap.send_request: " + e.message)
|
94
|
+
return nil
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Starts a transaction and sets the @transaction_id variable
|
99
|
+
def transaction_start
|
100
|
+
begin
|
101
|
+
response = self.send_request :start_transaction
|
102
|
+
xml_response = Nokogiri::XML(response.to_xml).remove_namespaces!
|
103
|
+
@transaction_id = xml_response.xpath("//transactionId/text()")
|
104
|
+
rescue Exception => e
|
105
|
+
@logger.error("Error in ultrasoap.transaction_start: " + e.message)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Rolls back the current transaction
|
110
|
+
def transaction_rollback
|
111
|
+
return nil unless @transaction_id != nil
|
112
|
+
|
113
|
+
message = {
|
114
|
+
:transaction_id => @transaction_id.to_s
|
115
|
+
}
|
116
|
+
|
117
|
+
begin
|
118
|
+
trans_rollback = self.send_request :rollback_transaction, message
|
119
|
+
rescue Exception => e
|
120
|
+
@logger.error("Error in ultrasoap.transaction_rollback: " + e.message)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# Commit the current transaction
|
125
|
+
def transaction_commit
|
126
|
+
return nil unless @transaction_id != nil
|
127
|
+
|
128
|
+
message = {
|
129
|
+
:transaction_id => @transaction_id.to_s
|
130
|
+
}
|
131
|
+
|
132
|
+
begin
|
133
|
+
trans_commit = self.send_request :commit_transaction, message
|
134
|
+
rescue Exception => e
|
135
|
+
@logger.error("Error in ultrasoap.transaction_commit: " + e.message)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# Helper method to retrieve load balancing pools data
|
140
|
+
# Parameters:
|
141
|
+
# - zone (don't forget the trailing dot)
|
142
|
+
def get_lb_pools(zone)
|
143
|
+
message = {
|
144
|
+
:zone_name => zone,
|
145
|
+
:lb_pool_type => 'SB'
|
146
|
+
}
|
147
|
+
|
148
|
+
begin
|
149
|
+
response = self.send_request :get_load_balancing_pools_by_zone, message
|
150
|
+
return response
|
151
|
+
rescue Exception => e
|
152
|
+
@logger.error("Error in retrieving SB pools for the zone #{zone}: #{e.message}")
|
153
|
+
return nil
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# Helper method to retrieve Pool's records
|
158
|
+
# Parameters:
|
159
|
+
# - poolID
|
160
|
+
def get_pool_records(pool_id)
|
161
|
+
message = {
|
162
|
+
:pool_id => pool_id.to_s
|
163
|
+
}
|
164
|
+
|
165
|
+
begin
|
166
|
+
return self.send_request :get_pool_records, message
|
167
|
+
rescue Exception => e
|
168
|
+
@logger.error("Error while retrieving Pool Records for the Pool ID #{pool_id.to_s}: #{e.message}")
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
# LOOKUP methods
|
173
|
+
|
174
|
+
def lookup_pool_type(pt_code)
|
175
|
+
case pt_code.to_s
|
176
|
+
when 'SB'
|
177
|
+
'SiteBacker'
|
178
|
+
when 'RD'
|
179
|
+
'Resource Distribution'
|
180
|
+
when 'TC'
|
181
|
+
'Traffic Controller'
|
182
|
+
else
|
183
|
+
'Other'
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def lookup_response_method(rm_code)
|
188
|
+
case rm_code.to_s
|
189
|
+
when 'FX'
|
190
|
+
'Fixed'
|
191
|
+
when 'RR'
|
192
|
+
'Round Robin'
|
193
|
+
when 'RD'
|
194
|
+
'Random'
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Copy this file into ~/.ultrasoap
|
2
|
+
# Edit credentials and debug options accordingly to your needs
|
3
|
+
# Default values are commented out
|
4
|
+
username : 'johndoe'
|
5
|
+
password : 'secret'
|
6
|
+
#log_file : 'ultrasoap.log'
|
7
|
+
#log : false
|
8
|
+
#log_level : 'error'
|
9
|
+
#test_wsdl : 'https://testapi.ultradns.com/UltraDNS_WS/v01?wsdl'
|
10
|
+
#prod_wsdl : 'https://ultra-api.ultradns.com/UltraDNS_WS/v01?wsdl'
|
11
|
+
#transactions: false
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'ultrasoap'
|
3
|
+
s.version = '0.0.5'
|
4
|
+
s.summary = "Simple Ruby client library for UltraDNS SOAP API"
|
5
|
+
s.description = "Connect to Neustar's UltraDNS SOAP API. FKA ultrasoap-ruby"
|
6
|
+
s.authors = ["Gabriel Sambarino"]
|
7
|
+
s.email = 'gabriel.sambarino@gmail.com'
|
8
|
+
s.files = `git ls-files`.split("\n")
|
9
|
+
s.homepage = 'https://github.com/chrean/ultrasoap-ruby'
|
10
|
+
s.license = "MIT"
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
s.required_ruby_version = '~> 2.0'
|
13
|
+
|
14
|
+
s.rubyforge_project = s.name
|
15
|
+
s.license = 'MIT'
|
16
|
+
|
17
|
+
s.add_dependency "savon", "~> 2.0"
|
18
|
+
s.add_dependency "settingslogic", "~> 2.0"
|
19
|
+
|
20
|
+
s.add_development_dependency "rspec", "~> 2.10"
|
21
|
+
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ultrasoap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gabriel Sambarino
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: savon
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: settingslogic
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.10'
|
55
|
+
description: Connect to Neustar's UltraDNS SOAP API. FKA ultrasoap-ruby
|
56
|
+
email: gabriel.sambarino@gmail.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- ".gitignore"
|
62
|
+
- Gemfile
|
63
|
+
- LICENSE
|
64
|
+
- README.md
|
65
|
+
- lib/constants.rb
|
66
|
+
- lib/settings.rb
|
67
|
+
- lib/ultrasoap.rb
|
68
|
+
- support/ultrasoap.yaml.sample
|
69
|
+
- ultrasoap-ruby.gemspec
|
70
|
+
homepage: https://github.com/chrean/ultrasoap-ruby
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project: ultrasoap
|
90
|
+
rubygems_version: 2.3.0
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Simple Ruby client library for UltraDNS SOAP API
|
94
|
+
test_files: []
|