class Fog::Compute::Google::TargetInstance

Constants

RUNNING_STATE

Public Instance Methods

destroy(async = true) click to toggle source
# File lib/fog/compute/google/models/target_instance.rb, line 33
def destroy(async = true)
  requires :name, :zone
  data = service.delete_target_instance(name, zone)
  operation = Fog::Compute::Google::Operations.new(:service => service)
                                              .get(data.name, data.zone)
  operation.wait_for { ready? } unless async
  operation
end
ready?() click to toggle source
# File lib/fog/compute/google/models/target_instance.rb, line 42
def ready?
  service.get_target_instance(name, zone)
  true
rescue ::Google::Apis::ClientError => e
  raise e unless e.status_code == 404
  false
end
reload() click to toggle source
# File lib/fog/compute/google/models/target_instance.rb, line 50
def reload
  requires :name, :zone

  begin
    data = collection.get(name, zone)
    new_attributes = data.attributes
    merge_attributes(new_attributes)
    return self
  rescue Excon::Errors::SocketError
    return nil
  end
end
save() click to toggle source
# File lib/fog/compute/google/models/target_instance.rb, line 16
def save
  requires :identity, :zone

  options = {
    :description => description,
    :zone => zone,
    :nat_policy => nat_policy,
    :instance => instance
  }

  data = service.insert_target_instance(identity, zone, options)
  operation = Fog::Compute::Google::Operations.new(:service => service)
                                              .get(data.name, data.zone)
  operation.wait_for { ready? }
  reload
end