コード例 #1
0
        public virtual ServiceGeneratevirtualwanvpnserverconfigurationvpnprofileOperation StartGeneratevirtualwanvpnserverconfigurationvpnprofile(string resourceGroupName, string virtualWANName, VirtualWanVpnProfileParameters vpnClientParams, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (virtualWANName == null)
            {
                throw new ArgumentNullException(nameof(virtualWANName));
            }
            if (vpnClientParams == null)
            {
                throw new ArgumentNullException(nameof(vpnClientParams));
            }

            using var scope = _clientDiagnostics.CreateScope("ServiceOperations.StartGeneratevirtualwanvpnserverconfigurationvpnprofile");
            scope.Start();
            try
            {
                var originalResponse = RestClient.Generatevirtualwanvpnserverconfigurationvpnprofile(resourceGroupName, virtualWANName, vpnClientParams, cancellationToken);
                return(new ServiceGeneratevirtualwanvpnserverconfigurationvpnprofileOperation(_clientDiagnostics, _pipeline, RestClient.CreateGeneratevirtualwanvpnserverconfigurationvpnprofileRequest(resourceGroupName, virtualWANName, vpnClientParams).Request, originalResponse));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
コード例 #2
0
 /// <summary>
 /// Generates a unique VPN profile for P2S clients for VirtualWan and
 /// associated VpnServerConfiguration combination in the specified resource
 /// group.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The resource group name.
 /// </param>
 /// <param name='virtualWANName'>
 /// The name of the VirtualWAN whose associated VpnServerConfigurations is
 /// needed.
 /// </param>
 /// <param name='vpnClientParams'>
 /// Parameters supplied to the generate VirtualWan VPN profile generation
 /// operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <VpnProfileResponse> BeginGeneratevirtualwanvpnserverconfigurationvpnprofileAsync(this INetworkManagementClient operations, string resourceGroupName, string virtualWANName, VirtualWanVpnProfileParameters vpnClientParams, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginGeneratevirtualwanvpnserverconfigurationvpnprofileWithHttpMessagesAsync(resourceGroupName, virtualWANName, vpnClientParams, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
コード例 #3
0
        public virtual VirtualWANGeneratevirtualwanvpnserverconfigurationvpnprofileOperation Generatevirtualwanvpnserverconfigurationvpnprofile(bool waitForCompletion, VirtualWanVpnProfileParameters vpnClientParams, CancellationToken cancellationToken = default)
        {
            if (vpnClientParams == null)
            {
                throw new ArgumentNullException(nameof(vpnClientParams));
            }

            using var scope = _defaultClientDiagnostics.CreateScope("VirtualWAN.Generatevirtualwanvpnserverconfigurationvpnprofile");
            scope.Start();
            try
            {
                var response  = _defaultRestClient.Generatevirtualwanvpnserverconfigurationvpnprofile(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, vpnClientParams, cancellationToken);
                var operation = new VirtualWANGeneratevirtualwanvpnserverconfigurationvpnprofileOperation(_defaultClientDiagnostics, Pipeline, _defaultRestClient.CreateGeneratevirtualwanvpnserverconfigurationvpnprofileRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, vpnClientParams).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
コード例 #4
0
        public virtual ArmOperation <VpnProfileResponse> Generatevirtualwanvpnserverconfigurationvpnprofile(WaitUntil waitUntil, VirtualWanVpnProfileParameters vpnClientParams, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(vpnClientParams, nameof(vpnClientParams));

            using var scope = _defaultClientDiagnostics.CreateScope("VirtualWan.Generatevirtualwanvpnserverconfigurationvpnprofile");
            scope.Start();
            try
            {
                var response  = _defaultRestClient.Generatevirtualwanvpnserverconfigurationvpnprofile(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, vpnClientParams, cancellationToken);
                var operation = new NetworkArmOperation <VpnProfileResponse>(new VpnProfileResponseOperationSource(), _defaultClientDiagnostics, Pipeline, _defaultRestClient.CreateGeneratevirtualwanvpnserverconfigurationvpnprofileRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, vpnClientParams).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
コード例 #5
0
 /// <summary>
 /// Generates a unique VPN profile for P2S clients for VirtualWan and
 /// associated VpnServerConfiguration combination in the specified resource
 /// group.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The resource group name.
 /// </param>
 /// <param name='virtualWANName'>
 /// The name of the VirtualWAN whose associated VpnServerConfigurations is
 /// needed.
 /// </param>
 /// <param name='vpnClientParams'>
 /// Parameters supplied to the generate VirtualWan VPN profile generation
 /// operation.
 /// </param>
 public static VpnProfileResponse BeginGeneratevirtualwanvpnserverconfigurationvpnprofile(this INetworkManagementClient operations, string resourceGroupName, string virtualWANName, VirtualWanVpnProfileParameters vpnClientParams)
 {
     return(operations.BeginGeneratevirtualwanvpnserverconfigurationvpnprofileAsync(resourceGroupName, virtualWANName, vpnClientParams).GetAwaiter().GetResult());
 }
コード例 #6
0
        public async Task <string> GenerateVirtualWanVpnProfileAsync(string resourceGroupName, string virtualWanName, VirtualWanVpnProfileParameters parameters,
                                                                     CancellationToken cancellationToken = default(CancellationToken))
        {
            string baseUrl    = NetworkManagementClient.BaseUri.ToString();
            string apiVersion = "2019-08-01";

            // Construct URL
            var url = new Uri(new Uri(baseUrl + (baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/" +
                              "providers/Microsoft.Network/virtualWans/{virtualWanName}/generatevpnprofile").ToString();

            url  = url.Replace("{resourceGroupName}", Uri.EscapeDataString(resourceGroupName));
            url  = url.Replace("{virtualWanName}", Uri.EscapeDataString(virtualWanName));
            url  = url.Replace("{subscriptionId}", Uri.EscapeDataString(NetworkManagementClient.SubscriptionId));
            url += "?" + string.Join("&", string.Format("api-version={0}", Uri.EscapeDataString(apiVersion)));

            if (parameters == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
            }

            AzureOperationResponse <string> result = await this.ExecuteOperationWithHttpMessagesAsync(resourceGroupName, virtualWanName, parameters, url, apiVersion, null, cancellationToken).ConfigureAwait(false);

            return(result.Body);
        }
コード例 #7
0
 public string GenerateVirtualWanVpnProfile(string resourceGroupName, string virtualWanName, VirtualWanVpnProfileParameters parameters)
 {
     return(Task.Factory.StartNew(() => GenerateVirtualWanVpnProfileAsync(resourceGroupName, virtualWanName, parameters)).Unwrap().GetAwaiter().GetResult());
 }
コード例 #8
0
        public async virtual Task <NetworkManagementGeneratevirtualwanvpnserverconfigurationvpnprofileOperation> GeneratevirtualwanvpnserverconfigurationvpnprofileAsync(VirtualWanVpnProfileParameters vpnClientParams, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (vpnClientParams == null)
            {
                throw new ArgumentNullException(nameof(vpnClientParams));
            }

            using var scope = _clientDiagnostics.CreateScope("VirtualWAN.Generatevirtualwanvpnserverconfigurationvpnprofile");
            scope.Start();
            try
            {
                var response = await _restClient.GeneratevirtualwanvpnserverconfigurationvpnprofileAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, vpnClientParams, cancellationToken).ConfigureAwait(false);

                var operation = new NetworkManagementGeneratevirtualwanvpnserverconfigurationvpnprofileOperation(_clientDiagnostics, Pipeline, _restClient.CreateGeneratevirtualwanvpnserverconfigurationvpnprofileRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, vpnClientParams).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
コード例 #9
0
        public async Task <Response> GenerateAsync(string resourceGroupName, string virtualWANName, VirtualWanVpnProfileParameters vpnClientParams, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (virtualWANName == null)
            {
                throw new ArgumentNullException(nameof(virtualWANName));
            }
            if (vpnClientParams == null)
            {
                throw new ArgumentNullException(nameof(vpnClientParams));
            }

            using var message = CreateGenerateRequest(resourceGroupName, virtualWANName, vpnClientParams);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            case 202:
                return(message.Response);

            default:
                throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }
コード例 #10
0
        internal HttpMessage CreateGenerateRequest(string resourceGroupName, string virtualWANName, VirtualWanVpnProfileParameters vpnClientParams)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;

            request.Method = RequestMethod.Post;
            var uri = new RawRequestUriBuilder();

            uri.Reset(endpoint);
            uri.AppendPath("/subscriptions/", false);
            uri.AppendPath(subscriptionId, true);
            uri.AppendPath("/resourceGroups/", false);
            uri.AppendPath(resourceGroupName, true);
            uri.AppendPath("/providers/Microsoft.Network/virtualWans/", false);
            uri.AppendPath(virtualWANName, true);
            uri.AppendPath("/GenerateVpnProfile", false);
            uri.AppendQuery("api-version", apiVersion, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("Content-Type", "application/json");
            var content = new Utf8JsonRequestContent();

            content.JsonWriter.WriteObjectValue(vpnClientParams);
            request.Content = content;
            message.SetProperty("UserAgentOverride", _userAgent);
            return(message);
        }