public async virtual Task <ArmOperation <AfdRoute> > CreateOrUpdateAsync(bool waitForCompletion, string routeName, AfdRouteData route, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(routeName, nameof(routeName)); if (route == null) { throw new ArgumentNullException(nameof(route)); } using var scope = _afdRouteClientDiagnostics.CreateScope("AfdRouteCollection.CreateOrUpdate"); scope.Start(); try { var response = await _afdRouteRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, routeName, route, cancellationToken).ConfigureAwait(false); var operation = new CdnArmOperation <AfdRoute>(new AfdRouteOperationSource(Client), _afdRouteClientDiagnostics, Pipeline, _afdRouteRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, routeName, route).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <AfdRouteCreateOperation> CreateOrUpdateAsync(string routeName, AfdRouteData route, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (routeName == null) { throw new ArgumentNullException(nameof(routeName)); } if (route == null) { throw new ArgumentNullException(nameof(route)); } using var scope = _clientDiagnostics.CreateScope("AfdRouteCollection.CreateOrUpdate"); scope.Start(); try { var response = await _afdRoutesRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, routeName, route, cancellationToken).ConfigureAwait(false); var operation = new AfdRouteCreateOperation(Parent, _clientDiagnostics, Pipeline, _afdRoutesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, routeName, route).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }