Sha256: b565d3cd19d9262b217cbc322b8fc90415d861606bc3c074a661305e879a49f5

Contents?: true

Size: 926 Bytes

Versions: 15

Compression:

Stored size: 926 Bytes

Contents

require "fog/core/collection"
require "fog/google/models/sql/instance"

module Fog
  module Google
    class SQL
      class Instances < Fog::Collection
        model Fog::Google::SQL::Instance

        ##
        # Lists all instance
        #
        # @return [Array<Fog::Google::SQL::Instance>] List of instance resources
        def all
          data = service.list_instances.to_h[:items] || []
          load(data)
        end

        ##
        # Retrieves an instance
        #
        # @param [String] instance_id Instance ID
        # @return [Fog::Google::SQL::Instance] Instance resource
        def get(instance_id)
          instance = service.get_instance(instance_id).to_h
          if instance
            new(instance)
          end
        rescue ::Google::Apis::ClientError => e
          raise e unless e.status_code == 404 || e.status_code == 403
          nil
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fog-google-1.7.1 lib/fog/google/models/sql/instances.rb
fog-google-1.7.0 lib/fog/google/models/sql/instances.rb
fog-google-1.6.0 lib/fog/google/models/sql/instances.rb
fog-google-1.5.0 lib/fog/google/models/sql/instances.rb
fog-google-1.4.0 lib/fog/google/models/sql/instances.rb
fog-google-1.3.3 lib/fog/google/models/sql/instances.rb
fog-google-1.3.2 lib/fog/google/models/sql/instances.rb
fog-google-1.3.1 lib/fog/google/models/sql/instances.rb
fog-google-1.3.0 lib/fog/google/models/sql/instances.rb
fog-google-1.2.2 lib/fog/google/models/sql/instances.rb
fog-google-1.2.1 lib/fog/google/models/sql/instances.rb
fog-google-1.2.0 lib/fog/google/models/sql/instances.rb
fog-google-1.1.0 lib/fog/google/models/sql/instances.rb
fog-google-1.0.1 lib/fog/google/models/sql/instances.rb
fog-google-1.0.0 lib/fog/google/models/sql/instances.rb