public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            ExecuteClientAction(() =>
            {
                if (this.ParameterSetName.Equals(ListVMImageParamSetName) || WildcardPattern.ContainsWildcardCharacters(Version))
                {
                    var result = this.VirtualMachineImageClient.ListWithHttpMessagesAsync(
                        this.Location.Canonicalize(),
                        this.PublisherName,
                        this.Offer,
                        this.Skus).GetAwaiter().GetResult();

                    var images = from r in result.Body
                                 select new PSVirtualMachineImage
                    {
                        RequestId     = result.RequestId,
                        StatusCode    = result.Response.StatusCode,
                        Id            = r.Id,
                        Location      = r.Location,
                        Version       = r.Name,
                        PublisherName = this.PublisherName,
                        Offer         = this.Offer,
                        Skus          = this.Skus
                    };

                    WriteObject(SubResourceWildcardFilter(Version, images), true);
                }
                else
                {
                    var response = this.VirtualMachineImageClient.GetWithHttpMessagesAsync(
                        this.Location.Canonicalize(),
                        this.PublisherName,
                        this.Offer,
                        this.Skus,
                        version: this.Version).GetAwaiter().GetResult();

                    var image = new PSVirtualMachineImageDetail
                    {
                        RequestId      = response.RequestId,
                        StatusCode     = response.Response.StatusCode,
                        Id             = response.Body.Id,
                        Location       = response.Body.Location,
                        Name           = response.Body.Name,
                        Version        = this.Version,
                        PublisherName  = this.PublisherName,
                        Offer          = this.Offer,
                        Skus           = this.Skus,
                        OSDiskImage    = response.Body.OsDiskImage,
                        DataDiskImages = response.Body.DataDiskImages,
                        PurchasePlan   = response.Body.Plan,
                        AutomaticOSUpgradeProperties = response.Body.AutomaticOSUpgradeProperties,
                        HyperVGeneration             = response.Body.HyperVGeneration
                    };

                    WriteObject(image);
                }
            });
        }
示例#2
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            var parameters = new VirtualMachineImageGetParameters
            {
                Location      = Location.Canonicalize(),
                PublisherName = PublisherName,
                Offer         = Offer,
                Skus          = Skus,
                Version       = Version
            };

            VirtualMachineImageGetResponse response = this.VirtualMachineImageClient.Get(parameters);

            var image = new PSVirtualMachineImageDetail
            {
                RequestId      = response.RequestId,
                StatusCode     = response.StatusCode,
                Id             = response.VirtualMachineImage.Id,
                Location       = response.VirtualMachineImage.Location,
                Name           = response.VirtualMachineImage.Name,
                OSDiskImage    = response.VirtualMachineImage.OSDiskImage,
                DataDiskImages = response.VirtualMachineImage.DataDiskImages,
                PurchasePlan   = response.VirtualMachineImage.PurchasePlan,
                PublisherName  = this.PublisherName,
                Offer          = this.Offer,
                Skus           = this.Skus,
                Version        = this.Version
            };

            WriteObject(image);
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            ExecuteClientAction(() =>
            {
                if (this.ParameterSetName.Equals(ListVMImageParamSetName))
                {
                    var filter = new ODataQuery <VirtualMachineImageResource>(this.FilterExpression);

                    var result = this.VirtualMachineImageClient.ListWithHttpMessagesAsync(
                        this.Location.Canonicalize(),
                        this.PublisherName,
                        this.Offer,
                        this.Skus,
                        odataQuery: filter).GetAwaiter().GetResult();

                    var images = from r in result.Body
                                 select new PSVirtualMachineImage
                    {
                        RequestId        = result.RequestId,
                        StatusCode       = result.Response.StatusCode,
                        Id               = r.Id,
                        Location         = r.Location,
                        Version          = r.Name,
                        PublisherName    = this.PublisherName,
                        Offer            = this.Offer,
                        Skus             = this.Skus,
                        FilterExpression = this.FilterExpression
                    };

                    WriteObject(images, true);
                }
                else
                {
                    var response = this.VirtualMachineImageClient.GetWithHttpMessagesAsync(
                        this.Location.Canonicalize(),
                        this.PublisherName,
                        this.Offer,
                        this.Skus,
                        version: this.Version).GetAwaiter().GetResult();

                    var image = new PSVirtualMachineImageDetail
                    {
                        RequestId      = response.RequestId,
                        StatusCode     = response.Response.StatusCode,
                        Id             = response.Body.Id,
                        Location       = response.Body.Location,
                        Name           = response.Body.Name,
                        Version        = this.Version,
                        PublisherName  = this.PublisherName,
                        Offer          = this.Offer,
                        Skus           = this.Skus,
                        OSDiskImage    = response.Body.OsDiskImage,
                        DataDiskImages = response.Body.DataDiskImages,
                        PurchasePlan   = response.Body.Plan,
                    };

                    WriteObject(image);
                }
            });
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            ExecuteClientAction(() =>
            {
                if (this.ParameterSetName.Equals(ListVMImageParamSetName))
                {
                    var parameters = new VirtualMachineImageListParameters
                    {
                        Location         = Location.Canonicalize(),
                        Offer            = Offer,
                        PublisherName    = PublisherName,
                        Skus             = Skus,
                        FilterExpression = FilterExpression
                    };

                    VirtualMachineImageResourceList result = this.VirtualMachineImageClient.List(parameters);

                    var images = from r in result.Resources
                                 select new PSVirtualMachineImage
                    {
                        RequestId        = result.RequestId,
                        StatusCode       = result.StatusCode,
                        Id               = r.Id,
                        Location         = r.Location,
                        Version          = r.Name,
                        PublisherName    = this.PublisherName,
                        Offer            = this.Offer,
                        Skus             = this.Skus,
                        FilterExpression = this.FilterExpression
                    };

                    WriteObject(images, true);
                }
                else
                {
                    var parameters = new VirtualMachineImageGetParameters
                    {
                        Location      = Location.Canonicalize(),
                        PublisherName = PublisherName,
                        Offer         = Offer,
                        Skus          = Skus,
                        Version       = Version
                    };

                    VirtualMachineImageGetResponse response = this.VirtualMachineImageClient.Get(parameters);

                    var image = new PSVirtualMachineImageDetail
                    {
                        RequestId      = response.RequestId,
                        StatusCode     = response.StatusCode,
                        Id             = response.VirtualMachineImage.Id,
                        Location       = response.VirtualMachineImage.Location,
                        Name           = response.VirtualMachineImage.Name,
                        Version        = response.VirtualMachineImage.Name,
                        PublisherName  = this.PublisherName,
                        Offer          = this.Offer,
                        Skus           = this.Skus,
                        OSDiskImage    = response.VirtualMachineImage.OSDiskImage,
                        DataDiskImages = response.VirtualMachineImage.DataDiskImages,
                        PurchasePlan   = response.VirtualMachineImage.PurchasePlan,
                    };

                    WriteObject(image);
                }
            });
        }