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



25
26
27
28
29
30
31
32
33
# File 'lib/fog/compute/google/models/target_http_proxy.rb', line 25

def destroy(async = true)
  requires :identity

  data = service.delete_target_http_proxy(identity)
  operation = Fog::Compute::Google::Operations.new(:service => service)
                                              .get(data.name)
  operation.wait_for { ready? } unless async
  operation
end

#ready?Boolean

Returns:

  • (Boolean)


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

def ready?
  requires :identity

  service.get_target_http_proxy(identity)
  true
rescue ::Google::Apis::ClientError => e
  raise e unless e.status_code == 404
  false
end

#reloadObject



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

def reload
  requires :identity

  return unless data = begin
    collection.get(identity)
  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
# File 'lib/fog/compute/google/models/target_http_proxy.rb', line 14

def save
  requires :identity
  data = service.insert_target_http_proxy(
    identity, :description => description, :url_map => url_map
  )
  operation = Fog::Compute::Google::Operations.new(:service => service)
                                              .get(data.name)
  operation.wait_for { ready? }
  reload
end

#set_url_map(url_map, async = true) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/fog/compute/google/models/target_http_proxy.rb', line 35

def set_url_map(url_map, async = true)
  requires :identity

  data = service.set_target_http_proxy_url_map(identity, url_map)
  operation = Fog::Compute::Google::Operations.new(:service => service)
                                              .get(data.name)
  operation.wait_for { ready? } unless async
  reload
end