Exemple #1
0
        /// <summary>
        /// Initializes the Organizations client object and then uses it to
        /// call the ListOrganizationalUnitsForParentAsync method to retrieve
        /// the list of Organizational Units.
        /// </summary>
        public static async Task Main()
        {
            // Create the client object using the default account.
            IAmazonOrganizations client = new AmazonOrganizationsClient();

            var parentId = "r-sso8";

            var request = new ListOrganizationalUnitsForParentRequest
            {
                ParentId   = parentId,
                MaxResults = 5,
            };

            var response = new ListOrganizationalUnitsForParentResponse();

            try
            {
                do
                {
                    response = await client.ListOrganizationalUnitsForParentAsync(request);

                    response.OrganizationalUnits.ForEach(u => DisplayOrganizationalUnit(u));
                    if (response.NextToken is not null)
                    {
                        request.NextToken = response.NextToken;
                    }
                } while (response.NextToken is not null);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #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)
        {
            ListOrganizationalUnitsForParentResponse response = new ListOrganizationalUnitsForParentResponse();

            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("OrganizationalUnits", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <OrganizationalUnit, OrganizationalUnitUnmarshaller>(OrganizationalUnitUnmarshaller.Instance);
                    response.OrganizationalUnits = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }