public virtual ProfileCreateOperation CreateOrUpdate(bool waitForCompletion, string profileName, ProfileData profile, CancellationToken cancellationToken = default) { if (profileName == null) { throw new ArgumentNullException(nameof(profileName)); } if (profile == null) { throw new ArgumentNullException(nameof(profile)); } using var scope = _clientDiagnostics.CreateScope("ProfileCollection.CreateOrUpdate"); scope.Start(); try { var response = _profilesRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, profileName, profile, cancellationToken); var operation = new ProfileCreateOperation(Parent, _clientDiagnostics, Pipeline, _profilesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, profileName, profile).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation <Profile> > CreateOrUpdateAsync(WaitUntil waitUntil, string profileName, ProfileData profile, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); Argument.AssertNotNull(profile, nameof(profile)); using var scope = _profileClientDiagnostics.CreateScope("ProfileCollection.CreateOrUpdate"); scope.Start(); try { var response = await _profileRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, profileName, profile, cancellationToken).ConfigureAwait(false); var operation = new CdnArmOperation <Profile>(new ProfileOperationSource(Client), _profileClientDiagnostics, Pipeline, _profileRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, profileName, profile).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }