Class: CloudflareClient::VirtualDnsCluster
- Inherits:
-
CloudflareClient
- Object
- CloudflareClient
- CloudflareClient::VirtualDnsCluster
- Defined in:
- lib/cloudflare_client/virtual_dns_cluster.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Analytic
Constant Summary collapse
- VALID_SCOPES =
%i[user organization].freeze
Constants inherited from CloudflareClient
API_BASE, POSSIBLE_API_SETTINGS, VALID_BUNDLE_METHODS, VALID_DIRECTIONS, VALID_MATCHES, VERSION
Instance Attribute Summary collapse
-
#uri_prefix ⇒ Object
readonly
Returns the value of attribute uri_prefix.
Instance Method Summary collapse
-
#create(name:, origin_ips:, minimum_cache_ttl: nil, maximum_cache_ttl: nil, deprecate_any_request: nil, ratelimit: nil) ⇒ Object
create a virtual dns cluster.
-
#delete(id:) ⇒ Object
delete a dns cluster (user).
-
#initialize(args) ⇒ VirtualDnsCluster
constructor
virtual DNS using scope to determine if this is for users or for orgs.
-
#list ⇒ Object
list virutal dns clsuters for a user or an org.
-
#show(id:) ⇒ Object
details of a cluster.
-
#update(id:, name: nil, origin_ips: nil, minimum_cache_ttl: nil, maximum_cache_ttl: nil, deprecate_any_request: nil, ratelimit: nil) ⇒ Object
updates a dns cluster (user).
Constructor Details
#initialize(args) ⇒ VirtualDnsCluster
virtual DNS using scope to determine if this is for users or for orgs
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cloudflare_client/virtual_dns_cluster.rb', line 11 def initialize(args) scope = args.delete(:scope)&.to_sym org_id = args.delete(:org_id) valid_value_check(:scope, scope, VALID_SCOPES) if scope == :user @uri_prefix = '/user' else id_check(:org_id, org_id) @uri_prefix = "/organizations/#{org_id}" end super(**args) end |
Instance Attribute Details
#uri_prefix ⇒ Object (readonly)
Returns the value of attribute uri_prefix.
6 7 8 |
# File 'lib/cloudflare_client/virtual_dns_cluster.rb', line 6 def uri_prefix @uri_prefix end |
Instance Method Details
#create(name:, origin_ips:, minimum_cache_ttl: nil, maximum_cache_ttl: nil, deprecate_any_request: nil, ratelimit: nil) ⇒ Object
create a virtual dns cluster
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cloudflare_client/virtual_dns_cluster.rb', line 36 def create(name:, origin_ips:, minimum_cache_ttl: nil, maximum_cache_ttl: nil, deprecate_any_request: nil, ratelimit: nil) id_check(:name, name) max_length_check(:name, name, 160) non_empty_array_check(:origin_ips, origin_ips) data = {name: name, origin_ips: origin_ips} unless minimum_cache_ttl.nil? range_check(:minimum_cache_ttl, minimum_cache_ttl, 30, 36000) data[:minimum_cache_ttl] = minimum_cache_ttl end unless maximum_cache_ttl.nil? range_check(:maximum_cache_ttl, maximum_cache_ttl, 30, 36000) data[:maximum_cache_ttl] = maximum_cache_ttl end unless deprecate_any_request.nil? valid_value_check(:deprecate_any_request, deprecate_any_request, [true, false]) data[:deprecate_any_request] = deprecate_any_request end unless ratelimit.nil? range_check(:ratelimit, ratelimit, 0, 100000000) data[:ratelimit] = ratelimit end cf_post(path: "#{uri_prefix}/virtual_dns", data: data) end |
#delete(id:) ⇒ Object
delete a dns cluster (user)
81 82 83 84 85 |
# File 'lib/cloudflare_client/virtual_dns_cluster.rb', line 81 def delete(id:) id_check(:id, id) cf_delete(path: "#{uri_prefix}/virtual_dns/#{id}") end |
#list ⇒ Object
list virutal dns clsuters for a user or an org
30 31 32 |
# File 'lib/cloudflare_client/virtual_dns_cluster.rb', line 30 def list cf_get(path: "#{uri_prefix}/virtual_dns") end |
#show(id:) ⇒ Object
details of a cluster
73 74 75 76 77 |
# File 'lib/cloudflare_client/virtual_dns_cluster.rb', line 73 def show(id:) id_check(:id, id) cf_get(path: "#{uri_prefix}/virtual_dns/#{id}") end |
#update(id:, name: nil, origin_ips: nil, minimum_cache_ttl: nil, maximum_cache_ttl: nil, deprecate_any_request: nil, ratelimit: nil) ⇒ Object
updates a dns cluster (user)
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/cloudflare_client/virtual_dns_cluster.rb', line 89 def update(id:, name: nil, origin_ips: nil, minimum_cache_ttl: nil, maximum_cache_ttl: nil, deprecate_any_request: nil, ratelimit: nil) id_check(:id, id) data = {} unless name.nil? id_check(:name, name) max_length_check(:name, name, 160) data[:name] = name end unless origin_ips.nil? non_empty_array_check(:origin_ips, origin_ips) data[:origin_ips] = origin_ips end unless minimum_cache_ttl.nil? range_check(:minimum_cache_ttl, minimum_cache_ttl, 30, 36000) data[:minimum_cache_ttl] = minimum_cache_ttl end unless maximum_cache_ttl.nil? range_check(:maximum_cache_ttl, maximum_cache_ttl, 30, 36000) data[:maximum_cache_ttl] = maximum_cache_ttl end unless deprecate_any_request.nil? valid_value_check(:deprecate_any_request, deprecate_any_request, [true, false]) data[:deprecate_any_request] = deprecate_any_request end unless ratelimit.nil? range_check(:ratelimit, ratelimit, 0, 100000000) data[:ratelimit] = ratelimit end cf_patch(path: "#{uri_prefix}/virtual_dns/#{id}", data: data) end |