idcf-dns 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b861ba7b2191302c0ed3274701013ee502adf511
4
- data.tar.gz: c28eb0197d213f6f3d68cabf592c385093800949
3
+ metadata.gz: 09205c0f89224e460fd1dccf2768a051bdd824fb
4
+ data.tar.gz: 32ca6b5153e6a497f04b7c758359dcb03e998d53
5
5
  SHA512:
6
- metadata.gz: 5268d175b7674ccfc191b2c443a5415f04469710912c96324aa54b488cb6a230e2b5a928f5bddea479a2de5b2e308f5736050a55344739ab06d747705af8e553
7
- data.tar.gz: d6da59613a8567de2e9c65569f4348424a32ac8ad1e5b6159c13ff99fdf38bf01886e19a0ffb7845d8a58030384f243d6c9f8f75d20c01fb544d86610c281c24
6
+ metadata.gz: 475670a05e091e75b3345c89343a1ab7857d88df8f0e5246b7d58f71ef884abdfea2e01fb25ed27903371f7eba63dff3128d1a597b62a9bf3f8f4b664d074be9
7
+ data.tar.gz: 2f5066946cf9f0551d88e4af1acf9537762e3074f8451c752536f4bd7ae04e3d9252aed396337bd2a36c5dffef1c1beb195d7e1d93f02cbfef3a23ceabb80a94
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  /.env
11
+ /.idea/
@@ -0,0 +1,91 @@
1
+ AllCops:
2
+ Exclude:
3
+ - "Gemfile"
4
+ - "*.gemspec"
5
+ DisplayCopNames: true
6
+
7
+ Documentation:
8
+ Enabled: false
9
+
10
+ Lint/AssignmentInCondition:
11
+ Enabled: false
12
+
13
+ Lint/HandleExceptions:
14
+ Enabled: false
15
+
16
+ Lint/UnderscorePrefixedVariableName:
17
+ Enabled: false
18
+
19
+ Lint/UnusedBlockArgument:
20
+ Enabled: false
21
+
22
+ Lint/UnusedMethodArgument:
23
+ Enabled: false
24
+
25
+ Metrics/AbcSize:
26
+ Max: 20
27
+
28
+ Metrics/CyclomaticComplexity:
29
+ Max: 6
30
+
31
+ Metrics/LineLength:
32
+ Max: 100
33
+
34
+ Metrics/MethodLength:
35
+ Max: 20
36
+
37
+ Metrics/PerceivedComplexity:
38
+ Max: 7
39
+
40
+ Style/AccessorMethodName:
41
+ Enabled: false
42
+
43
+ Style/AsciiComments:
44
+ Enabled: false
45
+
46
+ Style/Documentation:
47
+ Enabled: false
48
+
49
+ Style/DoubleNegation:
50
+ Enabled: false
51
+
52
+ Style/FormatString:
53
+ EnforcedStyle: percent
54
+
55
+ Style/GuardClause:
56
+ MinBodyLength: 4
57
+
58
+ Style/IfUnlessModifier:
59
+ Enabled: false
60
+
61
+ Style/MultilineBlockChain:
62
+ Enabled: false
63
+
64
+ Style/NumericLiterals:
65
+ MinDigits: 7
66
+
67
+ Style/PredicateName:
68
+ NamePrefixBlacklist:
69
+ - "is_"
70
+ - "have_"
71
+
72
+ Style/SignalException:
73
+ EnforcedStyle: only_raise
74
+
75
+ Style/SingleLineBlockParams:
76
+ Enabled: false
77
+
78
+ Style/SpaceAroundOperators:
79
+ MultiSpaceAllowedForOperators:
80
+ - "="
81
+ - "=>"
82
+ - "||="
83
+
84
+ Style/SpaceBeforeComma:
85
+ Enabled: false
86
+
87
+ Style/StringLiterals:
88
+ EnforcedStyle: double_quotes
89
+
90
+ Style/TrailingComma:
91
+ Enabled: false
@@ -1,4 +1,12 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1
4
- - 2.2
3
+ - 2.1
4
+ - 2.2
5
+ notifications:
6
+ slack:
7
+ secure: SLkfrjKn4L1J3sghg53QtvP9InoEvIgDpqsFBypxOH99EcI5XbonfBR/40Os66IFRzaLbGeSYY3/0ZEZiYnE7eEWr+q33uXomjGMSBSPdXKJ9GWFR1qou7vqu+K2TY6gzGK2VGpkp9YMRBrCDjxDgVilVAblH1N9Ba8DAAxggkaogm46UTkiy/37/uVSdvcqvLil6Stw/8jFR60ulJpC4hrIQzwqOQTWJNq6Czl3p4bWex+igNnQePZP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tNGUUmNUzDr1F2C71txQ3vc1OaifB0E0PBNiwG6nhh2QKPJhG7KlqUN5mspyfZDp93N+VvnqPIbxvpVIIDcQR6e6Mug1Wm0fvtcB6weNAbp3sNqMH8NUXSGZdZHrWsQPKSEUp7iKiTqSY5kLbLpxqI6dNfcDoJ7J36ExmIPkj7rlgfCllFBGFOEeR33ydTjUDDWWoDmB8NBV0Pf8RiTq9AcBE3r7nHcSDFYEzX0MOCLikqujLOd5uuQp4Us8HQOyMtIrQEMqlHpAfNu0Uu2Sdd04zo5ndgDx2eTEwZYRCqzDllBvNWzk/Wgbd1qW9xh67vKsD9Ixo/t8kS8ge15naaO392i+UrRTcXwQwOiLHaUDXY4R9DD2NKkZtIysS8=
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Idcf::Dns
2
2
  [![Gem Version](https://badge.fury.io/rb/idcf-dns.svg)](http://badge.fury.io/rb/idcf-dns)
3
- [![Build Status](https://travis-ci.org/idcf/idcf-dns-ruby.svg)](https://travis-ci.org/idcf/idcf-dns-ruby)
3
+ [![Build Status](https://travis-ci.org/idcf/idcf-dns-ruby.svg?branch=master)](https://travis-ci.org/idcf/idcf-dns-ruby)
4
4
  [![Code Climate](https://codeclimate.com/github/idcf/idcf-dns-ruby/badges/gpa.svg)](https://codeclimate.com/github/idcf/idcf-dns-ruby)
5
5
  [![Test Coverage](https://codeclimate.com/github/idcf/idcf-dns-ruby/badges/coverage.svg)](https://codeclimate.com/github/idcf/idcf-dns-ruby/coverage)
6
6
 
@@ -49,7 +49,7 @@ response[0] #=> zone1
49
49
  ```
50
50
 
51
51
  #### Zones
52
- ##### Create new zone
52
+ ##### Create a new zone
53
53
  ```ruby
54
54
  response =
55
55
  client.create_zone(
@@ -74,18 +74,18 @@ zone["name"] #=> "foobar.example.com"
74
74
  zone["records"].size #=> 3
75
75
  ```
76
76
 
77
- ##### Update zone
77
+ ##### Update a zone
78
78
  ```ruby
79
79
  client.update_zone(zone_uuid, description: "Updated")
80
80
  ```
81
81
 
82
- ##### Delete zone
82
+ ##### Delete a zone
83
83
  ```ruby
84
84
  client.delete_zone(zone_uuid)
85
85
  ```
86
86
 
87
87
  #### Records
88
- ##### Create new record
88
+ ##### Create a new record
89
89
  ```ruby
90
90
  response =
91
91
  client.create_record(
@@ -110,18 +110,18 @@ record = client.get_record(zone_uuid, record_uuid).body
110
110
  record["name"] #=> "baz.foobar.example.com"
111
111
  ```
112
112
 
113
- ##### Update record
113
+ ##### Update a record
114
114
  ```ruby
115
115
  client.update_record(zone_uuid, record_uuid, content: "210.140.158.1")
116
116
  ```
117
117
 
118
- ##### Delete record
118
+ ##### Delete a record
119
119
  ```ruby
120
120
  client.delete_record(zone_uuid, record_uuid)
121
121
  ```
122
122
 
123
123
  ### Advanced usage
124
- #### Custom expiration of requests
124
+ #### Custom expiration of requests
125
125
  In default, requests will expire in 600 seconds.
126
126
  You can use custom expirations for each request.
127
127
 
data/Rakefile CHANGED
@@ -1,5 +1,13 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require "rubocop/rake_task"
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
5
- task default: :spec
6
+ task default: [:rubocop, :spec]
7
+
8
+ desc "Run RuboCop on the lib directory"
9
+ RuboCop::RakeTask.new(:rubocop) do |task|
10
+ task.patterns = ["lib/**/*.rb", "spec/**/*.rb"]
11
+ task.formatters = ["files"]
12
+ task.fail_on_error = true
13
+ end
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "dotenv"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "rubocop"
25
26
  spec.add_development_dependency "simplecov"
26
27
 
27
28
  spec.add_dependency "activesupport", "~> 4.2.3"
@@ -127,7 +127,7 @@ module Idcf
127
127
  def send!(method, resource, parameters = {}, headers = {})
128
128
  response = send(method, resource, parameters, headers)
129
129
  unless response.success?
130
- fail(
130
+ raise(
131
131
  ApiError,
132
132
  "HTTP status code: #{response.status}, " \
133
133
  "Error message: #{response.message}, " \
@@ -15,6 +15,27 @@ module Idcf
15
15
  # @option attributes [Integer] :priority priority of record
16
16
  # @param headers [Hash] HTTP request headers
17
17
  # @return [Response] HTTP response object
18
+ # @example
19
+ # response =
20
+ # client.create_record(
21
+ # "ddcd8dbf-8d99-4f49-9958-7dd9a0bfb67f",
22
+ # name: "www.foobar.example.com",
23
+ # type: "A",
24
+ # content: "8.8.8.8",
25
+ # ttl: 3600
26
+ # )
27
+ #
28
+ # response.body #=>
29
+ # {"uuid"=>"40d5f26f-02bd-4fb1-b363-323675772289",
30
+ # "name"=>"www.foobar.example.com",
31
+ # "type"=>"A",
32
+ # "content"=>"8.8.8.8",
33
+ # "ttl"=>3600,
34
+ # "created_at"=>"2015-11-09T11:43:50+09:00",
35
+ # "updated_at"=>nil,
36
+ # "priority"=>nil}
37
+ #
38
+ # response.uuid #=> "40d5f26f-02bd-4fb1-b363-323675772289"
18
39
  def create_record(zone_uuid, attributes, headers = {})
19
40
  Validators::Record.validate_attributes!(attributes, :create)
20
41
  post!("zones/#{zone_uuid}/records", attributes, headers)
@@ -26,6 +47,16 @@ module Idcf
26
47
  # @param uuid [String] UUID of record
27
48
  # @param headers [Hash] HTTP request headers
28
49
  # @return [Response] HTTP response object
50
+ # @example
51
+ # response =
52
+ # client.delete_record(
53
+ # "ddcd8dbf-8d99-4f49-9958-7dd9a0bfb67f",
54
+ # "d612aabb-3fea-471a-8712-586f1ac9c29c"
55
+ # )
56
+ #
57
+ # response.body #=> {}
58
+ #
59
+ # response.status #=> 200
29
60
  def delete_record(zone_uuid, uuid, headers = {})
30
61
  delete!("zones/#{zone_uuid}/records/#{uuid}", {}, headers)
31
62
  end
@@ -36,6 +67,22 @@ module Idcf
36
67
  # @param uuid [String] UUID of record
37
68
  # @param headers [Hash] HTTP request headers
38
69
  # @return [Response] HTTP response object
70
+ # @example
71
+ # response =
72
+ # client.get_record(
73
+ # "ddcd8dbf-8d99-4f49-9958-7dd9a0bfb67f",
74
+ # "d612aabb-3fea-471a-8712-586f1ac9c29c"
75
+ # )
76
+ #
77
+ # response.body #=>
78
+ # {"uuid"=>"ecacc77f-e678-4f29-b6dd-6bec79c172a1",
79
+ # "name"=>"www.foobar.example.com",
80
+ # "type"=>"A",
81
+ # "content"=>"8.8.8.8",
82
+ # "ttl"=>3600,
83
+ # "created_at"=>"2015-11-09T16:07:21+09:00",
84
+ # "updated_at"=>nil,
85
+ # "priority"=>nil}
39
86
  def get_record(zone_uuid, uuid, headers = {})
40
87
  get!("zones/#{zone_uuid}/records/#{uuid}", {}, headers)
41
88
  end
@@ -44,6 +91,58 @@ module Idcf
44
91
  #
45
92
  # @param zone_uuid [String] UUID of zone
46
93
  # @return [Response] HTTP response object
94
+ # @example
95
+ # response =
96
+ # client.list_records("ddcd8dbf-8d99-4f49-9958-7dd9a0bfb67f")
97
+ #
98
+ # response.body #=>
99
+ # [{"uuid"=>"9fae4a12-319c-4afc-ac33-4542ef79dd0b",
100
+ # "name"=>"foobar.example.com",
101
+ # "type"=>"SOA",
102
+ # "content"=>
103
+ # {"dns"=>"ns01.idcfcloud.com",
104
+ # "email"=>"foobar.example.com.",
105
+ # "serial"=>4,
106
+ # "refresh"=>10800,
107
+ # "retry"=>3600,
108
+ # "expire"=>604800,
109
+ # "ttl"=>3600},
110
+ # "ttl"=>3600,
111
+ # "created_at"=>"2015-11-09T13:24:58+09:00",
112
+ # "updated_at"=>"2015-11-09T16:07:21+09:00",
113
+ # "priority"=>nil},
114
+ # {"uuid"=>"f61a75b7-8e9c-4e69-a91a-6e6aa90c2990",
115
+ # "name"=>"foobar.example.com",
116
+ # "type"=>"NS",
117
+ # "content"=>"ns01.idcfcloud.com",
118
+ # "ttl"=>3600,
119
+ # "created_at"=>"2015-11-09T13:24:58+09:00",
120
+ # "updated_at"=>nil,
121
+ # "priority"=>nil},
122
+ # {"uuid"=>"0195fe5d-7cff-4f94-8886-a13bb0f609b4",
123
+ # "name"=>"foobar.example.com",
124
+ # "type"=>"NS",
125
+ # "content"=>"ns02.idcfcloud.com",
126
+ # "ttl"=>3600,
127
+ # "created_at"=>"2015-11-09T13:24:58+09:00",
128
+ # "updated_at"=>nil,
129
+ # "priority"=>nil},
130
+ # {"uuid"=>"0bdc7d49-b1aa-4455-903f-35dc3c4338be",
131
+ # "name"=>"foobar.example.com",
132
+ # "type"=>"NS",
133
+ # "content"=>"ns03.idcfcloud.com",
134
+ # "ttl"=>3600,
135
+ # "created_at"=>"2015-11-09T13:24:58+09:00",
136
+ # "updated_at"=>nil,
137
+ # "priority"=>nil},
138
+ # {"uuid"=>"ecacc77f-e678-4f29-b6dd-6bec79c172a1",
139
+ # "name"=>"www.foobar.example.com",
140
+ # "type"=>"A",
141
+ # "content"=>"8.8.8.8",
142
+ # "ttl"=>3600,
143
+ # "created_at"=>"2015-11-09T16:07:21+09:00",
144
+ # "updated_at"=>nil,
145
+ # "priority"=>nil}]
47
146
  def list_records(zone_uuid, headers = {})
48
147
  get!("zones/#{zone_uuid}/records", {}, headers)
49
148
  end
@@ -61,6 +160,23 @@ module Idcf
61
160
  # @option attributes [Integer] :priority priority of record
62
161
  # @param headers [Hash] HTTP request headers
63
162
  # @return [Response] HTTP response object
163
+ # @example
164
+ # response =
165
+ # client.update_record(
166
+ # "ddcd8dbf-8d99-4f49-9958-7dd9a0bfb67f",
167
+ # "d612aabb-3fea-471a-8712-586f1ac9c29c",
168
+ # content: "6.6.6.6"
169
+ # )
170
+ #
171
+ # response.body #=>
172
+ # {"uuid"=>"ecacc77f-e678-4f29-b6dd-6bec79c172a1",
173
+ # "name"=>"www.foobar.example.com",
174
+ # "type"=>"A",
175
+ # "content"=>"6.6.6.6",
176
+ # "ttl"=>3600,
177
+ # "created_at"=>"2015-11-09T16:07:21+09:00",
178
+ # "updated_at"=>"2015-11-09T16:22:17+09:00",
179
+ # "priority"=>nil}
64
180
  def update_record(zone_uuid, uuid, attributes, headers = {})
65
181
  Validators::Record.validate_attributes!(attributes, :update)
66
182
  put!("zones/#{zone_uuid}/records/#{uuid}", attributes, headers)
@@ -12,6 +12,65 @@ module Idcf
12
12
  # @option attributes [Integer] :default_ttl default TTL (required)
13
13
  # @param headers [Hash] HTTP request headers
14
14
  # @return [Response] HTTP response object
15
+ # @example
16
+ # response =
17
+ # client.create_zone(
18
+ # name: "foobar.example.com",
19
+ # email: "foobar@example.com",
20
+ # description: "",
21
+ # default_ttl: 600
22
+ # )
23
+ #
24
+ # response.body #=>
25
+ # {"uuid"=>"384178f5-58a5-4f3c-9607-5e189ab2990d",
26
+ # "name"=>"foobar.example.com",
27
+ # "default_ttl"=>600,
28
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
29
+ # "updated_at"=>nil,
30
+ # "records"=>
31
+ # [{"uuid"=>"6aba1170-83b9-4324-b331-8c2b8dcb5162",
32
+ # "name"=>"foobar.example.com",
33
+ # "type"=>"SOA",
34
+ # "content"=>
35
+ # {"dns"=>"ns01.idcfcloud.com",
36
+ # "email"=>"foobar.example.com.",
37
+ # "serial"=>1,
38
+ # "refresh"=>10800,
39
+ # "retry"=>3600,
40
+ # "expire"=>604800,
41
+ # "ttl"=>3600},
42
+ # "ttl"=>3600,
43
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
44
+ # "updated_at"=>nil,
45
+ # "priority"=>nil},
46
+ # {"uuid"=>"0b18679d-dd47-46fe-8812-d20c284001ac",
47
+ # "name"=>"foobar.example.com",
48
+ # "type"=>"NS",
49
+ # "content"=>"ns01.idcfcloud.com",
50
+ # "ttl"=>3600,
51
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
52
+ # "updated_at"=>nil,
53
+ # "priority"=>nil},
54
+ # {"uuid"=>"a5a9ab9c-b19f-4411-880e-842ffd53027c",
55
+ # "name"=>"foobar.example.com",
56
+ # "type"=>"NS",
57
+ # "content"=>"ns02.idcfcloud.com",
58
+ # "ttl"=>3600,
59
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
60
+ # "updated_at"=>nil,
61
+ # "priority"=>nil},
62
+ # {"uuid"=>"2756ed66-2b69-4ae2-8065-69ac2b12b71d",
63
+ # "name"=>"foobar.example.com",
64
+ # "type"=>"NS",
65
+ # "content"=>"ns03.idcfcloud.com",
66
+ # "ttl"=>3600,
67
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
68
+ # "updated_at"=>nil,
69
+ # "priority"=>nil}],
70
+ # "description"=>"",
71
+ # "authenticated"=>false}
72
+ #
73
+ # response.uuid #=> "384178f5-58a5-4f3c-9607-5e189ab2990d"
15
74
  def create_zone(attributes, headers = {})
16
75
  Validators::Zone.validate_attributes!(attributes, :create)
17
76
  post!("zones", attributes, headers)
@@ -22,6 +81,13 @@ module Idcf
22
81
  # @param uuid [String] UUID of target zone
23
82
  # @param headers [Hash] HTTP request headers
24
83
  # @return [Response] HTTP response object
84
+ # @example
85
+ # response =
86
+ # client.delete_zone("83f55e72-e3fa-4961-89b3-99ee43617b93")
87
+ #
88
+ # response.body #=> {}
89
+ #
90
+ # response.status #=> 200
25
91
  def delete_zone(uuid, headers = {})
26
92
  delete!("zones/#{uuid}", {}, headers)
27
93
  end
@@ -31,6 +97,66 @@ module Idcf
31
97
  # @param uuid [String] UUID of target zone
32
98
  # @param headers [Hash] HTTP request headers
33
99
  # @return [Response] HTTP response object
100
+ # @example
101
+ # response =
102
+ # client.get_zone("b19e8211-e492-425d-b66a-7642dc2ff8fb")
103
+ #
104
+ # response.body #=>
105
+ # {"uuid"=>"b19e8211-e492-425d-b66a-7642dc2ff8fb",
106
+ # "name"=>"foobar.example.com",
107
+ # "default_ttl"=>600,
108
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
109
+ # "updated_at"=>nil,
110
+ # "records"=>
111
+ # [{"uuid"=>"1f30afd1-9b5e-45df-b03e-d07779a90e1c",
112
+ # "name"=>"foobar.example.com",
113
+ # "type"=>"SOA",
114
+ # "content"=>
115
+ # {"dns"=>"ns01.idcfcloud.com",
116
+ # "email"=>"foobar.example.com.",
117
+ # "serial"=>2,
118
+ # "refresh"=>10800,
119
+ # "retry"=>3600,
120
+ # "expire"=>604800,
121
+ # "ttl"=>3600},
122
+ # "ttl"=>3600,
123
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
124
+ # "updated_at"=>"2015-11-09T11:43:50+09:00",
125
+ # "priority"=>nil},
126
+ # {"uuid"=>"b5322649-625d-4b50-8cd3-7542f64912fa",
127
+ # "name"=>"foobar.example.com",
128
+ # "type"=>"NS",
129
+ # "content"=>"ns01.idcfcloud.com",
130
+ # "ttl"=>3600,
131
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
132
+ # "updated_at"=>nil,
133
+ # "priority"=>nil},
134
+ # {"uuid"=>"1fb4d44c-160a-45cd-835c-eb47fe1edb27",
135
+ # "name"=>"foobar.example.com",
136
+ # "type"=>"NS",
137
+ # "content"=>"ns02.idcfcloud.com",
138
+ # "ttl"=>3600,
139
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
140
+ # "updated_at"=>nil,
141
+ # "priority"=>nil},
142
+ # {"uuid"=>"765f8426-70b8-46c6-a45b-836c5dd57a7d",
143
+ # "name"=>"foobar.example.com",
144
+ # "type"=>"NS",
145
+ # "content"=>"ns03.idcfcloud.com",
146
+ # "ttl"=>3600,
147
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
148
+ # "updated_at"=>nil,
149
+ # "priority"=>nil},
150
+ # {"uuid"=>"ea81d8c0-8c6d-47e7-bca7-33656888a293",
151
+ # "name"=>"www.foobar.example.com",
152
+ # "type"=>"A",
153
+ # "content"=>"8.8.8.8",
154
+ # "ttl"=>3600,
155
+ # "created_at"=>"2015-11-09T11:43:50+09:00",
156
+ # "updated_at"=>nil,
157
+ # "priority"=>nil}],
158
+ # "description"=>"",
159
+ # "authenticated"=>false}
34
160
  def get_zone(uuid, headers = {})
35
161
  get!("zones/#{uuid}", {}, headers)
36
162
  end
@@ -39,6 +165,18 @@ module Idcf
39
165
  #
40
166
  # @param headers [Hash] HTTP request headers
41
167
  # @return [Response] HTTP response object
168
+ # @example
169
+ # response =
170
+ # client.list_zones
171
+ #
172
+ # response.body #=>
173
+ # [{"uuid"=>"384178f5-58a5-4f3c-9607-5e189ab2990d",
174
+ # "name"=>"foobar.example.com",
175
+ # "default_ttl"=>600,
176
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
177
+ # "updated_at"=>nil,
178
+ # "description"=>"",
179
+ # "authenticated"=>false}]
42
180
  def list_zones(headers = {})
43
181
  get!("zones", {}, headers)
44
182
  end
@@ -51,6 +189,70 @@ module Idcf
51
189
  # @option attributes [String] :description description
52
190
  # @option attributes [Integer] :default_ttl default TTL
53
191
  # @return [Response] HTTP response object
192
+ # @example
193
+ # response =
194
+ # client.update_zone(
195
+ # "384178f5-58a5-4f3c-9607-5e189ab2990d",
196
+ # description: "Change description",
197
+ # default_ttl: 3600
198
+ # )
199
+ #
200
+ # response.body #=>
201
+ # {"uuid"=>"384178f5-58a5-4f3c-9607-5e189ab2990d",
202
+ # "name"=>"foobar.example.com",
203
+ # "default_ttl"=>3600,
204
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
205
+ # "updated_at"=>"2015-11-09T11:43:50+09:00",
206
+ # "records"=>
207
+ # [{"uuid"=>"6aba1170-83b9-4324-b331-8c2b8dcb5162",
208
+ # "name"=>"foobar.example.com",
209
+ # "type"=>"SOA",
210
+ # "content"=>
211
+ # {"dns"=>"ns01.idcfcloud.com",
212
+ # "email"=>"foobar.example.com.",
213
+ # "serial"=>2,
214
+ # "refresh"=>10800,
215
+ # "retry"=>3600,
216
+ # "expire"=>604800,
217
+ # "ttl"=>3600},
218
+ # "ttl"=>3600,
219
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
220
+ # "updated_at"=>"2015-11-09T11:43:50+09:00",
221
+ # "priority"=>nil},
222
+ # {"uuid"=>"0b18679d-dd47-46fe-8812-d20c284001ac",
223
+ # "name"=>"foobar.example.com",
224
+ # "type"=>"NS",
225
+ # "content"=>"ns01.idcfcloud.com",
226
+ # "ttl"=>3600,
227
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
228
+ # "updated_at"=>nil,
229
+ # "priority"=>nil},
230
+ # {"uuid"=>"a5a9ab9c-b19f-4411-880e-842ffd53027c",
231
+ # "name"=>"foobar.example.com",
232
+ # "type"=>"NS",
233
+ # "content"=>"ns02.idcfcloud.com",
234
+ # "ttl"=>3600,
235
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
236
+ # "updated_at"=>nil,
237
+ # "priority"=>nil},
238
+ # {"uuid"=>"2756ed66-2b69-4ae2-8065-69ac2b12b71d",
239
+ # "name"=>"foobar.example.com",
240
+ # "type"=>"NS",
241
+ # "content"=>"ns03.idcfcloud.com",
242
+ # "ttl"=>3600,
243
+ # "created_at"=>"2015-11-09T11:43:49+09:00",
244
+ # "updated_at"=>nil,
245
+ # "priority"=>nil},
246
+ # {"uuid"=>"40d5f26f-02bd-4fb1-b363-323675772289",
247
+ # "name"=>"www.foobar.example.com",
248
+ # "type"=>"A",
249
+ # "content"=>"8.8.8.8",
250
+ # "ttl"=>3600,
251
+ # "created_at"=>"2015-11-09T11:43:50+09:00",
252
+ # "updated_at"=>nil,
253
+ # "priority"=>nil}],
254
+ # "description"=>"Change description",
255
+ # "authenticated"=>false}
54
256
  def update_zone(uuid, attributes, headers = {})
55
257
  Validators::Zone.validate_attributes!(attributes, :update)
56
258
  put!("zones/#{uuid}", attributes, headers)
@@ -46,14 +46,13 @@ module Idcf
46
46
  end
47
47
 
48
48
  def validate_absence!(attributes, action)
49
+ return unless action
49
50
  attributes.each do |name, value|
50
- if action &&
51
- (!valid_attributes[name] || !valid_attributes[name][action])
52
- fail(
53
- UnnecessaryAttribute,
54
- "`#{name}` is unnecessary in #{action} action"
55
- )
56
- end
51
+ next unless !valid_attributes[name] || !valid_attributes[name][action]
52
+ raise(
53
+ UnnecessaryAttribute,
54
+ "`#{name}` is unnecessary in #{action} action"
55
+ )
57
56
  end
58
57
  end
59
58
 
@@ -64,7 +63,7 @@ module Idcf
64
63
 
65
64
  def validate_attribute_name!(name)
66
65
  return true if valid_attributes.key?(name.to_sym)
67
- fail(
66
+ raise(
68
67
  InvalidAttributeName,
69
68
  "`#{name}` is invalid attribute name"
70
69
  )
@@ -73,7 +72,7 @@ module Idcf
73
72
  def validate_attribute_type!(name, value)
74
73
  valid_type = valid_attributes[name.to_sym][:type]
75
74
  return true if valid_attribute?(value, valid_type)
76
- fail(
75
+ raise(
77
76
  InvalidAttributeType,
78
77
  "`#{name}` is required to be a #{valid_type}"
79
78
  )
@@ -81,12 +80,11 @@ module Idcf
81
80
 
82
81
  def validate_presence!(attributes, action)
83
82
  required_attributes(action).each do |name|
84
- unless attributes.key?(name)
85
- fail(
86
- MissingAttribute,
87
- "`#{name}` is required in #{action} action"
88
- )
89
- end
83
+ next if attributes.key?(name)
84
+ raise(
85
+ MissingAttribute,
86
+ "`#{name}` is required in #{action} action"
87
+ )
90
88
  end
91
89
  end
92
90
  end
@@ -3,10 +3,11 @@ module Idcf
3
3
  module Validators
4
4
  # Record validator class
5
5
  class Record < Base
6
+ RECORD_TYPES = /^(A|CNAME|AAAA|MX|TXT|SRV|NS|SOA)$/
6
7
  self.valid_attributes = {
7
8
  uuid: { type: String },
8
9
  name: { type: String, create: :required, update: :optional },
9
- type: { type: /^(A|CNAME|AAAA|MX|TXT|SRV|NS|SOA)$/, create: :required, update: :optional },
10
+ type: { type: RECORD_TYPES, create: :required, update: :optional },
10
11
  content: { type: [String, Hash], create: :required, update: :optional },
11
12
  ttl: { type: Integer, create: :required, update: :optional },
12
13
  priority: { type: [Integer, NilClass], create: :optional },
@@ -1,5 +1,5 @@
1
1
  module Idcf
2
2
  module Dns
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idcf-dns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - nownabe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-02 00:00:00.000000000 Z
11
+ date: 2015-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: simplecov
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -145,6 +159,7 @@ extra_rdoc_files: []
145
159
  files:
146
160
  - ".gitignore"
147
161
  - ".rspec"
162
+ - ".rubocop.yml"
148
163
  - ".travis.yml"
149
164
  - Gemfile
150
165
  - LICENSE.txt
@@ -196,3 +211,4 @@ signing_key:
196
211
  specification_version: 4
197
212
  summary: A Ruby client for IDCF Cloud DNS Service.
198
213
  test_files: []
214
+ has_rdoc: