{-# 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.Glue.PutDataCatalogEncryptionSettings
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Sets the security configuration for a specified catalog. After the
-- configuration has been set, the specified encryption is applied to every
-- catalog write thereafter.
module Amazonka.Glue.PutDataCatalogEncryptionSettings
  ( -- * Creating a Request
    PutDataCatalogEncryptionSettings (..),
    newPutDataCatalogEncryptionSettings,

    -- * Request Lenses
    putDataCatalogEncryptionSettings_catalogId,
    putDataCatalogEncryptionSettings_dataCatalogEncryptionSettings,

    -- * Destructuring the Response
    PutDataCatalogEncryptionSettingsResponse (..),
    newPutDataCatalogEncryptionSettingsResponse,

    -- * Response Lenses
    putDataCatalogEncryptionSettingsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newPutDataCatalogEncryptionSettings' smart constructor.
data PutDataCatalogEncryptionSettings = PutDataCatalogEncryptionSettings'
  { -- | The ID of the Data Catalog to set the security configuration for. If
    -- none is provided, the Amazon Web Services account ID is used by default.
    PutDataCatalogEncryptionSettings -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | The security configuration to set.
    PutDataCatalogEncryptionSettings -> DataCatalogEncryptionSettings
dataCatalogEncryptionSettings :: DataCatalogEncryptionSettings
  }
  deriving (PutDataCatalogEncryptionSettings
-> PutDataCatalogEncryptionSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutDataCatalogEncryptionSettings
-> PutDataCatalogEncryptionSettings -> Bool
$c/= :: PutDataCatalogEncryptionSettings
-> PutDataCatalogEncryptionSettings -> Bool
== :: PutDataCatalogEncryptionSettings
-> PutDataCatalogEncryptionSettings -> Bool
$c== :: PutDataCatalogEncryptionSettings
-> PutDataCatalogEncryptionSettings -> Bool
Prelude.Eq, ReadPrec [PutDataCatalogEncryptionSettings]
ReadPrec PutDataCatalogEncryptionSettings
Int -> ReadS PutDataCatalogEncryptionSettings
ReadS [PutDataCatalogEncryptionSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutDataCatalogEncryptionSettings]
$creadListPrec :: ReadPrec [PutDataCatalogEncryptionSettings]
readPrec :: ReadPrec PutDataCatalogEncryptionSettings
$creadPrec :: ReadPrec PutDataCatalogEncryptionSettings
readList :: ReadS [PutDataCatalogEncryptionSettings]
$creadList :: ReadS [PutDataCatalogEncryptionSettings]
readsPrec :: Int -> ReadS PutDataCatalogEncryptionSettings
$creadsPrec :: Int -> ReadS PutDataCatalogEncryptionSettings
Prelude.Read, Int -> PutDataCatalogEncryptionSettings -> ShowS
[PutDataCatalogEncryptionSettings] -> ShowS
PutDataCatalogEncryptionSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutDataCatalogEncryptionSettings] -> ShowS
$cshowList :: [PutDataCatalogEncryptionSettings] -> ShowS
show :: PutDataCatalogEncryptionSettings -> String
$cshow :: PutDataCatalogEncryptionSettings -> String
showsPrec :: Int -> PutDataCatalogEncryptionSettings -> ShowS
$cshowsPrec :: Int -> PutDataCatalogEncryptionSettings -> ShowS
Prelude.Show, forall x.
Rep PutDataCatalogEncryptionSettings x
-> PutDataCatalogEncryptionSettings
forall x.
PutDataCatalogEncryptionSettings
-> Rep PutDataCatalogEncryptionSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutDataCatalogEncryptionSettings x
-> PutDataCatalogEncryptionSettings
$cfrom :: forall x.
PutDataCatalogEncryptionSettings
-> Rep PutDataCatalogEncryptionSettings x
Prelude.Generic)

-- |
-- Create a value of 'PutDataCatalogEncryptionSettings' 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:
--
-- 'catalogId', 'putDataCatalogEncryptionSettings_catalogId' - The ID of the Data Catalog to set the security configuration for. If
-- none is provided, the Amazon Web Services account ID is used by default.
--
-- 'dataCatalogEncryptionSettings', 'putDataCatalogEncryptionSettings_dataCatalogEncryptionSettings' - The security configuration to set.
newPutDataCatalogEncryptionSettings ::
  -- | 'dataCatalogEncryptionSettings'
  DataCatalogEncryptionSettings ->
  PutDataCatalogEncryptionSettings
newPutDataCatalogEncryptionSettings :: DataCatalogEncryptionSettings -> PutDataCatalogEncryptionSettings
newPutDataCatalogEncryptionSettings
  DataCatalogEncryptionSettings
pDataCatalogEncryptionSettings_ =
    PutDataCatalogEncryptionSettings'
      { $sel:catalogId:PutDataCatalogEncryptionSettings' :: Maybe Text
catalogId =
          forall a. Maybe a
Prelude.Nothing,
        $sel:dataCatalogEncryptionSettings:PutDataCatalogEncryptionSettings' :: DataCatalogEncryptionSettings
dataCatalogEncryptionSettings =
          DataCatalogEncryptionSettings
pDataCatalogEncryptionSettings_
      }

-- | The ID of the Data Catalog to set the security configuration for. If
-- none is provided, the Amazon Web Services account ID is used by default.
putDataCatalogEncryptionSettings_catalogId :: Lens.Lens' PutDataCatalogEncryptionSettings (Prelude.Maybe Prelude.Text)
putDataCatalogEncryptionSettings_catalogId :: Lens' PutDataCatalogEncryptionSettings (Maybe Text)
putDataCatalogEncryptionSettings_catalogId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutDataCatalogEncryptionSettings' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:PutDataCatalogEncryptionSettings' :: PutDataCatalogEncryptionSettings -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: PutDataCatalogEncryptionSettings
s@PutDataCatalogEncryptionSettings' {} Maybe Text
a -> PutDataCatalogEncryptionSettings
s {$sel:catalogId:PutDataCatalogEncryptionSettings' :: Maybe Text
catalogId = Maybe Text
a} :: PutDataCatalogEncryptionSettings)

-- | The security configuration to set.
putDataCatalogEncryptionSettings_dataCatalogEncryptionSettings :: Lens.Lens' PutDataCatalogEncryptionSettings DataCatalogEncryptionSettings
putDataCatalogEncryptionSettings_dataCatalogEncryptionSettings :: Lens'
  PutDataCatalogEncryptionSettings DataCatalogEncryptionSettings
putDataCatalogEncryptionSettings_dataCatalogEncryptionSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutDataCatalogEncryptionSettings' {DataCatalogEncryptionSettings
dataCatalogEncryptionSettings :: DataCatalogEncryptionSettings
$sel:dataCatalogEncryptionSettings:PutDataCatalogEncryptionSettings' :: PutDataCatalogEncryptionSettings -> DataCatalogEncryptionSettings
dataCatalogEncryptionSettings} -> DataCatalogEncryptionSettings
dataCatalogEncryptionSettings) (\s :: PutDataCatalogEncryptionSettings
s@PutDataCatalogEncryptionSettings' {} DataCatalogEncryptionSettings
a -> PutDataCatalogEncryptionSettings
s {$sel:dataCatalogEncryptionSettings:PutDataCatalogEncryptionSettings' :: DataCatalogEncryptionSettings
dataCatalogEncryptionSettings = DataCatalogEncryptionSettings
a} :: PutDataCatalogEncryptionSettings)

instance
  Core.AWSRequest
    PutDataCatalogEncryptionSettings
  where
  type
    AWSResponse PutDataCatalogEncryptionSettings =
      PutDataCatalogEncryptionSettingsResponse
  request :: (Service -> Service)
-> PutDataCatalogEncryptionSettings
-> Request PutDataCatalogEncryptionSettings
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 PutDataCatalogEncryptionSettings
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse PutDataCatalogEncryptionSettings)))
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 -> PutDataCatalogEncryptionSettingsResponse
PutDataCatalogEncryptionSettingsResponse'
            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
    PutDataCatalogEncryptionSettings
  where
  hashWithSalt :: Int -> PutDataCatalogEncryptionSettings -> Int
hashWithSalt
    Int
_salt
    PutDataCatalogEncryptionSettings' {Maybe Text
DataCatalogEncryptionSettings
dataCatalogEncryptionSettings :: DataCatalogEncryptionSettings
catalogId :: Maybe Text
$sel:dataCatalogEncryptionSettings:PutDataCatalogEncryptionSettings' :: PutDataCatalogEncryptionSettings -> DataCatalogEncryptionSettings
$sel:catalogId:PutDataCatalogEncryptionSettings' :: PutDataCatalogEncryptionSettings -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
catalogId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DataCatalogEncryptionSettings
dataCatalogEncryptionSettings

instance
  Prelude.NFData
    PutDataCatalogEncryptionSettings
  where
  rnf :: PutDataCatalogEncryptionSettings -> ()
rnf PutDataCatalogEncryptionSettings' {Maybe Text
DataCatalogEncryptionSettings
dataCatalogEncryptionSettings :: DataCatalogEncryptionSettings
catalogId :: Maybe Text
$sel:dataCatalogEncryptionSettings:PutDataCatalogEncryptionSettings' :: PutDataCatalogEncryptionSettings -> DataCatalogEncryptionSettings
$sel:catalogId:PutDataCatalogEncryptionSettings' :: PutDataCatalogEncryptionSettings -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
catalogId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DataCatalogEncryptionSettings
dataCatalogEncryptionSettings

instance
  Data.ToHeaders
    PutDataCatalogEncryptionSettings
  where
  toHeaders :: PutDataCatalogEncryptionSettings -> 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
"AWSGlue.PutDataCatalogEncryptionSettings" ::
                          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 PutDataCatalogEncryptionSettings where
  toJSON :: PutDataCatalogEncryptionSettings -> Value
toJSON PutDataCatalogEncryptionSettings' {Maybe Text
DataCatalogEncryptionSettings
dataCatalogEncryptionSettings :: DataCatalogEncryptionSettings
catalogId :: Maybe Text
$sel:dataCatalogEncryptionSettings:PutDataCatalogEncryptionSettings' :: PutDataCatalogEncryptionSettings -> DataCatalogEncryptionSettings
$sel:catalogId:PutDataCatalogEncryptionSettings' :: PutDataCatalogEncryptionSettings -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CatalogId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
catalogId,
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"DataCatalogEncryptionSettings"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DataCatalogEncryptionSettings
dataCatalogEncryptionSettings
              )
          ]
      )

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

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

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

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

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

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