{-# 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.KMS.ListKeyPolicies
-- 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)
--
-- Gets the names of the key policies that are attached to a KMS key. This
-- operation is designed to get policy names that you can use in a
-- GetKeyPolicy operation. However, the only valid policy name is
-- @default@.
--
-- __Cross-account use__: No. You cannot perform this operation on a KMS
-- key in a different Amazon Web Services account.
--
-- __Required permissions__:
-- <https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html kms:ListKeyPolicies>
-- (key policy)
--
-- __Related operations:__
--
-- -   GetKeyPolicy
--
-- -   PutKeyPolicy
--
-- This operation returns paginated results.
module Amazonka.KMS.ListKeyPolicies
  ( -- * Creating a Request
    ListKeyPolicies (..),
    newListKeyPolicies,

    -- * Request Lenses
    listKeyPolicies_marker,
    listKeyPolicies_limit,
    listKeyPolicies_keyId,

    -- * Destructuring the Response
    ListKeyPoliciesResponse (..),
    newListKeyPoliciesResponse,

    -- * Response Lenses
    listKeyPoliciesResponse_policyNames,
    listKeyPoliciesResponse_truncated,
    listKeyPoliciesResponse_nextMarker,
    listKeyPoliciesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.KMS.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:/ 'newListKeyPolicies' smart constructor.
data ListKeyPolicies = ListKeyPolicies'
  { -- | Use this parameter in a subsequent request after you receive a response
    -- with truncated results. Set it to the value of @NextMarker@ from the
    -- truncated response you just received.
    ListKeyPolicies -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | Use this parameter to specify the maximum number of items to return.
    -- When this value is present, KMS does not return more than the specified
    -- number of items, but it might return fewer.
    --
    -- This value is optional. If you include a value, it must be between 1 and
    -- 1000, inclusive. If you do not include a value, it defaults to 100.
    --
    -- Only one policy can be attached to a key.
    ListKeyPolicies -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | Gets the names of key policies for the specified KMS key.
    --
    -- Specify the key ID or key ARN of the KMS key.
    --
    -- For example:
    --
    -- -   Key ID: @1234abcd-12ab-34cd-56ef-1234567890ab@
    --
    -- -   Key ARN:
    --     @arn:aws:kms:us-east-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@
    --
    -- To get the key ID and key ARN for a KMS key, use ListKeys or
    -- DescribeKey.
    ListKeyPolicies -> Text
keyId :: Prelude.Text
  }
  deriving (ListKeyPolicies -> ListKeyPolicies -> Bool
(ListKeyPolicies -> ListKeyPolicies -> Bool)
-> (ListKeyPolicies -> ListKeyPolicies -> Bool)
-> Eq ListKeyPolicies
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListKeyPolicies -> ListKeyPolicies -> Bool
$c/= :: ListKeyPolicies -> ListKeyPolicies -> Bool
== :: ListKeyPolicies -> ListKeyPolicies -> Bool
$c== :: ListKeyPolicies -> ListKeyPolicies -> Bool
Prelude.Eq, ReadPrec [ListKeyPolicies]
ReadPrec ListKeyPolicies
Int -> ReadS ListKeyPolicies
ReadS [ListKeyPolicies]
(Int -> ReadS ListKeyPolicies)
-> ReadS [ListKeyPolicies]
-> ReadPrec ListKeyPolicies
-> ReadPrec [ListKeyPolicies]
-> Read ListKeyPolicies
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListKeyPolicies]
$creadListPrec :: ReadPrec [ListKeyPolicies]
readPrec :: ReadPrec ListKeyPolicies
$creadPrec :: ReadPrec ListKeyPolicies
readList :: ReadS [ListKeyPolicies]
$creadList :: ReadS [ListKeyPolicies]
readsPrec :: Int -> ReadS ListKeyPolicies
$creadsPrec :: Int -> ReadS ListKeyPolicies
Prelude.Read, Int -> ListKeyPolicies -> ShowS
[ListKeyPolicies] -> ShowS
ListKeyPolicies -> String
(Int -> ListKeyPolicies -> ShowS)
-> (ListKeyPolicies -> String)
-> ([ListKeyPolicies] -> ShowS)
-> Show ListKeyPolicies
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListKeyPolicies] -> ShowS
$cshowList :: [ListKeyPolicies] -> ShowS
show :: ListKeyPolicies -> String
$cshow :: ListKeyPolicies -> String
showsPrec :: Int -> ListKeyPolicies -> ShowS
$cshowsPrec :: Int -> ListKeyPolicies -> ShowS
Prelude.Show, (forall x. ListKeyPolicies -> Rep ListKeyPolicies x)
-> (forall x. Rep ListKeyPolicies x -> ListKeyPolicies)
-> Generic ListKeyPolicies
forall x. Rep ListKeyPolicies x -> ListKeyPolicies
forall x. ListKeyPolicies -> Rep ListKeyPolicies x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListKeyPolicies x -> ListKeyPolicies
$cfrom :: forall x. ListKeyPolicies -> Rep ListKeyPolicies x
Prelude.Generic)

-- |
-- Create a value of 'ListKeyPolicies' 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:
--
-- 'marker', 'listKeyPolicies_marker' - Use this parameter in a subsequent request after you receive a response
-- with truncated results. Set it to the value of @NextMarker@ from the
-- truncated response you just received.
--
-- 'limit', 'listKeyPolicies_limit' - Use this parameter to specify the maximum number of items to return.
-- When this value is present, KMS does not return more than the specified
-- number of items, but it might return fewer.
--
-- This value is optional. If you include a value, it must be between 1 and
-- 1000, inclusive. If you do not include a value, it defaults to 100.
--
-- Only one policy can be attached to a key.
--
-- 'keyId', 'listKeyPolicies_keyId' - Gets the names of key policies for the specified KMS key.
--
-- Specify the key ID or key ARN of the KMS key.
--
-- For example:
--
-- -   Key ID: @1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- -   Key ARN:
--     @arn:aws:kms:us-east-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- To get the key ID and key ARN for a KMS key, use ListKeys or
-- DescribeKey.
newListKeyPolicies ::
  -- | 'keyId'
  Prelude.Text ->
  ListKeyPolicies
newListKeyPolicies :: Text -> ListKeyPolicies
newListKeyPolicies Text
pKeyId_ =
  ListKeyPolicies' :: Maybe Text -> Maybe Natural -> Text -> ListKeyPolicies
ListKeyPolicies'
    { $sel:marker:ListKeyPolicies' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:ListKeyPolicies' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:keyId:ListKeyPolicies' :: Text
keyId = Text
pKeyId_
    }

-- | Use this parameter in a subsequent request after you receive a response
-- with truncated results. Set it to the value of @NextMarker@ from the
-- truncated response you just received.
listKeyPolicies_marker :: Lens.Lens' ListKeyPolicies (Prelude.Maybe Prelude.Text)
listKeyPolicies_marker :: (Maybe Text -> f (Maybe Text))
-> ListKeyPolicies -> f ListKeyPolicies
listKeyPolicies_marker = (ListKeyPolicies -> Maybe Text)
-> (ListKeyPolicies -> Maybe Text -> ListKeyPolicies)
-> Lens ListKeyPolicies ListKeyPolicies (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListKeyPolicies' {Maybe Text
marker :: Maybe Text
$sel:marker:ListKeyPolicies' :: ListKeyPolicies -> Maybe Text
marker} -> Maybe Text
marker) (\s :: ListKeyPolicies
s@ListKeyPolicies' {} Maybe Text
a -> ListKeyPolicies
s {$sel:marker:ListKeyPolicies' :: Maybe Text
marker = Maybe Text
a} :: ListKeyPolicies)

-- | Use this parameter to specify the maximum number of items to return.
-- When this value is present, KMS does not return more than the specified
-- number of items, but it might return fewer.
--
-- This value is optional. If you include a value, it must be between 1 and
-- 1000, inclusive. If you do not include a value, it defaults to 100.
--
-- Only one policy can be attached to a key.
listKeyPolicies_limit :: Lens.Lens' ListKeyPolicies (Prelude.Maybe Prelude.Natural)
listKeyPolicies_limit :: (Maybe Natural -> f (Maybe Natural))
-> ListKeyPolicies -> f ListKeyPolicies
listKeyPolicies_limit = (ListKeyPolicies -> Maybe Natural)
-> (ListKeyPolicies -> Maybe Natural -> ListKeyPolicies)
-> Lens
     ListKeyPolicies ListKeyPolicies (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListKeyPolicies' {Maybe Natural
limit :: Maybe Natural
$sel:limit:ListKeyPolicies' :: ListKeyPolicies -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: ListKeyPolicies
s@ListKeyPolicies' {} Maybe Natural
a -> ListKeyPolicies
s {$sel:limit:ListKeyPolicies' :: Maybe Natural
limit = Maybe Natural
a} :: ListKeyPolicies)

-- | Gets the names of key policies for the specified KMS key.
--
-- Specify the key ID or key ARN of the KMS key.
--
-- For example:
--
-- -   Key ID: @1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- -   Key ARN:
--     @arn:aws:kms:us-east-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab@
--
-- To get the key ID and key ARN for a KMS key, use ListKeys or
-- DescribeKey.
listKeyPolicies_keyId :: Lens.Lens' ListKeyPolicies Prelude.Text
listKeyPolicies_keyId :: (Text -> f Text) -> ListKeyPolicies -> f ListKeyPolicies
listKeyPolicies_keyId = (ListKeyPolicies -> Text)
-> (ListKeyPolicies -> Text -> ListKeyPolicies)
-> Lens ListKeyPolicies ListKeyPolicies Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListKeyPolicies' {Text
keyId :: Text
$sel:keyId:ListKeyPolicies' :: ListKeyPolicies -> Text
keyId} -> Text
keyId) (\s :: ListKeyPolicies
s@ListKeyPolicies' {} Text
a -> ListKeyPolicies
s {$sel:keyId:ListKeyPolicies' :: Text
keyId = Text
a} :: ListKeyPolicies)

instance Core.AWSPager ListKeyPolicies where
  page :: ListKeyPolicies
-> AWSResponse ListKeyPolicies -> Maybe ListKeyPolicies
page ListKeyPolicies
rq AWSResponse ListKeyPolicies
rs
    | Maybe Bool -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListKeyPolicies
ListKeyPoliciesResponse
rs
            ListKeyPoliciesResponse
-> Getting (First Bool) ListKeyPoliciesResponse Bool -> Maybe Bool
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Bool -> Const (First Bool) (Maybe Bool))
-> ListKeyPoliciesResponse
-> Const (First Bool) ListKeyPoliciesResponse
Lens' ListKeyPoliciesResponse (Maybe Bool)
listKeyPoliciesResponse_truncated
              ((Maybe Bool -> Const (First Bool) (Maybe Bool))
 -> ListKeyPoliciesResponse
 -> Const (First Bool) ListKeyPoliciesResponse)
-> ((Bool -> Const (First Bool) Bool)
    -> Maybe Bool -> Const (First Bool) (Maybe Bool))
-> Getting (First Bool) ListKeyPoliciesResponse Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Bool -> Const (First Bool) Bool)
-> Maybe Bool -> Const (First Bool) (Maybe Bool)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListKeyPolicies
forall a. Maybe a
Prelude.Nothing
    | Maybe Text -> Bool
forall a. Maybe a -> Bool
Prelude.isNothing
        ( AWSResponse ListKeyPolicies
ListKeyPoliciesResponse
rs
            ListKeyPoliciesResponse
-> Getting (First Text) ListKeyPoliciesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListKeyPoliciesResponse
-> Const (First Text) ListKeyPoliciesResponse
Lens' ListKeyPoliciesResponse (Maybe Text)
listKeyPoliciesResponse_nextMarker
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListKeyPoliciesResponse
 -> Const (First Text) ListKeyPoliciesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListKeyPoliciesResponse 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 ListKeyPolicies
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListKeyPolicies -> Maybe ListKeyPolicies
forall a. a -> Maybe a
Prelude.Just (ListKeyPolicies -> Maybe ListKeyPolicies)
-> ListKeyPolicies -> Maybe ListKeyPolicies
forall a b. (a -> b) -> a -> b
Prelude.$
        ListKeyPolicies
rq
          ListKeyPolicies
-> (ListKeyPolicies -> ListKeyPolicies) -> ListKeyPolicies
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListKeyPolicies -> Identity ListKeyPolicies
Lens ListKeyPolicies ListKeyPolicies (Maybe Text) (Maybe Text)
listKeyPolicies_marker
          ((Maybe Text -> Identity (Maybe Text))
 -> ListKeyPolicies -> Identity ListKeyPolicies)
-> Maybe Text -> ListKeyPolicies -> ListKeyPolicies
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListKeyPolicies
ListKeyPoliciesResponse
rs
          ListKeyPoliciesResponse
-> Getting (First Text) ListKeyPoliciesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListKeyPoliciesResponse
-> Const (First Text) ListKeyPoliciesResponse
Lens' ListKeyPoliciesResponse (Maybe Text)
listKeyPoliciesResponse_nextMarker
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListKeyPoliciesResponse
 -> Const (First Text) ListKeyPoliciesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListKeyPoliciesResponse 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 ListKeyPolicies where
  type
    AWSResponse ListKeyPolicies =
      ListKeyPoliciesResponse
  request :: ListKeyPolicies -> Request ListKeyPolicies
request = Service -> ListKeyPolicies -> Request ListKeyPolicies
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListKeyPolicies
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListKeyPolicies)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListKeyPolicies))
-> Logger
-> Service
-> Proxy ListKeyPolicies
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListKeyPolicies)))
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]
-> Maybe Bool -> Maybe Text -> Int -> ListKeyPoliciesResponse
ListKeyPoliciesResponse'
            (Maybe [Text]
 -> Maybe Bool -> Maybe Text -> Int -> ListKeyPoliciesResponse)
-> Either String (Maybe [Text])
-> Either
     String (Maybe Bool -> Maybe Text -> Int -> ListKeyPoliciesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"PolicyNames" Either String (Maybe (Maybe [Text]))
-> Maybe [Text] -> Either String (Maybe [Text])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String (Maybe Bool -> Maybe Text -> Int -> ListKeyPoliciesResponse)
-> Either String (Maybe Bool)
-> Either String (Maybe Text -> Int -> ListKeyPoliciesResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Truncated")
            Either String (Maybe Text -> Int -> ListKeyPoliciesResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListKeyPoliciesResponse)
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
"NextMarker")
            Either String (Int -> ListKeyPoliciesResponse)
-> Either String Int -> Either String ListKeyPoliciesResponse
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 ListKeyPolicies

instance Prelude.NFData ListKeyPolicies

instance Core.ToHeaders ListKeyPolicies where
  toHeaders :: ListKeyPolicies -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListKeyPolicies -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"TrentService.ListKeyPolicies" ::
                          Prelude.ByteString
                      ),
            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 ListKeyPolicies where
  toJSON :: ListKeyPolicies -> Value
toJSON ListKeyPolicies' {Maybe Natural
Maybe Text
Text
keyId :: Text
limit :: Maybe Natural
marker :: Maybe Text
$sel:keyId:ListKeyPolicies' :: ListKeyPolicies -> Text
$sel:limit:ListKeyPolicies' :: ListKeyPolicies -> Maybe Natural
$sel:marker:ListKeyPolicies' :: ListKeyPolicies -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Marker" 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
marker,
            (Text
"Limit" 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
limit,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"KeyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
keyId)
          ]
      )

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

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

-- | /See:/ 'newListKeyPoliciesResponse' smart constructor.
data ListKeyPoliciesResponse = ListKeyPoliciesResponse'
  { -- | A list of key policy names. The only valid value is @default@.
    ListKeyPoliciesResponse -> Maybe [Text]
policyNames :: 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.
    ListKeyPoliciesResponse -> Maybe Bool
truncated :: Prelude.Maybe Prelude.Bool,
    -- | When @Truncated@ is true, this element is present and contains the value
    -- to use for the @Marker@ parameter in a subsequent request.
    ListKeyPoliciesResponse -> Maybe Text
nextMarker :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListKeyPoliciesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListKeyPoliciesResponse -> ListKeyPoliciesResponse -> Bool
(ListKeyPoliciesResponse -> ListKeyPoliciesResponse -> Bool)
-> (ListKeyPoliciesResponse -> ListKeyPoliciesResponse -> Bool)
-> Eq ListKeyPoliciesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListKeyPoliciesResponse -> ListKeyPoliciesResponse -> Bool
$c/= :: ListKeyPoliciesResponse -> ListKeyPoliciesResponse -> Bool
== :: ListKeyPoliciesResponse -> ListKeyPoliciesResponse -> Bool
$c== :: ListKeyPoliciesResponse -> ListKeyPoliciesResponse -> Bool
Prelude.Eq, ReadPrec [ListKeyPoliciesResponse]
ReadPrec ListKeyPoliciesResponse
Int -> ReadS ListKeyPoliciesResponse
ReadS [ListKeyPoliciesResponse]
(Int -> ReadS ListKeyPoliciesResponse)
-> ReadS [ListKeyPoliciesResponse]
-> ReadPrec ListKeyPoliciesResponse
-> ReadPrec [ListKeyPoliciesResponse]
-> Read ListKeyPoliciesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListKeyPoliciesResponse]
$creadListPrec :: ReadPrec [ListKeyPoliciesResponse]
readPrec :: ReadPrec ListKeyPoliciesResponse
$creadPrec :: ReadPrec ListKeyPoliciesResponse
readList :: ReadS [ListKeyPoliciesResponse]
$creadList :: ReadS [ListKeyPoliciesResponse]
readsPrec :: Int -> ReadS ListKeyPoliciesResponse
$creadsPrec :: Int -> ReadS ListKeyPoliciesResponse
Prelude.Read, Int -> ListKeyPoliciesResponse -> ShowS
[ListKeyPoliciesResponse] -> ShowS
ListKeyPoliciesResponse -> String
(Int -> ListKeyPoliciesResponse -> ShowS)
-> (ListKeyPoliciesResponse -> String)
-> ([ListKeyPoliciesResponse] -> ShowS)
-> Show ListKeyPoliciesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListKeyPoliciesResponse] -> ShowS
$cshowList :: [ListKeyPoliciesResponse] -> ShowS
show :: ListKeyPoliciesResponse -> String
$cshow :: ListKeyPoliciesResponse -> String
showsPrec :: Int -> ListKeyPoliciesResponse -> ShowS
$cshowsPrec :: Int -> ListKeyPoliciesResponse -> ShowS
Prelude.Show, (forall x.
 ListKeyPoliciesResponse -> Rep ListKeyPoliciesResponse x)
-> (forall x.
    Rep ListKeyPoliciesResponse x -> ListKeyPoliciesResponse)
-> Generic ListKeyPoliciesResponse
forall x. Rep ListKeyPoliciesResponse x -> ListKeyPoliciesResponse
forall x. ListKeyPoliciesResponse -> Rep ListKeyPoliciesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListKeyPoliciesResponse x -> ListKeyPoliciesResponse
$cfrom :: forall x. ListKeyPoliciesResponse -> Rep ListKeyPoliciesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListKeyPoliciesResponse' 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:
--
-- 'policyNames', 'listKeyPoliciesResponse_policyNames' - A list of key policy names. The only valid value is @default@.
--
-- 'truncated', 'listKeyPoliciesResponse_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.
--
-- 'nextMarker', 'listKeyPoliciesResponse_nextMarker' - When @Truncated@ is true, this element is present and contains the value
-- to use for the @Marker@ parameter in a subsequent request.
--
-- 'httpStatus', 'listKeyPoliciesResponse_httpStatus' - The response's http status code.
newListKeyPoliciesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListKeyPoliciesResponse
newListKeyPoliciesResponse :: Int -> ListKeyPoliciesResponse
newListKeyPoliciesResponse Int
pHttpStatus_ =
  ListKeyPoliciesResponse' :: Maybe [Text]
-> Maybe Bool -> Maybe Text -> Int -> ListKeyPoliciesResponse
ListKeyPoliciesResponse'
    { $sel:policyNames:ListKeyPoliciesResponse' :: Maybe [Text]
policyNames =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:truncated:ListKeyPoliciesResponse' :: Maybe Bool
truncated = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:nextMarker:ListKeyPoliciesResponse' :: Maybe Text
nextMarker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListKeyPoliciesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of key policy names. The only valid value is @default@.
listKeyPoliciesResponse_policyNames :: Lens.Lens' ListKeyPoliciesResponse (Prelude.Maybe [Prelude.Text])
listKeyPoliciesResponse_policyNames :: (Maybe [Text] -> f (Maybe [Text]))
-> ListKeyPoliciesResponse -> f ListKeyPoliciesResponse
listKeyPoliciesResponse_policyNames = (ListKeyPoliciesResponse -> Maybe [Text])
-> (ListKeyPoliciesResponse
    -> Maybe [Text] -> ListKeyPoliciesResponse)
-> Lens
     ListKeyPoliciesResponse
     ListKeyPoliciesResponse
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListKeyPoliciesResponse' {Maybe [Text]
policyNames :: Maybe [Text]
$sel:policyNames:ListKeyPoliciesResponse' :: ListKeyPoliciesResponse -> Maybe [Text]
policyNames} -> Maybe [Text]
policyNames) (\s :: ListKeyPoliciesResponse
s@ListKeyPoliciesResponse' {} Maybe [Text]
a -> ListKeyPoliciesResponse
s {$sel:policyNames:ListKeyPoliciesResponse' :: Maybe [Text]
policyNames = Maybe [Text]
a} :: ListKeyPoliciesResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListKeyPoliciesResponse -> f ListKeyPoliciesResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListKeyPoliciesResponse
-> f ListKeyPoliciesResponse
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

-- | 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.
listKeyPoliciesResponse_truncated :: Lens.Lens' ListKeyPoliciesResponse (Prelude.Maybe Prelude.Bool)
listKeyPoliciesResponse_truncated :: (Maybe Bool -> f (Maybe Bool))
-> ListKeyPoliciesResponse -> f ListKeyPoliciesResponse
listKeyPoliciesResponse_truncated = (ListKeyPoliciesResponse -> Maybe Bool)
-> (ListKeyPoliciesResponse
    -> Maybe Bool -> ListKeyPoliciesResponse)
-> Lens' ListKeyPoliciesResponse (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListKeyPoliciesResponse' {Maybe Bool
truncated :: Maybe Bool
$sel:truncated:ListKeyPoliciesResponse' :: ListKeyPoliciesResponse -> Maybe Bool
truncated} -> Maybe Bool
truncated) (\s :: ListKeyPoliciesResponse
s@ListKeyPoliciesResponse' {} Maybe Bool
a -> ListKeyPoliciesResponse
s {$sel:truncated:ListKeyPoliciesResponse' :: Maybe Bool
truncated = Maybe Bool
a} :: ListKeyPoliciesResponse)

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

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

instance Prelude.NFData ListKeyPoliciesResponse