Ejemplo n.º 1
0
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonElasticsearchConfig config = new AmazonElasticsearchConfig();

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

            DescribeOutboundCrossClusterSearchConnectionsResponse resp = new DescribeOutboundCrossClusterSearchConnectionsResponse();

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

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

                foreach (var obj in resp.CrossClusterSearchConnections)
                {
                    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)
        {
            DescribeOutboundCrossClusterSearchConnectionsResponse response = new DescribeOutboundCrossClusterSearchConnectionsResponse();

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("CrossClusterSearchConnections", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <OutboundCrossClusterSearchConnection, OutboundCrossClusterSearchConnectionUnmarshaller>(OutboundCrossClusterSearchConnectionUnmarshaller.Instance);
                    response.CrossClusterSearchConnections = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("NextToken", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextToken = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }