Class: Fog::Compute::Google::Network

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

Overview

Represents a Network resource

Instance Method Summary collapse

Instance Method Details

#destroy(async = true) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/fog/compute/google/models/network.rb', line 30

def destroy(async = true)
  requires :identity

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

#get_as_interface_config(access_config = nil) ⇒ Object

Returns a ready API structure for insert_instance, used in insert_server request.



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

def get_as_interface_config(access_config = nil)
  network_interface = { "network" => self_link }
  network_interface["accessConfigs"] = [access_config] if access_config
  network_interface
end

#saveObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/fog/compute/google/models/network.rb', line 19

def save
  requires :identity, :ipv4_range

  data = service.insert_network(identity, ipv4_range, attributes)
  operation = Fog::Compute::Google::Operations.new(:service => service).get(data.body["name"])
  # Since network has no "state" we can query, we have to wait for the operation to finish
  # TODO: change back to async when there's a proper state API
  operation.wait_for { ready? }
  reload
end