Example #1
0
 internal GalleryApplicationVersion(ArmResource options, GalleryApplicationVersionData resource) : base(options, resource.Id)
 {
     HasData            = true;
     _data              = resource;
     _clientDiagnostics = new ClientDiagnostics(ClientOptions);
     _restClient        = new GalleryApplicationVersionsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri);
 }
Example #2
0
        GalleryApplicationVersion IOperationSource <GalleryApplicationVersion> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = GalleryApplicationVersionData.DeserializeGalleryApplicationVersionData(document.RootElement);

            return(new GalleryApplicationVersion(_client, data));
        }
        public async Task <Response <GalleryApplicationVersionData> > GetAsync(string resourceGroupName, string galleryName, string galleryApplicationName, string galleryApplicationVersionName, ReplicationStatusTypes?expand = null, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (galleryName == null)
            {
                throw new ArgumentNullException(nameof(galleryName));
            }
            if (galleryApplicationName == null)
            {
                throw new ArgumentNullException(nameof(galleryApplicationName));
            }
            if (galleryApplicationVersionName == null)
            {
                throw new ArgumentNullException(nameof(galleryApplicationVersionName));
            }

            using var message = CreateGetRequest(resourceGroupName, galleryName, galleryApplicationName, galleryApplicationVersionName, expand);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            {
                GalleryApplicationVersionData value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                value = GalleryApplicationVersionData.DeserializeGalleryApplicationVersionData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
 internal GalleryApplicationVersion(ArmClient armClient, GalleryApplicationVersionData data) : this(armClient, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Example #5
0
        public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string galleryName, string galleryApplicationName, string galleryApplicationVersionName, GalleryApplicationVersionData galleryApplicationVersion, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(galleryName, nameof(galleryName));
            Argument.AssertNotNullOrEmpty(galleryApplicationName, nameof(galleryApplicationName));
            Argument.AssertNotNullOrEmpty(galleryApplicationVersionName, nameof(galleryApplicationVersionName));
            Argument.AssertNotNull(galleryApplicationVersion, nameof(galleryApplicationVersion));

            using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, galleryName, galleryApplicationName, galleryApplicationVersionName, galleryApplicationVersion);
            _pipeline.Send(message, cancellationToken);
            switch (message.Response.Status)
            {
            case 200:
            case 201:
            case 202:
                return(message.Response);

            default:
                throw new RequestFailedException(message.Response);
            }
        }
        public Response CreateOrUpdate(string resourceGroupName, string galleryName, string galleryApplicationName, string galleryApplicationVersionName, GalleryApplicationVersionData galleryApplicationVersion, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (galleryName == null)
            {
                throw new ArgumentNullException(nameof(galleryName));
            }
            if (galleryApplicationName == null)
            {
                throw new ArgumentNullException(nameof(galleryApplicationName));
            }
            if (galleryApplicationVersionName == null)
            {
                throw new ArgumentNullException(nameof(galleryApplicationVersionName));
            }
            if (galleryApplicationVersion == null)
            {
                throw new ArgumentNullException(nameof(galleryApplicationVersion));
            }

            using var message = CreateCreateOrUpdateRequest(resourceGroupName, galleryName, galleryApplicationName, galleryApplicationVersionName, galleryApplicationVersion);
            _pipeline.Send(message, cancellationToken);
            switch (message.Response.Status)
            {
            case 200:
            case 201:
            case 202:
                return(message.Response);

            default:
                throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }
Example #7
0
        public virtual ArmOperation <GalleryApplicationVersion> CreateOrUpdate(bool waitForCompletion, string galleryApplicationVersionName, GalleryApplicationVersionData galleryApplicationVersion, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(galleryApplicationVersionName, nameof(galleryApplicationVersionName));
            if (galleryApplicationVersion == null)
            {
                throw new ArgumentNullException(nameof(galleryApplicationVersion));
            }

            using var scope = _galleryApplicationVersionClientDiagnostics.CreateScope("GalleryApplicationVersionCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _galleryApplicationVersionRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, galleryApplicationVersionName, galleryApplicationVersion, cancellationToken);
                var operation = new ComputeArmOperation <GalleryApplicationVersion>(new GalleryApplicationVersionOperationSource(Client), _galleryApplicationVersionClientDiagnostics, Pipeline, _galleryApplicationVersionRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, galleryApplicationVersionName, galleryApplicationVersion).Request, response, OperationFinalStateVia.Location);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }