internal QueryObjectsResponse QueryObjects(QueryObjectsRequest request) { var marshaller = new QueryObjectsRequestMarshaller(); var unmarshaller = QueryObjectsResponseUnmarshaller.Instance; return(Invoke <QueryObjectsRequest, QueryObjectsResponse>(request, marshaller, unmarshaller)); }
public void TestingAQueryWithVersioning() { string bucket = Guid.NewGuid().ToString(); PutBucketRequestECS pbr = new PutBucketRequestECS() { BucketName = bucket, }; pbr.SetMetadataSearchKeys(bucketMetadataSearchKeys); client.PutBucket(pbr); PutBucketVersioningRequest pbv = new PutBucketVersioningRequest() { BucketName = bucket, VersioningConfig = new S3BucketVersioningConfig() { Status = VersionStatus.Enabled } }; client.PutBucketVersioning(pbv); for (int i = 0; i < 5; i++) { PutObjectRequest object_request = new PutObjectRequest() { BucketName = bucket, Key = string.Format("obj-{0}", i), ContentBody = string.Format("This is sample content for object {0}.", i) }; object_request.Metadata.Add("x-amz-meta-decimalvalue", Convert.ToString(i * 2)); object_request.Metadata.Add("x-amz-meta-stringvalue", string.Format("sample-{0}", Convert.ToString(i))); client.PutObject(object_request); object_request.ContentBody = string.Format("This is sample content for object {0} after versioning has been enabled.", i); client.PutObject(object_request); } QueryObjectsRequest qor = new QueryObjectsRequest() { BucketName = bucket, IncludeOlderVersions = true, Query = "x-amz-meta-decimalvalue>4" }; var qor_respose = client.QueryObjects(qor); Assert.IsNotNull(qor_respose.ObjectMatches); Assert.AreEqual(4, qor_respose.ObjectMatches.Count); Assert.AreEqual(bucket, qor_respose.BucketName); CleanBucket(bucket); client.DeleteBucket(bucket); }
/// <summary> /// <para>Queries a pipeline for the names of objects that match a specified set of conditions.</para> <para>The objects returned by /// QueryObjects are paginated and then filtered by the value you set for query. This means the action may return an empty result set with a /// value set for marker. If <c>HasMoreResults</c> is set to <c>True</c> , you should continue to call QueryObjects, passing in the returned /// value for marker, until <c>HasMoreResults</c> returns <c>False</c> .</para> /// </summary> /// /// <param name="queryObjectsRequest">Container for the necessary parameters to execute the QueryObjects service method on /// AmazonDataPipeline.</param> /// /// <returns>The response from the QueryObjects service method, as returned by AmazonDataPipeline.</returns> /// /// <exception cref="T:Amazon.DataPipeline.Model.PipelineNotFoundException" /> /// <exception cref="T:Amazon.DataPipeline.Model.InternalServiceErrorException" /> /// <exception cref="T:Amazon.DataPipeline.Model.InvalidRequestException" /> /// <exception cref="T:Amazon.DataPipeline.Model.PipelineDeletedException" /> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> public Task <QueryObjectsResponse> QueryObjectsAsync(QueryObjectsRequest queryObjectsRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new QueryObjectsRequestMarshaller(); var unmarshaller = QueryObjectsResponseUnmarshaller.GetInstance(); return(Invoke <IRequest, QueryObjectsRequest, QueryObjectsResponse>(queryObjectsRequest, marshaller, unmarshaller, signer, cancellationToken)); }
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 void TestingAQueryWithMaxKeysPaging() { QueryObjectsRequest query_request = new QueryObjectsRequest() { BucketName = temp_bucket, Query = "x-amz-meta-decimalvalue>4", MaxKeys = 1 }; bool more = true; while (more) { var response = client.QueryObjects(query_request); Assert.AreEqual(temp_bucket, response.BucketName); Assert.AreEqual(1, response.ObjectMatches.Count); if (response.IsSetNextMarker()) { query_request.Marker = response.NextMarker; } else { more = false; } } }
/// <summary> /// Initiates the asynchronous execution of the QueryObjects operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the QueryObjects operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task <QueryObjectsResponse> QueryObjectsAsync(QueryObjectsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new QueryObjectsRequestMarshaller(); var unmarshaller = QueryObjectsResponseUnmarshaller.Instance; return(InvokeAsync <QueryObjectsRequest, QueryObjectsResponse>(request, marshaller, unmarshaller, cancellationToken)); }
/// <summary> /// Executes a bucket search and returns a list of objects including system and user metadata values based on supplied query. /// </summary> /// <param name="request">Container for the necessary parameters to execute the QueryObjects service method.</param> /// <returns>The response from the QueryObjects service method, as returned by ECS.</returns> public QueryObjectsResponse QueryObjects(QueryObjectsRequest request) { var marshaller = new QueryObjectsRequestMarshaller(); var unmarshaller = QueryObjectsResponseUnmarshaller.Instance; InvokeOptions invokeOptions = new InvokeOptions(); invokeOptions.RequestMarshaller = marshaller; invokeOptions.ResponseUnmarshaller = unmarshaller; return(Invoke <QueryObjectsResponse>(request, invokeOptions)); }
internal QueryObjectsResponse QueryObjects(QueryObjectsRequest request) { var task = QueryObjectsAsync(request); try { return(task.Result); } catch (AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return(null); } }
public void TestingAQueryString() { QueryObjectsRequest query_request = new QueryObjectsRequest() { BucketName = temp_bucket, Query = "x-amz-meta-stringvalue==\"sample-4\"", }; var response = client.QueryObjects(query_request); Assert.AreEqual(temp_bucket, response.BucketName); Assert.IsNotNull(response.ObjectMatches); Assert.AreEqual(1, response.ObjectMatches.Count); Assert.AreEqual(false, response.IsSetNextMarker()); }
public void TestingAQueryDecimal() { QueryObjectsRequest query_request = new QueryObjectsRequest() { BucketName = temp_bucket, Query = "x-amz-meta-decimalvalue>=6", }; var response = client.QueryObjects(query_request); Assert.AreEqual(temp_bucket, response.BucketName); Assert.IsNotNull(response.ObjectMatches); Assert.AreEqual(2, response.ObjectMatches.Count); Assert.AreEqual(false, response.IsSetNextMarker()); }
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); }