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


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

def destroy(async = true)
  requires :identity

  data = service.delete_network(identity)
  operation = Fog::Compute::Google::Operations.new(:service => service)
                                              .get(data.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.


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

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

#saveObject


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

def save
  requires :identity, :ipv4_range

  data = service.insert_network(identity, attributes)
  operation = Fog::Compute::Google::Operations.new(:service => service)
                                              .get(data.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