public override void ExecuteCmdlet() { base.ExecuteCmdlet(); ExecuteClientAction(() => { string resourceGroupName = this.ResourceGroupName; string containerServiceName = this.Name; if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(containerServiceName)) { var result = ContainerServicesClient.Get(resourceGroupName, containerServiceName); var psObject = new PSContainerService(); ComputeAutomationAutoMapperProfile.Mapper.Map <ContainerService, PSContainerService>(result, psObject); WriteObject(psObject); } else if (!string.IsNullOrEmpty(resourceGroupName)) { var result = ContainerServicesClient.ListByResourceGroup(resourceGroupName); var resultList = result.ToList(); var nextPageLink = result.NextPageLink; while (!string.IsNullOrEmpty(nextPageLink)) { var pageResult = ContainerServicesClient.ListByResourceGroupNext(nextPageLink); foreach (var pageItem in pageResult) { resultList.Add(pageItem); } nextPageLink = pageResult.NextPageLink; } var psObject = new List <PSContainerServiceList>(); foreach (var r in resultList) { psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <ContainerService, PSContainerServiceList>(r)); } WriteObject(psObject, true); } else { var result = ContainerServicesClient.List(); var resultList = result.ToList(); var nextPageLink = result.NextPageLink; while (!string.IsNullOrEmpty(nextPageLink)) { var pageResult = ContainerServicesClient.ListNext(nextPageLink); foreach (var pageItem in pageResult) { resultList.Add(pageItem); } nextPageLink = pageResult.NextPageLink; } var psObject = new List <PSContainerServiceList>(); foreach (var r in resultList) { psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <ContainerService, PSContainerServiceList>(r)); } WriteObject(psObject, true); } }); }
protected void ExecuteContainerServiceGetMethod(object[] invokeMethodInputParameters) { string resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]); string containerServiceName = (string)ParseParameter(invokeMethodInputParameters[1]); if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(containerServiceName)) { var result = ContainerServicesClient.Get(resourceGroupName, containerServiceName); var psObject = new PSContainerService(); Mapper.Map <ContainerService, PSContainerService>(result, psObject); WriteObject(psObject); } else if (!string.IsNullOrEmpty(resourceGroupName)) { var result = ContainerServicesClient.ListByResourceGroup(resourceGroupName); var resultList = result.ToList(); var nextPageLink = result.NextPageLink; while (!string.IsNullOrEmpty(nextPageLink)) { var pageResult = ContainerServicesClient.ListByResourceGroupNext(nextPageLink); foreach (var pageItem in pageResult) { resultList.Add(pageItem); } nextPageLink = pageResult.NextPageLink; } var psObject = new List <PSContainerServiceList>(); foreach (var r in resultList) { psObject.Add(Mapper.Map <ContainerService, PSContainerServiceList>(r)); } WriteObject(psObject, true); } else { var result = ContainerServicesClient.List(); var resultList = result.ToList(); var nextPageLink = result.NextPageLink; while (!string.IsNullOrEmpty(nextPageLink)) { var pageResult = ContainerServicesClient.ListNext(nextPageLink); foreach (var pageItem in pageResult) { resultList.Add(pageItem); } nextPageLink = pageResult.NextPageLink; } var psObject = new List <PSContainerServiceList>(); foreach (var r in resultList) { psObject.Add(Mapper.Map <ContainerService, PSContainerServiceList>(r)); } WriteObject(psObject, true); } }