{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE StrictData #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -fno-warn-unused-binds #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-unused-matches #-} -- Derived from AWS service descriptions, licensed under Apache 2.0. -- | -- Module : Amazonka.Inspector2.ListMembers -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- List members associated with the Amazon Inspector delegated -- administrator for your organization. -- -- This operation returns paginated results. module Amazonka.Inspector2.ListMembers ( -- * Creating a Request ListMembers (..), newListMembers, -- * Request Lenses listMembers_maxResults, listMembers_nextToken, listMembers_onlyAssociated, -- * Destructuring the Response ListMembersResponse (..), newListMembersResponse, -- * Response Lenses listMembersResponse_members, listMembersResponse_nextToken, listMembersResponse_httpStatus, ) where import qualified Amazonka.Core as Core import qualified Amazonka.Core.Lens.Internal as Lens import qualified Amazonka.Data as Data import Amazonka.Inspector2.Types import qualified Amazonka.Prelude as Prelude import qualified Amazonka.Request as Request import qualified Amazonka.Response as Response -- | /See:/ 'newListMembers' smart constructor. data ListMembers = ListMembers' { -- | The maximum number of results to return in the response. maxResults :: Prelude.Maybe Prelude.Natural, -- | A token to use for paginating results that are returned in the response. -- Set the value of this parameter to null for the first request to a list -- action. For subsequent calls, use the @NextToken@ value returned from -- the previous request to continue listing results after the first page. nextToken :: Prelude.Maybe Prelude.Text, -- | Specifies whether to list only currently associated members if @True@ or -- to list all members within the organization if @False@. onlyAssociated :: Prelude.Maybe Prelude.Bool } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListMembers' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'maxResults', 'listMembers_maxResults' - The maximum number of results to return in the response. -- -- 'nextToken', 'listMembers_nextToken' - A token to use for paginating results that are returned in the response. -- Set the value of this parameter to null for the first request to a list -- action. For subsequent calls, use the @NextToken@ value returned from -- the previous request to continue listing results after the first page. -- -- 'onlyAssociated', 'listMembers_onlyAssociated' - Specifies whether to list only currently associated members if @True@ or -- to list all members within the organization if @False@. newListMembers :: ListMembers newListMembers = ListMembers' { maxResults = Prelude.Nothing, nextToken = Prelude.Nothing, onlyAssociated = Prelude.Nothing } -- | The maximum number of results to return in the response. listMembers_maxResults :: Lens.Lens' ListMembers (Prelude.Maybe Prelude.Natural) listMembers_maxResults = Lens.lens (\ListMembers' {maxResults} -> maxResults) (\s@ListMembers' {} a -> s {maxResults = a} :: ListMembers) -- | A token to use for paginating results that are returned in the response. -- Set the value of this parameter to null for the first request to a list -- action. For subsequent calls, use the @NextToken@ value returned from -- the previous request to continue listing results after the first page. listMembers_nextToken :: Lens.Lens' ListMembers (Prelude.Maybe Prelude.Text) listMembers_nextToken = Lens.lens (\ListMembers' {nextToken} -> nextToken) (\s@ListMembers' {} a -> s {nextToken = a} :: ListMembers) -- | Specifies whether to list only currently associated members if @True@ or -- to list all members within the organization if @False@. listMembers_onlyAssociated :: Lens.Lens' ListMembers (Prelude.Maybe Prelude.Bool) listMembers_onlyAssociated = Lens.lens (\ListMembers' {onlyAssociated} -> onlyAssociated) (\s@ListMembers' {} a -> s {onlyAssociated = a} :: ListMembers) instance Core.AWSPager ListMembers where page rq rs | Core.stop ( rs Lens.^? listMembersResponse_nextToken Prelude.. Lens._Just ) = Prelude.Nothing | Core.stop ( rs Lens.^? listMembersResponse_members Prelude.. Lens._Just ) = Prelude.Nothing | Prelude.otherwise = Prelude.Just Prelude.$ rq Prelude.& listMembers_nextToken Lens..~ rs Lens.^? listMembersResponse_nextToken Prelude.. Lens._Just instance Core.AWSRequest ListMembers where type AWSResponse ListMembers = ListMembersResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> ListMembersResponse' Prelude.<$> (x Data..?> "members" Core..!@ Prelude.mempty) Prelude.<*> (x Data..?> "nextToken") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable ListMembers where hashWithSalt _salt ListMembers' {..} = _salt `Prelude.hashWithSalt` maxResults `Prelude.hashWithSalt` nextToken `Prelude.hashWithSalt` onlyAssociated instance Prelude.NFData ListMembers where rnf ListMembers' {..} = Prelude.rnf maxResults `Prelude.seq` Prelude.rnf nextToken `Prelude.seq` Prelude.rnf onlyAssociated instance Data.ToHeaders ListMembers where toHeaders = Prelude.const ( Prelude.mconcat [ "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON ListMembers where toJSON ListMembers' {..} = Data.object ( Prelude.catMaybes [ ("maxResults" Data..=) Prelude.<$> maxResults, ("nextToken" Data..=) Prelude.<$> nextToken, ("onlyAssociated" Data..=) Prelude.<$> onlyAssociated ] ) instance Data.ToPath ListMembers where toPath = Prelude.const "/members/list" instance Data.ToQuery ListMembers where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newListMembersResponse' smart constructor. data ListMembersResponse = ListMembersResponse' { -- | An object that contains details for each member account. members :: Prelude.Maybe [Member], -- | The pagination parameter to be used on the next list operation to -- retrieve more items. nextToken :: Prelude.Maybe Prelude.Text, -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListMembersResponse' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'members', 'listMembersResponse_members' - An object that contains details for each member account. -- -- 'nextToken', 'listMembersResponse_nextToken' - The pagination parameter to be used on the next list operation to -- retrieve more items. -- -- 'httpStatus', 'listMembersResponse_httpStatus' - The response's http status code. newListMembersResponse :: -- | 'httpStatus' Prelude.Int -> ListMembersResponse newListMembersResponse pHttpStatus_ = ListMembersResponse' { members = Prelude.Nothing, nextToken = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | An object that contains details for each member account. listMembersResponse_members :: Lens.Lens' ListMembersResponse (Prelude.Maybe [Member]) listMembersResponse_members = Lens.lens (\ListMembersResponse' {members} -> members) (\s@ListMembersResponse' {} a -> s {members = a} :: ListMembersResponse) Prelude.. Lens.mapping Lens.coerced -- | The pagination parameter to be used on the next list operation to -- retrieve more items. listMembersResponse_nextToken :: Lens.Lens' ListMembersResponse (Prelude.Maybe Prelude.Text) listMembersResponse_nextToken = Lens.lens (\ListMembersResponse' {nextToken} -> nextToken) (\s@ListMembersResponse' {} a -> s {nextToken = a} :: ListMembersResponse) -- | The response's http status code. listMembersResponse_httpStatus :: Lens.Lens' ListMembersResponse Prelude.Int listMembersResponse_httpStatus = Lens.lens (\ListMembersResponse' {httpStatus} -> httpStatus) (\s@ListMembersResponse' {} a -> s {httpStatus = a} :: ListMembersResponse) instance Prelude.NFData ListMembersResponse where rnf ListMembersResponse' {..} = Prelude.rnf members `Prelude.seq` Prelude.rnf nextToken `Prelude.seq` Prelude.rnf httpStatus