Beispiel #1
0
        public virtual TemplateSpecVersionCreateOrUpdateOperation CreateOrUpdate(string templateSpecVersion, TemplateSpecVersionData templateSpecVersionModel, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (templateSpecVersion == null)
            {
                throw new ArgumentNullException(nameof(templateSpecVersion));
            }
            if (templateSpecVersionModel == null)
            {
                throw new ArgumentNullException(nameof(templateSpecVersionModel));
            }

            using var scope = _clientDiagnostics.CreateScope("TemplateSpecVersionCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _restClient.CreateOrUpdate(Id.ResourceGroupName, Id.Name, templateSpecVersion, templateSpecVersionModel, cancellationToken);
                var operation = new TemplateSpecVersionCreateOrUpdateOperation(Parent, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public async virtual Task <TemplateSpecVersionCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string templateSpecVersion, TemplateSpecVersionData templateSpecVersionModel, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(templateSpecVersion, nameof(templateSpecVersion));
            if (templateSpecVersionModel == null)
            {
                throw new ArgumentNullException(nameof(templateSpecVersionModel));
            }

            using var scope = _templateSpecVersionClientDiagnostics.CreateScope("TemplateSpecVersionCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _templateSpecVersionRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, templateSpecVersion, templateSpecVersionModel, cancellationToken).ConfigureAwait(false);

                var operation = new TemplateSpecVersionCreateOrUpdateOperation(ArmClient, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }