Example #1
0
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            GetAccountAuthorizationDetailsResponse response = new GetAccountAuthorizationDetailsResponse();

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

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

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

            return(response);
        }
        private static void UnmarshallResult(XmlUnmarshallerContext context, GetAccountAuthorizationDetailsResponse 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("GroupDetailList/member", targetDepth))
                    {
                        var unmarshaller = GroupDetailUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.GroupDetailList.Add(item);
                        continue;
                    }
                    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("Policies/member", targetDepth))
                    {
                        var unmarshaller = ManagedPolicyDetailUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.Policies.Add(item);
                        continue;
                    }
                    if (context.TestExpression("RoleDetailList/member", targetDepth))
                    {
                        var unmarshaller = RoleDetailUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.RoleDetailList.Add(item);
                        continue;
                    }
                    if (context.TestExpression("UserDetailList/member", targetDepth))
                    {
                        var unmarshaller = UserDetailUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.UserDetailList.Add(item);
                        continue;
                    }
                }
            }

            return;
        }
Example #3
0
        private string BuildAuthorizedMessage(string id, GetAccountAuthorizationDetailsResponse response)
        {
            var policyNames = new List <string>();

            foreach (ManagedPolicyDetail policy in response.Policies)
            {
                policyNames.Add(policy.PolicyName);
            }

            string policyNamesText = string.Join(", ", policyNames);

            return($"id '{id}' is authorized for role policies '{policyNamesText}'.");
        }
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonIdentityManagementServiceConfig config = new AmazonIdentityManagementServiceConfig();

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

            GetAccountAuthorizationDetailsResponse resp = new GetAccountAuthorizationDetailsResponse();

            do
            {
                GetAccountAuthorizationDetailsRequest req = new GetAccountAuthorizationDetailsRequest
                {
                    Marker = resp.Marker
                    ,
                    MaxItems = maxItems
                };

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

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

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

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

                foreach (var obj in resp.GroupDetailList)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.Marker));
        }