protected override void ExecuteCmdletInternal()
        {
            ContainerInstanceCmdletBase.InitializeAutoMapper();

            if (!string.IsNullOrEmpty(this.ResourceGroupName) && !string.IsNullOrEmpty(this.Name))
            {
                var psContainerGroup = PSContainerGroup.FromContainerGroup(
                    this.ContainerClient.ContainerGroups.Get(this.ResourceGroupName, this.Name));
                this.WriteObject(psContainerGroup);
            }
            else if (!string.IsNullOrEmpty(this.ResourceId))
            {
                var resource = this.ResourceClient.Resources.GetById(this.ResourceId, this.ContainerClient.ApiVersion);
                if (resource != null)
                {
                    var psContainerGroup = PSContainerGroup.FromContainerGroup(
                        this.ContainerClient.ContainerGroups.Get(this.ParseResourceGroupFromResourceId(this.ResourceId), resource.Name));
                    this.WriteObject(psContainerGroup);
                }
            }
            else
            {
                var psContainerGroups = new List <PSContainerGroupList>();
                var containerGroups   = this.ListContainerGroups();
                foreach (var containerGroup in containerGroups)
                {
                    psContainerGroups.Add(Mapper.Map <PSContainerGroupList>(PSContainerGroup.FromContainerGroup(containerGroup)));
                }

                while (!string.IsNullOrEmpty(containerGroups.NextPageLink))
                {
                    containerGroups = this.ListContainerGroupsNext(containerGroups.NextPageLink);
                    foreach (var containerGroup in containerGroups)
                    {
                        psContainerGroups.Add(Mapper.Map <PSContainerGroupList>(PSContainerGroup.FromContainerGroup(containerGroup)));
                    }
                }

                this.WriteObject(psContainerGroups, true);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Implement ExecuteCmdlet.
 /// </summary>
 public override void ExecuteCmdlet()
 {
     ContainerInstanceCmdletBase.InitializeAutoMapper();
     this.ExecuteCmdletInternal();
 }