{-# 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.IoTSiteWise.ListAccessPolicies
-- 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)
--
-- Retrieves a paginated list of access policies for an identity (an Amazon
-- Web Services SSO user, an Amazon Web Services SSO group, or an IAM user)
-- or an IoT SiteWise Monitor resource (a portal or project).
--
-- This operation returns paginated results.
module Amazonka.IoTSiteWise.ListAccessPolicies
  ( -- * Creating a Request
    ListAccessPolicies (..),
    newListAccessPolicies,

    -- * Request Lenses
    listAccessPolicies_resourceId,
    listAccessPolicies_resourceType,
    listAccessPolicies_identityType,
    listAccessPolicies_nextToken,
    listAccessPolicies_iamArn,
    listAccessPolicies_identityId,
    listAccessPolicies_maxResults,

    -- * Destructuring the Response
    ListAccessPoliciesResponse (..),
    newListAccessPoliciesResponse,

    -- * Response Lenses
    listAccessPoliciesResponse_nextToken,
    listAccessPoliciesResponse_httpStatus,
    listAccessPoliciesResponse_accessPolicySummaries,
  )
where

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

-- | /See:/ 'newListAccessPolicies' smart constructor.
data ListAccessPolicies = ListAccessPolicies'
  { -- | The ID of the resource. This parameter is required if you specify
    -- @resourceType@.
    ListAccessPolicies -> Maybe Text
resourceId :: Prelude.Maybe Prelude.Text,
    -- | The type of resource (portal or project). This parameter is required if
    -- you specify @resourceId@.
    ListAccessPolicies -> Maybe ResourceType
resourceType :: Prelude.Maybe ResourceType,
    -- | The type of identity (Amazon Web Services SSO user, Amazon Web Services
    -- SSO group, or IAM user). This parameter is required if you specify
    -- @identityId@.
    ListAccessPolicies -> Maybe IdentityType
identityType :: Prelude.Maybe IdentityType,
    -- | The token to be used for the next set of paginated results.
    ListAccessPolicies -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the IAM user. For more information, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM ARNs>
    -- in the /IAM User Guide/. This parameter is required if you specify @IAM@
    -- for @identityType@.
    ListAccessPolicies -> Maybe Text
iamArn :: Prelude.Maybe Prelude.Text,
    -- | The ID of the identity. This parameter is required if you specify @USER@
    -- or @GROUP@ for @identityType@.
    ListAccessPolicies -> Maybe Text
identityId :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return for each paginated request.
    --
    -- Default: 50
    ListAccessPolicies -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListAccessPolicies -> ListAccessPolicies -> Bool
(ListAccessPolicies -> ListAccessPolicies -> Bool)
-> (ListAccessPolicies -> ListAccessPolicies -> Bool)
-> Eq ListAccessPolicies
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAccessPolicies -> ListAccessPolicies -> Bool
$c/= :: ListAccessPolicies -> ListAccessPolicies -> Bool
== :: ListAccessPolicies -> ListAccessPolicies -> Bool
$c== :: ListAccessPolicies -> ListAccessPolicies -> Bool
Prelude.Eq, ReadPrec [ListAccessPolicies]
ReadPrec ListAccessPolicies
Int -> ReadS ListAccessPolicies
ReadS [ListAccessPolicies]
(Int -> ReadS ListAccessPolicies)
-> ReadS [ListAccessPolicies]
-> ReadPrec ListAccessPolicies
-> ReadPrec [ListAccessPolicies]
-> Read ListAccessPolicies
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAccessPolicies]
$creadListPrec :: ReadPrec [ListAccessPolicies]
readPrec :: ReadPrec ListAccessPolicies
$creadPrec :: ReadPrec ListAccessPolicies
readList :: ReadS [ListAccessPolicies]
$creadList :: ReadS [ListAccessPolicies]
readsPrec :: Int -> ReadS ListAccessPolicies
$creadsPrec :: Int -> ReadS ListAccessPolicies
Prelude.Read, Int -> ListAccessPolicies -> ShowS
[ListAccessPolicies] -> ShowS
ListAccessPolicies -> String
(Int -> ListAccessPolicies -> ShowS)
-> (ListAccessPolicies -> String)
-> ([ListAccessPolicies] -> ShowS)
-> Show ListAccessPolicies
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAccessPolicies] -> ShowS
$cshowList :: [ListAccessPolicies] -> ShowS
show :: ListAccessPolicies -> String
$cshow :: ListAccessPolicies -> String
showsPrec :: Int -> ListAccessPolicies -> ShowS
$cshowsPrec :: Int -> ListAccessPolicies -> ShowS
Prelude.Show, (forall x. ListAccessPolicies -> Rep ListAccessPolicies x)
-> (forall x. Rep ListAccessPolicies x -> ListAccessPolicies)
-> Generic ListAccessPolicies
forall x. Rep ListAccessPolicies x -> ListAccessPolicies
forall x. ListAccessPolicies -> Rep ListAccessPolicies x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAccessPolicies x -> ListAccessPolicies
$cfrom :: forall x. ListAccessPolicies -> Rep ListAccessPolicies x
Prelude.Generic)

-- |
-- Create a value of 'ListAccessPolicies' 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:
--
-- 'resourceId', 'listAccessPolicies_resourceId' - The ID of the resource. This parameter is required if you specify
-- @resourceType@.
--
-- 'resourceType', 'listAccessPolicies_resourceType' - The type of resource (portal or project). This parameter is required if
-- you specify @resourceId@.
--
-- 'identityType', 'listAccessPolicies_identityType' - The type of identity (Amazon Web Services SSO user, Amazon Web Services
-- SSO group, or IAM user). This parameter is required if you specify
-- @identityId@.
--
-- 'nextToken', 'listAccessPolicies_nextToken' - The token to be used for the next set of paginated results.
--
-- 'iamArn', 'listAccessPolicies_iamArn' - The ARN of the IAM user. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM ARNs>
-- in the /IAM User Guide/. This parameter is required if you specify @IAM@
-- for @identityType@.
--
-- 'identityId', 'listAccessPolicies_identityId' - The ID of the identity. This parameter is required if you specify @USER@
-- or @GROUP@ for @identityType@.
--
-- 'maxResults', 'listAccessPolicies_maxResults' - The maximum number of results to return for each paginated request.
--
-- Default: 50
newListAccessPolicies ::
  ListAccessPolicies
newListAccessPolicies :: ListAccessPolicies
newListAccessPolicies =
  ListAccessPolicies' :: Maybe Text
-> Maybe ResourceType
-> Maybe IdentityType
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> ListAccessPolicies
ListAccessPolicies'
    { $sel:resourceId:ListAccessPolicies' :: Maybe Text
resourceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:ListAccessPolicies' :: Maybe ResourceType
resourceType = Maybe ResourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:identityType:ListAccessPolicies' :: Maybe IdentityType
identityType = Maybe IdentityType
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAccessPolicies' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:iamArn:ListAccessPolicies' :: Maybe Text
iamArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:identityId:ListAccessPolicies' :: Maybe Text
identityId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListAccessPolicies' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the resource. This parameter is required if you specify
-- @resourceType@.
listAccessPolicies_resourceId :: Lens.Lens' ListAccessPolicies (Prelude.Maybe Prelude.Text)
listAccessPolicies_resourceId :: (Maybe Text -> f (Maybe Text))
-> ListAccessPolicies -> f ListAccessPolicies
listAccessPolicies_resourceId = (ListAccessPolicies -> Maybe Text)
-> (ListAccessPolicies -> Maybe Text -> ListAccessPolicies)
-> Lens
     ListAccessPolicies ListAccessPolicies (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPolicies' {Maybe Text
resourceId :: Maybe Text
$sel:resourceId:ListAccessPolicies' :: ListAccessPolicies -> Maybe Text
resourceId} -> Maybe Text
resourceId) (\s :: ListAccessPolicies
s@ListAccessPolicies' {} Maybe Text
a -> ListAccessPolicies
s {$sel:resourceId:ListAccessPolicies' :: Maybe Text
resourceId = Maybe Text
a} :: ListAccessPolicies)

-- | The type of resource (portal or project). This parameter is required if
-- you specify @resourceId@.
listAccessPolicies_resourceType :: Lens.Lens' ListAccessPolicies (Prelude.Maybe ResourceType)
listAccessPolicies_resourceType :: (Maybe ResourceType -> f (Maybe ResourceType))
-> ListAccessPolicies -> f ListAccessPolicies
listAccessPolicies_resourceType = (ListAccessPolicies -> Maybe ResourceType)
-> (ListAccessPolicies -> Maybe ResourceType -> ListAccessPolicies)
-> Lens
     ListAccessPolicies
     ListAccessPolicies
     (Maybe ResourceType)
     (Maybe ResourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPolicies' {Maybe ResourceType
resourceType :: Maybe ResourceType
$sel:resourceType:ListAccessPolicies' :: ListAccessPolicies -> Maybe ResourceType
resourceType} -> Maybe ResourceType
resourceType) (\s :: ListAccessPolicies
s@ListAccessPolicies' {} Maybe ResourceType
a -> ListAccessPolicies
s {$sel:resourceType:ListAccessPolicies' :: Maybe ResourceType
resourceType = Maybe ResourceType
a} :: ListAccessPolicies)

-- | The type of identity (Amazon Web Services SSO user, Amazon Web Services
-- SSO group, or IAM user). This parameter is required if you specify
-- @identityId@.
listAccessPolicies_identityType :: Lens.Lens' ListAccessPolicies (Prelude.Maybe IdentityType)
listAccessPolicies_identityType :: (Maybe IdentityType -> f (Maybe IdentityType))
-> ListAccessPolicies -> f ListAccessPolicies
listAccessPolicies_identityType = (ListAccessPolicies -> Maybe IdentityType)
-> (ListAccessPolicies -> Maybe IdentityType -> ListAccessPolicies)
-> Lens
     ListAccessPolicies
     ListAccessPolicies
     (Maybe IdentityType)
     (Maybe IdentityType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPolicies' {Maybe IdentityType
identityType :: Maybe IdentityType
$sel:identityType:ListAccessPolicies' :: ListAccessPolicies -> Maybe IdentityType
identityType} -> Maybe IdentityType
identityType) (\s :: ListAccessPolicies
s@ListAccessPolicies' {} Maybe IdentityType
a -> ListAccessPolicies
s {$sel:identityType:ListAccessPolicies' :: Maybe IdentityType
identityType = Maybe IdentityType
a} :: ListAccessPolicies)

-- | The token to be used for the next set of paginated results.
listAccessPolicies_nextToken :: Lens.Lens' ListAccessPolicies (Prelude.Maybe Prelude.Text)
listAccessPolicies_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAccessPolicies -> f ListAccessPolicies
listAccessPolicies_nextToken = (ListAccessPolicies -> Maybe Text)
-> (ListAccessPolicies -> Maybe Text -> ListAccessPolicies)
-> Lens
     ListAccessPolicies ListAccessPolicies (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPolicies' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAccessPolicies' :: ListAccessPolicies -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAccessPolicies
s@ListAccessPolicies' {} Maybe Text
a -> ListAccessPolicies
s {$sel:nextToken:ListAccessPolicies' :: Maybe Text
nextToken = Maybe Text
a} :: ListAccessPolicies)

-- | The ARN of the IAM user. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html IAM ARNs>
-- in the /IAM User Guide/. This parameter is required if you specify @IAM@
-- for @identityType@.
listAccessPolicies_iamArn :: Lens.Lens' ListAccessPolicies (Prelude.Maybe Prelude.Text)
listAccessPolicies_iamArn :: (Maybe Text -> f (Maybe Text))
-> ListAccessPolicies -> f ListAccessPolicies
listAccessPolicies_iamArn = (ListAccessPolicies -> Maybe Text)
-> (ListAccessPolicies -> Maybe Text -> ListAccessPolicies)
-> Lens
     ListAccessPolicies ListAccessPolicies (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPolicies' {Maybe Text
iamArn :: Maybe Text
$sel:iamArn:ListAccessPolicies' :: ListAccessPolicies -> Maybe Text
iamArn} -> Maybe Text
iamArn) (\s :: ListAccessPolicies
s@ListAccessPolicies' {} Maybe Text
a -> ListAccessPolicies
s {$sel:iamArn:ListAccessPolicies' :: Maybe Text
iamArn = Maybe Text
a} :: ListAccessPolicies)

-- | The ID of the identity. This parameter is required if you specify @USER@
-- or @GROUP@ for @identityType@.
listAccessPolicies_identityId :: Lens.Lens' ListAccessPolicies (Prelude.Maybe Prelude.Text)
listAccessPolicies_identityId :: (Maybe Text -> f (Maybe Text))
-> ListAccessPolicies -> f ListAccessPolicies
listAccessPolicies_identityId = (ListAccessPolicies -> Maybe Text)
-> (ListAccessPolicies -> Maybe Text -> ListAccessPolicies)
-> Lens
     ListAccessPolicies ListAccessPolicies (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPolicies' {Maybe Text
identityId :: Maybe Text
$sel:identityId:ListAccessPolicies' :: ListAccessPolicies -> Maybe Text
identityId} -> Maybe Text
identityId) (\s :: ListAccessPolicies
s@ListAccessPolicies' {} Maybe Text
a -> ListAccessPolicies
s {$sel:identityId:ListAccessPolicies' :: Maybe Text
identityId = Maybe Text
a} :: ListAccessPolicies)

-- | The maximum number of results to return for each paginated request.
--
-- Default: 50
listAccessPolicies_maxResults :: Lens.Lens' ListAccessPolicies (Prelude.Maybe Prelude.Natural)
listAccessPolicies_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListAccessPolicies -> f ListAccessPolicies
listAccessPolicies_maxResults = (ListAccessPolicies -> Maybe Natural)
-> (ListAccessPolicies -> Maybe Natural -> ListAccessPolicies)
-> Lens
     ListAccessPolicies
     ListAccessPolicies
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPolicies' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListAccessPolicies' :: ListAccessPolicies -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListAccessPolicies
s@ListAccessPolicies' {} Maybe Natural
a -> ListAccessPolicies
s {$sel:maxResults:ListAccessPolicies' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListAccessPolicies)

instance Core.AWSPager ListAccessPolicies where
  page :: ListAccessPolicies
-> AWSResponse ListAccessPolicies -> Maybe ListAccessPolicies
page ListAccessPolicies
rq AWSResponse ListAccessPolicies
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAccessPolicies
ListAccessPoliciesResponse
rs
            ListAccessPoliciesResponse
-> Getting (First Text) ListAccessPoliciesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAccessPoliciesResponse
-> Const (First Text) ListAccessPoliciesResponse
Lens' ListAccessPoliciesResponse (Maybe Text)
listAccessPoliciesResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAccessPoliciesResponse
 -> Const (First Text) ListAccessPoliciesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAccessPoliciesResponse 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 ListAccessPolicies
forall a. Maybe a
Prelude.Nothing
    | [AccessPolicySummary] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAccessPolicies
ListAccessPoliciesResponse
rs
            ListAccessPoliciesResponse
-> Getting
     [AccessPolicySummary]
     ListAccessPoliciesResponse
     [AccessPolicySummary]
-> [AccessPolicySummary]
forall s a. s -> Getting a s a -> a
Lens.^. Getting
  [AccessPolicySummary]
  ListAccessPoliciesResponse
  [AccessPolicySummary]
Lens' ListAccessPoliciesResponse [AccessPolicySummary]
listAccessPoliciesResponse_accessPolicySummaries
        ) =
      Maybe ListAccessPolicies
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListAccessPolicies -> Maybe ListAccessPolicies
forall a. a -> Maybe a
Prelude.Just (ListAccessPolicies -> Maybe ListAccessPolicies)
-> ListAccessPolicies -> Maybe ListAccessPolicies
forall a b. (a -> b) -> a -> b
Prelude.$
        ListAccessPolicies
rq
          ListAccessPolicies
-> (ListAccessPolicies -> ListAccessPolicies) -> ListAccessPolicies
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListAccessPolicies -> Identity ListAccessPolicies
Lens
  ListAccessPolicies ListAccessPolicies (Maybe Text) (Maybe Text)
listAccessPolicies_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListAccessPolicies -> Identity ListAccessPolicies)
-> Maybe Text -> ListAccessPolicies -> ListAccessPolicies
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListAccessPolicies
ListAccessPoliciesResponse
rs
          ListAccessPoliciesResponse
-> Getting (First Text) ListAccessPoliciesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAccessPoliciesResponse
-> Const (First Text) ListAccessPoliciesResponse
Lens' ListAccessPoliciesResponse (Maybe Text)
listAccessPoliciesResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAccessPoliciesResponse
 -> Const (First Text) ListAccessPoliciesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAccessPoliciesResponse 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 ListAccessPolicies where
  type
    AWSResponse ListAccessPolicies =
      ListAccessPoliciesResponse
  request :: ListAccessPolicies -> Request ListAccessPolicies
request = Service -> ListAccessPolicies -> Request ListAccessPolicies
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListAccessPolicies
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAccessPolicies)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListAccessPolicies))
-> Logger
-> Service
-> Proxy ListAccessPolicies
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAccessPolicies)))
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 Text
-> Int -> [AccessPolicySummary] -> ListAccessPoliciesResponse
ListAccessPoliciesResponse'
            (Maybe Text
 -> Int -> [AccessPolicySummary] -> ListAccessPoliciesResponse)
-> Either String (Maybe Text)
-> Either
     String (Int -> [AccessPolicySummary] -> ListAccessPoliciesResponse)
forall (f :: * -> *) a b. Functor 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 -> [AccessPolicySummary] -> ListAccessPoliciesResponse)
-> Either String Int
-> Either
     String ([AccessPolicySummary] -> ListAccessPoliciesResponse)
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))
            Either String ([AccessPolicySummary] -> ListAccessPoliciesResponse)
-> Either String [AccessPolicySummary]
-> Either String ListAccessPoliciesResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe [AccessPolicySummary])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"accessPolicySummaries"
                            Either String (Maybe [AccessPolicySummary])
-> [AccessPolicySummary] -> Either String [AccessPolicySummary]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [AccessPolicySummary]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable ListAccessPolicies

instance Prelude.NFData ListAccessPolicies

instance Core.ToHeaders ListAccessPolicies where
  toHeaders :: ListAccessPolicies -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListAccessPolicies -> 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.ToPath ListAccessPolicies where
  toPath :: ListAccessPolicies -> ByteString
toPath = ByteString -> ListAccessPolicies -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/access-policies"

instance Core.ToQuery ListAccessPolicies where
  toQuery :: ListAccessPolicies -> QueryString
toQuery ListAccessPolicies' {Maybe Natural
Maybe Text
Maybe IdentityType
Maybe ResourceType
maxResults :: Maybe Natural
identityId :: Maybe Text
iamArn :: Maybe Text
nextToken :: Maybe Text
identityType :: Maybe IdentityType
resourceType :: Maybe ResourceType
resourceId :: Maybe Text
$sel:maxResults:ListAccessPolicies' :: ListAccessPolicies -> Maybe Natural
$sel:identityId:ListAccessPolicies' :: ListAccessPolicies -> Maybe Text
$sel:iamArn:ListAccessPolicies' :: ListAccessPolicies -> Maybe Text
$sel:nextToken:ListAccessPolicies' :: ListAccessPolicies -> Maybe Text
$sel:identityType:ListAccessPolicies' :: ListAccessPolicies -> Maybe IdentityType
$sel:resourceType:ListAccessPolicies' :: ListAccessPolicies -> Maybe ResourceType
$sel:resourceId:ListAccessPolicies' :: ListAccessPolicies -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"resourceId" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
resourceId,
        ByteString
"resourceType" ByteString -> Maybe ResourceType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe ResourceType
resourceType,
        ByteString
"identityType" ByteString -> Maybe IdentityType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe IdentityType
identityType,
        ByteString
"nextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"iamArn" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
iamArn,
        ByteString
"identityId" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
identityId,
        ByteString
"maxResults" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults
      ]

-- | /See:/ 'newListAccessPoliciesResponse' smart constructor.
data ListAccessPoliciesResponse = ListAccessPoliciesResponse'
  { -- | The token for the next set of results, or null if there are no
    -- additional results.
    ListAccessPoliciesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListAccessPoliciesResponse -> Int
httpStatus :: Prelude.Int,
    -- | A list that summarizes each access policy.
    ListAccessPoliciesResponse -> [AccessPolicySummary]
accessPolicySummaries :: [AccessPolicySummary]
  }
  deriving (ListAccessPoliciesResponse -> ListAccessPoliciesResponse -> Bool
(ListAccessPoliciesResponse -> ListAccessPoliciesResponse -> Bool)
-> (ListAccessPoliciesResponse
    -> ListAccessPoliciesResponse -> Bool)
-> Eq ListAccessPoliciesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAccessPoliciesResponse -> ListAccessPoliciesResponse -> Bool
$c/= :: ListAccessPoliciesResponse -> ListAccessPoliciesResponse -> Bool
== :: ListAccessPoliciesResponse -> ListAccessPoliciesResponse -> Bool
$c== :: ListAccessPoliciesResponse -> ListAccessPoliciesResponse -> Bool
Prelude.Eq, ReadPrec [ListAccessPoliciesResponse]
ReadPrec ListAccessPoliciesResponse
Int -> ReadS ListAccessPoliciesResponse
ReadS [ListAccessPoliciesResponse]
(Int -> ReadS ListAccessPoliciesResponse)
-> ReadS [ListAccessPoliciesResponse]
-> ReadPrec ListAccessPoliciesResponse
-> ReadPrec [ListAccessPoliciesResponse]
-> Read ListAccessPoliciesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAccessPoliciesResponse]
$creadListPrec :: ReadPrec [ListAccessPoliciesResponse]
readPrec :: ReadPrec ListAccessPoliciesResponse
$creadPrec :: ReadPrec ListAccessPoliciesResponse
readList :: ReadS [ListAccessPoliciesResponse]
$creadList :: ReadS [ListAccessPoliciesResponse]
readsPrec :: Int -> ReadS ListAccessPoliciesResponse
$creadsPrec :: Int -> ReadS ListAccessPoliciesResponse
Prelude.Read, Int -> ListAccessPoliciesResponse -> ShowS
[ListAccessPoliciesResponse] -> ShowS
ListAccessPoliciesResponse -> String
(Int -> ListAccessPoliciesResponse -> ShowS)
-> (ListAccessPoliciesResponse -> String)
-> ([ListAccessPoliciesResponse] -> ShowS)
-> Show ListAccessPoliciesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAccessPoliciesResponse] -> ShowS
$cshowList :: [ListAccessPoliciesResponse] -> ShowS
show :: ListAccessPoliciesResponse -> String
$cshow :: ListAccessPoliciesResponse -> String
showsPrec :: Int -> ListAccessPoliciesResponse -> ShowS
$cshowsPrec :: Int -> ListAccessPoliciesResponse -> ShowS
Prelude.Show, (forall x.
 ListAccessPoliciesResponse -> Rep ListAccessPoliciesResponse x)
-> (forall x.
    Rep ListAccessPoliciesResponse x -> ListAccessPoliciesResponse)
-> Generic ListAccessPoliciesResponse
forall x.
Rep ListAccessPoliciesResponse x -> ListAccessPoliciesResponse
forall x.
ListAccessPoliciesResponse -> Rep ListAccessPoliciesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListAccessPoliciesResponse x -> ListAccessPoliciesResponse
$cfrom :: forall x.
ListAccessPoliciesResponse -> Rep ListAccessPoliciesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAccessPoliciesResponse' 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:
--
-- 'nextToken', 'listAccessPoliciesResponse_nextToken' - The token for the next set of results, or null if there are no
-- additional results.
--
-- 'httpStatus', 'listAccessPoliciesResponse_httpStatus' - The response's http status code.
--
-- 'accessPolicySummaries', 'listAccessPoliciesResponse_accessPolicySummaries' - A list that summarizes each access policy.
newListAccessPoliciesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAccessPoliciesResponse
newListAccessPoliciesResponse :: Int -> ListAccessPoliciesResponse
newListAccessPoliciesResponse Int
pHttpStatus_ =
  ListAccessPoliciesResponse' :: Maybe Text
-> Int -> [AccessPolicySummary] -> ListAccessPoliciesResponse
ListAccessPoliciesResponse'
    { $sel:nextToken:ListAccessPoliciesResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAccessPoliciesResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:accessPolicySummaries:ListAccessPoliciesResponse' :: [AccessPolicySummary]
accessPolicySummaries = [AccessPolicySummary]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The token for the next set of results, or null if there are no
-- additional results.
listAccessPoliciesResponse_nextToken :: Lens.Lens' ListAccessPoliciesResponse (Prelude.Maybe Prelude.Text)
listAccessPoliciesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAccessPoliciesResponse -> f ListAccessPoliciesResponse
listAccessPoliciesResponse_nextToken = (ListAccessPoliciesResponse -> Maybe Text)
-> (ListAccessPoliciesResponse
    -> Maybe Text -> ListAccessPoliciesResponse)
-> Lens' ListAccessPoliciesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPoliciesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAccessPoliciesResponse' :: ListAccessPoliciesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAccessPoliciesResponse
s@ListAccessPoliciesResponse' {} Maybe Text
a -> ListAccessPoliciesResponse
s {$sel:nextToken:ListAccessPoliciesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAccessPoliciesResponse)

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

-- | A list that summarizes each access policy.
listAccessPoliciesResponse_accessPolicySummaries :: Lens.Lens' ListAccessPoliciesResponse [AccessPolicySummary]
listAccessPoliciesResponse_accessPolicySummaries :: ([AccessPolicySummary] -> f [AccessPolicySummary])
-> ListAccessPoliciesResponse -> f ListAccessPoliciesResponse
listAccessPoliciesResponse_accessPolicySummaries = (ListAccessPoliciesResponse -> [AccessPolicySummary])
-> (ListAccessPoliciesResponse
    -> [AccessPolicySummary] -> ListAccessPoliciesResponse)
-> Lens' ListAccessPoliciesResponse [AccessPolicySummary]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessPoliciesResponse' {[AccessPolicySummary]
accessPolicySummaries :: [AccessPolicySummary]
$sel:accessPolicySummaries:ListAccessPoliciesResponse' :: ListAccessPoliciesResponse -> [AccessPolicySummary]
accessPolicySummaries} -> [AccessPolicySummary]
accessPolicySummaries) (\s :: ListAccessPoliciesResponse
s@ListAccessPoliciesResponse' {} [AccessPolicySummary]
a -> ListAccessPoliciesResponse
s {$sel:accessPolicySummaries:ListAccessPoliciesResponse' :: [AccessPolicySummary]
accessPolicySummaries = [AccessPolicySummary]
a} :: ListAccessPoliciesResponse) (([AccessPolicySummary] -> f [AccessPolicySummary])
 -> ListAccessPoliciesResponse -> f ListAccessPoliciesResponse)
-> (([AccessPolicySummary] -> f [AccessPolicySummary])
    -> [AccessPolicySummary] -> f [AccessPolicySummary])
-> ([AccessPolicySummary] -> f [AccessPolicySummary])
-> ListAccessPoliciesResponse
-> f ListAccessPoliciesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AccessPolicySummary] -> f [AccessPolicySummary])
-> [AccessPolicySummary] -> f [AccessPolicySummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListAccessPoliciesResponse