Class: Fog::Compute::Google::TargetHttpProxy

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/compute/google/models/target_http_proxy.rb

Constant Summary collapse

RUNNING_STATE =
"READY".freeze

Instance Method Summary collapse

Instance Method Details

#destroy(async = true) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/compute/google/models/target_http_proxy.rb', line 28

def destroy(async = true)
  requires :name
  operation = service.delete_target_http_proxy(name)
  unless async
    # wait until "DONE" to ensure the operation doesn't fail, raises
    # exception on error
    Fog.wait_for do
      operation.body["status"] == "DONE"
    end
  end
  operation
end

#ready?Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
# File 'lib/fog/compute/google/models/target_http_proxy.rb', line 46

def ready?
  service.get_target_http_proxy(name)
  true
rescue Fog::Errors::NotFound
  false
end

#reloadObject



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fog/compute/google/models/target_http_proxy.rb', line 53

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

#saveObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/compute/google/models/target_http_proxy.rb', line 14

def save
  requires :name

  options = {
    "description" => description,
    "urlMap" => url_map
  }

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

#set_url_map(url_map) ⇒ Object



41
42
43
44
# File 'lib/fog/compute/google/models/target_http_proxy.rb', line 41

def set_url_map(url_map)
  service.set_target_http_proxy_url_map(self, url_map)
  reload
end