Sha256: 2a1b993daae29d953571e8e0eba70e25a5ac7f886a1ea0e4c8e27175e49feb2c

Contents?: true

Size: 1.26 KB

Versions: 41

Compression:

Stored size: 1.26 KB

Contents

module Fog
  module DNS
    class Google
      class Changes < Fog::Collection
        model Fog::DNS::Google::Change

        attribute :zone

        ##
        # Enumerates the list of Changes
        #
        # @return [Array<Fog::DNS::Google::Change>] List of Changes resources
        def all
          requires :zone

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

        ##
        # Fetches the representation of an existing Change
        #
        # @param [String] identity Change identity
        # @return [Fog::DNS::Google::Change] Change resource
        def get(identity)
          requires :zone
          if change = service.get_change(zone.identity, identity).to_h
            new(change)
          end
        rescue ::Google::Apis::ClientError => e
          raise e unless e.status_code == 404
          nil
        end

        ##
        # Creates a new instance of a Change
        #
        # @return [Fog::DNS::Google::Change] Change 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.0.0 lib/fog/dns/google/models/changes.rb