Class: Fog::Google::SQL::User

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/google/models/sql/user.rb

Overview

Represents a database user in a Cloud SQL instance.

Instance Method Summary collapse

Instance Method Details

#destroy(async: true) ⇒ Object


18
19
20
21
22
23
24
25
# File 'lib/fog/google/models/sql/user.rb', line 18

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

  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

#save(password: nil) ⇒ Object


27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fog/google/models/sql/user.rb', line 27

def save(password: nil)
  requires :instance, :name

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

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