cloud_party 0.1.12 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35c2223f859cbda2cc5c69a4b65bd8cd5155ad0127b3c555996d7c7b26257960
4
- data.tar.gz: 6cc96c55a0334cd664ad859a7877751780ed846651c5eaaab1cdcfbbc7e06145
3
+ metadata.gz: b6b2bf33cb61834c640e0c0bbfe4b4dc89366d6992401b2d02f4a414ffed624b
4
+ data.tar.gz: 2d2b4e215e0313d54e67a0dc9316fb447fefd9c73cca3f84cc1ca3dddd8f127f
5
5
  SHA512:
6
- metadata.gz: 10e20420e6bc2aa7bde4ce470d7576df62f453393d9ec3416c48f60cfae3b282666a6bb6e250c76b9e2050822c9736507320ce1bf5ad071edb81f55a267e00c9
7
- data.tar.gz: bd71cbff35e3ec3da513f048d32617b8c6b1d1cce2564115090f2dd98b93114d38095ebab25222ead4126e9358a25b8450e23568b038c5745496ca9f2deb2389
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
- # require "irb"
15
- # IRB.start
14
+ require "irb"
15
+ IRB.start
@@ -0,0 +1,11 @@
1
+ require 'uri'
2
+
3
+ module CloudParty
4
+ module Helpers
5
+ module_function
6
+ def self.build_query(params)
7
+ uri = URI::HTTPS.build(host: 'example.com', query: URI.encode_www_form(params))
8
+ return "?#{uri.query}"
9
+ end
10
+ end
11
+ end
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
-
2
+ require 'cloud_party/config'
3
3
  require 'cloud_party/context'
4
4
  require 'cloud_party/responses'
5
+ CloudParty::Config.new
5
6
  module CloudParty
6
7
  module Nodes
7
8
  class Accounts
@@ -6,8 +6,11 @@
6
6
  # Created: 9/14/19
7
7
  #
8
8
  # License is in project root, MIT License is in use.
9
+ require 'cloud_party/config'
10
+ require 'cloud_party/helpers'
9
11
  require 'cloud_party/context'
10
12
  require 'cloud_party/responses'
13
+ CloudParty::Config.new
11
14
  module CloudParty
12
15
  module Nodes
13
16
  class DNSRecords
@@ -18,7 +21,7 @@ module CloudParty
18
21
  'Content-Type' => 'application/json',
19
22
  'User-Agent' => "CloudParty/#{CloudParty::VERSION}"
20
23
 
21
- def self.id_by_name(zone)
24
+ def self.zone_id_by_name(zone)
22
25
  options = {
23
26
  match: 'all',
24
27
  name: zone,
@@ -29,15 +32,15 @@ module CloudParty
29
32
  else
30
33
  @options.merge!(options)
31
34
  end
32
- zone = CloudParty::Responses::Zones.new(:get, '/zones', get('/zones', query: @options), @options).result
33
- if zone.is_a?(Array)
34
- if zone.size > 1
35
- raise CloudParty::Errors::ResultError.new()
36
- else
37
- zone.first.fetch(:id, nil)
38
-
39
- end
40
- end
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
41
44
 
42
45
  end
43
46
  def initialize(options = {})
@@ -45,12 +48,101 @@ module CloudParty
45
48
  @options = options
46
49
  end
47
50
 
48
- def list(zone)
49
- zone_id = self.id_by_name(zone)
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)
50
141
  CloudParty::Responses::DNSRecords.new(:get, '/zones/:id/dns_records', self.class.get("/zones/#{zone_id}/dns_records", @options), @options)
51
142
  end
52
143
 
53
- def get(id)
144
+ def get(zone, id)
145
+ zone_id = DNSRecords.zone_id_by_name(zone)
54
146
  CloudParty::Responses::DNSRecords.new(:get, '/zones/:id/dns_records', self.class.get("/zones/#{zone_id}/dns_records", @options), @options)
55
147
  end
56
148
 
@@ -80,19 +172,7 @@ module CloudParty
80
172
  options.merge!(ttl: ttl) unless ttl.nil?
81
173
  options.merge!(priority: priority) unless priority.nil?
82
174
  options.merge!(proxied: proxied) unless proxied.nil?
83
- if zone
84
- zone_options = {
85
- match: 'all',
86
- name: zone,
87
- order: 'name'
88
- }
89
- zone_id = CloudParty::Responses::Zones.new(:get, '/zones', self.class.get('/zones', query: zone_options), @options).result.first.fetch(:id, nil)
90
- elsif self.class.class_variable_defined?(:@@zone)
91
- zone_id = @@zone
92
- else
93
- raise CloudParty::Errors::NoDefinedZoneError.new("neither the keyword 'zone:' nor the class variable @@zone ended up being defined.", nil)
94
- end
95
-
175
+ zone_id = zone_id_by_name(zone)
96
176
  CloudParty::Responses::DNSRecords.new(
97
177
  :post,
98
178
  '/zones/:id/dns_records',
@@ -100,13 +180,21 @@ module CloudParty
100
180
  @options)
101
181
  end
102
182
  def rem(id, zone: nil)
103
- zone_id = id_by_name(zone)
183
+ zone_id = zone_id_by_name(zone)
104
184
  CloudParty::Responses::DNSRecords.new(
105
185
  :delete,
106
186
  '/zones/:id/dns_records/:identifier',
107
187
  self.class.delete("/zones/#{zone_id}/dns_records/#{id}")
108
188
  )
109
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
110
198
  end
111
199
  end
112
200
  end
@@ -2,13 +2,14 @@
2
2
  require 'cloud_party/config'
3
3
  require 'cloud_party/context'
4
4
  require 'cloud_party/responses'
5
+ CloudParty::Config.new
5
6
  module CloudParty
6
7
  module Nodes
7
8
  class IPs
8
9
  include CloudParty::Context
9
10
  include HTTParty
10
11
  base_uri 'https://api.cloudflare.com/client/v4'
11
- headers 'Authorization' => "Bearer #{CloudParty::Config.new.token}",
12
+ headers 'Authorization' => "Bearer #{CloudParty::Config.token}",
12
13
  'Content-Type' => 'application/json',
13
14
  'User-Agent' => "CloudParty/#{CloudParty::VERSION}"
14
15
 
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
-
2
+ require 'cloud_party/config'
3
3
  require 'cloud_party/context'
4
4
  require 'cloud_party/responses'
5
+ CloudParty::Config.new
5
6
  module CloudParty
6
7
  module Nodes
7
8
  class Memberships
@@ -1,14 +1,15 @@
1
1
  # frozen_string_literal: true
2
-
2
+ require 'cloud_party/config'
3
3
  require 'cloud_party/context'
4
4
  require 'cloud_party/responses'
5
+ CloudParty::Config.new
5
6
  module CloudParty
6
7
  module Nodes
7
8
  class Zones
8
9
  include CloudParty::Context
9
10
  include HTTParty
10
11
  base_uri 'https://api.cloudflare.com/client/v4'
11
- headers 'Authorization' => "Bearer #{CloudParty::Config.new.token}",
12
+ headers 'Authorization' => "Bearer #{CloudParty::Config.token}",
12
13
  'Content-Type' => 'application/json',
13
14
  'User-Agent' => "CloudParty/#{CloudParty::VERSION}"
14
15
 
@@ -1,2 +1 @@
1
- require 'cloud_party/responses/nodes/dns_records/timing'
2
1
  require 'cloud_party/responses/nodes/dns_records/meta'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CloudParty
4
- VERSION = '0.1.12'
4
+ VERSION = '0.1.14'
5
5
  end
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.12
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-10 00:00:00.000000000 Z
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