{-# 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-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 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 Amazonka.FraudDetector.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:/ 'newGetKMSEncryptionKey' smart constructor.
data GetKMSEncryptionKey = GetKMSEncryptionKey'
  {
  }
  deriving (GetKMSEncryptionKey -> GetKMSEncryptionKey -> Bool
(GetKMSEncryptionKey -> GetKMSEncryptionKey -> Bool)
-> (GetKMSEncryptionKey -> GetKMSEncryptionKey -> Bool)
-> Eq GetKMSEncryptionKey
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]
(Int -> ReadS GetKMSEncryptionKey)
-> ReadS [GetKMSEncryptionKey]
-> ReadPrec GetKMSEncryptionKey
-> ReadPrec [GetKMSEncryptionKey]
-> Read 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
(Int -> GetKMSEncryptionKey -> ShowS)
-> (GetKMSEncryptionKey -> String)
-> ([GetKMSEncryptionKey] -> ShowS)
-> Show GetKMSEncryptionKey
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. GetKMSEncryptionKey -> Rep GetKMSEncryptionKey x)
-> (forall x. Rep GetKMSEncryptionKey x -> GetKMSEncryptionKey)
-> Generic GetKMSEncryptionKey
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 :: GetKMSEncryptionKey -> Request GetKMSEncryptionKey
request = Service -> GetKMSEncryptionKey -> Request GetKMSEncryptionKey
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetKMSEncryptionKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetKMSEncryptionKey)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetKMSEncryptionKey))
-> Logger
-> Service
-> Proxy GetKMSEncryptionKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetKMSEncryptionKey)))
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 KMSKey -> Int -> GetKMSEncryptionKeyResponse
GetKMSEncryptionKeyResponse'
            (Maybe KMSKey -> Int -> GetKMSEncryptionKeyResponse)
-> Either String (Maybe KMSKey)
-> Either String (Int -> GetKMSEncryptionKeyResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe KMSKey)
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"kmsKey")
            Either String (Int -> GetKMSEncryptionKeyResponse)
-> Either String Int -> Either String GetKMSEncryptionKeyResponse
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 GetKMSEncryptionKey

instance Prelude.NFData GetKMSEncryptionKey

instance Core.ToHeaders GetKMSEncryptionKey where
  toHeaders :: GetKMSEncryptionKey -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetKMSEncryptionKey -> 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
"AWSHawksNestServiceFacade.GetKMSEncryptionKey" ::
                          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 GetKMSEncryptionKey where
  toJSON :: GetKMSEncryptionKey -> Value
toJSON = Value -> GetKMSEncryptionKey -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

instance Core.ToQuery GetKMSEncryptionKey where
  toQuery :: GetKMSEncryptionKey -> QueryString
toQuery = QueryString -> GetKMSEncryptionKey -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetKMSEncryptionKeyResponse
 -> GetKMSEncryptionKeyResponse -> Bool)
-> (GetKMSEncryptionKeyResponse
    -> GetKMSEncryptionKeyResponse -> Bool)
-> Eq GetKMSEncryptionKeyResponse
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]
(Int -> ReadS GetKMSEncryptionKeyResponse)
-> ReadS [GetKMSEncryptionKeyResponse]
-> ReadPrec GetKMSEncryptionKeyResponse
-> ReadPrec [GetKMSEncryptionKeyResponse]
-> Read 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
(Int -> GetKMSEncryptionKeyResponse -> ShowS)
-> (GetKMSEncryptionKeyResponse -> String)
-> ([GetKMSEncryptionKeyResponse] -> ShowS)
-> Show GetKMSEncryptionKeyResponse
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.
 GetKMSEncryptionKeyResponse -> Rep GetKMSEncryptionKeyResponse x)
-> (forall x.
    Rep GetKMSEncryptionKeyResponse x -> GetKMSEncryptionKeyResponse)
-> Generic GetKMSEncryptionKeyResponse
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' :: Maybe KMSKey -> Int -> GetKMSEncryptionKeyResponse
GetKMSEncryptionKeyResponse'
    { $sel:kmsKey:GetKMSEncryptionKeyResponse' :: Maybe KMSKey
kmsKey =
        Maybe 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 :: (Maybe KMSKey -> f (Maybe KMSKey))
-> GetKMSEncryptionKeyResponse -> f GetKMSEncryptionKeyResponse
getKMSEncryptionKeyResponse_kmsKey = (GetKMSEncryptionKeyResponse -> Maybe KMSKey)
-> (GetKMSEncryptionKeyResponse
    -> Maybe KMSKey -> GetKMSEncryptionKeyResponse)
-> Lens
     GetKMSEncryptionKeyResponse
     GetKMSEncryptionKeyResponse
     (Maybe KMSKey)
     (Maybe 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 :: (Int -> f Int)
-> GetKMSEncryptionKeyResponse -> f GetKMSEncryptionKeyResponse
getKMSEncryptionKeyResponse_httpStatus = (GetKMSEncryptionKeyResponse -> Int)
-> (GetKMSEncryptionKeyResponse
    -> Int -> GetKMSEncryptionKeyResponse)
-> Lens
     GetKMSEncryptionKeyResponse GetKMSEncryptionKeyResponse Int Int
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