예제 #1
0
        /// <summary>
        /// Creates the Organizations client and then calls its
        /// ListAccountsAsync method.
        /// </summary>
        static async Task Main()
        {
            // Create the client object using the default account.
            IAmazonOrganizations client = new AmazonOrganizationsClient();

            var request = new ListAccountsRequest
            {
                MaxResults = 5,
            };

            var response = new ListAccountsResponse();

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

                    response.Accounts.ForEach(a => DisplayAccounts(a));
                    if (response.NextToken is not null)
                    {
                        request.NextToken = response.NextToken;
                    }
                } while (response.NextToken is not null);
            }
            catch (AWSOrganizationsNotInUseException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #2
0
        internal virtual ListAccountsResponse ListAccounts(ListAccountsRequest request)
        {
            var marshaller   = ListAccountsRequestMarshaller.Instance;
            var unmarshaller = ListAccountsResponseUnmarshaller.Instance;

            return(Invoke <ListAccountsRequest, ListAccountsResponse>(request, marshaller, unmarshaller));
        }
예제 #3
0
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonOrganizationsConfig config = new AmazonOrganizationsConfig();

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

            ListAccountsResponse resp = new ListAccountsResponse();

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

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

                foreach (var obj in resp.Accounts)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
예제 #4
0
        public async Task <ApiPaginationResponse <AccountModel> > List([FromQuery] ListAccountsRequest request)
        {
            var query    = Mapper.Map <ListAccountsQuery>(request);
            var response = await Mediator.Send(query);

            return(Mapper.Map <ApiPaginationResponse <AccountModel> >(response));
        }
예제 #5
0
        /// <summary>
        /// Initiates the asynchronous execution of the ListAccounts operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the ListAccounts operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/chime-2018-05-01/ListAccounts">REST API Reference for ListAccounts Operation</seealso>
        public virtual Task <ListAccountsResponse> ListAccountsAsync(ListAccountsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = ListAccountsRequestMarshaller.Instance;
            var unmarshaller = ListAccountsResponseUnmarshaller.Instance;

            return(InvokeAsync <ListAccountsRequest, ListAccountsResponse>(request, marshaller,
                                                                           unmarshaller, cancellationToken));
        }
예제 #6
0
        /// <summary>
        /// Lists all AWS accounts assigned to the user. These AWS accounts are assigned by the
        /// administrator of the account. For more information, see <a href="https://docs.aws.amazon.com/singlesignon/latest/userguide/useraccess.html#assignusers">Assign
        /// User Access</a> in the <i>AWS SSO User Guide</i>. This operation returns a paginated
        /// response.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the ListAccounts service method.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        ///
        /// <returns>The response from the ListAccounts service method, as returned by SSO.</returns>
        /// <exception cref="Amazon.SSO.Model.InvalidRequestException">
        /// Indicates that a problem occurred with the input to the request. For example, a required
        /// parameter might be missing or out of range.
        /// </exception>
        /// <exception cref="Amazon.SSO.Model.ResourceNotFoundException">
        /// The specified resource doesn't exist.
        /// </exception>
        /// <exception cref="Amazon.SSO.Model.TooManyRequestsException">
        /// Indicates that the request is being made too frequently and is more than what the
        /// server can handle.
        /// </exception>
        /// <exception cref="Amazon.SSO.Model.UnauthorizedException">
        /// Indicates that the request is not authorized. This can happen due to an invalid access
        /// token in the request.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/sso-2019-06-10/ListAccounts">REST API Reference for ListAccounts Operation</seealso>
        public virtual Task <ListAccountsResponse> ListAccountsAsync(ListAccountsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = ListAccountsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = ListAccountsResponseUnmarshaller.Instance;

            return(InvokeAsync <ListAccountsResponse>(request, options, cancellationToken));
        }
예제 #7
0
        internal virtual ListAccountsResponse ListAccounts(ListAccountsRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = ListAccountsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = ListAccountsResponseUnmarshaller.Instance;

            return(Invoke <ListAccountsResponse>(request, options));
        }
예제 #8
0
        /// <summary>
        /// Initiates the asynchronous execution of the ListAccounts operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the ListAccounts operation on AmazonSSOClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        ///
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndListAccounts
        ///         operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/sso-2019-06-10/ListAccounts">REST API Reference for ListAccounts Operation</seealso>
        public virtual IAsyncResult BeginListAccounts(ListAccountsRequest request, AsyncCallback callback, object state)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = ListAccountsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = ListAccountsResponseUnmarshaller.Instance;

            return(BeginInvoke(request, options, callback, state));
        }
예제 #9
0
        public ListAccountsResponse ListAccounts(ListAccountsRequest request)
        {
            var command = new ListAccounts(_apiKey, _secret, _baseUri, _authenticator, _builder)
            {
                Parameters = request
            };

            return((ListAccountsResponse)((ICommandExecutor)this).Execute(command));
        }
예제 #10
0
        public async Task <List <AccountDto> > LoadAccountsAsync()
        {
            ListAccountsRequest request = new ListAccountsRequest {
                RequestSource = Source.Measurements, RequestingUser = new UserSummaryDto()
            };

            var response = await _bus.RequestAsync <ListAccountsRequest, ListAccountsResponse>(request);

            return(response.Accounts);
        }
예제 #11
0
        public ListAccountsResponse listAccounts(string nextToken = null)
        {
            AmazonOrganizationsClient client = new AmazonOrganizationsClient();

            ListAccountsRequest request = new ListAccountsRequest()
            {
                NextToken = nextToken
            };
            ListAccountsResponse response = client.ListAccountsAsync(request).Result;

            return(response);
        }
        public async Task <IActionResult> List([FromQuery] ListAccountsRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }

            var response = await _accountService.ListAsync(request);

            if (!response.IsValid)
            {
                return(BadRequest(response.Message));
            }
            return(Ok(response));
        }
예제 #13
0
        public async Task <ListResponse <AccountsListItemDto> > ListAsync(ListAccountsRequest request)
        {
            var loggedUser = await _authenticationService.GetLoggedUserAsync();

            var filter = _mapper.Map <ListAccountsRequest, AccountsFilter>(request);

            filter.UserId = loggedUser.User.Id;

            var accounts = await _accountRepository.GetListAsync(filter);

            var accountsCount = await _accountRepository.CountAsync(filter);

            var accountsDtosList = _mapper.Map <List <Account>, List <AccountsListItemDto> >(accounts);

            return(new ListResponse <AccountsListItemDto>(accountsDtosList, accountsCount));
        }
예제 #14
0
        /// <summary>Snippet for ListAccountsAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task ListAccountsRequestObjectAsync()
        {
            // Create client
            AnalyticsAdminServiceClient analyticsAdminServiceClient = await AnalyticsAdminServiceClient.CreateAsync();

            // Initialize request argument(s)
            ListAccountsRequest request = new ListAccountsRequest {
                ShowDeleted = false,
            };
            // Make the request
            PagedAsyncEnumerable <ListAccountsResponse, Account> response = analyticsAdminServiceClient.ListAccountsAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((Account item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListAccountsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Account item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int            pageSize   = 10;
            Page <Account> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (Account item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
        }