Sha256: f83f2790f5807e5a71f7c33345c503c4f42d8f58633a0a3c2da4f43d41fdef95

Contents?: true

Size: 1.95 KB

Versions: 10

Compression:

Stored size: 1.95 KB

Contents

module Fog
  module Compute
    class Google
      ##
      # Represents a Network resource
      #
      # @see https://developers.google.com/compute/docs/reference/latest/networks
      class Network < Fog::Model
        identity :name

        attribute :auto_create_subnetworks, aliases => "autoCreateSubnetworks"
        attribute :creation_timestamp, aliases => "creationTimestamp"
        attribute :description
        attribute :gateway_ipv4, aliases => %w(gateway_i_pv4 gatewayIPv4)
        attribute :ipv4_range, aliases => %w(i_pv4_range IPv4Range)
        attribute :id
        attribute :kind
        attribute :peerings
        attribute :routing_config, aliases => "routingConfig"
        attribute :self_link, aliases => "selfLink"
        attribute :subnetworks

        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

        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

        # Returns a ready API structure for insert_instance, used in insert_server request.
        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
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fog-google-1.3.3 lib/fog/compute/google/models/network.rb
fog-google-1.3.2 lib/fog/compute/google/models/network.rb
fog-google-1.3.1 lib/fog/compute/google/models/network.rb
fog-google-1.3.0 lib/fog/compute/google/models/network.rb
fog-google-1.2.2 lib/fog/compute/google/models/network.rb
fog-google-1.2.1 lib/fog/compute/google/models/network.rb
fog-google-1.2.0 lib/fog/compute/google/models/network.rb
fog-google-1.1.0 lib/fog/compute/google/models/network.rb
fog-google-1.0.1 lib/fog/compute/google/models/network.rb
fog-google-1.0.0 lib/fog/compute/google/models/network.rb