public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonDataPipelineConfig config = new AmazonDataPipelineConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonDataPipelineClient client = new AmazonDataPipelineClient(creds, config); QueryObjectsResponse resp = new QueryObjectsResponse(); do { QueryObjectsRequest req = new QueryObjectsRequest { Marker = resp.Marker , Limit = maxItems }; resp = client.QueryObjects(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.Ids) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.Marker)); }
public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { QueryObjectsResponse response = new QueryObjectsResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("ids", targetDepth)) { var unmarshaller = new ListUnmarshaller <String, StringUnmarshaller>( StringUnmarshaller.GetInstance()); response.Ids = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("marker", targetDepth)) { response.Marker = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("hasMoreResults", targetDepth)) { response.HasMoreResults = BoolUnmarshaller.GetInstance().Unmarshall(context); continue; } } return(response); }
public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { QueryObjectsResponse response = new QueryObjectsResponse(); context.Read(); UnmarshallResult(context, response); return(response); }
public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { QueryObjectsResponse response = new QueryObjectsResponse(); context.Read(); response.QueryObjectsResult = QueryObjectsResultUnmarshaller.GetInstance().Unmarshall(context); return(response); }
private static void UnmarshallResult(JsonUnmarshallerContext context, QueryObjectsResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; while (context.Read()) { if (context.TestExpression("ids", targetDepth)) { context.Read(); response.Ids = new List <String>(); StringUnmarshaller unmarshaller = StringUnmarshaller.GetInstance(); while (context.Read()) { JsonToken token = context.CurrentTokenType; if (token == JsonToken.ArrayStart) { continue; } if (token == JsonToken.ArrayEnd) { break; } response.Ids.Add(unmarshaller.Unmarshall(context)); } continue; } if (context.TestExpression("marker", targetDepth)) { context.Read(); response.Marker = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("hasMoreResults", targetDepth)) { context.Read(); response.HasMoreResults = BoolUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.CurrentDepth <= originalDepth) { return; } } return; }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { QueryObjectsResponse response = new QueryObjectsResponse(); while (context.Read()) { if (context.IsStartElement) { UnmarshallResult(context, response); continue; } } return(response); }
private static void UnmarshallResult(XmlUnmarshallerContext context, QueryObjectsResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth += 2; } while (context.Read()) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("Name", targetDepth)) { response.BucketName = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("NextMarker", targetDepth)) { response.NextMarker = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("MaxKeys", targetDepth)) { response.MaxKeys = IntUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("ObjectMatches/object", targetDepth)) { response.ObjectMatches.Add(QueryObjectUnmarshaller.Instance.Unmarshall(context)); continue; } } else if (context.IsEndElement && context.CurrentDepth < originalDepth) { return; } } return; }
public static void Main(string[] args) { // create the ECS S3 client ECSS3Client s3 = ECSS3Factory.getS3Client(); // Create the bucket with indexed keys List <MetaSearchKey> bucketMetadataSearchKeys = new List <MetaSearchKey>() { new MetaSearchKey() { Name = USER_PREFIX + FIELD_ACCOUNT_ID, Type = MetaSearchDatatype.integer }, new MetaSearchKey() { Name = USER_PREFIX + FIELD_BILLING_DATE, Type = MetaSearchDatatype.datetime }, new MetaSearchKey() { Name = USER_PREFIX + FIELD_BILL_TYPE, Type = MetaSearchDatatype.@string } }; PutBucketRequestECS pbr = new PutBucketRequestECS(); pbr.BucketName = BUCKET_NAME; pbr.SetMetadataSearchKeys(bucketMetadataSearchKeys); s3.PutBucket(pbr); foreach (string key in KEY_LIST) { PutObjectRequestECS por = new PutObjectRequestECS(); por.BucketName = BUCKET_NAME; por.Key = key; por.Metadata.Add(FIELD_ACCOUNT_ID, extractAccountId(key)); por.Metadata.Add(FIELD_BILLING_DATE, extractBillDate(key)); por.Metadata.Add(FIELD_BILL_TYPE, extractBillType(key)); s3.PutObject(por); } while (true) { Console.Write("Enter the account id (empty for none): "); string accountId = Console.ReadLine(); Console.Write("Enter the billing date (e.g. 2016-09-22, empty for none): "); string billingDate = Console.ReadLine(); Console.Write("Enter the bill type (e.g. xml. empty for none): "); string billType = Console.ReadLine(); QueryObjectsRequest qor = new QueryObjectsRequest() { BucketName = BUCKET_NAME }; StringBuilder query = new StringBuilder(); if (accountId.Length > 0) { query.Append(USER_PREFIX + FIELD_ACCOUNT_ID + "==" + accountId + ""); } if (billingDate.Length > 0) { if (query.Length > 0) { query.Append(" and "); } query.Append(USER_PREFIX + FIELD_BILLING_DATE + "==" + billingDate + "T00:00:00Z"); } if (billType.Length > 0) { if (query.Length > 0) { query.Append(" and "); } query.Append(USER_PREFIX + FIELD_BILL_TYPE + "=='" + billType + "'"); } qor.Query = query.ToString(); QueryObjectsResponse res = s3.QueryObjects(qor); Console.WriteLine("--------------------------"); Console.WriteLine("Bucket: " + res.BucketName); Console.WriteLine("Query: " + qor.Query); Console.WriteLine(); Console.WriteLine("Key"); Console.WriteLine("--------------------------"); foreach (QueryObject obj in res.ObjectMatches) { Console.WriteLine(string.Format("{0}", obj.Name)); } Console.Write("Another? (Y/N) "); string another = Console.ReadLine(); if (another.ToUpper() == "N") { break; } } //cleanup foreach (string key in KEY_LIST) { s3.DeleteObject(BUCKET_NAME, key); } s3.DeleteBucket(BUCKET_NAME); }