/// <summary> /// The process record method. /// </summary> protected override void ProcessRecord() { base.ProcessRecord(); try { if (Mcp1.IsPresent) { if (Network != null && string.IsNullOrEmpty(DataCenterId)) { DataCenterId = Network.location; } IEnumerable <ImagesWithDiskSpeedImage> resultlist = Connection.ApiClient.ServerManagementLegacy.ServerImage.GetImages( Id.HasValue ? Id.ToString() : null, Name, DataCenterId, OperatingSystemId, OperatingSystemFamily).Result; WriteObject(resultlist, true); return; } ServerOsImageListOptions options = new ServerOsImageListOptions() { Id = Id, DatacenterId = DataCenterId, Name = Name, State = State, OperatingSystemId = OperatingSystemId, OperatingSystemFamily = OperatingSystemFamily }; this.WritePagedObject(Connection.ApiClient.ServerManagement.ServerImage.GetOsImages(options, PageableRequest).Result); } catch (AggregateException ae) { ae.Handle( e => { if (e is ComputeApiException) { WriteError(new ErrorRecord(e, "-2", ErrorCategory.InvalidOperation, Connection)); } else { // if (e is HttpRequestException) ThrowTerminatingError(new ErrorRecord(e, "-1", ErrorCategory.ConnectionError, Connection)); } return(true); }); } }
/// <summary> /// Get OS Images /// </summary> /// <param name="filteringOptions">Filtering options</param> /// <param name="pagingOptions"></param> /// <returns>OS Images</returns> public async Task <PagedResponse <OsImageType> > GetOsImages(ServerOsImageListOptions filteringOptions = null, IPageableRequest pagingOptions = null) { var response = await _apiClient.GetAsync <osImages>( ApiUris.GetMcp2OsImages(_apiClient.OrganizationId), pagingOptions, filteringOptions); return(new PagedResponse <OsImageType> { items = response.osImage, totalCount = response.totalCountSpecified ? response.totalCount : (int?)null, pageCount = response.pageCountSpecified ? response.pageCount : (int?)null, pageNumber = response.pageNumberSpecified ? response.pageNumber : (int?)null, pageSize = response.pageSizeSpecified ? response.pageSize : (int?)null }); }