/// <summary> /// Performs execution of the command /// </summary> protected override void ProcessRecord() { try { List <SpuFilter> filters = new List <SpuFilter>(); if (ParameterPresent("SpuSerial")) { SpuFilter f = new SpuFilter(); f.Serial = new StringFilter(); f.Serial.MustEqual = SpuSerial; filters.Add(f); } if (ParameterPresent("Unused")) { SpuFilter f = new SpuFilter(); f.NotInNPod = true; filters.Add(f); } // convert to filter SpuFilter filter = GenerateFilter(filters); SpuSort sort = new SpuSort(); sort.Serial = SortDirection.Ascending; PageInput page = PageInput.First; SpuList list = Connection.GetSpus(page, filter, sort); foreach (Spu item in list.Items) { WriteObject(item); } while (list.More) { // advance the page page.Page = page.Page + 1; list = Connection.GetSpus(page, filter, sort); foreach (Spu item in list.Items) { WriteObject(item); } } } catch (AggregateException exceptions) { foreach (Exception ex in exceptions.InnerExceptions) { WriteError(ex); } } catch (Exception ex) { WriteError(ex); } }
/// <summary> /// Retrieves a list of SPUs /// </summary> /// <param name="page"> /// The requested page from the server. This is an optional argument /// and if omitted the server will default to returning the first page /// with a maximum of <c>100</c> items. /// </param> /// <param name="filter"> /// A filter object to filter the SPUs on the server. If omitted, the /// server will return all objects as a paginated response. /// </param> /// <param name="sort"> /// A sort definition object to sort the SPU objects on supported /// properties. If omitted objects are returned in the order as they /// were created in. /// </param> /// <returns></returns> public SpuList GetSpus(PageInput page = null, SpuFilter filter = null, SpuSort sort = null) { // prepare parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("page", page, true); parameters.Add("filter", filter, true); parameters.Add("sort", sort, true); return(RunQuery <SpuList>(@"getSPUs", parameters)); }