Sha256: 6e1ed8a8fdaf8d1babbf7465d8b947bdcf18123bdd05e8e0154e6c2aaff98d9d

Contents?: true

Size: 1.84 KB

Versions: 2

Compression:

Stored size: 1.84 KB

Contents

module Fog
  module VcloudDirector
    class Compute
      class Real
        # Delete an OrgVdcNetwork
        #
        # This operation is asynchronous and returns a task that you can
        # monitor to track the progress of the request.
        #
        # @param [String] id Object identifier of the OrgVdcNetwork.
        # @return [Excon::Response]
        #   * body<~Hash>:
        #
        # @raise [Fog::VcloudDirector::Compute::BadRequest]
        #
        # @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/DELETE-Network.html
        # @since vCloud API version 0.9
        def delete_network(id)
          request(
            :expects => 202,
            :method  => 'DELETE',
            :parser  => Fog::ToHashDocument.new,
            :path    => "admin/network/#{id}"
          )
        end
      end

      class Mock
        def delete_network(id)
          unless data[:networks][id]
            raise Fog::VcloudDirector::Compute::Forbidden.new(
              "No access to entity \"(com.vmware.vcloud.entity.orgVdcNetwork:#{id})\""
            )
          end

          owner = {
            :href => make_href("network/#{id}"),
            :type => 'application/vnd.vmware.vcloud.network+xml'
          }
          task_id = enqueue_task(
            "Deleting Network(#{id})", 'DeleteNetwork', owner,
            :on_success => lambda do
              data[:networks].delete(id)
            end
          )

          body = {
            :xmlns => xmlns,
            :xmlns_xsi => xmlns_xsi,
            :xsi_schemaLocation => xsi_schema_location,
          }.merge(task_body(task_id))

          Excon::Response.new(
            :status => 202,
            :headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
            :body => body
          )
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-vcloud-director-0.3.1 lib/fog/vcloud_director/requests/compute/delete_network.rb
fog-vcloud-director-0.3.0 lib/fog/vcloud_director/requests/compute/delete_network.rb