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 ArmOperation <Profile> CreateOrUpdate(bool waitForCompletion, string profileName, ProfileData profile, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); if (profile == null) { throw new ArgumentNullException(nameof(profile)); } using var scope = _profileClientDiagnostics.CreateScope("ProfileCollection.CreateOrUpdate"); scope.Start(); try { var response = _profileRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, profileName, profile, cancellationToken); var operation = new CdnArmOperation <Profile>(new ProfileOperationSource(Client), _profileClientDiagnostics, Pipeline, _profileRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, profileName, profile).Request, response, OperationFinalStateVia.Location); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }