cloud_party 0.1.13 → 0.1.14
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 +4 -4
- data/bin/console +4 -4
- data/lib/cloud_party/helpers.rb +11 -0
- data/lib/cloud_party/nodes/dns_records.rb +113 -27
- data/lib/cloud_party/responses/nodes/dns_records.rb +0 -1
- data/lib/cloud_party/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6b2bf33cb61834c640e0c0bbfe4b4dc89366d6992401b2d02f4a414ffed624b
|
4
|
+
data.tar.gz: 2d2b4e215e0313d54e67a0dc9316fb447fefd9c73cca3f84cc1ca3dddd8f127f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afe0f76830a0c96685a86a85969bf56a3d7cc4ae1ac76e895644b1fead048e85192648c1c06197890a9a0bafbaf38bc1852300f1f77b58d147d7a31f32c344f1
|
7
|
+
data.tar.gz: 9787873b795dc8ad29ab371ca74fa69c040b00e336e72534eef05f3309b6f261dc35f49e5c9bd352932bdb1112ec0f171a738370984f63f4d937c67fe2cc6932
|
data/bin/console
CHANGED
@@ -8,8 +8,8 @@ require 'cloud_party'
|
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
9
9
|
|
10
10
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
require 'pry'
|
12
|
-
Pry.start
|
11
|
+
# require 'pry'
|
12
|
+
# Pry.start
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
require "irb"
|
15
|
+
IRB.start
|
@@ -7,6 +7,7 @@
|
|
7
7
|
#
|
8
8
|
# License is in project root, MIT License is in use.
|
9
9
|
require 'cloud_party/config'
|
10
|
+
require 'cloud_party/helpers'
|
10
11
|
require 'cloud_party/context'
|
11
12
|
require 'cloud_party/responses'
|
12
13
|
CloudParty::Config.new
|
@@ -20,7 +21,7 @@ module CloudParty
|
|
20
21
|
'Content-Type' => 'application/json',
|
21
22
|
'User-Agent' => "CloudParty/#{CloudParty::VERSION}"
|
22
23
|
|
23
|
-
def self.
|
24
|
+
def self.zone_id_by_name(zone)
|
24
25
|
options = {
|
25
26
|
match: 'all',
|
26
27
|
name: zone,
|
@@ -31,15 +32,15 @@ module CloudParty
|
|
31
32
|
else
|
32
33
|
@options.merge!(options)
|
33
34
|
end
|
34
|
-
zone = CloudParty::Responses::Zones.new(:get, '/zones',
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
zone = CloudParty::Responses::Zones.new(:get, '/zones',
|
36
|
+
get('/zones', query: @options), @options).result
|
37
|
+
if zone.is_a?(Array)
|
38
|
+
if zone.size > 1
|
39
|
+
raise CloudParty::Errors::ResultError.new()
|
40
|
+
else
|
41
|
+
zone.first.fetch(:id, nil)
|
42
|
+
end
|
43
|
+
end
|
43
44
|
|
44
45
|
end
|
45
46
|
def initialize(options = {})
|
@@ -47,12 +48,101 @@ module CloudParty
|
|
47
48
|
@options = options
|
48
49
|
end
|
49
50
|
|
50
|
-
|
51
|
-
|
51
|
+
# Retrieve a list of DNS records for the given zone
|
52
|
+
#
|
53
|
+
# @param zone [String] Zone to retrieve DNS records for
|
54
|
+
# @param opts [Hash] Additional query options
|
55
|
+
# @option opts [String] :name Name of DNS record to search for
|
56
|
+
# @option opts [String] :type Type of DNS record to search for
|
57
|
+
# @option opts [Integer] :page Page number to retrieve
|
58
|
+
# @option opts [Integer] :per_page Number of items per page
|
59
|
+
# @option opts [String] :order Direction of results
|
60
|
+
# @option opts [String] :comment Exact value of the DNS record comment. This is a convenience alias for comment.exact.
|
61
|
+
# Example: Hello, world
|
62
|
+
# @option opts [String] :"comment.absent" If this parameter is present, only records without a comment are returned.
|
63
|
+
# @option opts [String] :"comment.contains" Substring of the DNS record comment. Comment filters are case-insensitive.
|
64
|
+
# Example: ello, worl
|
65
|
+
# @option opts [String] :"comment.endswith" Suffix of the DNS record comment. Comment filters are case-insensitive.
|
66
|
+
# Example: o, world
|
67
|
+
# @option opts [String] :"comment.present" If this parameter is present, only records with a comment are returned.
|
68
|
+
# @option opts [String] :"comment.exact" Exact value of the DNS record comment. Comment filters are case-insensitive.
|
69
|
+
# Example: Hello, world
|
70
|
+
# @option opts [String] :"comment.startswith" Prefix of the DNS record comment. Comment filters are case-insensitive.
|
71
|
+
# Example: Hello, w
|
72
|
+
# @option opts [String] :content Exact value of the DNS record content. This is a convenience alias for content.exact.
|
73
|
+
# Example: 127.0.0.1
|
74
|
+
# @option opts [String] :"content.contains" Substring of the DNS record content. Content filters are case-insensitive.
|
75
|
+
# Example: 7.0.0.
|
76
|
+
# @option opts [String] :"content.endswith" Suffix of the DNS record content. Content filters are case-insensitive.
|
77
|
+
# Example: .0.1
|
78
|
+
# @option opts [String] :"content.exact" Exact value of the DNS record content. Content filters are case-insensitive.
|
79
|
+
# Example: 127.0.0.1
|
80
|
+
# @option opts [String] :"content.startswith" Prefix of the DNS record content. Content filters are case-insensitive.
|
81
|
+
# Example: 127.0.
|
82
|
+
# @option opts [String] :direction Direction to order DNS records in.
|
83
|
+
# Allowed values: asc, desc
|
84
|
+
# Default: asc
|
85
|
+
# Example: desc
|
86
|
+
# @option opts [String] :match Whether to match all search requirements or at least one (any). If set to all, acts like a logical AND between filters. If set to any, acts like a logical OR instead. Note that the interaction between tag filters is controlled by the tag-match parameter instead.
|
87
|
+
# Allowed values: any, all
|
88
|
+
# Default: all
|
89
|
+
# Example: any
|
90
|
+
# @option opts [String] :name Exact value of the DNS record name. This is a convenience alias for name.exact.
|
91
|
+
# Example: www.example.com
|
92
|
+
# @option opts [String] :name.contains Substring of the DNS record name. Name filters are case-insensitive.
|
93
|
+
# Example: w.example.
|
94
|
+
# @option opts [String] :name.endswith Suffix of the DNS record name. Name filters are case-insensitive.
|
95
|
+
# Example: .example.com
|
96
|
+
# @option opts [String] :name.exact Exact value of the DNS record name. Name filters are case-insensitive.
|
97
|
+
# Example: www.example.com
|
98
|
+
# @option opts [String] :name.startswith Prefix of the DNS record name. Name filters are case-insensitive.
|
99
|
+
# Example: www.example
|
100
|
+
# @option opts [String] :order Field to order DNS records by.
|
101
|
+
# Allowed values: type, name, content, ttl, proxied
|
102
|
+
# Default: type
|
103
|
+
# Example: name
|
104
|
+
# @option opts [String] :page Page number of paginated results.
|
105
|
+
# >= 1
|
106
|
+
# Default: 1
|
107
|
+
# @option opts [Integer] :per_page Number of DNS records per page.
|
108
|
+
# >= 1
|
109
|
+
# <= 5000000
|
110
|
+
# Default: 100
|
111
|
+
# @option opts [String] :proxied Whether the record is receiving the performance and security benefits of Cloudflare.
|
112
|
+
# Default: false
|
113
|
+
# Example: true
|
114
|
+
# @option opts [String] :search Allows searching in multiple properties of a DNS record simultaneously. This parameter is intended for human users, not automation. Its exact behavior is intentionally left unspecified and is subject to change in the future. This parameter works independently of the match setting. For automated searches, please use the other available parameters.
|
115
|
+
# Example: www.cloudflare.com
|
116
|
+
# @option opts [String] :tag Name of a tag which must not be present on the DNS record. Tag filters are case-insensitive.
|
117
|
+
# Example: important
|
118
|
+
# @option opts [String] :tag.absent Name of a tag which must not be present on the DNS record. Tag filters are case-insensitive.
|
119
|
+
# Example: important
|
120
|
+
# @option opts [String] :tag.contains A tag and value, of the form <tag-name>:<tag-value>. The API will only return DNS records that have a tag named <tag-name> whose value contains <tag-value>. Tag filters are case-insensitive.
|
121
|
+
# Example: greeting:ello, world
|
122
|
+
# @option opts [String] :tag.endswith Name of a tag whose value must end with the given value. Tag filters are case-insensitive.
|
123
|
+
# Example: greeting:ello, world
|
124
|
+
# @option opts [String] :tag.exact Name of a tag whose value must exactly match the given value. Tag filters are case-insensitive.
|
125
|
+
# Example: greeting:ello, world
|
126
|
+
# @option opts [String] :tag.startswith Name of a tag whose value must start with the given value. Tag filters are case-insensitive.
|
127
|
+
# Example: greeting:ello, world
|
128
|
+
# @option opts [String] :type Type of the DNS record.
|
129
|
+
# Allowed values: A, AAAA, CAA, CERT, CNAME, DNSKEY, DS, HTTPS, LOC, MX, NAPTR, NS, OPENPGPKEY, PTR, SMIMEA, SRV, SSHFP, SVCB, TLSA, TXT, URI
|
130
|
+
# Default: A
|
131
|
+
# Example: A
|
132
|
+
# @return [CloudParty::Responses::DNSRecords] DNS records response object
|
133
|
+
def list(zone, opts = {})
|
134
|
+
zone_id = DNSRecords.zone_id_by_name(zone)
|
135
|
+
|
136
|
+
CloudParty::Responses::DNSRecords.new(:get, '/zones/:id/dns_records', self.class.get("/zones/#{zone_id}/dns_records", query: opts), @options)
|
137
|
+
end
|
138
|
+
|
139
|
+
def search(zone, query)
|
140
|
+
zone_id = DNSRecords.zone_id_by_name(zone)
|
52
141
|
CloudParty::Responses::DNSRecords.new(:get, '/zones/:id/dns_records', self.class.get("/zones/#{zone_id}/dns_records", @options), @options)
|
53
142
|
end
|
54
143
|
|
55
|
-
def get(id)
|
144
|
+
def get(zone, id)
|
145
|
+
zone_id = DNSRecords.zone_id_by_name(zone)
|
56
146
|
CloudParty::Responses::DNSRecords.new(:get, '/zones/:id/dns_records', self.class.get("/zones/#{zone_id}/dns_records", @options), @options)
|
57
147
|
end
|
58
148
|
|
@@ -82,19 +172,7 @@ module CloudParty
|
|
82
172
|
options.merge!(ttl: ttl) unless ttl.nil?
|
83
173
|
options.merge!(priority: priority) unless priority.nil?
|
84
174
|
options.merge!(proxied: proxied) unless proxied.nil?
|
85
|
-
|
86
|
-
zone_options = {
|
87
|
-
match: 'all',
|
88
|
-
name: zone,
|
89
|
-
order: 'name'
|
90
|
-
}
|
91
|
-
zone_id = CloudParty::Responses::Zones.new(:get, '/zones', self.class.get('/zones', query: zone_options), @options).result.first.fetch(:id, nil)
|
92
|
-
elsif self.class.class_variable_defined?(:@@zone)
|
93
|
-
zone_id = @@zone
|
94
|
-
else
|
95
|
-
raise CloudParty::Errors::NoDefinedZoneError.new("neither the keyword 'zone:' nor the class variable @@zone ended up being defined.", nil)
|
96
|
-
end
|
97
|
-
|
175
|
+
zone_id = zone_id_by_name(zone)
|
98
176
|
CloudParty::Responses::DNSRecords.new(
|
99
177
|
:post,
|
100
178
|
'/zones/:id/dns_records',
|
@@ -102,13 +180,21 @@ module CloudParty
|
|
102
180
|
@options)
|
103
181
|
end
|
104
182
|
def rem(id, zone: nil)
|
105
|
-
zone_id =
|
183
|
+
zone_id = zone_id_by_name(zone)
|
106
184
|
CloudParty::Responses::DNSRecords.new(
|
107
185
|
:delete,
|
108
186
|
'/zones/:id/dns_records/:identifier',
|
109
187
|
self.class.delete("/zones/#{zone_id}/dns_records/#{id}")
|
110
188
|
)
|
111
189
|
end
|
190
|
+
def update(id, type, name, content, opts, zone: nil)
|
191
|
+
zone_id = zone_id_by_name(zone)
|
192
|
+
|
193
|
+
end
|
194
|
+
|
195
|
+
def batch(records, zone: nil)
|
196
|
+
zone_id = zone_id_by_name(zone)
|
197
|
+
end
|
112
198
|
end
|
113
199
|
end
|
114
200
|
end
|
data/lib/cloud_party/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloud_party
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Spencer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -208,6 +208,7 @@ files:
|
|
208
208
|
- lib/cloud_party/exceptions/request_errors/unsupported_media_type_error.rb
|
209
209
|
- lib/cloud_party/exceptions/un_recognized_endpoint_error.rb
|
210
210
|
- lib/cloud_party/exceptions/un_recognized_result_type_error.rb
|
211
|
+
- lib/cloud_party/helpers.rb
|
211
212
|
- lib/cloud_party/nodes.rb
|
212
213
|
- lib/cloud_party/nodes/accounts.rb
|
213
214
|
- lib/cloud_party/nodes/dns_records.rb
|