Class: Fog::Compute::Google::UrlMap

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

Constant Summary collapse

RUNNING_STATE =
"READY"

Instance Method Summary collapse

Instance Method Details

#add_host_rules(hostRules) ⇒ Object



53
54
55
56
57
# File 'lib/fog/compute/google/models/url_map.rb', line 53

def add_host_rules(hostRules)
  hostRules = [hostRules] unless hostRules.class == Array
  service.update_url_map(self, hostRules)
  reload
end

#add_path_matchers(pathMatchers, hostRules) ⇒ Object



59
60
61
62
63
64
# File 'lib/fog/compute/google/models/url_map.rb', line 59

def add_path_matchers(pathMatchers, hostRules)
  pathMatchers = [pathMatchers] unless pathMatchers.class == Array
  hostRules = [hostRules] unless hostRules.class == Array
  service.update_url_map(self, hostRules, pathMatchers)
  reload
end

#destroy(async = true) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/compute/google/models/url_map.rb', line 36

def destroy(async = true)
  requires :name

  operation = service.delete_url_map(name)
  unless async
    Fog.wait_for do
      operation = service.get_global_operation(operation.body["name"])
      operation.body["status"] == "DONE"
    end
  end
  operation
end

#ready?Boolean

Returns:

  • (Boolean)


66
67
68
69
70
71
# File 'lib/fog/compute/google/models/url_map.rb', line 66

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

#reloadObject



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/fog/compute/google/models/url_map.rb', line 73

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



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/compute/google/models/url_map.rb', line 18

def save
  requires :name, :default_service

  options = {
    "defaultService" => default_service,
    "description" => description,
    "fingerprint" => fingerprint,
    "hostRules" => host_rules,
    "pathMatchers" => path_matchers,
    "tests" => tests
  }

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

#validateObject



49
50
51
# File 'lib/fog/compute/google/models/url_map.rb', line 49

def validate
  service.validate_url_map self
end