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

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("ListRolePoliciesResult", 2))
                    {
                        UnmarshallResult(context, response);
                        continue;
                    }

                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context);
                    }
                }
            }

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

            while ((response = await _IAMClient.ListRolePoliciesAsync(new ListRolePoliciesRequest()
            {
                MaxItems = 1000,
                Marker = response?.Marker,
                RoleName = roleName
            }, cancellationToken).EnsureSuccessAsync()) != null)
            {
                if (!response.PolicyNames.IsNullOrEmpty())
                {
                    results.AddRange(response.PolicyNames);
                }

                if (!response.IsTruncated)
                {
                    break;
                }

                await Task.Delay(100);
            }

            return(results.ToArray());
        }
Example #3
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, ListRolePoliciesResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("PolicyNames/member", targetDepth))
                    {
                        response.PolicyNames.Add(StringUnmarshaller.GetInstance().Unmarshall(context));

                        continue;
                    }
                    if (context.TestExpression("IsTruncated", targetDepth))
                    {
                        response.IsTruncated = BoolUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                    if (context.TestExpression("Marker", targetDepth))
                    {
                        response.Marker = StringUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return;
                }
            }



            return;
        }
        private static void UnmarshallResult(XmlUnmarshallerContext context, ListRolePoliciesResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.ReadAtDepth(originalDepth))
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("IsTruncated", targetDepth))
                    {
                        var unmarshaller = BoolUnmarshaller.Instance;
                        response.IsTruncated = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("Marker", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.Marker = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("PolicyNames/member", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.PolicyNames.Add(item);
                        continue;
                    }
                }
            }

            return;
        }
Example #5
0
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            ListRolePoliciesResponse response = new ListRolePoliciesResponse();

            while (context.Read())
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("ListRolePoliciesResult", 2))
                    {
                        response.ListRolePoliciesResult = ListRolePoliciesResultUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.GetInstance().Unmarshall(context);
                    }
                }
            }


            return(response);
        }