dnscaster 0.2.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 649f52da69e201dba57be755d708abd98c6fdef359ec90521b744a946b9682c2
4
+ data.tar.gz: a021553142612c3f9fd600c297aef301ebcd8bc13cd07d97a7f9ee090210231c
5
+ SHA512:
6
+ metadata.gz: 81bfef0008fd8c24354a9144d202277cfdf555a2a59eb6ea5b43902a33e64c4dbcbf715ddafa4951d7ac4c7ccc8e3c610da6c6d405715655c3b9161ef5bac968
7
+ data.tar.gz: e29d4b9a475f0a5d5ed8e1b3ced4ca3bdc420365747a3bbd8737cbfa11f2b9477f7da001a9ae52363e80342591eccfc3709afbeedcd9d018076d814883e94092
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ *.gem
2
+ .bundle
3
+ .config
4
+ coverage/
5
+ doc/
6
+ Gemfile.lock
7
+ pkg/
8
+ rdoc
9
+ spec/reports/
10
+ test/tmp
11
+ test/version_tmp
12
+ tmp/
13
+ .yardoc
14
+ _yardoc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dnscaster.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright 2022-2025 Notioneer, Inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # DNScaster
2
+
3
+ [DNScaster](https://dnscaster.com/) is a powerful, easy to use DNS service, with full suite of modern features, including near realtime updates, Geo-location, true ALIAS records, IP restrictions, target monitoring, and more.
4
+
5
+ This gem works with both Rails and plain Ruby.
6
+
7
+
8
+
9
+ ## Usage
10
+
11
+ To your Gemfile, add:
12
+
13
+ gem 'dnscaster'
14
+
15
+ Then go create an API key (DNScaster -> Preferences -> API keys) and set this environment variable:
16
+
17
+ DNSCASTER_KEY = key_SAMPLE
18
+
19
+ Alternatively, the API key may be configured programmatically. Be sure to store your key securely and not commit it with your code!
20
+
21
+ Dnscaster::Api.credentials = {
22
+ api_key: 'key_SAMPLE'
23
+ }
24
+
25
+
26
+
27
+ ## Reference
28
+
29
+ For full details on the DNScaster API, see our [documentation](https://dnscaster.com/docs).
30
+
31
+
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new Pull Request
40
+
41
+
42
+
43
+ ## License
44
+
45
+ MIT
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/dnscaster.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dnscaster/api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dnscaster"
8
+ spec.version = Dnscaster::VERSION
9
+ spec.authors = ["DNScaster Team"]
10
+ spec.email = ["hello@notioneer.com"]
11
+ spec.description = %q{DNScaster client for Ruby.}
12
+ spec.summary = %q{DNScaster client for Ruby}
13
+ spec.homepage = "https://dnscaster.com/"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.required_ruby_version = '>= 2.7'
22
+
23
+ spec.add_dependency 'ncore', '>= 3.10', '< 4'
24
+
25
+ spec.add_development_dependency "bundler"
26
+ spec.add_development_dependency "rake"
27
+ end
@@ -0,0 +1,36 @@
1
+ module Dnscaster
2
+ include NCore::Builder
3
+
4
+ configure do
5
+ self.default_url = proc do
6
+ ENV['DNSCASTER_URL'] || 'https://api.dnscaster.com/v1/'
7
+ end
8
+
9
+ self.default_headers = {
10
+ accept: 'application/json',
11
+ content_type: 'application/json',
12
+ user_agent: "DNScaster/ruby v#{VERSION} [nc #{NCore::VERSION}]"
13
+ }
14
+
15
+ self.credentials = proc do
16
+ { api_key: ENV['DNSCASTER_KEY'] }
17
+ end
18
+
19
+ self.debug = false
20
+
21
+ self.strict_attributes = true
22
+
23
+ self.i18n_scope = :dnscaster
24
+
25
+ self.instrument_key = 'request.dnscaster'
26
+
27
+ self.status_page = 'http://status.notioneer.com/'
28
+
29
+ self.auth_header_prefix = 'dnscaster'
30
+
31
+ self.bearer_credential_key = :api_key
32
+
33
+ self.credentials_error_message = %Q{Missing API credentials. Set default credentials using env var "DNSCASTER_KEY" or "Dnscaster::Api.credentials = {api_key: YOUR_SECRET_KEY}"}
34
+
35
+ end
36
+ end
@@ -0,0 +1,10 @@
1
+ require 'ncore/rails/log_subscriber'
2
+
3
+ module Dnscaster
4
+ class LogSubscriber < ActiveSupport::LogSubscriber
5
+ include NCore::LogSubscriber
6
+ self.runtime_variable = 'dnscaster_runtime'
7
+ end
8
+ end
9
+
10
+ Dnscaster::LogSubscriber.attach_to :dnscaster
@@ -0,0 +1,28 @@
1
+ module Dnscaster
2
+ class Railtie < Rails::Railtie
3
+
4
+ config.before_initialize do
5
+ config.action_dispatch.rescue_responses.merge!(
6
+ 'Dnscaster::RecordInvalid' => :unprocessable_entity, # 422
7
+ 'Dnscaster::RecordNotFound' => :not_found, # 404
8
+ )
9
+ end
10
+
11
+ initializer "dnscaster.cache_store" do |app|
12
+ Dnscaster::Api.cache_store = Rails.cache
13
+ end
14
+
15
+ initializer "dnscaster.log_runtime" do |app|
16
+ require 'dnscaster/api/log_subscriber'
17
+ ActiveSupport.on_load(:action_controller) do
18
+ include NCore::ControllerRuntime
19
+ register_api_runtime Dnscaster::LogSubscriber, 'DNScaster'
20
+ end
21
+ end
22
+
23
+ initializer "dnscaster.logger" do |app|
24
+ Dnscaster::Api.logger = Rails.logger
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module Dnscaster
2
+ VERSION = '0.2.0'
3
+ end
@@ -0,0 +1,12 @@
1
+ module Dnscaster
2
+ class Boundary < Resource
3
+ crud :all, :find, :create, :update, :delete
4
+
5
+ belongs_to :nameserver_set
6
+ has_many :hosts
7
+
8
+ attr :external_ref, :ips, :locations, :name
9
+ attr :in_use # readonly
10
+
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ module Dnscaster
2
+ class DomainProvider < Resource
3
+ crud :all, :find
4
+
5
+ attr :credential_state, :domains, :name, :provider_name, :provider_type
6
+ attr :in_use
7
+ attr_datetime :credential_state_at, :domains_updated_at
8
+
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ module Dnscaster
2
+ class Host < Resource
3
+ crud :all, :find, :create, :update, :delete
4
+
5
+ belongs_to :boundary
6
+ belongs_to :ip_monitor
7
+ belongs_to :zone
8
+
9
+ attr :data, :dns_type, :external_ref, :hostname, :priority, :state, :ttl
10
+ attr :notes
11
+ attr :effective_ttl, :fqdn, :fqdn_utf8, :hostname_utf8 # readonly
12
+
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ module Dnscaster
2
+ class Instance < Resource
3
+
4
+ belongs_to :nameserver
5
+
6
+ attr :health, :ipv4, :ipv6, :region, :state
7
+ attr_datetime :health_at
8
+
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ module Dnscaster
2
+ class IpMonitor < Resource
3
+ crud :all, :find, :create, :update, :delete
4
+
5
+ belongs_to :nameserver_set
6
+ has_many :hosts
7
+
8
+ attr :external_ref, :hostname, :name, :uri
9
+ attr :health, :in_use # readonly
10
+ attr_datetime :health_at
11
+
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module Dnscaster
2
+ class Nameserver < Resource
3
+ crud :all, :find, :create, :delete
4
+
5
+ belongs_to :nameserver_set
6
+
7
+ attr :region
8
+ attr :fqdn, :instances, :vanity_fqdns, :state # readonly
9
+
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Dnscaster
2
+ class NameserverSet < Resource
3
+ crud :all, :find, :create, :update, :delete
4
+
5
+ has_many :boundaries
6
+ has_many :ip_monitors
7
+ has_many :nameservers
8
+ has_many :vanity_sets
9
+ has_many :zones
10
+
11
+ attr :external_ref, :hostmaster, :ip_ttl, :name, :ns_ttl
12
+ attr :in_use # readonly
13
+
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ module Dnscaster
2
+ class Region < Resource
3
+ crud :all
4
+
5
+ attr :name, :region, :state
6
+
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ module Dnscaster
2
+ class VanitySet < Resource
3
+ crud :all, :find, :create, :update, :delete
4
+
5
+ belongs_to :nameserver_set
6
+ belongs_to :vanity_zone
7
+ has_many :zones
8
+
9
+ attr :default_set, :external_ref, :pattern
10
+ attr :in_use, :name, :vanity_domain # readonly
11
+
12
+
13
+ end
14
+ end
@@ -0,0 +1,25 @@
1
+ module Dnscaster
2
+ class Zone < Resource
3
+ crud :all, :find, :create, :update, :delete
4
+
5
+ belongs_to :domain_provider
6
+ belongs_to :nameserver_set
7
+ belongs_to :vanity_set
8
+ has_many :hosts
9
+
10
+ attr :default_ttl, :domain, :external_ref, :nx_ttl, :tags
11
+ attr :delegation_updates, :glue_updates
12
+ attr :notes
13
+ attr :delegation_errors, :domain_utf8, :glue_errors, :in_use, :synced # readonly
14
+ attr_datetime :live_checked_at
15
+
16
+
17
+ def check(attribs={})
18
+ params = parse_request_params(attribs, json_root: json_root).reverse_merge credentials: api_creds
19
+ parsed, _ = request(:post, resource_path+'/check', params)
20
+ load(parsed)
21
+ errors.empty? ? self : false
22
+ end
23
+
24
+ end
25
+ end
data/lib/dnscaster.rb ADDED
@@ -0,0 +1,22 @@
1
+ require 'ncore'
2
+
3
+ %w(version api_config).each do |f|
4
+ require "dnscaster/api/#{f}"
5
+ end
6
+
7
+ %w(
8
+ boundary
9
+ domain_provider
10
+ host
11
+ instance
12
+ ip_monitor
13
+ nameserver
14
+ nameserver_set
15
+ region
16
+ vanity_set
17
+ zone
18
+ ).each do |f|
19
+ require "dnscaster/#{f}"
20
+ end
21
+
22
+ require 'dnscaster/api/railtie' if defined?(Rails)
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dnscaster
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - DNScaster Team
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: ncore
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '3.10'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '4'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '3.10'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '4'
32
+ - !ruby/object:Gem::Dependency
33
+ name: bundler
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ type: :development
54
+ prerelease: false
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ description: DNScaster client for Ruby.
61
+ email:
62
+ - hello@notioneer.com
63
+ executables: []
64
+ extensions: []
65
+ extra_rdoc_files: []
66
+ files:
67
+ - ".gitignore"
68
+ - Gemfile
69
+ - LICENSE
70
+ - README.md
71
+ - Rakefile
72
+ - dnscaster.gemspec
73
+ - lib/dnscaster.rb
74
+ - lib/dnscaster/api/api_config.rb
75
+ - lib/dnscaster/api/log_subscriber.rb
76
+ - lib/dnscaster/api/railtie.rb
77
+ - lib/dnscaster/api/version.rb
78
+ - lib/dnscaster/boundary.rb
79
+ - lib/dnscaster/domain_provider.rb
80
+ - lib/dnscaster/host.rb
81
+ - lib/dnscaster/instance.rb
82
+ - lib/dnscaster/ip_monitor.rb
83
+ - lib/dnscaster/nameserver.rb
84
+ - lib/dnscaster/nameserver_set.rb
85
+ - lib/dnscaster/region.rb
86
+ - lib/dnscaster/vanity_set.rb
87
+ - lib/dnscaster/zone.rb
88
+ homepage: https://dnscaster.com/
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '2.7'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubygems_version: 3.6.9
107
+ specification_version: 4
108
+ summary: DNScaster client for Ruby
109
+ test_files: []