Class: Fog::Google::SQL::Operations

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

Instance Method Summary collapse

Instance Method Details

#all(instance_id) ⇒ Array<Fog::Google::SQL::Operation>

Lists all instance operations that have been performed on the given instance

Parameters:

  • instance_id (String)

    Instance ID

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/google/models/sql/operations.rb', line 15

def all(instance_id)
  data = []
  begin
    data = service.list_operations(instance_id).items || []
    data = data.map(&:to_h)
  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 an empty Array
    raise e unless e.message == "The client is not authorized to make this request."
  end

  load(data)
end

#get(operation_id) ⇒ Fog::Google::SQL::Operation

Retrieves an instance operation that has been performed on an instance

Parameters:

  • operation_id (String)

    Instance operation ID

Returns:



34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/google/models/sql/operations.rb', line 34

def get(operation_id)
  if operation = service.get_operation(operation_id).to_h
    new(operation)
  end
rescue ::Google::Apis::ClientError => 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
  raise e unless e.status_code == 404 || e.status_code == 403
  nil
end