1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
require "fog/core/model"
module Fog
module Google
class SQL
##
# An Operation resource contains information about database instance operations
# such as create, delete, and restart
#
# @see https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/operations
class Operation < Fog::Model
identity :name
attribute :kind, :aliases => "kind"
attribute :self_link, :aliases => "selfLink"
attribute :target_project, :aliases => "targetProject"
attribute :target_id, :aliases => "targetId"
attribute :target_link, :aliases => "targetLink"
attribute :name, :aliases => "name"
attribute :operation_type, :aliases => "operationType"
attribute :status, :aliases => "status"
attribute :user, :aliases => "user"
attribute :insert_time, :aliases => "insertTime"
attribute :start_time, :aliases => "startTime"
attribute :end_time, :aliases => "endTime"
attribute :error, :aliases => "error"
attribute :import_context, :aliases => "importContext"
attribute :export_context, :aliases => "exportContext"
attribute :sql_export_options, :aliases => "sqlExportOptions"
attribute :csv_export_options, :aliases => "csvExportOptions"
DONE_STATE = "DONE".freeze
PENDING_STATE = "PENDING".freeze
RUNNING_STATE = "RUNNING".freeze
UNKNOWN_STATE = "UNKNOWN".freeze
##
# Checks if the instance operation is pending
#
# @return [Boolean] True if the operation is pending; False otherwise
def pending?
status == PENDING_STATE
end
##
# Checks if the instance operation is done
#
# @return [Boolean] True if the operation is done; False otherwise
def ready?
status == DONE_STATE
end
##
# Reloads an instance operation
#
# @return [Fog::Google::SQL::Operation] Instance operation resource
def reload
requires :identity
data = collection.get(identity)
merge_attributes(data.attributes)
self
end
end
end
end
end
|