{-# 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-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)
--
-- 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 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:/ 'newPutKMSEncryptionKey' smart constructor.
data PutKMSEncryptionKey = PutKMSEncryptionKey'
  { -- | The KMS encryption key ARN.
    PutKMSEncryptionKey -> Text
kmsEncryptionKeyArn :: Prelude.Text
  }
  deriving (PutKMSEncryptionKey -> PutKMSEncryptionKey -> Bool
(PutKMSEncryptionKey -> PutKMSEncryptionKey -> Bool)
-> (PutKMSEncryptionKey -> PutKMSEncryptionKey -> Bool)
-> Eq PutKMSEncryptionKey
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]
(Int -> ReadS PutKMSEncryptionKey)
-> ReadS [PutKMSEncryptionKey]
-> ReadPrec PutKMSEncryptionKey
-> ReadPrec [PutKMSEncryptionKey]
-> Read 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
(Int -> PutKMSEncryptionKey -> ShowS)
-> (PutKMSEncryptionKey -> String)
-> ([PutKMSEncryptionKey] -> ShowS)
-> Show PutKMSEncryptionKey
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. PutKMSEncryptionKey -> Rep PutKMSEncryptionKey x)
-> (forall x. Rep PutKMSEncryptionKey x -> PutKMSEncryptionKey)
-> Generic PutKMSEncryptionKey
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.
newPutKMSEncryptionKey ::
  -- | 'kmsEncryptionKeyArn'
  Prelude.Text ->
  PutKMSEncryptionKey
newPutKMSEncryptionKey :: Text -> PutKMSEncryptionKey
newPutKMSEncryptionKey Text
pKmsEncryptionKeyArn_ =
  PutKMSEncryptionKey' :: Text -> PutKMSEncryptionKey
PutKMSEncryptionKey'
    { $sel:kmsEncryptionKeyArn:PutKMSEncryptionKey' :: Text
kmsEncryptionKeyArn =
        Text
pKmsEncryptionKeyArn_
    }

-- | The KMS encryption key ARN.
putKMSEncryptionKey_kmsEncryptionKeyArn :: Lens.Lens' PutKMSEncryptionKey Prelude.Text
putKMSEncryptionKey_kmsEncryptionKeyArn :: (Text -> f Text) -> PutKMSEncryptionKey -> f PutKMSEncryptionKey
putKMSEncryptionKey_kmsEncryptionKeyArn = (PutKMSEncryptionKey -> Text)
-> (PutKMSEncryptionKey -> Text -> PutKMSEncryptionKey)
-> Lens PutKMSEncryptionKey PutKMSEncryptionKey Text Text
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 :: PutKMSEncryptionKey -> Request PutKMSEncryptionKey
request = Service -> PutKMSEncryptionKey -> Request PutKMSEncryptionKey
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutKMSEncryptionKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutKMSEncryptionKey)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutKMSEncryptionKey))
-> Logger
-> Service
-> Proxy PutKMSEncryptionKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutKMSEncryptionKey)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutKMSEncryptionKeyResponse
PutKMSEncryptionKeyResponse'
            (Int -> PutKMSEncryptionKeyResponse)
-> Either String Int -> Either String PutKMSEncryptionKeyResponse
forall (f :: * -> *) a b. Functor 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 PutKMSEncryptionKey

instance Prelude.NFData PutKMSEncryptionKey

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

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

instance Core.ToQuery PutKMSEncryptionKey where
  toQuery :: PutKMSEncryptionKey -> QueryString
toQuery = QueryString -> PutKMSEncryptionKey -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(PutKMSEncryptionKeyResponse
 -> PutKMSEncryptionKeyResponse -> Bool)
-> (PutKMSEncryptionKeyResponse
    -> PutKMSEncryptionKeyResponse -> Bool)
-> Eq PutKMSEncryptionKeyResponse
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]
(Int -> ReadS PutKMSEncryptionKeyResponse)
-> ReadS [PutKMSEncryptionKeyResponse]
-> ReadPrec PutKMSEncryptionKeyResponse
-> ReadPrec [PutKMSEncryptionKeyResponse]
-> Read 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
(Int -> PutKMSEncryptionKeyResponse -> ShowS)
-> (PutKMSEncryptionKeyResponse -> String)
-> ([PutKMSEncryptionKeyResponse] -> ShowS)
-> Show PutKMSEncryptionKeyResponse
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.
 PutKMSEncryptionKeyResponse -> Rep PutKMSEncryptionKeyResponse x)
-> (forall x.
    Rep PutKMSEncryptionKeyResponse x -> PutKMSEncryptionKeyResponse)
-> Generic PutKMSEncryptionKeyResponse
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' :: Int -> PutKMSEncryptionKeyResponse
PutKMSEncryptionKeyResponse'
    { $sel:httpStatus:PutKMSEncryptionKeyResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
putKMSEncryptionKeyResponse_httpStatus :: Lens.Lens' PutKMSEncryptionKeyResponse Prelude.Int
putKMSEncryptionKeyResponse_httpStatus :: (Int -> f Int)
-> PutKMSEncryptionKeyResponse -> f PutKMSEncryptionKeyResponse
putKMSEncryptionKeyResponse_httpStatus = (PutKMSEncryptionKeyResponse -> Int)
-> (PutKMSEncryptionKeyResponse
    -> Int -> PutKMSEncryptionKeyResponse)
-> Lens
     PutKMSEncryptionKeyResponse PutKMSEncryptionKeyResponse Int Int
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