Class: Fog::Google::SQL::Instances

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

Instance Method Summary collapse

Instance Method Details

#allArray<Fog::Google::SQL::Instance>

Lists all instance

Returns:



14
15
16
17
# File 'lib/fog/google/models/sql/instances.rb', line 14

def all
  data = service.list_instances.body['items'] || []
  load(data)
end

#get(instance_id) ⇒ Fog::Google::SQL::Instance

Retrieves an instance

Parameters:

  • instance_id (String)

    Instance ID

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/google/models/sql/instances.rb', line 24

def get(instance_id)
  if instance = service.get_instance(instance_id).body
    new(instance)
  end
rescue Fog::Errors::NotFound
  nil
rescue Fog::Errors::Error => e
  # Google SQL returns a 403 if we try to access a non-existing resource
  # The default behaviour in Fog is to return a nil
  return nil if e.message == 'The client is not authorized to make this request.'
  raise e
end