Example #1
0
        public void CommunityGalleryImageVersion_GetAndList_Tests()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                EnsureClientsInitialized(context);

                CommunityGalleryImageVersion communityGalleryImageVersionOut = m_CrpClient.CommunityGalleryImageVersions.Get(galleryAccessLocation, PublicGalleryName, GalleryImageName, GalleryImageVersionName);
                Trace.TraceInformation("Got the community gallery image name {0} which is shared to public.", GalleryImageVersionName);
                Assert.NotNull(communityGalleryImageVersionOut);
                ValidateCommunityGalleryImageVersion(communityGalleryImageVersionOut);

                IPage <CommunityGalleryImageVersion> communityGalleryImageVersionsList = m_CrpClient.CommunityGalleryImageVersions.List(galleryAccessLocation, PublicGalleryName, GalleryImageName);
                Trace.TraceInformation("Got the community gallery image versions which are shared to public.");

                int count = communityGalleryImageVersionsList.Count();
                Assert.Equal(1, count);

                foreach (CommunityGalleryImageVersion galleryImageVersion in communityGalleryImageVersionsList)
                {
                    if (galleryImageVersion.Name == GalleryImageVersionName)
                    {
                        ValidateCommunityGalleryImageVersion(galleryImageVersion);
                        break;
                    }
                }
            }
        }
Example #2
0
        private void ValidateCommunityGalleryImageVersion(CommunityGalleryImageVersion communityGalleryImageVersion)
        {
            string expectedId = "/CommunityGalleries/" + PublicGalleryName + "/Images/" + GalleryImageName + "/Versions/" + GalleryImageVersionName;

            Assert.Equal(expectedId, communityGalleryImageVersion.UniqueId);
            Assert.NotNull(communityGalleryImageVersion.StorageProfile);
            Assert.NotNull(communityGalleryImageVersion.ExcludeFromLatest);
            Assert.NotNull(communityGalleryImageVersion.StorageProfile.OsDiskImage);
        }
Example #3
0
        public async Task <Response <CommunityGalleryImageVersion> > GetAsync(string subscriptionId, string location, string publicGalleryName, string galleryImageName, string galleryImageVersionName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(location, nameof(location));
            Argument.AssertNotNullOrEmpty(publicGalleryName, nameof(publicGalleryName));
            Argument.AssertNotNullOrEmpty(galleryImageName, nameof(galleryImageName));
            Argument.AssertNotNullOrEmpty(galleryImageVersionName, nameof(galleryImageVersionName));

            using var message = CreateGetRequest(subscriptionId, location, publicGalleryName, galleryImageName, galleryImageVersionName);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

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

                value = CommunityGalleryImageVersion.DeserializeCommunityGalleryImageVersion(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }