Sha256: 63ef6a8340769f774bdbe62854b9a2858373b8004e641fed9b08a045e926c80e

Contents?: true

Size: 1.95 KB

Versions: 47

Compression:

Stored size: 1.95 KB

Contents

module Fog
  module Network
    class AzureRM
      # Real class for Network Request
      class Real
        def detach_network_security_group_from_subnet(resource_group, subnet_name, virtual_network_name, address_prefix, route_table_id)
          msg = "Detaching Network Security Group from Subnet: #{subnet_name}"
          Fog::Logger.debug msg
          subnet = get_subnet_object_for_detach_network_security_group(address_prefix, route_table_id)
          begin
            subnet = @network_client.subnets.create_or_update(resource_group, virtual_network_name, subnet_name, subnet)
          rescue MsRestAzure::AzureOperationError => e
            raise_azure_exception(e, msg)
          end
          Fog::Logger.debug 'Network Security Group detached successfully.'
          subnet
        end

        private

        def get_subnet_object_for_detach_network_security_group(address_prefix, route_table_id)
          subnet = Azure::ARM::Network::Models::Subnet.new
          route_table = Azure::ARM::Network::Models::RouteTable.new

          route_table.id = route_table_id
          subnet.address_prefix = address_prefix
          subnet.route_table = route_table unless route_table_id.nil?
          subnet.network_security_group = nil
          subnet
        end
      end

      # Mock class for Network Request
      class Mock
        def detach_network_security_group_from_subnet(*)
          subnet = {
            'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-rg/providers/Microsoft.Network/virtualNetworks/fog-vnet/subnets/fog-subnet',
            'properties' =>
              {
                'addressPrefix' => '10.1.0.0/24',
                'provisioningState' => 'Succeeded'
              },
            'name' => 'fog-subnet'
          }
          subnet_mapper = Azure::ARM::Network::Models::Subnet.mapper
          @network_client.deserialize(subnet_mapper, subnet, 'result.body')
        end
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 4 rubygems

Version Path
fog-azure-rm-0.6.0 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
fog-azure-rm-0.5.3 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
fog-azure-rm-0.5.2 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
far-gem-0.5.6 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
fog-azure-rm-0.5.1 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
far-gem-0.5.5 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
fog-azure-rm-0.5.0 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
far-gem-0.5.4 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
far-gem-0.5.3 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
fog-azure-rm-0.4.9 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
far-gem-0.5.2 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
fog-azure-rm-0.4.8 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
fog-azure-rm-0.4.7 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
fog-azure-rm-0.4.6 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
fog-azure-rm-0.4.5 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
fog-azure-rm-temp-0.0.5 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
fog-azure-rm-0.4.4 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
fog-azure-rm-0.4.3 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
far-gem-0.5.1 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb
fog-azure-rm-0.4.2 lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb