class Fog::Compute::Google::TargetPool

Constants

RUNNING_STATE

Public Instance Methods

add_health_check(health_check) click to toggle source
# File lib/fog/google/models/compute/target_pool.rb, line 66
def add_health_check health_check
  health_check = health_check.self_link unless health_check.class == String
  service.add_target_pool_health_checks(self, [health_check])
  reload
end
add_instance(instance) click to toggle source
# File lib/fog/google/models/compute/target_pool.rb, line 54
def add_instance instance
  instance = instance.self_link unless instance.class == String
  service.add_target_pool_instances(self, [instance])
  reload
end
destroy(async=true) click to toggle source
# File lib/fog/google/models/compute/target_pool.rb, line 40
def destroy(async=true)
  requires :name, :region
  operation = service.delete_target_pool(name, region)
  if not async
    # wait until "DONE" to ensure the operation doesn't fail, raises
    # exception on error
    Fog.wait_for do
      operation = service.get_region_operation(region, operation.body["name"])
      operation.body["status"] == "DONE"
    end
  end
  operation
end
get_health() click to toggle source
# File lib/fog/google/models/compute/target_pool.rb, line 78
def get_health
  service.get_target_pool_health self
end
ready?() click to toggle source
# File lib/fog/google/models/compute/target_pool.rb, line 82
def ready?
  begin
    service.get_target_pool(self.name, self.region)
    true
  rescue Fog::Errors::NotFound
    false
  end
end
reload() click to toggle source
# File lib/fog/google/models/compute/target_pool.rb, line 91
def reload
  requires :name, :region

  return unless data = begin
    collection.get(name, region)
  rescue Excon::Errors::SocketError
    nil
  end

  new_attributes = data.attributes
  merge_attributes(new_attributes)
  self
end
remove_health_check(health_check) click to toggle source
# File lib/fog/google/models/compute/target_pool.rb, line 72
def remove_health_check health_check
  health_check = health_check.self_link unless health_check.class == String
  service.remove_target_pool_health_checks(self, [health_check])
  reload
end
remove_instance(instance) click to toggle source
# File lib/fog/google/models/compute/target_pool.rb, line 60
def remove_instance instance
  instance = instance.self_link unless instance.class == String
  service.remove_target_pool_instances(self, [instance])
  reload
end
save() click to toggle source
# File lib/fog/google/models/compute/target_pool.rb, line 21
def save
  requires :name, :region

  options = {
    'description' => description,
    'region' => region,
    'healthChecks' => health_checks,
    'instances' => instances,
    'sessionAffinity' => session_affinity,
    'failoverRatio' => failover_ratio,
    'backupPool' => backup_pool
  }

  data = service.insert_target_pool(name, region, options).body
  operation = Fog::Compute::Google::Operations.new(:service => service).get(data['name'], nil, data['region'])
  operation.wait_for { !pending? }
  reload
end