{-# 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.RAM.ListPrincipals
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists the principals that you have shared resources with or that have
-- shared resources with you.
--
-- This operation returns paginated results.
module Amazonka.RAM.ListPrincipals
  ( -- * Creating a Request
    ListPrincipals (..),
    newListPrincipals,

    -- * Request Lenses
    listPrincipals_resourceType,
    listPrincipals_principals,
    listPrincipals_nextToken,
    listPrincipals_resourceArn,
    listPrincipals_maxResults,
    listPrincipals_resourceShareArns,
    listPrincipals_resourceOwner,

    -- * Destructuring the Response
    ListPrincipalsResponse (..),
    newListPrincipalsResponse,

    -- * Response Lenses
    listPrincipalsResponse_principals,
    listPrincipalsResponse_nextToken,
    listPrincipalsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RAM.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListPrincipals' smart constructor.
data ListPrincipals = ListPrincipals'
  { -- | The resource type.
    --
    -- Valid values: @acm-pca:CertificateAuthority@ | @appmesh:Mesh@ |
    -- @codebuild:Project@ | @codebuild:ReportGroup@ |
    -- @ec2:CapacityReservation@ | @ec2:DedicatedHost@ |
    -- @ec2:LocalGatewayRouteTable@ | @ec2:PrefixList@ | @ec2:Subnet@ |
    -- @ec2:TrafficMirrorTarget@ | @ec2:TransitGateway@ |
    -- @imagebuilder:Component@ | @imagebuilder:Image@ |
    -- @imagebuilder:ImageRecipe@ | @imagebuilder:ContainerRecipe@ |
    -- @glue:Catalog@ | @glue:Database@ | @glue:Table@ |
    -- @license-manager:LicenseConfiguration@ I
    -- @network-firewall:FirewallPolicy@ | @network-firewall:StatefulRuleGroup@
    -- | @network-firewall:StatelessRuleGroup@ | @outposts:Outpost@ |
    -- @resource-groups:Group@ | @rds:Cluster@ |
    -- @route53resolver:FirewallRuleGroup@
    -- |@route53resolver:ResolverQueryLogConfig@ |
    -- @route53resolver:ResolverRule@ | @s3-outposts:Outpost@ |
    -- @ssm-contacts:Contact@ | @ssm-incidents:ResponsePlan@
    ListPrincipals -> Maybe Text
resourceType :: Prelude.Maybe Prelude.Text,
    -- | The principals.
    ListPrincipals -> Maybe [Text]
principals :: Prelude.Maybe [Prelude.Text],
    -- | The token for the next page of results.
    ListPrincipals -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the resource.
    ListPrincipals -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return with a single call. To retrieve
    -- the remaining results, make another call with the returned @nextToken@
    -- value.
    ListPrincipals -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Resource Names (ARN) of the resource shares.
    ListPrincipals -> Maybe [Text]
resourceShareArns :: Prelude.Maybe [Prelude.Text],
    -- | The type of owner.
    ListPrincipals -> ResourceOwner
resourceOwner :: ResourceOwner
  }
  deriving (ListPrincipals -> ListPrincipals -> Bool
(ListPrincipals -> ListPrincipals -> Bool)
-> (ListPrincipals -> ListPrincipals -> Bool) -> Eq ListPrincipals
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPrincipals -> ListPrincipals -> Bool
$c/= :: ListPrincipals -> ListPrincipals -> Bool
== :: ListPrincipals -> ListPrincipals -> Bool
$c== :: ListPrincipals -> ListPrincipals -> Bool
Prelude.Eq, ReadPrec [ListPrincipals]
ReadPrec ListPrincipals
Int -> ReadS ListPrincipals
ReadS [ListPrincipals]
(Int -> ReadS ListPrincipals)
-> ReadS [ListPrincipals]
-> ReadPrec ListPrincipals
-> ReadPrec [ListPrincipals]
-> Read ListPrincipals
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPrincipals]
$creadListPrec :: ReadPrec [ListPrincipals]
readPrec :: ReadPrec ListPrincipals
$creadPrec :: ReadPrec ListPrincipals
readList :: ReadS [ListPrincipals]
$creadList :: ReadS [ListPrincipals]
readsPrec :: Int -> ReadS ListPrincipals
$creadsPrec :: Int -> ReadS ListPrincipals
Prelude.Read, Int -> ListPrincipals -> ShowS
[ListPrincipals] -> ShowS
ListPrincipals -> String
(Int -> ListPrincipals -> ShowS)
-> (ListPrincipals -> String)
-> ([ListPrincipals] -> ShowS)
-> Show ListPrincipals
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPrincipals] -> ShowS
$cshowList :: [ListPrincipals] -> ShowS
show :: ListPrincipals -> String
$cshow :: ListPrincipals -> String
showsPrec :: Int -> ListPrincipals -> ShowS
$cshowsPrec :: Int -> ListPrincipals -> ShowS
Prelude.Show, (forall x. ListPrincipals -> Rep ListPrincipals x)
-> (forall x. Rep ListPrincipals x -> ListPrincipals)
-> Generic ListPrincipals
forall x. Rep ListPrincipals x -> ListPrincipals
forall x. ListPrincipals -> Rep ListPrincipals x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPrincipals x -> ListPrincipals
$cfrom :: forall x. ListPrincipals -> Rep ListPrincipals x
Prelude.Generic)

-- |
-- Create a value of 'ListPrincipals' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'resourceType', 'listPrincipals_resourceType' - The resource type.
--
-- Valid values: @acm-pca:CertificateAuthority@ | @appmesh:Mesh@ |
-- @codebuild:Project@ | @codebuild:ReportGroup@ |
-- @ec2:CapacityReservation@ | @ec2:DedicatedHost@ |
-- @ec2:LocalGatewayRouteTable@ | @ec2:PrefixList@ | @ec2:Subnet@ |
-- @ec2:TrafficMirrorTarget@ | @ec2:TransitGateway@ |
-- @imagebuilder:Component@ | @imagebuilder:Image@ |
-- @imagebuilder:ImageRecipe@ | @imagebuilder:ContainerRecipe@ |
-- @glue:Catalog@ | @glue:Database@ | @glue:Table@ |
-- @license-manager:LicenseConfiguration@ I
-- @network-firewall:FirewallPolicy@ | @network-firewall:StatefulRuleGroup@
-- | @network-firewall:StatelessRuleGroup@ | @outposts:Outpost@ |
-- @resource-groups:Group@ | @rds:Cluster@ |
-- @route53resolver:FirewallRuleGroup@
-- |@route53resolver:ResolverQueryLogConfig@ |
-- @route53resolver:ResolverRule@ | @s3-outposts:Outpost@ |
-- @ssm-contacts:Contact@ | @ssm-incidents:ResponsePlan@
--
-- 'principals', 'listPrincipals_principals' - The principals.
--
-- 'nextToken', 'listPrincipals_nextToken' - The token for the next page of results.
--
-- 'resourceArn', 'listPrincipals_resourceArn' - The Amazon Resource Name (ARN) of the resource.
--
-- 'maxResults', 'listPrincipals_maxResults' - The maximum number of results to return with a single call. To retrieve
-- the remaining results, make another call with the returned @nextToken@
-- value.
--
-- 'resourceShareArns', 'listPrincipals_resourceShareArns' - The Amazon Resource Names (ARN) of the resource shares.
--
-- 'resourceOwner', 'listPrincipals_resourceOwner' - The type of owner.
newListPrincipals ::
  -- | 'resourceOwner'
  ResourceOwner ->
  ListPrincipals
newListPrincipals :: ResourceOwner -> ListPrincipals
newListPrincipals ResourceOwner
pResourceOwner_ =
  ListPrincipals' :: Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Maybe [Text]
-> ResourceOwner
-> ListPrincipals
ListPrincipals'
    { $sel:resourceType:ListPrincipals' :: Maybe Text
resourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:principals:ListPrincipals' :: Maybe [Text]
principals = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListPrincipals' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:ListPrincipals' :: Maybe Text
resourceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListPrincipals' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceShareArns:ListPrincipals' :: Maybe [Text]
resourceShareArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceOwner:ListPrincipals' :: ResourceOwner
resourceOwner = ResourceOwner
pResourceOwner_
    }

-- | The resource type.
--
-- Valid values: @acm-pca:CertificateAuthority@ | @appmesh:Mesh@ |
-- @codebuild:Project@ | @codebuild:ReportGroup@ |
-- @ec2:CapacityReservation@ | @ec2:DedicatedHost@ |
-- @ec2:LocalGatewayRouteTable@ | @ec2:PrefixList@ | @ec2:Subnet@ |
-- @ec2:TrafficMirrorTarget@ | @ec2:TransitGateway@ |
-- @imagebuilder:Component@ | @imagebuilder:Image@ |
-- @imagebuilder:ImageRecipe@ | @imagebuilder:ContainerRecipe@ |
-- @glue:Catalog@ | @glue:Database@ | @glue:Table@ |
-- @license-manager:LicenseConfiguration@ I
-- @network-firewall:FirewallPolicy@ | @network-firewall:StatefulRuleGroup@
-- | @network-firewall:StatelessRuleGroup@ | @outposts:Outpost@ |
-- @resource-groups:Group@ | @rds:Cluster@ |
-- @route53resolver:FirewallRuleGroup@
-- |@route53resolver:ResolverQueryLogConfig@ |
-- @route53resolver:ResolverRule@ | @s3-outposts:Outpost@ |
-- @ssm-contacts:Contact@ | @ssm-incidents:ResponsePlan@
listPrincipals_resourceType :: Lens.Lens' ListPrincipals (Prelude.Maybe Prelude.Text)
listPrincipals_resourceType :: (Maybe Text -> f (Maybe Text))
-> ListPrincipals -> f ListPrincipals
listPrincipals_resourceType = (ListPrincipals -> Maybe Text)
-> (ListPrincipals -> Maybe Text -> ListPrincipals)
-> Lens ListPrincipals ListPrincipals (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipals' {Maybe Text
resourceType :: Maybe Text
$sel:resourceType:ListPrincipals' :: ListPrincipals -> Maybe Text
resourceType} -> Maybe Text
resourceType) (\s :: ListPrincipals
s@ListPrincipals' {} Maybe Text
a -> ListPrincipals
s {$sel:resourceType:ListPrincipals' :: Maybe Text
resourceType = Maybe Text
a} :: ListPrincipals)

-- | The principals.
listPrincipals_principals :: Lens.Lens' ListPrincipals (Prelude.Maybe [Prelude.Text])
listPrincipals_principals :: (Maybe [Text] -> f (Maybe [Text]))
-> ListPrincipals -> f ListPrincipals
listPrincipals_principals = (ListPrincipals -> Maybe [Text])
-> (ListPrincipals -> Maybe [Text] -> ListPrincipals)
-> Lens ListPrincipals ListPrincipals (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipals' {Maybe [Text]
principals :: Maybe [Text]
$sel:principals:ListPrincipals' :: ListPrincipals -> Maybe [Text]
principals} -> Maybe [Text]
principals) (\s :: ListPrincipals
s@ListPrincipals' {} Maybe [Text]
a -> ListPrincipals
s {$sel:principals:ListPrincipals' :: Maybe [Text]
principals = Maybe [Text]
a} :: ListPrincipals) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListPrincipals -> f ListPrincipals)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListPrincipals
-> f ListPrincipals
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token for the next page of results.
listPrincipals_nextToken :: Lens.Lens' ListPrincipals (Prelude.Maybe Prelude.Text)
listPrincipals_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListPrincipals -> f ListPrincipals
listPrincipals_nextToken = (ListPrincipals -> Maybe Text)
-> (ListPrincipals -> Maybe Text -> ListPrincipals)
-> Lens ListPrincipals ListPrincipals (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipals' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListPrincipals' :: ListPrincipals -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListPrincipals
s@ListPrincipals' {} Maybe Text
a -> ListPrincipals
s {$sel:nextToken:ListPrincipals' :: Maybe Text
nextToken = Maybe Text
a} :: ListPrincipals)

-- | The Amazon Resource Name (ARN) of the resource.
listPrincipals_resourceArn :: Lens.Lens' ListPrincipals (Prelude.Maybe Prelude.Text)
listPrincipals_resourceArn :: (Maybe Text -> f (Maybe Text))
-> ListPrincipals -> f ListPrincipals
listPrincipals_resourceArn = (ListPrincipals -> Maybe Text)
-> (ListPrincipals -> Maybe Text -> ListPrincipals)
-> Lens ListPrincipals ListPrincipals (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipals' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:ListPrincipals' :: ListPrincipals -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: ListPrincipals
s@ListPrincipals' {} Maybe Text
a -> ListPrincipals
s {$sel:resourceArn:ListPrincipals' :: Maybe Text
resourceArn = Maybe Text
a} :: ListPrincipals)

-- | The maximum number of results to return with a single call. To retrieve
-- the remaining results, make another call with the returned @nextToken@
-- value.
listPrincipals_maxResults :: Lens.Lens' ListPrincipals (Prelude.Maybe Prelude.Natural)
listPrincipals_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListPrincipals -> f ListPrincipals
listPrincipals_maxResults = (ListPrincipals -> Maybe Natural)
-> (ListPrincipals -> Maybe Natural -> ListPrincipals)
-> Lens
     ListPrincipals ListPrincipals (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipals' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListPrincipals' :: ListPrincipals -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListPrincipals
s@ListPrincipals' {} Maybe Natural
a -> ListPrincipals
s {$sel:maxResults:ListPrincipals' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListPrincipals)

-- | The Amazon Resource Names (ARN) of the resource shares.
listPrincipals_resourceShareArns :: Lens.Lens' ListPrincipals (Prelude.Maybe [Prelude.Text])
listPrincipals_resourceShareArns :: (Maybe [Text] -> f (Maybe [Text]))
-> ListPrincipals -> f ListPrincipals
listPrincipals_resourceShareArns = (ListPrincipals -> Maybe [Text])
-> (ListPrincipals -> Maybe [Text] -> ListPrincipals)
-> Lens ListPrincipals ListPrincipals (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipals' {Maybe [Text]
resourceShareArns :: Maybe [Text]
$sel:resourceShareArns:ListPrincipals' :: ListPrincipals -> Maybe [Text]
resourceShareArns} -> Maybe [Text]
resourceShareArns) (\s :: ListPrincipals
s@ListPrincipals' {} Maybe [Text]
a -> ListPrincipals
s {$sel:resourceShareArns:ListPrincipals' :: Maybe [Text]
resourceShareArns = Maybe [Text]
a} :: ListPrincipals) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListPrincipals -> f ListPrincipals)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListPrincipals
-> f ListPrincipals
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The type of owner.
listPrincipals_resourceOwner :: Lens.Lens' ListPrincipals ResourceOwner
listPrincipals_resourceOwner :: (ResourceOwner -> f ResourceOwner)
-> ListPrincipals -> f ListPrincipals
listPrincipals_resourceOwner = (ListPrincipals -> ResourceOwner)
-> (ListPrincipals -> ResourceOwner -> ListPrincipals)
-> Lens ListPrincipals ListPrincipals ResourceOwner ResourceOwner
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipals' {ResourceOwner
resourceOwner :: ResourceOwner
$sel:resourceOwner:ListPrincipals' :: ListPrincipals -> ResourceOwner
resourceOwner} -> ResourceOwner
resourceOwner) (\s :: ListPrincipals
s@ListPrincipals' {} ResourceOwner
a -> ListPrincipals
s {$sel:resourceOwner:ListPrincipals' :: ResourceOwner
resourceOwner = ResourceOwner
a} :: ListPrincipals)

instance Core.AWSPager ListPrincipals where
  page :: ListPrincipals
-> AWSResponse ListPrincipals -> Maybe ListPrincipals
page ListPrincipals
rq AWSResponse ListPrincipals
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPrincipals
ListPrincipalsResponse
rs
            ListPrincipalsResponse
-> Getting (First Text) ListPrincipalsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListPrincipalsResponse
-> Const (First Text) ListPrincipalsResponse
Lens' ListPrincipalsResponse (Maybe Text)
listPrincipalsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListPrincipalsResponse
 -> Const (First Text) ListPrincipalsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListPrincipalsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListPrincipals
forall a. Maybe a
Prelude.Nothing
    | Maybe [Principal] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPrincipals
