Class: RecordStore::Provider::GoogleCloudDNS
- Inherits:
-
RecordStore::Provider
- Object
- RecordStore::Provider
- RecordStore::Provider::GoogleCloudDNS
- Defined in:
- lib/record_store/provider/google_cloud_dns.rb
Class Method Summary collapse
- .apply_changeset(changeset, _stdout = nil) ⇒ Object
-
.retrieve_current_records(zone:, stdout: $stdout) ⇒ Object
returns an array of Record objects that match the records which exist in the provider.
-
.zones ⇒ Object
Returns an array of the zones managed by provider as strings.
Methods inherited from RecordStore::Provider
build_zone, empty_non_terminal_over_wildcard?, freezable?, provider_for, record_types, supports_alias?, thawable?, to_s
Class Method Details
.apply_changeset(changeset, _stdout = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/record_store/provider/google_cloud_dns.rb', line 6 def apply_changeset(changeset, _stdout = nil) zone = session.zone(convert_to_name(changeset.zone)) deletions = convert_records_to_gcloud_record_sets(zone, changeset.current_records) additions = convert_records_to_gcloud_record_sets(zone, changeset.desired_records) # The Google API library will handle applying the changeset transactionally zone.update(additions, deletions) end |
.retrieve_current_records(zone:, stdout: $stdout) ⇒ Object
returns an array of Record objects that match the records which exist in the provider
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/record_store/provider/google_cloud_dns.rb', line 17 def retrieve_current_records(zone:, stdout: $stdout) gcloud_record_sets = session.zone(convert_to_name(zone)).records records = gcloud_record_sets.map do |record_set| next if record_set.type == 'SOA' # Unroll each record set into multiple records record_set.data.map do |record| record_set_member = record_set.dup record_set_member.data = [record] build_from_api(record_set_member) rescue StandardError stdout.puts "Cannot build record: #{record}" end end # We need to filter out for nil records (i.e. since skip the SOA record) records.flatten.compact end |
.zones ⇒ Object
Returns an array of the zones managed by provider as strings
38 39 40 |
# File 'lib/record_store/provider/google_cloud_dns.rb', line 38 def zones session.zones.map { |zone| zone.gapi.dns_name } end |