public virtual Response <GenerateExpressRoutePortsLOAResult> GenerateLOA(GenerateExpressRoutePortsLOARequest request, CancellationToken cancellationToken = default) { Argument.AssertNotNull(request, nameof(request)); using var scope = _expressRoutePortClientDiagnostics.CreateScope("ExpressRoutePort.GenerateLOA"); scope.Start(); try { var response = _expressRoutePortRestClient.GenerateLOA(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, request, cancellationToken); return(response); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <GenerateExpressRoutePortsLOAResult> GenerateLOA(GenerateExpressRoutePortsLOARequest request, CancellationToken cancellationToken = default) { if (request == null) { throw new ArgumentNullException(nameof(request)); } using var scope = _clientDiagnostics.CreateScope("ExpressRoutePort.GenerateLOA"); scope.Start(); try { var response = _restClient.GenerateLOA(Id.ResourceGroupName, Id.Name, request, cancellationToken); return(response); } catch (Exception e) { scope.Failed(e); throw; } }
public override void Execute() { base.Execute(); if (string.Equals(this.ParameterSetName, ResourceObjectParameterSet, StringComparison.OrdinalIgnoreCase)) { ResourceGroupName = ExpressRoutePort.ResourceGroupName; PortName = ExpressRoutePort.Name; } if (string.Equals(this.ParameterSetName, ResourceIdParameterSet, StringComparison.OrdinalIgnoreCase)) { var resourceInfo = new ResourceIdentifier(Id); ResourceGroupName = resourceInfo.ResourceGroupName; PortName = resourceInfo.ResourceName; } if (this.ResourceGroupName == null || this.PortName == null) { Console.WriteLine("Empty resource group or port name."); return; } GenerateExpressRoutePortsLOARequest generateExpressRoutePortsLOARequest = new GenerateExpressRoutePortsLOARequest(CustomerName); var response = this.NetworkClient.NetworkManagementClient.ExpressRoutePorts.GenerateLOA(this.ResourceGroupName, this.PortName, generateExpressRoutePortsLOARequest); var decodedDocument = Convert.FromBase64String(response.EncodedContent); if (String.IsNullOrEmpty(Destination)) { Destination = DefaultFileName; } if (!(Path.IsPathRooted(Destination))) { Destination = Directory.GetCurrentDirectory() + "\\" + Destination; } File.WriteAllBytes(Destination, decodedDocument); Console.WriteLine("Written Letter of Authorization To: " + Destination); if (PassThru) { WriteObject(true); } }
public async virtual Task <Response <GenerateExpressRoutePortsLOAResult> > GenerateLOAAsync(GenerateExpressRoutePortsLOARequest request, CancellationToken cancellationToken = default) { if (request == null) { throw new ArgumentNullException(nameof(request)); } using var scope = _clientDiagnostics.CreateScope("ExpressRoutePort.GenerateLOA"); scope.Start(); try { var response = await _expressRoutePortsRestClient.GenerateLOAAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, request, cancellationToken).ConfigureAwait(false); return(response); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Generate a letter of authorization for the requested ExpressRoutePort /// resource. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='expressRoutePortName'> /// The name of ExpressRoutePort. /// </param> /// <param name='request'> /// Request parameters supplied to generate a letter of authorization. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <GenerateExpressRoutePortsLOAResult> GenerateLOAAsync(this IExpressRoutePortsOperations operations, string resourceGroupName, string expressRoutePortName, GenerateExpressRoutePortsLOARequest request, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GenerateLOAWithHttpMessagesAsync(resourceGroupName, expressRoutePortName, request, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Generate a letter of authorization for the requested ExpressRoutePort /// resource. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='expressRoutePortName'> /// The name of ExpressRoutePort. /// </param> /// <param name='request'> /// Request parameters supplied to generate a letter of authorization. /// </param> public static GenerateExpressRoutePortsLOAResult GenerateLOA(this IExpressRoutePortsOperations operations, string resourceGroupName, string expressRoutePortName, GenerateExpressRoutePortsLOARequest request) { return(operations.GenerateLOAAsync(resourceGroupName, expressRoutePortName, request).GetAwaiter().GetResult()); }