reg.api2 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -45,6 +45,22 @@ RegApi2.service.nop(services: [
45
45
  ])
46
46
  ```
47
47
 
48
+ or with including of {RegApi2} module:
49
+
50
+ ```ruby
51
+ require "reg_api2"
52
+
53
+ include RegApi2
54
+
55
+ service.nop(services: [
56
+ { dname: "test.ru" },
57
+ { dname: "test.su", servtype: "srv_hosting_ispmgr" },
58
+ { service_id: 111111 },
59
+ { service_id: "22bug22" },
60
+ { surprise: "surprise.ru" }
61
+ ])
62
+ ```
63
+
48
64
  Other examples available as examples of concrete method calls.
49
65
 
50
66
  ### Console
@@ -63,7 +79,7 @@ Your default username: "test", and You can change it with "~/.regapi2".
63
79
  Console use test/test credentials by default, but you can assign new ones
64
80
  before any operations over REG.API through {RegApi2} properties.
65
81
 
66
- Also console reads `~/.regapi2` configuration file if exists, to assign properties from. It knows about these properties in configuration file: `username`, `password`, `lang`, `pem`, `pem_password` and `ca_cert_path`.
82
+ Also console reads `~/.regapi2` configuration file if exists, to assign properties from. It knows about these properties in configuration file: `username`, `password`, `lang`, `pem`, `pem_password` and `ca_cert_path`. Properties should be written in `key=value` format separated by newline.
67
83
 
68
84
  ## Recommendations for effective use of REG.API
69
85
 
@@ -11,9 +11,17 @@ def try_lo_load_defaults
11
11
  if File.readable?(filename)
12
12
  IO.read(filename).split("\n").each do |line|
13
13
  line.strip!
14
- props.each do |prop|
15
- RegApi2.send("#{prop}=", $1) if line =~ /\A\s*#{Regexp.escape(prop)}\s*\=(.+)\s*\z/;
14
+ next if line =~ /\A\s*#/ # skip comments
15
+ if line !~ /\A\s*(\w+)\s*\=(.+)\s*\z/
16
+ $stderr.puts "#{filename}: We expect key=value string but got \"#{line}\""
17
+ exit 1
16
18
  end
19
+ name, value = $1, $2
20
+ unless props.include?(name)
21
+ $stderr.puts "#{filename}: Unknown name: \"#{name}\", we know only #{props.join(', ')}"
22
+ exit 1
23
+ end
24
+ RegApi2.send("#{name}=", value)
17
25
  end
18
26
  end
19
27
 
@@ -17,6 +17,12 @@ module RegApi2
17
17
  renew_domains_get_ctrl_cnt
18
18
  undelegated_domains_cnt
19
19
  bill_id
20
+ service_id
21
+ server_id
22
+ cpu_count
23
+ cpu_core
24
+ hdd_count
25
+ ram_count
20
26
  ].freeze
21
27
 
22
28
  # Fields that will be converted to {Float}.
@@ -26,6 +32,8 @@ module RegApi2
26
32
  total_amount
27
33
  payment
28
34
  total_payment
35
+ month_traf
36
+ price_retail
29
37
  ].freeze
30
38
 
31
39
  # Fields that will be converted to {Boolean}.
@@ -10,8 +10,10 @@ module RegApi2
10
10
  # @!method nop(opts = {})
11
11
  # Return list of specified services with its stats if specified.
12
12
  # @param opts Options.
13
- # @option opts [Array] services
14
- # @return [Hash("services" => [])]
13
+ # @option opts [Array<Hash>] services List of services to be retrieved.
14
+ # @return [Array<Hash>] List of specified services with its stats.
15
+ # @note Accessibility: clients
16
+ # @note Support of service lists: yes
15
17
  # @example List of services by specified identifiers
16
18
  # RegApi2.service.nop(services: [
17
19
  # { dname:"test.ru" },
@@ -20,7 +22,7 @@ module RegApi2
20
22
  # { service_id: "22bug22" },
21
23
  # { surprise: "surprise.ru" }
22
24
  # ])
23
- define :nop
25
+ define :nop, field: :services
24
26
 
25
27
  # @!method get_prices(opts = {})
26
28
  # Get services registration/renewal prices.
@@ -28,6 +30,8 @@ module RegApi2
28
30
  # @option opts [Boolean] :show_renew_data With this flag enabled the system will return the price of renewal (1/0). Optional field.
29
31
  # @option opts [String, Symbol] :currency Identifier of the currency in which the prices will be quoted: rur (default), uah, usd, eur. Optional field.
30
32
  # @return [Hash(currency, price_group, show_renew_data, prices)] Prices.
33
+ # @note Accessibility: everyone
34
+ # @note Support of service lists: no
31
35
  # @example Get prices.
32
36
  # RegApi2.service.get_prices
33
37
  define :get_prices
@@ -40,6 +44,7 @@ module RegApi2
40
44
  # @option opts [String, Symbol] :subtype Service subtype.
41
45
  # @option opts [Boolean] :unroll_prices Show prices in expanded form.
42
46
  # @return [Array(Hash(commonname, ...))] Service type details.
47
+ # @note Accessibility: everyone
43
48
  # @example Get service type details.
44
49
  # RegApi2.service.get_servtype_details servtype: :srv_hosting_ispmgr
45
50
  define :get_servtype_details
@@ -47,44 +52,43 @@ module RegApi2
47
52
 
48
53
  # @!method create(opts = {})
49
54
  # Use the function to order new services.
50
- # `servtype` values are supported:
51
- #
52
- # | servtype | service type |
53
- # | ---------|--------------|
54
- # | srv_webfwd | web forwarding |
55
- # | srv_parking | domain parking |
56
- # | srv_dns_both | DNS support |
57
- # | srv_hosting_ispmgr | ISPManager hosting |
58
- # | srv_hosting_cpanel | CPanel hosting |
59
- # | srv_hosting_plesk | PLesk hosting |
60
- # | srv_ssl_certificate | SSL certificate |
61
- # | srv_certificate | Domain certificate |
62
- # | srv_voucher | Domain voucher |
63
- # | srv_vps | VPS server |
64
- # | srv_license_isp | ISP Manager license |
65
- # | srv_addip | additional IP address |
66
- # | srv_disk_space | additional disk space |
67
- # | srv_antispam | advanced spam protection |
68
- # | srv_dedicated | dedicated server |
69
- # | srv_kvm | KVM access |
70
- #
71
- # Common payment options are allowed.
72
- # folder_name or folder_id are allowed.
73
55
  # @param opts Options.
74
56
  # @option opts [String] :domain_name Name of the domain, for which the service is ordered.
75
57
  # @option opts [String, Symbol] :servtype The type of the ordered service.
58
+ #
59
+ # | servtype | service type |
60
+ # | ---------|--------------|
61
+ # | srv_webfwd | web forwarding |
62
+ # | srv_parking | domain parking |
63
+ # | srv_dns_both | DNS support |
64
+ # | srv_hosting_ispmgr | ISPManager hosting |
65
+ # | srv_hosting_cpanel | CPanel hosting |
66
+ # | srv_hosting_plesk | PLesk hosting |
67
+ # | srv_ssl_certificate | SSL certificate |
68
+ # | srv_certificate | Domain certificate |
69
+ # | srv_voucher | Domain voucher |
70
+ # | srv_vps | VPS server |
71
+ # | srv_license_isp | ISP Manager license |
72
+ # | srv_addip | additional IP address |
73
+ # | srv_disk_space | additional disk space |
74
+ # | srv_antispam | advanced spam protection |
75
+ # | srv_dedicated | dedicated server |
76
+ # | srv_kvm | KVM access |
77
+ #
76
78
  # @option opts [Object] :period The period for which the service is ordered, the unit of measurement (year or month) depends on the type of the service being ordered. To learn about the measurement units used for each service, use the {#get_servtype_details} function.
77
79
  # @option opts [String] :user_servid Domain ID set by the user. Allowed symbols: digits (from 0 through 9), Latin letters (from a through f). Maximum length: 32 symbols. This ID cannot be generated automatically; if it is not defined upon service ordering, the field will be empty. Optional field.
78
- # @option opts :point_of_sale See common payment parameters in {file:README.md}.
79
- # @option opts :pay_type See common payment parameters in {file:README.md}.
80
- # @option opts :ok_if_no_money See common payment parameters in {file:README.md}.
81
- # @option opts :folder_name Defines the name of the folder, to which the services will be added (see the list of common folder identification parameters in {file:README.md}).
82
- # @option opts :folder_id Defines the name of the folder, to which the services will be added (see the list of common folder identification parameters in {file:README.md}).
80
+ # @option opts :point_of_sale See {file:README.md#Common_payment_options common payment parameters}.
81
+ # @option opts :pay_type See {file:README.md#Common_payment_options common payment parameters}.
82
+ # @option opts :ok_if_no_money See See {file:README.md#Common_payment_options common payment parameters}.
83
+ # @option opts :folder_name Defines the name of the folder, to which the services will be added (see {file:README.md#Folder_identification_parameters folder identification parameters}).
84
+ # @option opts :folder_id Defines the name of the folder, to which the services will be added (see {file:README.md#Folder_identification_parameters folder identification parameters}).
83
85
  # @option opts [Boolean] :no_new_folder Dont't create non-existing folder; otherwise create if not exists.
84
86
  # @option opts [String] :comment An arbitrary text describing the order. Optional field.
85
87
  # @option opts [String] :admin_comment A comment for administrators. An arbitrary text describing the order. Optional field.
86
88
  # TODO: specific options.
87
89
  # @return [Hash(descr, service_id, ...)] Information about ordered service.
90
+ # @note Accessibility: everyone
91
+ # @note Support of service lists: no
88
92
  # @see #get_servtype_details
89
93
  # @example Create srv_hosting_ispmgr service.
90
94
  # RegApi2.service.create dname: 'qqq.ru', servtype: :srv_hosting_ispmgr, period: 1, plan: 'Host-2-1209'
@@ -93,17 +97,62 @@ module RegApi2
93
97
  # @!method delete(opts = {})
94
98
  # Removes the service.
95
99
  # @param opts Options.
100
+ # @option opts [String, Symbol] :servtype Service type, which is to be removed. These values are supported:
101
+ #
102
+ # | servtype | service type |
103
+ # | ---------|--------------|
104
+ # | srv_hosting_ispmgr | ISPManager hosting |
105
+ # | srv_hosting_cpanel | CPanel hosting |
106
+ # | srv_hosting_plesk | PLesk hosting |
107
+ # | srv_addip | additional IP address |
108
+ # | srv_antispam | advanced spam protection |
109
+ # | srv_sitebuilder_plsk | SiteBuilder Plesk |
110
+ # | srv_vps | VPS server |
111
+ # | srv_license_isp | ISP Manager license |
112
+ # | srv_disk_space | additional disk space |
113
+ # | srv_dedicated | dedicated server |
114
+ # | srv_kvm | KVM access |
115
+ #
116
+ # @return [NilClass] nil
117
+ # @note Accessibility: clients
118
+ # @note Support of service lists: no
119
+ # @example Removing of `srv_hosting_ispmgr` service.
120
+ # RegApi2.service.delete domain_name: 'test.ru', servtype: :srv_hosting_ispmgr
96
121
  define :delete, required: %w[ servtype ]
97
122
 
98
123
  # @!method get_info(opts = {})
99
124
  # Use this function to obtain information about all services.
100
125
  # @param opts Options.
126
+ # @note Accessibility: clients
127
+ # @note Support of service lists: yes
101
128
  define :get_info
102
129
 
103
130
  # @!method get_list(opts = {})
104
131
  # Use this function to obtain a list of active services.
105
132
  # @param opts Options.
106
- define :get_list
133
+ # @option opts [String,Symbol] :servtype Type of service. If nothing is defined, information about all types of services will be returned.
134
+ #
135
+ # | Type | Description |
136
+ # |--------|-------------|
137
+ # |domain | Domain|
138
+ # |srv_webfwd | web forwarding|
139
+ # |srv_parking | domain parking|
140
+ # |srv_dns_both | DNS support|
141
+ # |srv_hosting_ispmgr | ISPManager hosting|
142
+ # |srv_hosting_cpanel | CPanel hosting|
143
+ # |srv_hosting_plesk | Plesk hosting|
144
+ # |srv_antispam | Extended spam protection|
145
+ # |srv_vps | VPS server|
146
+ # |srv_addip | Additional IP address|
147
+ # |srv_license_isp | ISPManager license|
148
+ # |srv_certificate | Domain certificate|
149
+ # |srv_voucher | Domain voucher |
150
+ #
151
+ # @return [Array<Hash>] List of service of specified `servtype`.
152
+ # @note Accessibility: clients
153
+ # @example Get list of domains.
154
+ # RegApi2.service.get_list servtype: :domain
155
+ define :get_list, field: :services
107
156
 
108
157
  # @!method get_folders(opts = {})
109
158
  # Use this function to get the list of folders the service is associated with.
@@ -124,7 +173,28 @@ module RegApi2
124
173
  # @!method get_dedicated_server_list(opts = {})
125
174
  # Get the dedicated server list.
126
175
  # @param opts Options.
127
- define :get_dedicated_server_list
176
+ # @return [Array<Hash>] List of dedicated servers. Each item of {RegApi2::SymHash} class contain these fields:
177
+ #
178
+ # | Field | Description |
179
+ # |-------|-------------|
180
+ # | server_id | Unique server id
181
+ # | cpu_content | Processor model
182
+ # | cpu_count | Processor count
183
+ # | cpu_core | Core count
184
+ # | ram_content | RAM type
185
+ # | ram_count | RAM count
186
+ # | ram_size | RAM size
187
+ # | hdd_content | HDD interface type
188
+ # | hdd_count | HDD count
189
+ # | hdd_size | HDD disk size
190
+ # | month_traf | Traffic, GB per month
191
+ # | price_retail | Rent per month
192
+ #
193
+ # @note Accessibility: clients
194
+ # @note Support of service lists: no
195
+ # @example Get list of dedicated servers
196
+ # RegApi2.service.get_dedicated_server_list
197
+ define :get_dedicated_server_list, field: :server_list
128
198
 
129
199
  # @!method update(opts = {})
130
200
  # Service configuration.
@@ -139,6 +209,17 @@ module RegApi2
139
209
  # @!method get_bills(opts = {})
140
210
  # Use this function to get a list of invoices associated with the defined services.
141
211
  # @param opts Options.
212
+ # @return [Hash] List of invoices associated with the defined services.
213
+ #
214
+ # | Field | Description |
215
+ # | ----- | ----------- |
216
+ # | services | A list of requested services. |
217
+ # | bills | A list of IDs of invoices associated with this service. |
218
+ #
219
+ # @note Accessibility: partners
220
+ # @note Support of service lists: yes
221
+ # @example Get invoices and services for `qqq.ru` domain.
222
+ # RegApi2.service.get_bills dname: "qqq.ru"
142
223
  define :get_bills
143
224
 
144
225
  # @!method set_autorenew_flag(opts = {})
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module RegApi2
3
3
  # Gem version.
4
- VERSION = "0.0.7".freeze
4
+ VERSION = "0.0.8".freeze
5
5
  end
data/lib/reg_api2.rb CHANGED
@@ -15,18 +15,6 @@ require 'reg_api2/bill'
15
15
  require 'reg_api2/folder'
16
16
  require 'reg_api2/zone'
17
17
 
18
- # # REG.API v2
19
- # @example List of services by specified identifiers
20
- # RegApi2.service.nop(services: [
21
- # { dname:"test.ru" },
22
- # { dname: "test.su", servtype: "srv_hosting_ispmgr" },
23
- # { service_id: 111111 },
24
- # { service_id: "22bug22" },
25
- # { surprise: "surprise.ru" }
26
- # ])
27
- #
28
- # ## RegApi2 module
29
- #
30
18
  # Provides r/w settings for API connection:
31
19
  #
32
20
  # * {RegApi2.username} - Your user name. `test` by default.
@@ -46,6 +34,16 @@ require 'reg_api2/zone'
46
34
  # * {RegApi2.zone} API category implemented as {RegApi2::Zone} methods.
47
35
  #
48
36
  # Please read {file:README.md} for API overview.
37
+ #
38
+ # @example List of services by specified identifiers
39
+ # RegApi2.service.nop(services: [
40
+ # { dname:"test.ru" },
41
+ # { dname: "test.su", servtype: "srv_hosting_ispmgr" },
42
+ # { service_id: 111111 },
43
+ # { service_id: "22bug22" },
44
+ # { surprise: "surprise.ru" }
45
+ # ])
46
+ #
49
47
 
50
48
  module RegApi2
51
49
 
@@ -12,7 +12,7 @@ describe RegApi2::Service do
12
12
  { service_id: "22bug22" },
13
13
  { surprise: "surprise.ru" }
14
14
  ])
15
- ans.services.map do |rec|
15
+ ans.map do |rec|
16
16
  rec.result == 'success' ? rec.dname : rec.error_code
17
17
  end.sort.should == %w[ INVALID_SERVICE_ID NO_DOMAIN test.ru test.su test12347.ru ]
18
18
  end
@@ -38,4 +38,36 @@ describe RegApi2::Service do
38
38
  ans.descr.should =~ /srv_hosting_ispmgr.+ordered/
39
39
  end
40
40
  end
41
+
42
+ describe :delete do
43
+ it "should remove srv_hosting_ispmgr service" do
44
+ ans = service.delete domain_name: 'test.ru', servtype: :srv_hosting_ispmgr
45
+ ans.should be_nil
46
+ end
47
+ end
48
+
49
+ describe :get_list do
50
+ it "should get list of domains" do
51
+ ans = service.get_list servtype: :domain
52
+ ans.should be_kind_of Array
53
+ ans.map(&:servtype).uniq.should == [ "domain"]
54
+ ans.map(&:service_id).each { |id| id.should be_kind_of Fixnum }
55
+ end
56
+ end
57
+
58
+ describe :get_dedicated_server_list do
59
+ it "should get list of dedicated servers" do
60
+ ans = RegApi2.service.get_dedicated_server_list
61
+ ans.should be_kind_of Array
62
+ ans.map(&:server_id).each { |id| id.should be_kind_of Fixnum }
63
+ end
64
+ end
65
+
66
+ describe :get_bills do
67
+ it "should get list of services and bills" do
68
+ ans = RegApi2.service.get_bills dname: "qqq.ru"
69
+ ans.services.should be_kind_of Array
70
+ ans.bills.should be_nil
71
+ end
72
+ end
41
73
  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.7
4
+ version: 0.0.8
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-10-06 00:00:00.000000000 Z
12
+ date: 2013-10-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yajl-ruby
@@ -252,7 +252,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
252
252
  version: '0'
253
253
  segments:
254
254
  - 0
255
- hash: -3548838866357939780
255
+ hash: 1698904277702567800
256
256
  required_rubygems_version: !ruby/object:Gem::Requirement
257
257
  none: false
258
258
  requirements:
@@ -261,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
261
  version: '0'
262
262
  segments:
263
263
  - 0
264
- hash: -3548838866357939780
264
+ hash: 1698904277702567800
265
265
  requirements: []
266
266
  rubyforge_project:
267
267
  rubygems_version: 1.8.24