Ejemplo n.º 1
0
        public void QueryMarshallTest()
        {
            var request    = InstantiateClassGenerator.Execute <QueryRequest>();
            var marshaller = new QueryRequestMarshaller();

            var internalRequest = marshaller.Marshall(request);
            var jsonRequest     = UTF8Encoding.UTF8.GetString(internalRequest.Content);

            Comparer.CompareObjectToJson <QueryRequest>(request, jsonRequest);

            var webResponse = new WebResponseData
            {
                Headers =
                {
                    { "x-amzn-RequestId", Guid.NewGuid().ToString() },
                    { "x-amz-crc32",      "0"                       }
                }
            };
            var jsonResponse = new JsonSampleGenerator(service_model, service_model.FindOperation("Query").ResponseStructure).Execute();

            webResponse.Headers.Add("Content-Length", UTF8Encoding.UTF8.GetBytes(jsonResponse).Length.ToString());
            UnmarshallerContext context = new JsonUnmarshallerContext(Utils.CreateStreamFromString(jsonResponse), false, webResponse);
            var response = QueryResponseUnmarshaller.Instance.Unmarshall(context)
                           as QueryResponse;

            InstantiateClassGenerator.ValidateObjectFullyInstantiated(response);
        }
        public void Query_ValidationExceptionMarshallTest()
        {
            var operation = service_model.FindOperation("Query");

            var request         = InstantiateClassGenerator.Execute <QueryRequest>();
            var marshaller      = new QueryRequestMarshaller();
            var internalRequest = marshaller.Marshall(request);
            var jsonRequest     = UTF8Encoding.UTF8.GetString(internalRequest.Content);

            Comparer.CompareObjectToJson <QueryRequest>(request, jsonRequest);

            var exception    = operation.Exceptions.First(e => e.Name.Equals("ValidationException"));
            var jsonResponse = new JsonSampleGenerator(service_model, exception).Execute();
            var webResponse  = new WebResponseData
            {
                Headers =
                {
                    { "x-amzn-RequestId", Guid.NewGuid().ToString()                                  },
                    { "x-amz-crc32",      "0"                                                        },
                    { "x-amzn-ErrorType", "ValidationException"                                      },
                    { "Content-Length",   UTF8Encoding.UTF8.GetBytes(jsonResponse).Length.ToString() }
                }
            };
            var context  = new JsonUnmarshallerContext(Utils.CreateStreamFromString(jsonResponse), true, webResponse, true);
            var response = QueryResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK);

            InstantiateClassGenerator.ValidateObjectFullyInstantiated(response);
        }
        internal QueryResponse Query(QueryRequest request)
        {
            var marshaller   = new QueryRequestMarshaller();
            var unmarshaller = QueryResponseUnmarshaller.Instance;

            return(Invoke <QueryRequest, QueryResponse>(request, marshaller, unmarshaller));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// <para>A <i>Query</i> operation directly accesses items from a table using the table primary key, or from an index using the index key. You
        /// must provide a specific hash key value. You can narrow the scope of the query by using comparison operators on the range key value, or on
        /// the index key. You can use the <i>ScanIndexForward</i> parameter to get results in forward or reverse order, by range key or by index key.
        /// </para> <para>Queries that do not return results consume the minimum read capacity units according to the type of read.</para> <para>If the
        /// total number of items meeting the query criteria exceeds the result set size limit of 1 MB, the query stops and results are returned to the
        /// user with a <i>LastEvaluatedKey</i> to continue the query in a subsequent operation. Unlike a <i>Scan</i> operation, a <i>Query</i>
        /// operation never returns an empty result set <i>and</i> a
        /// <i>LastEvaluatedKey</i> . The <i>LastEvaluatedKey</i> is only provided if the results exceed 1 MB, or if you have used
        /// <i>Limit</i> . </para> <para>You can query a table, a local secondary index (LSI), or a global secondary index (GSI). For a query on a table
        /// or on an LSI, you can set <i>ConsistentRead</i> to true and obtain a strongly consistent result. GSIs support eventually consistent reads
        /// only, so do not specify <i>ConsistentRead</i> when querying a GSI.</para>
        /// </summary>
        ///
        /// <param name="queryRequest">Container for the necessary parameters to execute the Query service method on AmazonDynamoDBv2.</param>
        ///
        /// <returns>The response from the Query service method, as returned by AmazonDynamoDBv2.</returns>
        ///
        /// <exception cref="T:Amazon.DynamoDBv2.Model.ResourceNotFoundException" />
        /// <exception cref="T:Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException" />
        /// <exception cref="T:Amazon.DynamoDBv2.Model.InternalServerErrorException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        public Task <QueryResponse> QueryAsync(QueryRequest queryRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new QueryRequestMarshaller();
            var unmarshaller = QueryResponseUnmarshaller.GetInstance();

            return(Invoke <IRequest, QueryRequest, QueryResponse>(queryRequest, marshaller, unmarshaller, signer, cancellationToken));
        }
        /// <summary>
        /// Initiates the asynchronous execution of the Query operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the Query 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 <QueryResponse> QueryAsync(QueryRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new QueryRequestMarshaller();
            var unmarshaller = QueryResponseUnmarshaller.Instance;

            return(InvokeAsync <QueryRequest, QueryResponse>(request, marshaller,
                                                             unmarshaller, cancellationToken));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initiates the asynchronous execution of the Query operation.
        /// <seealso cref="Amazon.DynamoDBv2.IAmazonDynamoDB"/>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the Query operation.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// <returns>void</returns>
        public void QueryAsync(QueryRequest request, AmazonServiceCallback callback, object state)
        {
            if (!AmazonInitializer.IsInitialized)
            {
                throw new Exception("AWSPrefab is not added to the scene");
            }

            ThreadPool.QueueUserWorkItem(new WaitCallback(delegate
            {
                var marshaller   = new QueryRequestMarshaller();
                var unmarshaller = QueryResponseUnmarshaller.Instance;
                Invoke(request, callback, state, marshaller, unmarshaller, signer);
            }));
            return;
        }
        /// <summary>
        /// Initiates the asynchronous execution of the Query operation.
        /// <seealso cref="Amazon.DynamoDBv2.IAmazonDynamoDB"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the Query 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<QueryResponse> QueryAsync(QueryRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new QueryRequestMarshaller();
            var unmarshaller = QueryResponseUnmarshaller.Instance;

            return InvokeAsync<QueryRequest,QueryResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
        internal QueryResponse Query(QueryRequest request)
        {
            var marshaller = new QueryRequestMarshaller();
            var unmarshaller = QueryResponseUnmarshaller.Instance;

            return Invoke<QueryRequest,QueryResponse>(request, marshaller, unmarshaller);
        }
