public virtual AfdEndpointUpdateOperation Update(bool waitForCompletion, AfdEndpointUpdateOptions endpointUpdateProperties, CancellationToken cancellationToken = default) { if (endpointUpdateProperties == null) { throw new ArgumentNullException(nameof(endpointUpdateProperties)); } using var scope = _afdEndpointClientDiagnostics.CreateScope("AfdEndpoint.Update"); scope.Start(); try { var response = _afdEndpointRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, endpointUpdateProperties, cancellationToken); var operation = new AfdEndpointUpdateOperation(ArmClient, _afdEndpointClientDiagnostics, Pipeline, _afdEndpointRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, endpointUpdateProperties).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <AfdEndpointUpdateOperation> UpdateAsync(AfdEndpointUpdateOptions endpointUpdateProperties, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (endpointUpdateProperties == null) { throw new ArgumentNullException(nameof(endpointUpdateProperties)); } using var scope = _clientDiagnostics.CreateScope("AfdEndpoint.Update"); scope.Start(); try { var response = await _afdEndpointsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, endpointUpdateProperties, cancellationToken).ConfigureAwait(false); var operation = new AfdEndpointUpdateOperation(this, _clientDiagnostics, Pipeline, _afdEndpointsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, endpointUpdateProperties).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public static void AssertAfdEndpointUpdate(AfdEndpoint updatedAfdEndpoint, AfdEndpointUpdateOptions updateOptions) { Assert.AreEqual(updatedAfdEndpoint.Data.OriginResponseTimeoutSeconds, updateOptions.OriginResponseTimeoutSeconds); Assert.AreEqual(updatedAfdEndpoint.Data.Tags.Count, updateOptions.Tags.Count); foreach (var kv in updatedAfdEndpoint.Data.Tags) { Assert.True(updateOptions.Tags.ContainsKey(kv.Key)); Assert.AreEqual(kv.Value, updateOptions.Tags[kv.Key]); } }
public virtual ArmOperation <AfdEndpoint> Update(bool waitForCompletion, AfdEndpointUpdateOptions options, CancellationToken cancellationToken = default) { Argument.AssertNotNull(options, nameof(options)); using var scope = _afdEndpointClientDiagnostics.CreateScope("AfdEndpoint.Update"); scope.Start(); try { var response = _afdEndpointRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, options, cancellationToken); var operation = new CdnArmOperation <AfdEndpoint>(new AfdEndpointOperationSource(Client), _afdEndpointClientDiagnostics, Pipeline, _afdEndpointRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, options).Request, response, OperationFinalStateVia.OriginalUri); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async Task Update() { Subscription subscription = await Client.GetDefaultSubscriptionAsync(); ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-"); string afdProfileName = Recording.GenerateAssetName("AFDProfile-"); Profile afdProfile = await CreateAfdProfile(rg, afdProfileName, SkuName.StandardAzureFrontDoor); string afdEndpointName = Recording.GenerateAssetName("AFDEndpoint-"); AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName); AfdEndpointUpdateOptions updateOptions = new AfdEndpointUpdateOptions { OriginResponseTimeoutSeconds = 30 }; updateOptions.Tags.Add("newTag", "newValue"); var lro = await afdEndpointInstance.UpdateAsync(updateOptions); AfdEndpoint updatedAfdEndpointInstance = lro.Value; ResourceDataHelper.AssertAfdEndpointUpdate(updatedAfdEndpointInstance, updateOptions); }