class Fog::Compute::Google::HttpHealthCheck

Constants

MODIFIABLE_FIELDS
RUNNING_STATE

Public Instance Methods

create(opts) click to toggle source
# File lib/fog/compute/google/models/http_health_check.rb, line 50
def create(opts)
  requires :name

  data = service.insert_http_health_check(name, opts)
  operation = Fog::Compute::Google::Operations.new(service: service)
                                              .get(data.name, data.zone)
  operation.wait_for { ready? }
  reload
end
destroy(async = true) click to toggle source
# File lib/fog/compute/google/models/http_health_check.rb, line 69
def destroy(async = true)
  requires :name
  data = service.delete_http_health_check(name)
  operation = Fog::Compute::Google::Operations.new(:service => service)
                                              .get(data.name)
  operation.wait_for { ready? } unless async
  operation
end
ready?() click to toggle source
# File lib/fog/compute/google/models/http_health_check.rb, line 78
def ready?
  service.get_http_health_check(name)
  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/http_health_check.rb, line 86
def reload
  requires :name

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

  new_attributes = data.attributes
  merge_attributes(new_attributes)
  self
end
save() click to toggle source
# File lib/fog/compute/google/models/http_health_check.rb, line 33
def save
  opts = {
    :name => name,
    :check_interval_sec => check_interval_sec,
    :creation_timestamp => creation_timestamp,
    :description => description,
    :healthy_threshold => healthy_threshold,
    :host => host,
    :port => port,
    :request_path => request_path,
    :timeout_sec => timeout_sec,
    :unhealthy_threshold => unhealthy_threshold
  }

  id.nil? ? create(opts) : update(opts)
end
update(opts) click to toggle source
# File lib/fog/compute/google/models/http_health_check.rb, line 60
def update(opts)
  requires :name
  data = service.update_http_health_check(name, opts)
  operation = Fog::Compute::Google::Operations.new(service: service)
                                              .get(data.name, data.zone)
  operation.wait_for { ready? }
  reload
end