public virtual async Task <ArmOperation <VCenterResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string vcenterName, VCenterData data = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(vcenterName, nameof(vcenterName));

            using var scope = _vCenterClientDiagnostics.CreateScope("VCenterCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _vCenterRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, vcenterName, data, cancellationToken).ConfigureAwait(false);

                var operation = new ConnectedVMwarevSphereArmOperation <VCenterResource>(new VCenterOperationSource(Client), _vCenterClientDiagnostics, Pipeline, _vCenterRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, vcenterName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Ejemplo n.º 2
0
        public async virtual Task <VCenterCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string vcenterName, VCenterData body = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(vcenterName, nameof(vcenterName));

            using var scope = _vCenterClientDiagnostics.CreateScope("VCenterCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _vCenterRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, vcenterName, body, cancellationToken).ConfigureAwait(false);

                var operation = new VCenterCreateOrUpdateOperation(ArmClient, _vCenterClientDiagnostics, Pipeline, _vCenterRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, vcenterName, body).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }