Sha256: 8629ccdc115c1058e0b917ff48e3ef1ba01535b64c2f4d73978f47e155231dd9

Contents?: true

Size: 1.55 KB

Versions: 41

Compression:

Stored size: 1.55 KB

Contents

module Fog
  module DNS
    class Google
      class Records < Fog::Collection
        model Fog::DNS::Google::Record

        attribute :zone

        ##
        # Enumerates Resource Record Sets that have been created but not yet deleted
        #
        # @return [Array<Fog::DNS::Google::Record>] List of Resource Record Sets resources
        def all
          requires :zone

          data = service.list_resource_record_sets(zone.identity)
                        .to_h[:rrsets] || []
          load(data)
        rescue ::Google::Apis::ClientError => e
          raise e unless e.status_code == 404
          []
        end

        ##
        # Fetches the representation of an existing Resource Record Set
        #
        # @param [String] name Resource Record Set name
        # @param [String] type Resource Record Set type
        # @return [Fog::DNS::Google::Record] Resource Record Set resource
        def get(name, type)
          requires :zone

          records = service.list_resource_record_sets(zone.identity, :name => name, :type => type)
                           .to_h[:rrsets] || []
          records.any? ? new(records.first) : nil
        rescue ::Google::Apis::ClientError => e
          raise e unless e.status_code == 404
          nil
        end

        ##
        # Creates a new instance of a Resource Record Set
        #
        # @return [Fog::DNS::Google::Record] Resource Record Set resource
        def new(attributes = {})
          requires :zone

          super({ :zone => zone }.merge!(attributes))
        end
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
fog-google-1.24.1 lib/fog/dns/google/models/records.rb
fog-google-1.24.0 lib/fog/dns/google/models/records.rb
fog-google-1.23.0 lib/fog/dns/google/models/records.rb
fog-google-1.22.0 lib/fog/dns/google/models/records.rb
fog-google-1.21.1 lib/fog/dns/google/models/records.rb
fog-google-1.21.0 lib/fog/dns/google/models/records.rb
fog-google-1.20.0 lib/fog/dns/google/models/records.rb
fog-google-1.19.0 lib/fog/dns/google/models/records.rb
fog-google-1.18.0 lib/fog/dns/google/models/records.rb
fog-google-1.17.0 lib/fog/dns/google/models/records.rb
fog-google-1.16.1 lib/fog/dns/google/models/records.rb
fog-google-1.16.0 lib/fog/dns/google/models/records.rb
fog-google-1.15.0 lib/fog/dns/google/models/records.rb
fog-google-1.14.0 lib/fog/dns/google/models/records.rb
gitlab-fog-google-1.14.0 lib/fog/dns/google/models/records.rb
fog-google-1.13.0 lib/fog/dns/google/models/records.rb
gitlab-fog-google-1.13.0 lib/fog/dns/google/models/records.rb
fog-google-1.12.1 lib/fog/dns/google/models/records.rb
fog-google-1.12.0 lib/fog/dns/google/models/records.rb
fog-google-1.11.0 lib/fog/dns/google/models/records.rb