Ejemplo n.º 9
0
        public void QueryMarshallTest()
        {
            var request = InstantiateClassGenerator.Execute<QueryRequest>();
            var marshaller = new QueryRequestMarshaller();

            var internalRequest = marshaller.Marshall(request);
            var jsonRequest = UTF8Encoding.UTF8.GetString(internalRequest.Content);                        
            Comparer.CompareObjectToJson<QueryRequest>(request,jsonRequest);

            var webResponse = new WebResponseData
            {
                Headers = {
                    {"x-amzn-RequestId", Guid.NewGuid().ToString()},
                    {"x-amz-crc32","0"}
                }
            };
            var jsonResponse = new JsonSampleGenerator(service_model, service_model.FindOperation("Query").ResponseStructure).Execute();
            webResponse.Headers.Add("Content-Length", UTF8Encoding.UTF8.GetBytes(jsonResponse).Length.ToString());
            UnmarshallerContext context = new JsonUnmarshallerContext(Utils.CreateStreamFromString(jsonResponse), false, webResponse);
            var response = QueryResponseUnmarshaller.Instance.Unmarshall(context)
                as QueryResponse;
            InstantiateClassGenerator.ValidateObjectFullyInstantiated(response);
        }
 IAsyncResult invokeQuery(QueryRequest queryRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new QueryRequestMarshaller().Marshall(queryRequest);
     var unmarshaller = QueryResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
        /// <summary>
        /// <para>A <i>Query</i> operation directly accesses items from a table using the table primary key, or from an index using the index key. You
        /// must provide a specific hash key value. You can narrow the scope of the query by using comparison operators on the range key value, or on
        /// the index key. You can use the <i>ScanIndexForward</i> parameter to get results in forward or reverse order, by range key or by index key.
        /// </para> <para>Queries that do not return results consume the minimum read capacity units according to the type of read.</para> <para>If the
        /// total number of items meeting the query criteria exceeds the result set size limit of 1 MB, the query stops and results are returned to the
        /// user with a <i>LastEvaluatedKey</i> to continue the query in a subsequent operation. Unlike a <i>Scan</i> operation, a <i>Query</i>
        /// operation never returns an empty result set <i>and</i> a
        /// <i>LastEvaluatedKey</i> . The <i>LastEvaluatedKey</i> is only provided if the results exceed 1 MB, or if you have used
        /// <i>Limit</i> . </para> <para>You can query a table, a local secondary index, or a global secondary index. For a query on a table or on a
        /// local secondary index, you can set <i>ConsistentRead</i> to true and obtain a strongly consistent result. Global secondary indexes support
        /// eventually consistent reads only, so do not specify <i>ConsistentRead</i> when querying a global secondary index.</para>
        /// </summary>
        /// 
        /// <param name="queryRequest">Container for the necessary parameters to execute the Query service method on AmazonDynamoDBv2.</param>
        /// 
        /// <returns>The response from the Query service method, as returned by AmazonDynamoDBv2.</returns>
        /// 
        /// <exception cref="T:Amazon.DynamoDBv2.Model.ResourceNotFoundException" />
        /// <exception cref="T:Amazon.DynamoDBv2.Model.ProvisionedThroughputExceededException" />
        /// <exception cref="T:Amazon.DynamoDBv2.Model.InternalServerErrorException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<QueryResponse> QueryAsync(QueryRequest queryRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new QueryRequestMarshaller();
            var unmarshaller = QueryResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, QueryRequest, QueryResponse>(queryRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Initiates the asynchronous execution of the Query operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the Query operation on AmazonDynamoDBClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndQuery
        ///         operation.</returns>
        public IAsyncResult BeginQuery(QueryRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new QueryRequestMarshaller();
            var unmarshaller = QueryResponseUnmarshaller.Instance;

            return BeginInvoke<QueryRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
 /// <summary>
 /// <para> The Query operation gets the values of one or more items and its attributes by primary key (composite primary key, only). Narrow the
 /// scope of the query using comparison operators on the RangeKeyValue of the composite key. Use the ScanIndexForward parameter to get results
 /// in forward or reverse order by range key. </para>
 /// </summary>
 /// 
 /// <param name="queryRequest">Container for the necessary parameters to execute the Query service method on AmazonDynamoDB.</param>
 /// 
 /// <returns>The response from the Query service method, as returned by AmazonDynamoDB.</returns>
 /// 
 /// <exception cref="ProvisionedThroughputExceededException"/>
 /// <exception cref="InternalServerErrorException"/>
 /// <exception cref="ResourceNotFoundException"/>
 public QueryResponse Query(QueryRequest queryRequest)
 {
     IRequest<QueryRequest> request = new QueryRequestMarshaller().Marshall(queryRequest);
     QueryResponse response = Invoke<QueryRequest, QueryResponse> (request, this.signer, QueryResponseUnmarshaller.GetInstance());
     return response;
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Initiates the asynchronous execution of the Query operation.
        /// <seealso cref="Amazon.DynamoDBv2.IAmazonDynamoDB.Query"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the Query 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 async Task<QueryResponse> QueryAsync(QueryRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new QueryRequestMarshaller();
            var unmarshaller = QueryResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, QueryRequest, QueryResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Initiates the asynchronous execution of the Query operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the Query operation on AmazonDynamoDBClient.</param>
 /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
 /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public void QueryAsync(QueryRequest request, AmazonServiceCallback<QueryRequest, QueryResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new QueryRequestMarshaller();
     var unmarshaller = QueryResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<QueryRequest,QueryResponse> responseObject 
                     = new AmazonServiceResult<QueryRequest,QueryResponse>((QueryRequest)req, (QueryResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<QueryRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }