Sha256: 259f02774721f39d2396445117ec35df27a28db458916f4e185c505baecb9160

Contents?: true

Size: 1.94 KB

Versions: 1

Compression:

Stored size: 1.94 KB

Contents

module Fog
  module Network
    class AzureRM
      # Real class for Network Request
      class Real
        def create_public_ip(resource_group, name, location, public_ip_allocation_method)
          Fog::Logger.debug "Creating PublicIP #{name} in Resource Group #{resource_group}."
          public_ip = Azure::ARM::Network::Models::PublicIPAddress.new
          public_ip.name = name
          public_ip.location = location
          public_ip.public_ipallocation_method = public_ip_allocation_method
          begin
            public_ip = @network_client.public_ipaddresses.create_or_update(resource_group, name, public_ip)
          rescue MsRestAzure::AzureOperationError => e
            raise_azure_exception(e, "Creating PublicIP #{name} in Resource Group #{resource_group}")
          end
          Fog::Logger.debug "PublicIP #{name} Created Successfully!"
          public_ip
        end
      end

      # Mock class for Network Request
      class Mock
        def create_public_ip(resource_group, name, location, public_ip_allocation_method)
          public_ip = {
            'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/publicIPAddresses/#{name}",
            'name' => name,
            'type' => 'Microsoft.Network/publicIPAddresses',
            'location' => location,
            'properties' =>
              {
                'publicIPAllocationMethod' => public_ip_allocation_method,
                'ipAddress' => '13.91.253.67',
                'idleTimeoutInMinutes' => 4,
                'resourceGuid' => '767b1955-94de-433c-8e4a-ea0ad25e8d0c',
                'provisioningState' => 'Succeeded'
              }
          }
          public_ip_mapper = Azure::ARM::Network::Models::PublicIPAddress.mapper
          @network_client.deserialize(public_ip_mapper, public_ip, 'result.body')
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-azure-rm-0.0.5 lib/fog/azurerm/requests/network/create_public_ip.rb