{-# 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.FraudDetector.GetKMSEncryptionKey
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets the encryption key if a KMS key has been specified to be used to
-- encrypt content in Amazon Fraud Detector.
module Amazonka.FraudDetector.GetKMSEncryptionKey
  ( -- * Creating a Request
    GetKMSEncryptionKey (..),
    newGetKMSEncryptionKey,

    -- * Destructuring the Response
    GetKMSEncryptionKeyResponse (..),
    newGetKMSEncryptionKeyResponse,

    -- * Response Lenses
    getKMSEncryptionKeyResponse_kmsKey,
    getKMSEncryptionKeyResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FraudDetector.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetKMSEncryptionKey' smart constructor.
data GetKMSEncryptionKey = GetKMSEncryptionKey'
  {
  }
  deriving (GetKMSEncryptionKey -> GetKMSEncryptionKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetKMSEncryptionKey -> GetKMSEncryptionKey -> Bool
$c/= :: GetKMSEncryptionKey -> GetKMSEncryptionKey -> Bool
== :: GetKMSEncryptionKey -> GetKMSEncryptionKey -> Bool
$c== :: GetKMSEncryptionKey -> GetKMSEncryptionKey -> Bool
Prelude.Eq, ReadPrec [GetKMSEncryptionKey]
ReadPrec GetKMSEncryptionKey
Int -> ReadS GetKMSEncryptionKey
ReadS [GetKMSEncryptionKey]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetKMSEncryptionKey]
$creadListPrec :: ReadPrec [GetKMSEncryptionKey]
readPrec :: ReadPrec GetKMSEncryptionKey
$creadPrec :: ReadPrec GetKMSEncryptionKey
readList :: ReadS [GetKMSEncryptionKey]
$creadList :: ReadS [GetKMSEncryptionKey]
readsPrec :: Int -> ReadS GetKMSEncryptionKey
$creadsPrec :: Int -> ReadS GetKMSEncryptionKey
Prelude.Read, Int -> GetKMSEncryptionKey -> ShowS
[GetKMSEncryptionKey] -> ShowS
GetKMSEncryptionKey -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetKMSEncryptionKey] -> ShowS
$cshowList :: [GetKMSEncryptionKey] -> ShowS
show :: GetKMSEncryptionKey -> String
$cshow :: GetKMSEncryptionKey -> String
showsPrec :: Int -> GetKMSEncryptionKey -> ShowS
$cshowsPrec :: Int -> GetKMSEncryptionKey -> ShowS
Prelude.Show, forall x. Rep GetKMSEncryptionKey x -> GetKMSEncryptionKey
forall x. GetKMSEncryptionKey -> Rep GetKMSEncryptionKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetKMSEncryptionKey x -> GetKMSEncryptionKey
$cfrom :: forall x. GetKMSEncryptionKey -> Rep GetKMSEncryptionKey x
Prelude.Generic)

-- |
-- Create a value of 'GetKMSEncryptionKey' 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.
newGetKMSEncryptionKey ::
  GetKMSEncryptionKey
newGetKMSEncryptionKey :: GetKMSEncryptionKey
newGetKMSEncryptionKey = GetKMSEncryptionKey
GetKMSEncryptionKey'

instance Core.AWSRequest GetKMSEncryptionKey where
  type
    AWSResponse GetKMSEncryptionKey =
      GetKMSEncryptionKeyResponse
  request :: (Service -> Service)
-> GetKMSEncryptionKey -> Request GetKMSEncryptionKey
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetKMSEncryptionKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetKMSEncryptionKey)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe KMSKey -> Int -> GetKMSEncryptionKeyResponse
GetKMSEncryptionKeyResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"kmsKey")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetKMSEncryptionKey where
  hashWithSalt :: Int -> GetKMSEncryptionKey -> Int
hashWithSalt Int
_salt GetKMSEncryptionKey
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

instance Prelude.NFData GetKMSEncryptionKey where
  rnf :: GetKMSEncryptionKey -> ()
rnf GetKMSEncryptionKey
_ = ()

instance Data.ToHeaders GetKMSEncryptionKey where
  toHeaders :: GetKMSEncryptionKey -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSHawksNestServiceFacade.GetKMSEncryptionKey" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON GetKMSEncryptionKey where
  toJSON :: GetKMSEncryptionKey -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

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

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

-- | /See:/ 'newGetKMSEncryptionKeyResponse' smart constructor.
data GetKMSEncryptionKeyResponse = GetKMSEncryptionKeyResponse'
  { -- | The KMS encryption key.
    GetKMSEncryptionKeyResponse -> Maybe KMSKey
kmsKey :: Prelude.Maybe KMSKey,
    -- | The response's http status code.
    GetKMSEncryptionKeyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetKMSEncryptionKeyResponse -> GetKMSEncryptionKeyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetKMSEncryptionKeyResponse -> GetKMSEncryptionKeyResponse -> Bool
$c/= :: GetKMSEncryptionKeyResponse -> GetKMSEncryptionKeyResponse -> Bool
== :: GetKMSEncryptionKeyResponse -> GetKMSEncryptionKeyResponse -> Bool
$c== :: GetKMSEncryptionKeyResponse -> GetKMSEncryptionKeyResponse -> Bool
Prelude.Eq, ReadPrec [GetKMSEncryptionKeyResponse]
ReadPrec GetKMSEncryptionKeyResponse
Int -> ReadS GetKMSEncryptionKeyResponse
ReadS [GetKMSEncryptionKeyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetKMSEncryptionKeyResponse]
$creadListPrec :: ReadPrec [GetKMSEncryptionKeyResponse]
readPrec :: ReadPrec GetKMSEncryptionKeyResponse
$creadPrec :: ReadPrec GetKMSEncryptionKeyResponse
readList :: ReadS [GetKMSEncryptionKeyResponse]
$creadList :: ReadS [GetKMSEncryptionKeyResponse]
readsPrec :: Int -> ReadS GetKMSEncryptionKeyResponse
$creadsPrec :: Int -> ReadS GetKMSEncryptionKeyResponse
Prelude.Read, Int -> GetKMSEncryptionKeyResponse -> ShowS
[GetKMSEncryptionKeyResponse] -> ShowS
GetKMSEncryptionKeyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetKMSEncryptionKeyResponse] -> ShowS
$cshowList :: [GetKMSEncryptionKeyResponse] -> ShowS
show :: GetKMSEncryptionKeyResponse -> String
$cshow :: GetKMSEncryptionKeyResponse -> String
showsPrec :: Int -> GetKMSEncryptionKeyResponse -> ShowS
$cshowsPrec :: Int -> GetKMSEncryptionKeyResponse -> ShowS
Prelude.Show, forall x.
Rep GetKMSEncryptionKeyResponse x -> GetKMSEncryptionKeyResponse
forall x.
GetKMSEncryptionKeyResponse -> Rep GetKMSEncryptionKeyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetKMSEncryptionKeyResponse x -> GetKMSEncryptionKeyResponse
$cfrom :: forall x.
GetKMSEncryptionKeyResponse -> Rep GetKMSEncryptionKeyResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetKMSEncryptionKeyResponse' 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:
--
-- 'kmsKey', 'getKMSEncryptionKeyResponse_kmsKey' - The KMS encryption key.
--
-- 'httpStatus', 'getKMSEncryptionKeyResponse_httpStatus' - The response's http status code.
newGetKMSEncryptionKeyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetKMSEncryptionKeyResponse
newGetKMSEncryptionKeyResponse :: Int -> GetKMSEncryptionKeyResponse
newGetKMSEncryptionKeyResponse Int
pHttpStatus_ =
  GetKMSEncryptionKeyResponse'
    { $sel:kmsKey:GetKMSEncryptionKeyResponse' :: Maybe KMSKey
kmsKey =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetKMSEncryptionKeyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The KMS encryption key.
getKMSEncryptionKeyResponse_kmsKey :: Lens.Lens' GetKMSEncryptionKeyResponse (Prelude.Maybe KMSKey)
getKMSEncryptionKeyResponse_kmsKey :: Lens' GetKMSEncryptionKeyResponse (Maybe KMSKey)
getKMSEncryptionKeyResponse_kmsKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetKMSEncryptionKeyResponse' {Maybe KMSKey
kmsKey :: Maybe KMSKey
$sel:kmsKey:GetKMSEncryptionKeyResponse' :: GetKMSEncryptionKeyResponse -> Maybe KMSKey
kmsKey} -> Maybe KMSKey
kmsKey) (\s :: GetKMSEncryptionKeyResponse
s@GetKMSEncryptionKeyResponse' {} Maybe KMSKey
a -> GetKMSEncryptionKeyResponse
s {$sel:kmsKey:GetKMSEncryptionKeyResponse' :: Maybe KMSKey
kmsKey = Maybe KMSKey
a} :: GetKMSEncryptionKeyResponse)

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

instance Prelude.NFData GetKMSEncryptionKeyResponse where
  rnf :: GetKMSEncryptionKeyResponse -> ()
rnf GetKMSEncryptionKeyResponse' {Int
Maybe KMSKey
httpStatus :: Int
kmsKey :: Maybe KMSKey
$sel:httpStatus:GetKMSEncryptionKeyResponse' :: GetKMSEncryptionKeyResponse -> Int
$sel:kmsKey:GetKMSEncryptionKeyResponse' :: GetKMSEncryptionKeyResponse -> Maybe KMSKey
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe KMSKey
kmsKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus