public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonGlueConfig config = new AmazonGlueConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonGlueClient client = new AmazonGlueClient(creds, config); GetJobsResponse resp = new GetJobsResponse(); do { GetJobsRequest req = new GetJobsRequest { NextToken = resp.NextToken , MaxResults = maxItems }; resp = client.GetJobs(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.Jobs) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.NextToken)); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetJobsResponse response = new GetJobsResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Jobs", targetDepth)) { var unmarshaller = new ListUnmarshaller <Job, JobUnmarshaller>(JobUnmarshaller.Instance); response.Jobs = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("NextToken", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextToken = unmarshaller.Unmarshall(context); continue; } } return(response); }
private static void ConfigureGetJobsResponse(SimpleMapper mapper) { mapper.CreateMap <GetJobsRequest, IppRequestMessage>((src, map) => { var dst = new IppRequestMessage { IppOperation = IppOperation.GetJobs }; mapper.Map <IIppPrinterRequest, IppRequestMessage>(src, dst); var operation = dst.OperationAttributes; if (src.Limit != null) { operation.Add(new IppAttribute(Tag.Integer, "requesting-user-name", src.Limit.Value)); } if (src.WhichJobs != null) { operation.Add(new IppAttribute(Tag.Keyword, "which-jobs", Mapper.Map <string>(src.WhichJobs.Value))); } if (src.MyJobs != null) { operation.Add(new IppAttribute(Tag.Boolean, "my-jobs", Mapper.Map <string>(src.MyJobs.Value))); } if (src.RequestedAttributes != null) { operation.AddRange(src.RequestedAttributes.Select(requestedAttribute => new IppAttribute(Tag.Keyword, "requested-attributes", requestedAttribute))); } dst.OperationAttributes.Populate(src.AdditionalOperationAttributes); dst.JobAttributes.Populate(src.AdditionalJobAttributes); return(dst); }); mapper.CreateMap <IppResponseMessage, GetJobsResponse>((src, map) => { var dst = new GetJobsResponse { Jobs = map.Map <List <IppSection>, JobAttributes[]>(src.Sections) }; map.Map <IppResponseMessage, IIppResponseMessage>(src, dst); return(dst); }); //https://tools.ietf.org/html/rfc2911#section-4.4 mapper.CreateMap <List <IppSection>, JobAttributes[]>((src, map) => src.Where(x => x.Tag == SectionTag.JobAttributesTag) .Select(x => map.Map <JobAttributes>(x.AllAttributes())) .ToArray()); }