Sha256: b313f62d3c7366b2fa188360a1433d4d7e028704dc475e75e25d158129ad3683

Contents?: true

Size: 1.54 KB

Versions: 21

Compression:

Stored size: 1.54 KB

Contents

require "fog/core/model"

module Fog
  module Google
    class SQL
      ##
      # Represents a database user in a Cloud SQL instance.
      #
      # @see https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/users
      class User < Fog::Model
        attribute :name
        attribute :etag
        attribute :host
        attribute :instance
        attribute :kind
        attribute :project

        def destroy(async = true)
          requires :instance, :name, :host

          # TODO(2.0): Add a deprecation warning here, depending on the decision in #27
          # This is a compatibility fix leftover from breaking named parameter change
          if async.is_a?(Hash)
            async = async[:async]
          end

          resp = service.delete_user(instance, host, name)
          operation = Fog::Google::SQL::Operations.new(:service => service).get(resp.name)
          operation.wait_for { ready? } unless async
          operation
        end

        def save(password: nil)
          # TODO(2.0): make :host a required parameter
          # See: https://github.com/fog/fog-google/issues/462
          requires :instance, :name

          data = attributes
          data[:password] = password unless password.nil?
          if etag.nil?
            resp = service.insert_user(instance, data)
          else
            resp = service.update_user(instance, data)
          end

          operation = Fog::Google::SQL::Operations.new(:service => service).get(resp.name)
          operation.wait_for { ready? }
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

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