{-# 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-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)
module Amazonka.KMS.Types.ListGrantsResponse where

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

-- | /See:/ 'newListGrantsResponse' smart constructor.
data ListGrantsResponse = 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 -> Maybe Bool
truncated :: Prelude.Maybe Prelude.Bool,
    -- | 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
  }
  deriving (ListGrantsResponse -> ListGrantsResponse -> Bool
(ListGrantsResponse -> ListGrantsResponse -> Bool)
-> (ListGrantsResponse -> ListGrantsResponse -> Bool)
-> Eq ListGrantsResponse
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]
(Int -> ReadS ListGrantsResponse)
-> ReadS [ListGrantsResponse]
-> ReadPrec ListGrantsResponse
-> ReadPrec [ListGrantsResponse]
-> Read 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
(Int -> ListGrantsResponse -> ShowS)
-> (ListGrantsResponse -> String)
-> ([ListGrantsResponse] -> ShowS)
-> Show ListGrantsResponse
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. ListGrantsResponse -> Rep ListGrantsResponse x)
-> (forall x. Rep ListGrantsResponse x -> ListGrantsResponse)
-> Generic ListGrantsResponse
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:
--
-- '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.
--
-- '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.
newListGrantsResponse ::
  ListGrantsResponse
newListGrantsResponse :: ListGrantsResponse
newListGrantsResponse =
  ListGrantsResponse' :: Maybe Bool
-> Maybe [GrantListEntry] -> Maybe Text -> ListGrantsResponse
ListGrantsResponse'
    { $sel:truncated:ListGrantsResponse' :: Maybe Bool
truncated = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:grants:ListGrantsResponse' :: Maybe [GrantListEntry]
grants = Maybe [GrantListEntry]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextMarker:ListGrantsResponse' :: Maybe Text
nextMarker = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Bool -> f (Maybe Bool))
-> ListGrantsResponse -> f ListGrantsResponse
listGrantsResponse_truncated = (ListGrantsResponse -> Maybe Bool)
-> (ListGrantsResponse -> Maybe Bool -> ListGrantsResponse)
-> Lens
     ListGrantsResponse ListGrantsResponse (Maybe Bool) (Maybe Bool)
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)

-- | A list of grants.
listGrantsResponse_grants :: Lens.Lens' ListGrantsResponse (Prelude.Maybe [GrantListEntry])
listGrantsResponse_grants :: (Maybe [GrantListEntry] -> f (Maybe [GrantListEntry]))
-> ListGrantsResponse -> f ListGrantsResponse
listGrantsResponse_grants = (ListGrantsResponse -> Maybe [GrantListEntry])
-> (ListGrantsResponse
    -> Maybe [GrantListEntry] -> ListGrantsResponse)
-> Lens
     ListGrantsResponse
     ListGrantsResponse
     (Maybe [GrantListEntry])
     (Maybe [GrantListEntry])
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) ((Maybe [GrantListEntry] -> f (Maybe [GrantListEntry]))
 -> ListGrantsResponse -> f ListGrantsResponse)
-> ((Maybe [GrantListEntry] -> f (Maybe [GrantListEntry]))
    -> Maybe [GrantListEntry] -> f (Maybe [GrantListEntry]))
-> (Maybe [GrantListEntry] -> f (Maybe [GrantListEntry]))
-> ListGrantsResponse
-> f ListGrantsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [GrantListEntry] [GrantListEntry] [GrantListEntry] [GrantListEntry]
-> Iso
     (Maybe [GrantListEntry])
     (Maybe [GrantListEntry])
     (Maybe [GrantListEntry])
     (Maybe [GrantListEntry])
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
  [GrantListEntry] [GrantListEntry] [GrantListEntry] [GrantListEntry]
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 :: (Maybe Text -> f (Maybe Text))
-> ListGrantsResponse -> f ListGrantsResponse
listGrantsResponse_nextMarker = (ListGrantsResponse -> Maybe Text)
-> (ListGrantsResponse -> Maybe Text -> ListGrantsResponse)
-> Lens
     ListGrantsResponse ListGrantsResponse (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable ListGrantsResponse

instance Prelude.NFData ListGrantsResponse