public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonResourceGroupsConfig config = new AmazonResourceGroupsConfig();

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

            SearchResourcesResponse resp = new SearchResourcesResponse();

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

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

                foreach (var obj in resp.ResourceIdentifiers)
                {
                    AddObject(obj);
                }

                foreach (var obj in resp.QueryErrors)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
示例#2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            SearchResourcesResponse response = new SearchResourcesResponse();

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

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

            return(response);
        }