reg.api2 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.md +5 -0
- data/Rakefile +9 -26
- data/bin/regapi2console +3 -3
- data/lib/reg_api2/action.rb +144 -0
- data/lib/reg_api2/api_error.rb +30 -0
- data/lib/reg_api2/console.rb +1 -1
- data/lib/reg_api2/contract_error.rb +17 -0
- data/lib/reg_api2/entity/entity_base.rb +1 -0
- data/lib/reg_api2/entity/user.rb +1 -0
- data/lib/reg_api2/hosting.rb +39 -0
- data/lib/reg_api2/impl.rb +3 -181
- data/lib/reg_api2/net_error.rb +7 -0
- data/lib/reg_api2/result_contract.rb +2 -1
- data/lib/reg_api2/service.rb +1 -1
- data/lib/reg_api2/sym_hash.rb +1 -0
- data/lib/reg_api2/version.rb +1 -1
- data/lib/reg_api2.rb +35 -0
- data/spec/blueprints/user.rb +1 -0
- data/spec/lib/reg_api2/hosting_spec.rb +25 -0
- metadata +11 -4
data/CHANGES.md
CHANGED
data/Rakefile
CHANGED
@@ -1,36 +1,19 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require "bundler/gem_tasks"
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'yard'
|
3
5
|
|
4
|
-
|
6
|
+
GEM_ROOT = File.dirname(__FILE__).freeze
|
5
7
|
|
6
|
-
|
7
|
-
$LOAD_PATH.unshift(
|
8
|
-
require 'reg_api2/version'
|
8
|
+
lib_path = File.expand_path('lib', GEM_ROOT)
|
9
|
+
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include? lib_path
|
9
10
|
|
10
|
-
|
11
|
-
require 'rspec/core/rake_task'
|
11
|
+
require 'reg_api2/version'
|
12
12
|
|
13
|
-
|
13
|
+
RSpec::Core::RakeTask.new
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
t.ruby_opts = '-w'
|
18
|
-
t.rcov_opts = %q[-Ilib --exclude "spec/*,gems/*"]
|
19
|
-
end
|
20
|
-
rescue LoadError
|
21
|
-
$stderr.puts "RSpec not available. Install it with: gem install rspec-core rspec-expectations"
|
15
|
+
YARD::Rake::YardocTask.new do |yard|
|
16
|
+
yard.options << "--title='reg.api2 #{RegApi2::VERSION}'"
|
22
17
|
end
|
23
18
|
|
24
19
|
task :default => :spec
|
25
|
-
|
26
|
-
begin
|
27
|
-
require 'yard'
|
28
|
-
|
29
|
-
YARD::Rake::YardocTask.new do |yard|
|
30
|
-
|
31
|
-
version = RegApi2::VERSION
|
32
|
-
yard.options << "--title='reg.api2 #{version}'"
|
33
|
-
end
|
34
|
-
rescue LoadError
|
35
|
-
$stderr.puts "Please install YARD with: gem install yard"
|
36
|
-
end
|
data/bin/regapi2console
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
begin
|
4
4
|
require 'reg_api2/console'
|
5
5
|
rescue LoadError # local run
|
6
|
-
|
7
|
-
|
8
|
-
$LOAD_PATH.unshift(
|
6
|
+
LOCAL_GEM_ROOT = File.expand_path('..', File.dirname(__FILE__)).freeze
|
7
|
+
lib_path = File.expand_path('lib', LOCAL_GEM_ROOT)
|
8
|
+
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
|
9
9
|
require 'reg_api2/console'
|
10
10
|
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'uri'
|
3
|
+
require 'net/http'
|
4
|
+
require 'net/https'
|
5
|
+
require 'yajl'
|
6
|
+
|
7
|
+
module RegApi2
|
8
|
+
# Implementation of request/response activity.
|
9
|
+
module Action
|
10
|
+
# Default IO encoding
|
11
|
+
DEFAULT_IO_ENCODING = 'utf-8'.freeze
|
12
|
+
# Default lang.
|
13
|
+
DEFAULT_LANG = 'en'.freeze
|
14
|
+
# Default user name.
|
15
|
+
DEFAULT_USERNAME = 'test'.freeze
|
16
|
+
# Default password.
|
17
|
+
DEFAULT_PASSWORD = 'test'.freeze
|
18
|
+
|
19
|
+
# REG.API base URI
|
20
|
+
API_URI = URI.parse("https://api.reg.ru/api/regru2")
|
21
|
+
|
22
|
+
|
23
|
+
def apply_ca_cert_path(http)
|
24
|
+
unless ca_cert_path.nil?
|
25
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
26
|
+
http.ca_file = ca_cert_path
|
27
|
+
else
|
28
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def apply_pem(http)
|
33
|
+
return if pem.nil?
|
34
|
+
http.cert = OpenSSL::X509::Certificate.new(pem)
|
35
|
+
if pem_password
|
36
|
+
raise ArgumentError, "The private key requires a password" if pem_password.empty?
|
37
|
+
http.key = OpenSSL::PKey::RSA.new(pem, pem_password)
|
38
|
+
else
|
39
|
+
http.key = OpenSSL::PKey::RSA.new(pem)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private :apply_pem, :apply_ca_cert_path
|
44
|
+
|
45
|
+
# Creates HTTPS handler.
|
46
|
+
# @return [Net::HTTP] HTTPS handler.
|
47
|
+
# @see #http
|
48
|
+
def create_http
|
49
|
+
http = Net::HTTP.new(
|
50
|
+
API_URI.host,
|
51
|
+
API_URI.port
|
52
|
+
)
|
53
|
+
http.use_ssl = true
|
54
|
+
apply_ca_cert_path(http)
|
55
|
+
apply_pem(http)
|
56
|
+
http
|
57
|
+
end
|
58
|
+
|
59
|
+
# Creates or gets HTTPS handler.
|
60
|
+
# @return [Net::HTTP] HTTPS handler.
|
61
|
+
# @see #create_http
|
62
|
+
# @see #clear_http
|
63
|
+
def http
|
64
|
+
@http ||= create_http
|
65
|
+
end
|
66
|
+
|
67
|
+
# Clears internal `http` singleton.
|
68
|
+
# Also finishes any started HTTP session.
|
69
|
+
# @return nil
|
70
|
+
# @note For testing purposes.
|
71
|
+
# @see #http
|
72
|
+
def clear_http
|
73
|
+
return nil unless @http
|
74
|
+
@http.finish if @http.respond_to?(:started) && @http.started
|
75
|
+
@http = nil
|
76
|
+
end
|
77
|
+
|
78
|
+
# Gets form data for POST request
|
79
|
+
# @param [Hash] defopts
|
80
|
+
# @param [Hash] opts
|
81
|
+
# @return [Hash] Form data to be sent.
|
82
|
+
# @raise [ContractError]
|
83
|
+
def get_form_data(defopts, opts)
|
84
|
+
# HACK: REG.API doesn't know about utf-8.
|
85
|
+
io_encoding = 'utf8' if !io_encoding || io_encoding == DEFAULT_IO_ENCODING
|
86
|
+
opts = opts.to_hash if opts.respond_to?(:to_hash)
|
87
|
+
req_contract = RegApi2::RequestContract.new(defopts)
|
88
|
+
opts = req_contract.validate(opts)
|
89
|
+
|
90
|
+
form = {
|
91
|
+
'username' => username || DEFAULT_USERNAME,
|
92
|
+
'password' => password || DEFAULT_PASSWORD,
|
93
|
+
'io_encoding' => io_encoding,
|
94
|
+
'lang' => lang || DEFAULT_LANG,
|
95
|
+
'output_format' => 'json',
|
96
|
+
'input_format' => 'json',
|
97
|
+
'show_input_params' => 0,
|
98
|
+
'input_data' => Yajl::Encoder.encode(opts)
|
99
|
+
}
|
100
|
+
|
101
|
+
form
|
102
|
+
end
|
103
|
+
|
104
|
+
# Handles response
|
105
|
+
# @param [Hash] defopts
|
106
|
+
# @param [Net::HTTPResponse] res HTTP Response
|
107
|
+
# @return [Object] Contracted response.
|
108
|
+
# @raise [NetError]
|
109
|
+
# @raise [ApiError]
|
110
|
+
def handle_response(defopts, res)
|
111
|
+
raise NetError.new(res.body) unless res.code == '200'
|
112
|
+
|
113
|
+
json = Yajl::Parser.parse(res.body)
|
114
|
+
RegApi2.got_response(json)
|
115
|
+
|
116
|
+
raise ApiError.from_json(json) if json['result'] == 'error'
|
117
|
+
|
118
|
+
res_contract = RegApi2::ResultContract.new(defopts)
|
119
|
+
res_contract.handle_result(json)
|
120
|
+
end
|
121
|
+
|
122
|
+
# Do actual call to REG.API using POST/JSON convention.
|
123
|
+
# @param [Symbol] category
|
124
|
+
# @param [Symbol] name
|
125
|
+
# @param [Hash] defopts
|
126
|
+
# @param [Hash] opts
|
127
|
+
# @return [Hash] Result answer field.
|
128
|
+
# @raise [NetError]
|
129
|
+
# @raise [ApiError]
|
130
|
+
# @raise [ContractError]
|
131
|
+
def make_action category, name, defopts, opts = {}
|
132
|
+
req = Net::HTTP::Post.new(
|
133
|
+
category.nil? ? "#{API_URI.path}/#{name}" : "#{API_URI.path}/#{category}/#{name}"
|
134
|
+
)
|
135
|
+
form = get_form_data(defopts, opts)
|
136
|
+
RegApi2.form_to_be_sent(req.path, form)
|
137
|
+
|
138
|
+
req.set_form_data(form)
|
139
|
+
res = http.request(req)
|
140
|
+
|
141
|
+
handle_response(defopts, res)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module RegApi2
|
3
|
+
# API Error from REG.API provider.
|
4
|
+
# Please refer to {file:README.md#Common_error_codes common error codes}.
|
5
|
+
class ApiError < StandardError
|
6
|
+
# @!attribute [r] description
|
7
|
+
# @return [String] Localized error description.
|
8
|
+
attr_reader :description
|
9
|
+
# @!attribute [r] params
|
10
|
+
# @return [Hash] Optional error params.
|
11
|
+
attr_reader :params
|
12
|
+
|
13
|
+
def initialize code, description, params
|
14
|
+
super code
|
15
|
+
@description = description
|
16
|
+
@params = params || {}
|
17
|
+
end
|
18
|
+
|
19
|
+
# Extracts error arguments from specified json.
|
20
|
+
# @param [Hash] json
|
21
|
+
# @return [ApiError] Initialized error object.
|
22
|
+
def self.from_json json
|
23
|
+
new(
|
24
|
+
json['error_code'],
|
25
|
+
json['error_text'],
|
26
|
+
json['error_params']
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/reg_api2/console.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module RegApi2
|
3
|
+
# API Contract Error.
|
4
|
+
# Raised when input parameters doesn't pass Ruby client tests.
|
5
|
+
class ContractError < ArgumentError
|
6
|
+
# @!attribute [r] fields
|
7
|
+
# @return [Array<String>] Wrong fields.
|
8
|
+
attr_reader :fields
|
9
|
+
|
10
|
+
def initialize message, fields = []
|
11
|
+
super message
|
12
|
+
fields = [] if fields.nil?
|
13
|
+
fields = [ fields ] unless fields.kind_of?(Array)
|
14
|
+
@fields = fields
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/reg_api2/entity/user.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module RegApi2
|
3
|
+
# REG.API hosting category
|
4
|
+
module Hosting
|
5
|
+
|
6
|
+
include RegApi2::Builder
|
7
|
+
|
8
|
+
category :hosting
|
9
|
+
|
10
|
+
# @!method nop(opts = {})
|
11
|
+
# @param [Hash] opts
|
12
|
+
# This function serves for testing purposes.
|
13
|
+
# @return [Hash(domains)] A list of domains. Domains that allow DNS zone management will have the “success” value in the “result” field, otherwise the “result” field will feature an error code explaining the error reason.
|
14
|
+
# @note Accessibility: everyone
|
15
|
+
# @example Test
|
16
|
+
# RegApi2.hosting.nop
|
17
|
+
define :nop
|
18
|
+
|
19
|
+
# @!method get_jelastic_refill_url(opts = {})
|
20
|
+
# @param [Hash] opts
|
21
|
+
# Gets Jelastic refill URL for current reseller.
|
22
|
+
# @return [String] Jelastic refill URL.
|
23
|
+
# @note Accessibility: partners
|
24
|
+
# @example Typical usage
|
25
|
+
# puts RegApi2.get_jelastic_refill_url
|
26
|
+
define :get_jelastic_refill_url, field: :url
|
27
|
+
|
28
|
+
# @!method set_jelastic_refill_url(opts = {})
|
29
|
+
# @param [Hash] opts
|
30
|
+
# @option opts [String] :url Jelastic refill URL.
|
31
|
+
# Sets Jelastic refill URL for current reseller.
|
32
|
+
# @note Accessibility: partners
|
33
|
+
# @example Typical usage
|
34
|
+
# RegApi2.set_jelastic_refill_url url: 'http://mysite.com?service_id=<service_id>&email=<email>'
|
35
|
+
define :set_jelastic_refill_url, required: :url
|
36
|
+
|
37
|
+
extend self
|
38
|
+
end
|
39
|
+
end
|
data/lib/reg_api2/impl.rb
CHANGED
@@ -1,58 +1,8 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
require 'uri'
|
3
|
-
require 'net/http'
|
4
|
-
require 'net/https'
|
5
|
-
require 'yajl'
|
6
2
|
|
7
|
-
|
8
|
-
# Networking Error.
|
9
|
-
# Raised when response doesn't meet HTTP 200 OK status.
|
10
|
-
class NetError < IOError
|
11
|
-
end
|
12
|
-
|
13
|
-
# API Contract Error.
|
14
|
-
# Raised when input parameters doesn't pass Ruby client tests.
|
15
|
-
class ContractError < ArgumentError
|
16
|
-
# @!attribute [r] fields
|
17
|
-
# @return [Array<String>] Wrong fields.
|
18
|
-
attr_reader :fields
|
19
|
-
|
20
|
-
def initialize message, fields = []
|
21
|
-
super message
|
22
|
-
fields = [] if fields.nil?
|
23
|
-
fields = [ fields ] unless fields.kind_of?(Array)
|
24
|
-
@fields = fields
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# API Error from REG.API provider.
|
29
|
-
# Please refer to {file:README.md#Common_error_codes common error codes}.
|
30
|
-
class ApiError < StandardError
|
31
|
-
# @!attribute [r] description
|
32
|
-
# @return [String] Localized error description.
|
33
|
-
attr_reader :description
|
34
|
-
# @!attribute [r] params
|
35
|
-
# @return [Hash] Optional error params.
|
36
|
-
attr_reader :params
|
37
|
-
|
38
|
-
def initialize code, description, params
|
39
|
-
super code
|
40
|
-
@description = description
|
41
|
-
@params = params || {}
|
42
|
-
end
|
43
|
-
|
44
|
-
# Extracts error arguments from specified json.
|
45
|
-
# @param [Hash] json
|
46
|
-
# @return [ApiError] Initialized error object.
|
47
|
-
def self.from_json json
|
48
|
-
new(
|
49
|
-
json['error_code'],
|
50
|
-
json['error_text'],
|
51
|
-
json['error_params']
|
52
|
-
)
|
53
|
-
end
|
54
|
-
end
|
3
|
+
require 'reg_api2/action'
|
55
4
|
|
5
|
+
module RegApi2
|
56
6
|
class << self
|
57
7
|
# @!attribute [rw] username
|
58
8
|
# @return [String] User name (`test` by default).
|
@@ -144,69 +94,6 @@ module RegApi2
|
|
144
94
|
nil
|
145
95
|
end
|
146
96
|
|
147
|
-
# Default IO encoding
|
148
|
-
DEFAULT_IO_ENCODING = 'utf-8'
|
149
|
-
# Default lang.
|
150
|
-
DEFAULT_LANG = 'en'
|
151
|
-
|
152
|
-
# REG.API base URI
|
153
|
-
API_URI = URI.parse("https://api.reg.ru/api/regru2")
|
154
|
-
|
155
|
-
def apply_ca_cert_path(http)
|
156
|
-
unless ca_cert_path.nil?
|
157
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
158
|
-
http.ca_file = ca_cert_path
|
159
|
-
else
|
160
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def apply_pem(http)
|
165
|
-
return if pem.nil?
|
166
|
-
http.cert = OpenSSL::X509::Certificate.new(pem)
|
167
|
-
if pem_password
|
168
|
-
raise ArgumentError, "The private key requires a password" if pem_password.empty?
|
169
|
-
http.key = OpenSSL::PKey::RSA.new(pem, pem_password)
|
170
|
-
else
|
171
|
-
http.key = OpenSSL::PKey::RSA.new(pem)
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
private :apply_pem, :apply_ca_cert_path
|
176
|
-
|
177
|
-
# Creates HTTPS handler.
|
178
|
-
# @return [Net::HTTP] HTTPS handler.
|
179
|
-
# @see #http
|
180
|
-
def create_http
|
181
|
-
_http = Net::HTTP.new(
|
182
|
-
API_URI.host,
|
183
|
-
API_URI.port
|
184
|
-
)
|
185
|
-
_http.use_ssl = true
|
186
|
-
apply_ca_cert_path(_http)
|
187
|
-
apply_pem(_http)
|
188
|
-
_http
|
189
|
-
end
|
190
|
-
|
191
|
-
# Creates or gets HTTPS handler.
|
192
|
-
# @return [Net::HTTP] HTTPS handler.
|
193
|
-
# @see #create_http
|
194
|
-
# @see #clear_http
|
195
|
-
def http
|
196
|
-
@http ||= create_http
|
197
|
-
end
|
198
|
-
|
199
|
-
# Clears internal `http` singleton.
|
200
|
-
# Also finishes any started HTTP session.
|
201
|
-
# @return nil
|
202
|
-
# @note For testing purposes.
|
203
|
-
# @see #http
|
204
|
-
def clear_http
|
205
|
-
return nil unless @http
|
206
|
-
@http.finish if @http.respond_to?(:started) && @http.started
|
207
|
-
@http = nil
|
208
|
-
end
|
209
|
-
|
210
97
|
# Placeholder to inspect sent form
|
211
98
|
# @param [String] path
|
212
99
|
# @param [Hash] form
|
@@ -246,71 +133,6 @@ module RegApi2
|
|
246
133
|
nil
|
247
134
|
end
|
248
135
|
|
249
|
-
|
250
|
-
# @param [Hash] defopts
|
251
|
-
# @param [Hash] opts
|
252
|
-
# @return [Hash] Form data to be sent.
|
253
|
-
# @raise [ContractError]
|
254
|
-
def get_form_data(defopts, opts)
|
255
|
-
# HACK: REG.API doesn't know about utf-8.
|
256
|
-
io_encoding = 'utf8' if !io_encoding || io_encoding == DEFAULT_IO_ENCODING
|
257
|
-
opts = opts.to_hash if opts.respond_to?(:to_hash)
|
258
|
-
req_contract = RegApi2::RequestContract.new(defopts)
|
259
|
-
opts = req_contract.validate(opts)
|
260
|
-
|
261
|
-
form = {
|
262
|
-
'username' => username || 'test',
|
263
|
-
'password' => password || 'test',
|
264
|
-
'io_encoding' => io_encoding,
|
265
|
-
'lang' => lang || DEFAULT_LANG,
|
266
|
-
'output_format' => 'json',
|
267
|
-
'input_format' => 'json',
|
268
|
-
'show_input_params' => 0,
|
269
|
-
'input_data' => Yajl::Encoder.encode(opts)
|
270
|
-
}
|
271
|
-
|
272
|
-
form
|
273
|
-
end
|
274
|
-
|
275
|
-
# Handles response
|
276
|
-
# @param [Hash] defopts
|
277
|
-
# @param [Net::HTTPResponse] res HTTP Response
|
278
|
-
# @return [Object] Contracted response.
|
279
|
-
# @raise [NetError]
|
280
|
-
# @raise [ApiError]
|
281
|
-
def handle_response(defopts, res)
|
282
|
-
raise NetError.new(res.body) unless res.code == '200'
|
283
|
-
|
284
|
-
json = Yajl::Parser.parse(res.body)
|
285
|
-
got_response(json)
|
286
|
-
|
287
|
-
raise ApiError.from_json(json) if json['result'] == 'error'
|
288
|
-
|
289
|
-
res_contract = RegApi2::ResultContract.new(defopts)
|
290
|
-
res_contract.handle_result(json)
|
291
|
-
end
|
292
|
-
|
293
|
-
# Do actual call to REG.API using POST/JSON convention.
|
294
|
-
# @param [Symbol] category
|
295
|
-
# @param [Symbol] name
|
296
|
-
# @param [Hash] defopts
|
297
|
-
# @param [Hash] opts
|
298
|
-
# @return [Hash] Result answer field.
|
299
|
-
# @raise [NetError]
|
300
|
-
# @raise [ApiError]
|
301
|
-
# @raise [ContractError]
|
302
|
-
def make_action category, name, defopts, opts = {}
|
303
|
-
req = Net::HTTP::Post.new(
|
304
|
-
category.nil? ? "#{API_URI.path}/#{name}" : "#{API_URI.path}/#{category}/#{name}"
|
305
|
-
)
|
306
|
-
form = get_form_data(defopts, opts)
|
307
|
-
form_to_be_sent(req.path, form)
|
308
|
-
|
309
|
-
req.set_form_data(form)
|
310
|
-
res = http.request(req)
|
311
|
-
|
312
|
-
handle_response(defopts, res)
|
313
|
-
end
|
314
|
-
|
136
|
+
include RegApi2::Action
|
315
137
|
end
|
316
138
|
end
|
@@ -19,6 +19,7 @@ module RegApi2
|
|
19
19
|
bill_id
|
20
20
|
service_id
|
21
21
|
server_id
|
22
|
+
folder_id
|
22
23
|
cpu_count
|
23
24
|
cpu_core
|
24
25
|
hdd_count
|
@@ -113,8 +114,8 @@ module RegApi2
|
|
113
114
|
# @see #convert
|
114
115
|
# @see #opts
|
115
116
|
def handle_answer(answer)
|
116
|
-
answer = convert(answer)
|
117
117
|
return nil if answer.nil?
|
118
|
+
answer = convert(answer)
|
118
119
|
field = opts[:field]
|
119
120
|
if field
|
120
121
|
answer = answer[field]
|
data/lib/reg_api2/service.rb
CHANGED
@@ -281,7 +281,7 @@ module RegApi2
|
|
281
281
|
# @return [Hash(service_id, dname)]
|
282
282
|
# @note Accessibility: clients
|
283
283
|
# @note Support of service lists: no
|
284
|
-
|
284
|
+
# @example Resend mail.
|
285
285
|
# RegApi2.service.resend_mail servtype: :srv_ssl_certificate
|
286
286
|
define :resend_mail
|
287
287
|
|
data/lib/reg_api2/sym_hash.rb
CHANGED
data/lib/reg_api2/version.rb
CHANGED
data/lib/reg_api2.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
require "reg_api2/version"
|
3
3
|
|
4
|
+
require 'reg_api2/net_error'
|
5
|
+
require 'reg_api2/contract_error'
|
6
|
+
require 'reg_api2/api_error'
|
7
|
+
|
4
8
|
require "reg_api2/request_contract"
|
5
9
|
require "reg_api2/result_contract"
|
6
10
|
|
@@ -14,6 +18,7 @@ require 'reg_api2/service'
|
|
14
18
|
require 'reg_api2/bill'
|
15
19
|
require 'reg_api2/folder'
|
16
20
|
require 'reg_api2/zone'
|
21
|
+
require 'reg_api2/hosting'
|
17
22
|
|
18
23
|
# Provides r/w settings for API connection:
|
19
24
|
#
|
@@ -32,6 +37,7 @@ require 'reg_api2/zone'
|
|
32
37
|
# * {RegApi2.bill} API category implemented as {RegApi2::Bill} methods.
|
33
38
|
# * {RegApi2.folder} API category implemented as {RegApi2::Folder} methods.
|
34
39
|
# * {RegApi2.zone} API category implemented as {RegApi2::Zone} methods.
|
40
|
+
# * {RegApi2.hosting} API category implemented as {RegApi2::Hosting} methods.
|
35
41
|
#
|
36
42
|
# Provides dump hooks:
|
37
43
|
#
|
@@ -96,4 +102,33 @@ module RegApi2
|
|
96
102
|
def zone; RegApi2::Zone; end
|
97
103
|
module_function :zone
|
98
104
|
|
105
|
+
# Shortcut for {RegApi2::Hosting} methods.
|
106
|
+
# @return [Module] {RegApi2::Hosting}
|
107
|
+
# @api Shortcuts
|
108
|
+
def hosting; RegApi2::Hosting; end
|
109
|
+
module_function :hosting
|
110
|
+
|
111
|
+
class << self
|
112
|
+
# @!attribute [rw] username
|
113
|
+
# @return [String] User name (`test` by default).
|
114
|
+
attr_accessor :username
|
115
|
+
# @!attribute [rw] password
|
116
|
+
# @return [String] Password (`test` by default).
|
117
|
+
attr_accessor :password
|
118
|
+
# @!attribute [rw] io_encoding
|
119
|
+
# @return [String] IO encoding (`utf-8` by default).
|
120
|
+
attr_accessor :io_encoding
|
121
|
+
# @!attribute [rw] lang
|
122
|
+
# @return [String] Language (`en` by default).
|
123
|
+
attr_accessor :lang
|
124
|
+
# @!attribute [rw] ca_cert_path
|
125
|
+
# @return [String] Path to certification authority certificate (nil by default).
|
126
|
+
attr_accessor :ca_cert_path
|
127
|
+
# @!attribute [rw] pem
|
128
|
+
# @return [String] X.509 certificate (nil by default).
|
129
|
+
attr_accessor :pem
|
130
|
+
# @!attribute [rw] pem_password
|
131
|
+
# @return [String] X.509 certificate password (nil by default).
|
132
|
+
attr_accessor :pem_password
|
133
|
+
end
|
99
134
|
end
|
data/spec/blueprints/user.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
describe RegApi2::Hosting do
|
4
|
+
|
5
|
+
include RegApi2
|
6
|
+
|
7
|
+
describe :nop do
|
8
|
+
it "should return nil" do
|
9
|
+
hosting.nop.should be_nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe :get_jelastic_refill_url do
|
14
|
+
it "should return nil" do
|
15
|
+
hosting.get_jelastic_refill_url.should == "https://test1.ru"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe :set_jelastic_refill_url do
|
20
|
+
it "should return nil" do
|
21
|
+
hosting.set_jelastic_refill_url(url: "http://ya.ru/").should be_nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reg.api2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yajl-ruby
|
@@ -206,16 +206,21 @@ files:
|
|
206
206
|
- Rakefile
|
207
207
|
- bin/regapi2console
|
208
208
|
- lib/reg_api2.rb
|
209
|
+
- lib/reg_api2/action.rb
|
210
|
+
- lib/reg_api2/api_error.rb
|
209
211
|
- lib/reg_api2/bill.rb
|
210
212
|
- lib/reg_api2/builder.rb
|
211
213
|
- lib/reg_api2/common.rb
|
212
214
|
- lib/reg_api2/console.rb
|
213
215
|
- lib/reg_api2/console_helpers.rb
|
216
|
+
- lib/reg_api2/contract_error.rb
|
214
217
|
- lib/reg_api2/domain.rb
|
215
218
|
- lib/reg_api2/entity/entity_base.rb
|
216
219
|
- lib/reg_api2/entity/user.rb
|
217
220
|
- lib/reg_api2/folder.rb
|
221
|
+
- lib/reg_api2/hosting.rb
|
218
222
|
- lib/reg_api2/impl.rb
|
223
|
+
- lib/reg_api2/net_error.rb
|
219
224
|
- lib/reg_api2/request_contract.rb
|
220
225
|
- lib/reg_api2/result_contract.rb
|
221
226
|
- lib/reg_api2/service.rb
|
@@ -230,6 +235,7 @@ files:
|
|
230
235
|
- spec/lib/reg_api2/domain_spec.rb
|
231
236
|
- spec/lib/reg_api2/entity/entity_base_spec.rb
|
232
237
|
- spec/lib/reg_api2/folder_spec.rb
|
238
|
+
- spec/lib/reg_api2/hosting_spec.rb
|
233
239
|
- spec/lib/reg_api2/impl_spec.rb
|
234
240
|
- spec/lib/reg_api2/request_contract_spec.rb
|
235
241
|
- spec/lib/reg_api2/result_contract_spec.rb
|
@@ -253,7 +259,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
253
259
|
version: '0'
|
254
260
|
segments:
|
255
261
|
- 0
|
256
|
-
hash:
|
262
|
+
hash: -789251017170447539
|
257
263
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
264
|
none: false
|
259
265
|
requirements:
|
@@ -262,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
262
268
|
version: '0'
|
263
269
|
segments:
|
264
270
|
- 0
|
265
|
-
hash:
|
271
|
+
hash: -789251017170447539
|
266
272
|
requirements: []
|
267
273
|
rubyforge_project:
|
268
274
|
rubygems_version: 1.8.24
|
@@ -276,6 +282,7 @@ test_files:
|
|
276
282
|
- spec/lib/reg_api2/domain_spec.rb
|
277
283
|
- spec/lib/reg_api2/entity/entity_base_spec.rb
|
278
284
|
- spec/lib/reg_api2/folder_spec.rb
|
285
|
+
- spec/lib/reg_api2/hosting_spec.rb
|
279
286
|
- spec/lib/reg_api2/impl_spec.rb
|
280
287
|
- spec/lib/reg_api2/request_contract_spec.rb
|
281
288
|
- spec/lib/reg_api2/result_contract_spec.rb
|