Beispiel #1
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();
            ExecuteClientAction(() =>
            {
                string resourceGroupName = this.ResourceGroupName;
                string imageName         = this.ImageName;
                string expand            = this.Expand;

                if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(imageName))
                {
                    var result   = ImagesClient.Get(resourceGroupName, imageName, expand);
                    var psObject = new PSImage();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Image, PSImage>(result, psObject);
                    WriteObject(psObject);
                }
                else if (!string.IsNullOrEmpty(resourceGroupName))
                {
                    var result       = ImagesClient.ListByResourceGroup(resourceGroupName);
                    var resultList   = result.ToList();
                    var nextPageLink = result.NextPageLink;
                    while (!string.IsNullOrEmpty(nextPageLink))
                    {
                        var pageResult = ImagesClient.ListByResourceGroupNext(nextPageLink);
                        foreach (var pageItem in pageResult)
                        {
                            resultList.Add(pageItem);
                        }
                        nextPageLink = pageResult.NextPageLink;
                    }
                    var psObject = new List <PSImageList>();
                    foreach (var r in resultList)
                    {
                        psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <Image, PSImageList>(r));
                    }
                    WriteObject(psObject, true);
                }
                else
                {
                    var result       = ImagesClient.List();
                    var resultList   = result.ToList();
                    var nextPageLink = result.NextPageLink;
                    while (!string.IsNullOrEmpty(nextPageLink))
                    {
                        var pageResult = ImagesClient.ListNext(nextPageLink);
                        foreach (var pageItem in pageResult)
                        {
                            resultList.Add(pageItem);
                        }
                        nextPageLink = pageResult.NextPageLink;
                    }
                    var psObject = new List <PSImageList>();
                    foreach (var r in resultList)
                    {
                        psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <Image, PSImageList>(r));
                    }
                    WriteObject(psObject, true);
                }
            });
        }
        protected void ExecuteImageListNextMethod(object[] invokeMethodInputParameters)
        {
            string nextPageLink = (string)ParseParameter(invokeMethodInputParameters[0]);

            var result = ImagesClient.ListNext(nextPageLink);

            WriteObject(result);
        }
Beispiel #3
0
        protected void ExecuteImageGetMethod(object[] invokeMethodInputParameters)
        {
            string resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]);
            string imageName         = (string)ParseParameter(invokeMethodInputParameters[1]);
            string expand            = (string)ParseParameter(invokeMethodInputParameters[2]);

            if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(imageName))
            {
                var result   = ImagesClient.Get(resourceGroupName, imageName, expand);
                var psObject = new PSImage();
                Mapper.Map <Image, PSImage>(result, psObject);
                WriteObject(psObject);
            }
            else if (!string.IsNullOrEmpty(resourceGroupName))
            {
                var result       = ImagesClient.ListByResourceGroup(resourceGroupName);
                var resultList   = result.ToList();
                var nextPageLink = result.NextPageLink;
                while (!string.IsNullOrEmpty(nextPageLink))
                {
                    var pageResult = ImagesClient.ListByResourceGroupNext(nextPageLink);
                    foreach (var pageItem in pageResult)
                    {
                        resultList.Add(pageItem);
                    }
                    nextPageLink = pageResult.NextPageLink;
                }
                var psObject = new List <PSImageList>();
                foreach (var r in resultList)
                {
                    psObject.Add(Mapper.Map <Image, PSImageList>(r));
                }
                WriteObject(psObject);
            }
            else
            {
                var result       = ImagesClient.List();
                var resultList   = result.ToList();
                var nextPageLink = result.NextPageLink;
                while (!string.IsNullOrEmpty(nextPageLink))
                {
                    var pageResult = ImagesClient.ListNext(nextPageLink);
                    foreach (var pageItem in pageResult)
                    {
                        resultList.Add(pageItem);
                    }
                    nextPageLink = pageResult.NextPageLink;
                }
                var psObject = new List <PSImageList>();
                foreach (var r in resultList)
                {
                    psObject.Add(Mapper.Map <Image, PSImageList>(r));
                }
                WriteObject(psObject);
            }
        }
        protected void ExecuteImageListMethod(object[] invokeMethodInputParameters)
        {
            var result       = ImagesClient.List();
            var resultList   = result.ToList();
            var nextPageLink = result.NextPageLink;

            while (!string.IsNullOrEmpty(nextPageLink))
            {
                var pageResult = ImagesClient.ListNext(nextPageLink);
                foreach (var pageItem in pageResult)
                {
                    resultList.Add(pageItem);
                }
                nextPageLink = pageResult.NextPageLink;
            }
            WriteObject(resultList, true);
        }
        public override void ExecuteCmdlet()
        {
            ExecuteClientAction(() =>
            {
                WriteWarning("Get-AzureRmImage: A property of the output of this cmdlet will change in an upcoming breaking change release. " +
                             "The StorageAccountType property for a DataDisk will return Standard_LRS and Premium_LRS");

                string resourceGroupName = this.ResourceGroupName;
                string imageName         = this.ImageName;
                string expand            = this.Expand;

                if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(imageName))
                {
                    var result   = ImagesClient.Get(resourceGroupName, imageName, expand);
                    var psObject = new PSImage();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Image, PSImage>(result, psObject);
                    WriteObject(psObject);
                }
                else if (!string.IsNullOrEmpty(resourceGroupName))
                {
                    var result       = ImagesClient.ListByResourceGroup(resourceGroupName);
                    var resultList   = result.ToList();
                    var nextPageLink = result.NextPageLink;
                    while (!string.IsNullOrEmpty(nextPageLink))
                    {
                        var pageResult = ImagesClient.ListByResourceGroupNext(nextPageLink);
                        foreach (var pageItem in pageResult)
                        {
                            resultList.Add(pageItem);
                        }
                        nextPageLink = pageResult.NextPageLink;
                    }
                    var psObject = new List <PSImageList>();
                    foreach (var r in resultList)
                    {
                        psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <Image, PSImageList>(r));
                    }
                    WriteObject(psObject, true);
                }
                else
                {
                    var result       = ImagesClient.List();
                    var resultList   = result.ToList();
                    var nextPageLink = result.NextPageLink;
                    while (!string.IsNullOrEmpty(nextPageLink))
                    {
                        var pageResult = ImagesClient.ListNext(nextPageLink);
                        foreach (var pageItem in pageResult)
                        {
                            resultList.Add(pageItem);
                        }
                        nextPageLink = pageResult.NextPageLink;
                    }
                    var psObject = new List <PSImageList>();
                    foreach (var r in resultList)
                    {
                        psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <Image, PSImageList>(r));
                    }
                    WriteObject(psObject, true);
                }
            });
        }