/// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ListIndicesResponse response = new ListIndicesResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("indexNames", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <string, StringUnmarshaller>(StringUnmarshaller.Instance);
                    response.IndexNames = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("nextToken", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextToken = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
예제 #2
0
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonKendraConfig config = new AmazonKendraConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonKendraClient client = new AmazonKendraClient(creds, config);

            ListIndicesResponse resp = new ListIndicesResponse();

            do
            {
                ListIndicesRequest req = new ListIndicesRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

                resp = client.ListIndices(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.IndexConfigurationSummaryItems)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
    protected void PreviousTestCleanUp()
    {
        _indices = SearchClient.ListIndices();

        if (_indices?.Items == null || !_indices.Items.Any())
        {
            return;
        }

        var yesterday       = DateTime.UtcNow.AddDays(-1);
        var indicesToDelete = _indices?.Items?.Where(x =>
                                                     x.Name.Contains($"csharp_") && x.CreatedAt <= yesterday).ToList();

        var operations = new List <BatchOperation <string> >();

        if (!indicesToDelete.Any())
        {
            return;
        }

        foreach (var index in indicesToDelete)
        {
            operations.Add(new BatchOperation <string>
            {
                IndexName = index.Name,
                Action    = BatchActionType.Delete
            });
        }

        SearchClient.MultipleBatch(operations);
    }