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
|
module Fog
module Compute
class Google
##
# Represents an Address resource
#
# @see https://developers.google.com/compute/docs/reference/latest/addresses
class GlobalAddress < Fog::Model
identity :name
attribute :address
attribute :creation_timestamp, :aliases => "creationTimestamp"
attribute :description
attribute :id
attribute :ip_version, :aliases => "ipVersion"
attribute :kind
attribute :self_link, :aliases => "selfLink"
attribute :status
attribute :users
IN_USE_STATE = "IN_USE".freeze
RESERVED_STATE = "RESERVED".freeze
def save
requires :identity
data = service.insert_global_address(identity, attributes)
operation = Fog::Compute::Google::Operations.new(:service => service)
.get(data.name)
operation.wait_for { ready? }
reload
end
def destroy(async = true)
requires :identity
data = service.delete_global_address(identity)
operation = Fog::Compute::Google::Operations.new(:service => service)
.get(data.name)
operation.wait_for { ready? } unless async
operation
end
def reload
requires :identity
data = collection.get(identity)
merge_attributes(data.attributes)
self
end
def in_use?
status == IN_USE_STATE
end
end
end
end
end
|