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

    -- * Request Lenses
    putKMSEncryptionKey_kmsEncryptionKeyArn,

    -- * Destructuring the Response
    PutKMSEncryptionKeyResponse (..),
    newPutKMSEncryptionKeyResponse,

    -- * Response Lenses
    putKMSEncryptionKeyResponse_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:/ 'newPutKMSEncryptionKey' smart constructor.
data PutKMSEncryptionKey = PutKMSEncryptionKey'
  { -- | The KMS encryption key ARN.
    --
    -- The KMS key must be single-Region key. Amazon Fraud Detector does not
    -- support multi-Region KMS key.
    PutKMSEncryptionKey -> Text
kmsEncryptionKeyArn :: Prelude.Text
  }
  deriving (PutKMSEncryptionKey -> PutKMSEncryptionKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutKMSEncryptionKey -> PutKMSEncryptionKey -> Bool
$c/= :: PutKMSEncryptionKey -> PutKMSEncryptionKey -> Bool
== :: PutKMSEncryptionKey -> PutKMSEncryptionKey -> Bool
$c== :: PutKMSEncryptionKey -> PutKMSEncryptionKey -> Bool
Prelude.Eq, ReadPrec [PutKMSEncryptionKey]
ReadPrec PutKMSEncryptionKey
Int -> ReadS PutKMSEncryptionKey
ReadS [PutKMSEncryptionKey]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutKMSEncryptionKey]
$creadListPrec :: ReadPrec [PutKMSEncryptionKey]
readPrec :: ReadPrec PutKMSEncryptionKey
$creadPrec :: ReadPrec PutKMSEncryptionKey
readList :: ReadS [PutKMSEncryptionKey]
$creadList :: ReadS [PutKMSEncryptionKey]
readsPrec :: Int -> ReadS PutKMSEncryptionKey
$creadsPrec :: Int -> ReadS PutKMSEncryptionKey
Prelude.Read, Int -> PutKMSEncryptionKey -> ShowS
[PutKMSEncryptionKey] -> ShowS
PutKMSEncryptionKey -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutKMSEncryptionKey] -> ShowS
$cshowList :: [PutKMSEncryptionKey] -> ShowS
show :: PutKMSEncryptionKey -> String
$cshow :: PutKMSEncryptionKey -> String
showsPrec :: Int -> PutKMSEncryptionKey -> ShowS
$cshowsPrec :: Int -> PutKMSEncryptionKey -> ShowS
Prelude.Show, forall x. Rep PutKMSEncryptionKey x -> PutKMSEncryptionKey
forall x. PutKMSEncryptionKey -> Rep PutKMSEncryptionKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutKMSEncryptionKey x -> PutKMSEncryptionKey
$cfrom :: forall x. PutKMSEncryptionKey -> Rep PutKMSEncryptionKey x
Prelude.Generic)

-- |
-- Create a value of 'PutKMSEncryptionKey' 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:
--
-- 'kmsEncryptionKeyArn', 'putKMSEncryptionKey_kmsEncryptionKeyArn' - The KMS encryption key ARN.
--
-- The KMS key must be single-Region key. Amazon Fraud Detector does not
-- support multi-Region KMS key.
newPutKMSEncryptionKey ::
  -- | 'kmsEncryptionKeyArn'
  Prelude.Text ->
  PutKMSEncryptionKey
newPutKMSEncryptionKey :: Text -> PutKMSEncryptionKey
newPutKMSEncryptionKey Text
pKmsEncryptionKeyArn_ =
  PutKMSEncryptionKey'
    { $sel:kmsEncryptionKeyArn:PutKMSEncryptionKey' :: Text
kmsEncryptionKeyArn =
        Text
pKmsEncryptionKeyArn_
    }

-- | The KMS encryption key ARN.
--
-- The KMS key must be single-Region key. Amazon Fraud Detector does not
-- support multi-Region KMS key.
putKMSEncryptionKey_kmsEncryptionKeyArn :: Lens.Lens' PutKMSEncryptionKey Prelude.Text
putKMSEncryptionKey_kmsEncryptionKeyArn :: Lens' PutKMSEncryptionKey Text
putKMSEncryptionKey_kmsEncryptionKeyArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutKMSEncryptionKey' {Text
kmsEncryptionKeyArn :: Text
$sel:kmsEncryptionKeyArn:PutKMSEncryptionKey' :: PutKMSEncryptionKey -> Text
kmsEncryptionKeyArn} -> Text
kmsEncryptionKeyArn) (\s :: PutKMSEncryptionKey
s@PutKMSEncryptionKey' {} Text
a -> PutKMSEncryptionKey
s {$sel:kmsEncryptionKeyArn:PutKMSEncryptionKey' :: Text
kmsEncryptionKeyArn = Text
a} :: PutKMSEncryptionKey)

instance Core.AWSRequest PutKMSEncryptionKey where
  type
    AWSResponse PutKMSEncryptionKey =
      PutKMSEncryptionKeyResponse
  request :: (Service -> Service)
-> PutKMSEncryptionKey -> Request PutKMSEncryptionKey
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 PutKMSEncryptionKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutKMSEncryptionKey)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutKMSEncryptionKeyResponse
PutKMSEncryptionKeyResponse'
            forall (f :: * -> *) a b. Functor 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 PutKMSEncryptionKey where
  hashWithSalt :: Int -> PutKMSEncryptionKey -> Int
hashWithSalt Int
_salt PutKMSEncryptionKey' {Text
kmsEncryptionKeyArn :: Text
$sel:kmsEncryptionKeyArn:PutKMSEncryptionKey' :: PutKMSEncryptionKey -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
kmsEncryptionKeyArn

instance Prelude.NFData PutKMSEncryptionKey where
  rnf :: PutKMSEncryptionKey -> ()
rnf PutKMSEncryptionKey' {Text
kmsEncryptionKeyArn :: Text
$sel:kmsEncryptionKeyArn:PutKMSEncryptionKey' :: PutKMSEncryptionKey -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
kmsEncryptionKeyArn

instance Data.ToHeaders PutKMSEncryptionKey where
  toHeaders :: PutKMSEncryptionKey -> 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.PutKMSEncryptionKey" ::
                          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 PutKMSEncryptionKey where
  toJSON :: PutKMSEncryptionKey -> Value
toJSON PutKMSEncryptionKey' {Text
kmsEncryptionKeyArn :: Text
$sel:kmsEncryptionKeyArn:PutKMSEncryptionKey' :: PutKMSEncryptionKey -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"kmsEncryptionKeyArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
kmsEncryptionKeyArn)
          ]
      )

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

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

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

-- |
-- Create a value of 'PutKMSEncryptionKeyResponse' 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:
--
-- 'httpStatus', 'putKMSEncryptionKeyResponse_httpStatus' - The response's http status code.
newPutKMSEncryptionKeyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutKMSEncryptionKeyResponse
newPutKMSEncryptionKeyResponse :: Int -> PutKMSEncryptionKeyResponse
newPutKMSEncryptionKeyResponse Int
pHttpStatus_ =
  PutKMSEncryptionKeyResponse'
    { $sel:httpStatus:PutKMSEncryptionKeyResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData PutKMSEncryptionKeyResponse where
  rnf :: PutKMSEncryptionKeyResponse -> ()
rnf PutKMSEncryptionKeyResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutKMSEncryptionKeyResponse' :: PutKMSEncryptionKeyResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus