public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ListKeyPoliciesResponse response = new ListKeyPoliciesResponse();

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("NextMarker", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextMarker = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("PolicyNames", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <string, StringUnmarshaller>(StringUnmarshaller.Instance);
                    response.PolicyNames = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Truncated", targetDepth))
                {
                    var unmarshaller = BoolUnmarshaller.Instance;
                    response.Truncated = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Example #2
0
        public async Task <string[]> ListKeyPoliciesAsync(string keyId, CancellationToken cancellationToken = default(CancellationToken))
        {
            ListKeyPoliciesResponse response = null;
            var results = new List <string>();

            while ((response = await _client.ListKeyPoliciesAsync(new ListKeyPoliciesRequest()
            {
                Marker = response?.NextMarker,
                Limit = 1000,
                KeyId = keyId
            }, cancellationToken).EnsureSuccessAsync()) != null)
            {
                if (!response.PolicyNames.IsNullOrEmpty())
                {
                    results.AddRange(response.PolicyNames);
                }

                if (!response.Truncated)
                {
                    break;
                }

                await Task.Delay(100);
            }

            return(results.ToArray());
        }