ListPrincipalsResponse
rs
            ListPrincipalsResponse
-> Getting (First [Principal]) ListPrincipalsResponse [Principal]
-> Maybe [Principal]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Principal]
 -> Const (First [Principal]) (Maybe [Principal]))
-> ListPrincipalsResponse
-> Const (First [Principal]) ListPrincipalsResponse
Lens' ListPrincipalsResponse (Maybe [Principal])
listPrincipalsResponse_principals
              ((Maybe [Principal]
  -> Const (First [Principal]) (Maybe [Principal]))
 -> ListPrincipalsResponse
 -> Const (First [Principal]) ListPrincipalsResponse)
-> (([Principal] -> Const (First [Principal]) [Principal])
    -> Maybe [Principal]
    -> Const (First [Principal]) (Maybe [Principal]))
-> Getting (First [Principal]) ListPrincipalsResponse [Principal]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Principal] -> Const (First [Principal]) [Principal])
-> Maybe [Principal]
-> Const (First [Principal]) (Maybe [Principal])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListPrincipals
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListPrincipals -> Maybe ListPrincipals
forall a. a -> Maybe a
Prelude.Just (ListPrincipals -> Maybe ListPrincipals)
-> ListPrincipals -> Maybe ListPrincipals
forall a b. (a -> b) -> a -> b
Prelude.$
        ListPrincipals
rq
          ListPrincipals
-> (ListPrincipals -> ListPrincipals) -> ListPrincipals
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListPrincipals -> Identity ListPrincipals
Lens ListPrincipals ListPrincipals (Maybe Text) (Maybe Text)
listPrincipals_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListPrincipals -> Identity ListPrincipals)
-> Maybe Text -> ListPrincipals -> ListPrincipals
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListPrincipals
ListPrincipalsResponse
rs
          ListPrincipalsResponse
-> Getting (First Text) ListPrincipalsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListPrincipalsResponse
-> Const (First Text) ListPrincipalsResponse
Lens' ListPrincipalsResponse (Maybe Text)
listPrincipalsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListPrincipalsResponse
 -> Const (First Text) ListPrincipalsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListPrincipalsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListPrincipals where
  type
    AWSResponse ListPrincipals =
      ListPrincipalsResponse
  request :: ListPrincipals -> Request ListPrincipals
request = Service -> ListPrincipals -> Request ListPrincipals
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListPrincipals
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListPrincipals)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListPrincipals))
-> Logger
-> Service
-> Proxy ListPrincipals
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListPrincipals)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Principal] -> Maybe Text -> Int -> ListPrincipalsResponse
ListPrincipalsResponse'
            (Maybe [Principal] -> Maybe Text -> Int -> ListPrincipalsResponse)
-> Either String (Maybe [Principal])
-> Either String (Maybe Text -> Int -> ListPrincipalsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Principal]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"principals" Either String (Maybe (Maybe [Principal]))
-> Maybe [Principal] -> Either String (Maybe [Principal])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Principal]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> ListPrincipalsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListPrincipalsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextToken")
            Either String (Int -> ListPrincipalsResponse)
-> Either String Int -> Either String ListPrincipalsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListPrincipals

instance Prelude.NFData ListPrincipals

instance Core.ToHeaders ListPrincipals where
  toHeaders :: ListPrincipals -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListPrincipals -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON ListPrincipals where
  toJSON :: ListPrincipals -> Value
toJSON ListPrincipals' {Maybe Natural
Maybe [Text]
Maybe Text
ResourceOwner
resourceOwner :: ResourceOwner
resourceShareArns :: Maybe [Text]
maxResults :: Maybe Natural
resourceArn :: Maybe Text
nextToken :: Maybe Text
principals :: Maybe [Text]
resourceType :: Maybe Text
$sel:resourceOwner:ListPrincipals' :: ListPrincipals -> ResourceOwner
$sel:resourceShareArns:ListPrincipals' :: ListPrincipals -> Maybe [Text]
$sel:maxResults:ListPrincipals' :: ListPrincipals -> Maybe Natural
$sel:resourceArn:ListPrincipals' :: ListPrincipals -> Maybe Text
$sel:nextToken:ListPrincipals' :: ListPrincipals -> Maybe Text
$sel:principals:ListPrincipals' :: ListPrincipals -> Maybe [Text]
$sel:resourceType:ListPrincipals' :: ListPrincipals -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"resourceType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
resourceType,
            (Text
"principals" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
principals,
            (Text
"nextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"resourceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
resourceArn,
            (Text
"maxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            (Text
"resourceShareArns" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
resourceShareArns,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"resourceOwner" Text -> ResourceOwner -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ResourceOwner
resourceOwner)
          ]
      )

instance Core.ToPath ListPrincipals where
  toPath :: ListPrincipals -> ByteString
toPath = ByteString -> ListPrincipals -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/listprincipals"

instance Core.ToQuery ListPrincipals where
  toQuery :: ListPrincipals -> QueryString
toQuery = QueryString -> ListPrincipals -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListPrincipalsResponse' smart constructor.
data ListPrincipalsResponse = ListPrincipalsResponse'
  { -- | The principals.
    ListPrincipalsResponse -> Maybe [Principal]
principals :: Prelude.Maybe [Principal],
    -- | The token to use to retrieve the next page of results. This value is
    -- @null@ when there are no more results to return.
    ListPrincipalsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListPrincipalsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListPrincipalsResponse -> ListPrincipalsResponse -> Bool
(ListPrincipalsResponse -> ListPrincipalsResponse -> Bool)
-> (ListPrincipalsResponse -> ListPrincipalsResponse -> Bool)
-> Eq ListPrincipalsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPrincipalsResponse -> ListPrincipalsResponse -> Bool
$c/= :: ListPrincipalsResponse -> ListPrincipalsResponse -> Bool
== :: ListPrincipalsResponse -> ListPrincipalsResponse -> Bool
$c== :: ListPrincipalsResponse -> ListPrincipalsResponse -> Bool
Prelude.Eq, ReadPrec [ListPrincipalsResponse]
ReadPrec ListPrincipalsResponse
Int -> ReadS ListPrincipalsResponse
ReadS [ListPrincipalsResponse]
(Int -> ReadS ListPrincipalsResponse)
-> ReadS [ListPrincipalsResponse]
-> ReadPrec ListPrincipalsResponse
-> ReadPrec [ListPrincipalsResponse]
-> Read ListPrincipalsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPrincipalsResponse]
$creadListPrec :: ReadPrec [ListPrincipalsResponse]
readPrec :: ReadPrec ListPrincipalsResponse
$creadPrec :: ReadPrec ListPrincipalsResponse
readList :: ReadS [ListPrincipalsResponse]
$creadList :: ReadS [ListPrincipalsResponse]
readsPrec :: Int -> ReadS ListPrincipalsResponse
$creadsPrec :: Int -> ReadS ListPrincipalsResponse
Prelude.Read, Int -> ListPrincipalsResponse -> ShowS
[ListPrincipalsResponse] -> ShowS
ListPrincipalsResponse -> String
(Int -> ListPrincipalsResponse -> ShowS)
-> (ListPrincipalsResponse -> String)
-> ([ListPrincipalsResponse] -> ShowS)
-> Show ListPrincipalsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPrincipalsResponse] -> ShowS
$cshowList :: [ListPrincipalsResponse] -> ShowS
show :: ListPrincipalsResponse -> String
$cshow :: ListPrincipalsResponse -> String
showsPrec :: Int -> ListPrincipalsResponse -> ShowS
$cshowsPrec :: Int -> ListPrincipalsResponse -> ShowS
Prelude.Show, (forall x. ListPrincipalsResponse -> Rep ListPrincipalsResponse x)
-> (forall x.
    Rep ListPrincipalsResponse x -> ListPrincipalsResponse)
-> Generic ListPrincipalsResponse
forall x. Rep ListPrincipalsResponse x -> ListPrincipalsResponse
forall x. ListPrincipalsResponse -> Rep ListPrincipalsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPrincipalsResponse x -> ListPrincipalsResponse
$cfrom :: forall x. ListPrincipalsResponse -> Rep ListPrincipalsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListPrincipalsResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'principals', 'listPrincipalsResponse_principals' - The principals.
--
-- 'nextToken', 'listPrincipalsResponse_nextToken' - The token to use to retrieve the next page of results. This value is
-- @null@ when there are no more results to return.
--
-- 'httpStatus', 'listPrincipalsResponse_httpStatus' - The response's http status code.
newListPrincipalsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPrincipalsResponse
newListPrincipalsResponse :: Int -> ListPrincipalsResponse
newListPrincipalsResponse Int
pHttpStatus_ =
  ListPrincipalsResponse' :: Maybe [Principal] -> Maybe Text -> Int -> ListPrincipalsResponse
ListPrincipalsResponse'
    { $sel:principals:ListPrincipalsResponse' :: Maybe [Principal]
principals =
        Maybe [Principal]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListPrincipalsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPrincipalsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The principals.
listPrincipalsResponse_principals :: Lens.Lens' ListPrincipalsResponse (Prelude.Maybe [Principal])
listPrincipalsResponse_principals :: (Maybe [Principal] -> f (Maybe [Principal]))
-> ListPrincipalsResponse -> f ListPrincipalsResponse
listPrincipalsResponse_principals = (ListPrincipalsResponse -> Maybe [Principal])
-> (ListPrincipalsResponse
    -> Maybe [Principal] -> ListPrincipalsResponse)
-> Lens' ListPrincipalsResponse (Maybe [Principal])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipalsResponse' {Maybe [Principal]
principals :: Maybe [Principal]
$sel:principals:ListPrincipalsResponse' :: ListPrincipalsResponse -> Maybe [Principal]
principals} -> Maybe [Principal]
principals) (\s :: ListPrincipalsResponse
s@ListPrincipalsResponse' {} Maybe [Principal]
a -> ListPrincipalsResponse
s {$sel:principals:ListPrincipalsResponse' :: Maybe [Principal]
principals = Maybe [Principal]
a} :: ListPrincipalsResponse) ((Maybe [Principal] -> f (Maybe [Principal]))
 -> ListPrincipalsResponse -> f ListPrincipalsResponse)
-> ((Maybe [Principal] -> f (Maybe [Principal]))
    -> Maybe [Principal] -> f (Maybe [Principal]))
-> (Maybe [Principal] -> f (Maybe [Principal]))
-> ListPrincipalsResponse
-> f ListPrincipalsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Principal] [Principal] [Principal] [Principal]
-> Iso
     (Maybe [Principal])
     (Maybe [Principal])
     (Maybe [Principal])
     (Maybe [Principal])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Principal] [Principal] [Principal] [Principal]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token to use to retrieve the next page of results. This value is
-- @null@ when there are no more results to return.
listPrincipalsResponse_nextToken :: Lens.Lens' ListPrincipalsResponse (Prelude.Maybe Prelude.Text)
listPrincipalsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListPrincipalsResponse -> f ListPrincipalsResponse
listPrincipalsResponse_nextToken = (ListPrincipalsResponse -> Maybe Text)
-> (ListPrincipalsResponse -> Maybe Text -> ListPrincipalsResponse)
-> Lens' ListPrincipalsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipalsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListPrincipalsResponse' :: ListPrincipalsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListPrincipalsResponse
s@ListPrincipalsResponse' {} Maybe Text
a -> ListPrincipalsResponse
s {$sel:nextToken:ListPrincipalsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListPrincipalsResponse)

-- | The response's http status code.
listPrincipalsResponse_httpStatus :: Lens.Lens' ListPrincipalsResponse Prelude.Int
listPrincipalsResponse_httpStatus :: (Int -> f Int)
-> ListPrincipalsResponse -> f ListPrincipalsResponse
listPrincipalsResponse_httpStatus = (ListPrincipalsResponse -> Int)
-> (ListPrincipalsResponse -> Int -> ListPrincipalsResponse)
-> Lens ListPrincipalsResponse ListPrincipalsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPrincipalsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListPrincipalsResponse' :: ListPrincipalsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListPrincipalsResponse
s@ListPrincipalsResponse' {} Int
a -> ListPrincipalsResponse
s {$sel:httpStatus:ListPrincipalsResponse' :: Int
httpStatus = Int
a} :: ListPrincipalsResponse)

instance Prelude.NFData ListPrincipalsResponse