ultradns-sdk 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ultradns/api/authentication.rb +5 -3
- data/lib/ultradns/client.rb +3 -3
- data/lib/ultradns/version.rb +1 -1
- data/test/fixtures/vcr_cassettes/test_different_base_uri.yml +124 -0
- data/test/test_client_api.rb +12 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 022ce047b720fbed64b50289908118bb10ffdd10
|
4
|
+
data.tar.gz: 01f4b615c5329e6c61cdc248cf1b5b602c8af7d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8e4cfe27ba7f547f467b25b1b767ba72cad1ca16e2917badabb7d4d07bcfe95fc3601f0fa04097e1f0d3f0ff99ba2251f6c4ed393d17d4ed729bf10f7dd5422
|
7
|
+
data.tar.gz: 1794c9643093bac2ac7c0a689fe7f573d85253e4ecf393e70f8d277423409d90546b2f36368b191c41d4493c334ebcf5bfbff11c8dd46023d076c9ce70474da5
|
@@ -39,7 +39,7 @@ module Ultradns::Api::Authentication
|
|
39
39
|
params
|
40
40
|
end
|
41
41
|
|
42
|
-
def auth(username, password)
|
42
|
+
def auth(username, password, base_uri)
|
43
43
|
@auth = {}
|
44
44
|
@auth[:requested_at] = Time.now.to_i
|
45
45
|
response = self.class.post('/authorization/token',
|
@@ -50,7 +50,8 @@ module Ultradns::Api::Authentication
|
|
50
50
|
},
|
51
51
|
headers: {
|
52
52
|
'Content-Type' => 'application/x-www-form-urlencoded'
|
53
|
-
}
|
53
|
+
},
|
54
|
+
base_uri: base_uri
|
54
55
|
)
|
55
56
|
|
56
57
|
body = response.parsed_response
|
@@ -61,6 +62,7 @@ module Ultradns::Api::Authentication
|
|
61
62
|
# temp
|
62
63
|
@auth[:username] = username
|
63
64
|
@auth[:password] = password
|
65
|
+
@auth[:base_url] = base_uri
|
64
66
|
|
65
67
|
@auth[:access_token] = body['accessToken']
|
66
68
|
@auth[:refresh_token] = body['refreshToken']
|
@@ -78,7 +80,7 @@ module Ultradns::Api::Authentication
|
|
78
80
|
|
79
81
|
def refresh
|
80
82
|
# expires not available, then reauth
|
81
|
-
return auth(@auth[:username], @auth[:password]) if no_expiry?
|
83
|
+
return auth(@auth[:username], @auth[:password], @auth[:base_url]) if no_expiry?
|
82
84
|
|
83
85
|
# not expired yet.
|
84
86
|
return unless refresh?
|
data/lib/ultradns/client.rb
CHANGED
@@ -49,12 +49,12 @@ class Ultradns::Client
|
|
49
49
|
def initialize(username, password, options = {})
|
50
50
|
@logger ||= ::Logger.new($stdout)
|
51
51
|
|
52
|
-
auth(username, password)
|
53
|
-
|
54
52
|
@options = {}
|
55
53
|
# override or ignored if nil
|
56
54
|
@options[:base_uri] = HTTParty.normalize_base_uri(options[:host]) if options[:host]
|
57
55
|
|
56
|
+
auth(username, password, @options[:base_uri] || self.class.default_options[:base_uri])
|
57
|
+
|
58
58
|
logger.debug "Initializing UltraDNS Client using #{@options.inspect}"
|
59
59
|
end
|
60
60
|
|
@@ -134,7 +134,7 @@ class Ultradns::Client
|
|
134
134
|
# === Optional Parameters
|
135
135
|
#
|
136
136
|
# * +:q+ - The search parameters, in a hash. The query used to construct the list.
|
137
|
-
# Valid keys are:
|
137
|
+
# Valid keys are:
|
138
138
|
# code - valid values for 'code' are PENDING, IN_PROCESS, COMPLETE, and ERROR.
|
139
139
|
# hasData - valid values for 'hasData' are true and false.
|
140
140
|
#
|
data/lib/ultradns/version.rb
CHANGED
@@ -0,0 +1,124 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://test-restapi.ultradns.com/v1/authorization/token
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: grant_type=password&password=SECRET&username=SECRET
|
9
|
+
headers:
|
10
|
+
accept:
|
11
|
+
- application/json
|
12
|
+
content-type:
|
13
|
+
- application/x-www-form-urlencoded
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
access-control-allow-credentials:
|
20
|
+
- 'true'
|
21
|
+
access-control-allow-headers:
|
22
|
+
- Origin, X-Requested-With, Content-Type, Accept, Authorization
|
23
|
+
access-control-allow-methods:
|
24
|
+
- POST, GET, OPTIONS, DELETE, PUT, PATCH
|
25
|
+
access-control-allow-origin:
|
26
|
+
- "*"
|
27
|
+
access-control-max-age:
|
28
|
+
- '3600'
|
29
|
+
content-type:
|
30
|
+
- application/json
|
31
|
+
date:
|
32
|
+
- Tue, 28 Oct 2014 02:43:39 GMT
|
33
|
+
transfer-encoding:
|
34
|
+
- chunked
|
35
|
+
connection:
|
36
|
+
- Close
|
37
|
+
body:
|
38
|
+
encoding: UTF-8
|
39
|
+
string: '{"tokenType":"bearer","refreshToken":"c8d899264251409c96007fae44496c6c","accessToken":"d09553ac441148359da51fed81c0e8c6","expiresIn":"900","refresh_token":"c8d899264251409c96007fae44496c6c","access_token":"d09553ac441148359da51fed81c0e8c6","expires_in":"900","token_type":"bearer"}'
|
40
|
+
http_version: '1.1'
|
41
|
+
recorded_at: Tue, 28 Oct 2014 02:43:40 GMT
|
42
|
+
- request:
|
43
|
+
method: get
|
44
|
+
uri: https://test-restapi.ultradns.com/v1/status
|
45
|
+
body:
|
46
|
+
encoding: US-ASCII
|
47
|
+
string: ''
|
48
|
+
headers:
|
49
|
+
accept:
|
50
|
+
- application/json
|
51
|
+
content-type:
|
52
|
+
- application/json
|
53
|
+
authorization:
|
54
|
+
- Bearer d09553ac441148359da51fed81c0e8c6
|
55
|
+
response:
|
56
|
+
status:
|
57
|
+
code: 200
|
58
|
+
message: OK
|
59
|
+
headers:
|
60
|
+
access-control-allow-credentials:
|
61
|
+
- 'true'
|
62
|
+
access-control-allow-headers:
|
63
|
+
- Origin, X-Requested-With, Content-Type, Accept, Authorization
|
64
|
+
access-control-allow-methods:
|
65
|
+
- POST, GET, OPTIONS, DELETE, PUT, PATCH
|
66
|
+
access-control-allow-origin:
|
67
|
+
- "*"
|
68
|
+
access-control-max-age:
|
69
|
+
- '3600'
|
70
|
+
content-type:
|
71
|
+
- application/json
|
72
|
+
date:
|
73
|
+
- Tue, 28 Oct 2014 02:43:40 GMT
|
74
|
+
transfer-encoding:
|
75
|
+
- chunked
|
76
|
+
connection:
|
77
|
+
- Close
|
78
|
+
body:
|
79
|
+
encoding: UTF-8
|
80
|
+
string: '{"message":"Good"}'
|
81
|
+
http_version: '1.1'
|
82
|
+
recorded_at: Tue, 28 Oct 2014 02:43:40 GMT
|
83
|
+
- request:
|
84
|
+
method: get
|
85
|
+
uri: https://test-restapi.ultradns.com/v1/version
|
86
|
+
body:
|
87
|
+
encoding: US-ASCII
|
88
|
+
string: ''
|
89
|
+
headers:
|
90
|
+
accept:
|
91
|
+
- application/json
|
92
|
+
content-type:
|
93
|
+
- application/json
|
94
|
+
authorization:
|
95
|
+
- Bearer d09553ac441148359da51fed81c0e8c6
|
96
|
+
response:
|
97
|
+
status:
|
98
|
+
code: 200
|
99
|
+
message: OK
|
100
|
+
headers:
|
101
|
+
access-control-allow-credentials:
|
102
|
+
- 'true'
|
103
|
+
access-control-allow-headers:
|
104
|
+
- Origin, X-Requested-With, Content-Type, Accept, Authorization
|
105
|
+
access-control-allow-methods:
|
106
|
+
- POST, GET, OPTIONS, DELETE, PUT, PATCH
|
107
|
+
access-control-allow-origin:
|
108
|
+
- "*"
|
109
|
+
access-control-max-age:
|
110
|
+
- '3600'
|
111
|
+
content-type:
|
112
|
+
- application/json
|
113
|
+
date:
|
114
|
+
- Tue, 28 Oct 2014 02:43:40 GMT
|
115
|
+
transfer-encoding:
|
116
|
+
- chunked
|
117
|
+
connection:
|
118
|
+
- Close
|
119
|
+
body:
|
120
|
+
encoding: UTF-8
|
121
|
+
string: '{"version":"1.16.0-20141009193948.baa3c35"}'
|
122
|
+
http_version: '1.1'
|
123
|
+
recorded_at: Tue, 28 Oct 2014 02:43:40 GMT
|
124
|
+
recorded_with: VCR 2.9.2
|
data/test/test_client_api.rb
CHANGED
@@ -16,6 +16,18 @@ class TestClientApi < Minitest::Unit::TestCase
|
|
16
16
|
setup_credentials
|
17
17
|
end
|
18
18
|
|
19
|
+
def test_different_base_uri
|
20
|
+
VCR.use_cassette('test_different_base_uri') do
|
21
|
+
client = Ultradns::Client.new(@user, @pw, host: 'test-restapi.ultradns.com:443/v1')
|
22
|
+
|
23
|
+
result = client.status
|
24
|
+
assert result['message'] != nil
|
25
|
+
|
26
|
+
result = client.version
|
27
|
+
assert result['version'] != nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
19
31
|
def test_basic_client_apis
|
20
32
|
VCR.use_cassette('test_basic_client_apis') do
|
21
33
|
client = Ultradns::Client.new(@user, @pw)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ultradns-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ultradns
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- test/fixtures/vcr_cassettes/test_auth.yml
|
152
152
|
- test/fixtures/vcr_cassettes/test_auth_failure.yml
|
153
153
|
- test/fixtures/vcr_cassettes/test_basic_client_apis.yml
|
154
|
+
- test/fixtures/vcr_cassettes/test_different_base_uri.yml
|
154
155
|
- test/fixtures/vcr_cassettes/test_tasks_list.yml
|
155
156
|
- test/fixtures/vcr_cassettes/test_zone_apis.yml
|
156
157
|
- test/fixtures/vcr_cassettes/test_zone_rrsets_apis.yml
|
@@ -187,6 +188,7 @@ test_files:
|
|
187
188
|
- test/fixtures/vcr_cassettes/test_auth.yml
|
188
189
|
- test/fixtures/vcr_cassettes/test_auth_failure.yml
|
189
190
|
- test/fixtures/vcr_cassettes/test_basic_client_apis.yml
|
191
|
+
- test/fixtures/vcr_cassettes/test_different_base_uri.yml
|
190
192
|
- test/fixtures/vcr_cassettes/test_tasks_list.yml
|
191
193
|
- test/fixtures/vcr_cassettes/test_zone_apis.yml
|
192
194
|
- test/fixtures/vcr_cassettes/test_zone_rrsets_apis.yml
|