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

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

            ListOrganizationsResponse resp = new ListOrganizationsResponse();

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

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

                foreach (var obj in resp.OrganizationSummaries)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
Ejemplo n.º 2
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListOrganizationsRequest request;

            try
            {
                request = new ListOrganizationsRequest
                {
                    CompartmentId = CompartmentId,
                    OpcRequestId  = OpcRequestId,
                    Page          = Page,
                    Limit         = Limit
                };
                IEnumerable <ListOrganizationsResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.OrganizationCollection, true);
                }
                if (!ParameterSetName.Equals(AllPageSet) && !ParameterSetName.Equals(LimitSet) && response.OpcNextPage != null)
                {
                    WriteWarning("This operation supports pagination and not all resources were returned. Re-run using the -All option to auto paginate and list all resources.");
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }