{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.KMS.Types.ListGrantsResponse
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.KMS.Types.ListGrantsResponse where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.KMS.Types.GrantListEntry
import qualified Amazonka.Prelude as Prelude

-- | /See:/ 'newListGrantsResponse' smart constructor.
data ListGrantsResponse = ListGrantsResponse'
  { -- | A list of grants.
    ListGrantsResponse -> Maybe [GrantListEntry]
grants :: Prelude.Maybe [GrantListEntry],
    -- | When @Truncated@ is true, this element is present and contains the value
    -- to use for the @Marker@ parameter in a subsequent request.
    ListGrantsResponse -> Maybe Text
nextMarker :: Prelude.Maybe Prelude.Text,
    -- | A flag that indicates whether there are more items in the list. When
    -- this value is true, the list in this response is truncated. To get more
    -- items, pass the value of the @NextMarker@ element in thisresponse to the
    -- @Marker@ parameter in a subsequent request.
    ListGrantsResponse -> Maybe Bool
truncated :: Prelude.Maybe Prelude.Bool
  }
  deriving (ListGrantsResponse -> ListGrantsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListGrantsResponse -> ListGrantsResponse -> Bool
$c/= :: ListGrantsResponse -> ListGrantsResponse -> Bool
== :: ListGrantsResponse -> ListGrantsResponse -> Bool
$c== :: ListGrantsResponse -> ListGrantsResponse -> Bool
Prelude.Eq, ReadPrec [ListGrantsResponse]
ReadPrec ListGrantsResponse
Int -> ReadS ListGrantsResponse
ReadS [ListGrantsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListGrantsResponse]
$creadListPrec :: ReadPrec [ListGrantsResponse]
readPrec :: ReadPrec ListGrantsResponse
$creadPrec :: ReadPrec ListGrantsResponse
readList :: ReadS [ListGrantsResponse]
$creadList :: ReadS [ListGrantsResponse]
readsPrec :: Int -> ReadS ListGrantsResponse
$creadsPrec :: Int -> ReadS ListGrantsResponse
Prelude.Read, Int -> ListGrantsResponse -> ShowS
[ListGrantsResponse] -> ShowS
ListGrantsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListGrantsResponse] -> ShowS
$cshowList :: [ListGrantsResponse] -> ShowS
show :: ListGrantsResponse -> String
$cshow :: ListGrantsResponse -> String
showsPrec :: Int -> ListGrantsResponse -> ShowS
$cshowsPrec :: Int -> ListGrantsResponse -> ShowS
Prelude.Show, forall x. Rep ListGrantsResponse x -> ListGrantsResponse
forall x. ListGrantsResponse -> Rep ListGrantsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListGrantsResponse x -> ListGrantsResponse
$cfrom :: forall x. ListGrantsResponse -> Rep ListGrantsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListGrantsResponse' 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:
--
-- 'grants', 'listGrantsResponse_grants' - A list of grants.
--
-- 'nextMarker', 'listGrantsResponse_nextMarker' - When @Truncated@ is true, this element is present and contains the value
-- to use for the @Marker@ parameter in a subsequent request.
--
-- 'truncated', 'listGrantsResponse_truncated' - A flag that indicates whether there are more items in the list. When
-- this value is true, the list in this response is truncated. To get more
-- items, pass the value of the @NextMarker@ element in thisresponse to the
-- @Marker@ parameter in a subsequent request.
newListGrantsResponse ::
  ListGrantsResponse
newListGrantsResponse :: ListGrantsResponse
newListGrantsResponse =
  ListGrantsResponse'
    { $sel:grants:ListGrantsResponse' :: Maybe [GrantListEntry]
grants = forall a. Maybe a
Prelude.Nothing,
      $sel:nextMarker:ListGrantsResponse' :: Maybe Text
nextMarker = forall a. Maybe a
Prelude.Nothing,
      $sel:truncated:ListGrantsResponse' :: Maybe Bool
truncated = forall a. Maybe a
Prelude.Nothing
    }

-- | A list of grants.
listGrantsResponse_grants :: Lens.Lens' ListGrantsResponse (Prelude.Maybe [GrantListEntry])
listGrantsResponse_grants :: Lens' ListGrantsResponse (Maybe [GrantListEntry])
listGrantsResponse_grants = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGrantsResponse' {Maybe [GrantListEntry]
grants :: Maybe [GrantListEntry]
$sel:grants:ListGrantsResponse' :: ListGrantsResponse -> Maybe [GrantListEntry]
grants} -> Maybe [GrantListEntry]
grants) (\s :: ListGrantsResponse
s@ListGrantsResponse' {} Maybe [GrantListEntry]
a -> ListGrantsResponse
s {$sel:grants:ListGrantsResponse' :: Maybe [GrantListEntry]
grants = Maybe [GrantListEntry]
a} :: ListGrantsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | When @Truncated@ is true, this element is present and contains the value
-- to use for the @Marker@ parameter in a subsequent request.
listGrantsResponse_nextMarker :: Lens.Lens' ListGrantsResponse (Prelude.Maybe Prelude.Text)
listGrantsResponse_nextMarker :: Lens' ListGrantsResponse (Maybe Text)
listGrantsResponse_nextMarker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGrantsResponse' {Maybe Text
nextMarker :: Maybe Text
$sel:nextMarker:ListGrantsResponse' :: ListGrantsResponse -> Maybe Text
nextMarker} -> Maybe Text
nextMarker) (\s :: ListGrantsResponse
s@ListGrantsResponse' {} Maybe Text
a -> ListGrantsResponse
s {$sel:nextMarker:ListGrantsResponse' :: Maybe Text
nextMarker = Maybe Text
a} :: ListGrantsResponse)

-- | A flag that indicates whether there are more items in the list. When
-- this value is true, the list in this response is truncated. To get more
-- items, pass the value of the @NextMarker@ element in thisresponse to the
-- @Marker@ parameter in a subsequent request.
listGrantsResponse_truncated :: Lens.Lens' ListGrantsResponse (Prelude.Maybe Prelude.Bool)
listGrantsResponse_truncated :: Lens' ListGrantsResponse (Maybe Bool)
listGrantsResponse_truncated = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGrantsResponse' {Maybe Bool
truncated :: Maybe Bool
$sel:truncated:ListGrantsResponse' :: ListGrantsResponse -> Maybe Bool
truncated} -> Maybe Bool
truncated) (\s :: ListGrantsResponse
s@ListGrantsResponse' {} Maybe Bool
a -> ListGrantsResponse
s {$sel:truncated:ListGrantsResponse' :: Maybe Bool
truncated = Maybe Bool
a} :: ListGrantsResponse)

instance Data.FromJSON ListGrantsResponse where
  parseJSON :: Value -> Parser ListGrantsResponse
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ListGrantsResponse"
      ( \Object
x ->
          Maybe [GrantListEntry]
-> Maybe Text -> Maybe Bool -> ListGrantsResponse
ListGrantsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Grants" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"NextMarker")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Truncated")
      )

instance Prelude.Hashable ListGrantsResponse where
  hashWithSalt :: Int -> ListGrantsResponse -> Int
hashWithSalt Int
_salt ListGrantsResponse' {Maybe Bool
Maybe [GrantListEntry]
Maybe Text
truncated :: Maybe Bool
nextMarker :: Maybe Text
grants :: Maybe [GrantListEntry]
$sel:truncated:ListGrantsResponse' :: ListGrantsResponse -> Maybe Bool
$sel:nextMarker:ListGrantsResponse' :: ListGrantsResponse -> Maybe Text
$sel:grants:ListGrantsResponse' :: ListGrantsResponse -> Maybe [GrantListEntry]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [GrantListEntry]
grants
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextMarker
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
truncated

instance Prelude.NFData ListGrantsResponse where
  rnf :: ListGrantsResponse -> ()
rnf ListGrantsResponse' {Maybe Bool
Maybe [GrantListEntry]
Maybe Text
truncated :: Maybe Bool
nextMarker :: Maybe Text
grants :: Maybe [GrantListEntry]
$sel:truncated:ListGrantsResponse' :: ListGrantsResponse -> Maybe Bool
$sel:nextMarker:ListGrantsResponse' :: ListGrantsResponse -> Maybe Text
$sel:grants:ListGrantsResponse' :: ListGrantsResponse -> Maybe [GrantListEntry]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [GrantListEntry]
grants
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextMarker
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
truncated