Class: Fog::Compute::Google::BackendService
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Google::BackendService
- Defined in:
- lib/fog/google/models/compute/backend_service.rb
Constant Summary collapse
- RUNNING_STATE =
"READY"
Instance Method Summary collapse
- #add_backend(backend) ⇒ Object
- #destroy(async = false) ⇒ Object
- #get_health ⇒ Object
- #ready? ⇒ Boolean
- #reload ⇒ Object
- #save ⇒ Object
Instance Method Details
#add_backend(backend) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/fog/google/models/compute/backend_service.rb', line 56 def add_backend backend # ensure backend is an array of hashes backend = [backend] unless backend.class == Array backend.map! { |resource| resource.class == String ? { 'group' => resource }: resource } service.add_backend_service_backends(self, backend) reload end |
#destroy(async = false) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fog/google/models/compute/backend_service.rb', line 40 def destroy(async=false) requires :name operation = service.delete_backend_service(name) unless async Fog.wait_for do operation.body["status"] == "DONE" end end operation end |
#get_health ⇒ Object
52 53 54 |
# File 'lib/fog/google/models/compute/backend_service.rb', line 52 def get_health service.get_backend_service_health self end |
#ready? ⇒ Boolean
64 65 66 67 68 69 70 71 |
# File 'lib/fog/google/models/compute/backend_service.rb', line 64 def ready? begin service.get_backend_service(self.name) true rescue Fog::Errors::NotFound false end end |
#reload ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/fog/google/models/compute/backend_service.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 |
#save ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fog/google/models/compute/backend_service.rb', line 21 def save requires :name, :health_checks = { 'description' => description, 'backends' => backends, 'fingerprint' => fingerprint, 'healthChecks' => health_checks, 'port' => port, 'protocol' => protocol, 'timeoutSec' => timeout_sec } data = service.insert_backend_service(name, ).body operation = Fog::Compute::Google::Operations.new(:service => service).get(data['name']) operation.wait_for { !pending? } reload end |