{-# 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.CloudFront.GetFieldLevelEncryption
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Get the field-level encryption configuration information.
module Amazonka.CloudFront.GetFieldLevelEncryption
  ( -- * Creating a Request
    GetFieldLevelEncryption (..),
    newGetFieldLevelEncryption,

    -- * Request Lenses
    getFieldLevelEncryption_id,

    -- * Destructuring the Response
    GetFieldLevelEncryptionResponse (..),
    newGetFieldLevelEncryptionResponse,

    -- * Response Lenses
    getFieldLevelEncryptionResponse_eTag,
    getFieldLevelEncryptionResponse_fieldLevelEncryption,
    getFieldLevelEncryptionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetFieldLevelEncryption' smart constructor.
data GetFieldLevelEncryption = GetFieldLevelEncryption'
  { -- | Request the ID for the field-level encryption configuration information.
    GetFieldLevelEncryption -> Text
id :: Prelude.Text
  }
  deriving (GetFieldLevelEncryption -> GetFieldLevelEncryption -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetFieldLevelEncryption -> GetFieldLevelEncryption -> Bool
$c/= :: GetFieldLevelEncryption -> GetFieldLevelEncryption -> Bool
== :: GetFieldLevelEncryption -> GetFieldLevelEncryption -> Bool
$c== :: GetFieldLevelEncryption -> GetFieldLevelEncryption -> Bool
Prelude.Eq, ReadPrec [GetFieldLevelEncryption]
ReadPrec GetFieldLevelEncryption
Int -> ReadS GetFieldLevelEncryption
ReadS [GetFieldLevelEncryption]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetFieldLevelEncryption]
$creadListPrec :: ReadPrec [GetFieldLevelEncryption]
readPrec :: ReadPrec GetFieldLevelEncryption
$creadPrec :: ReadPrec GetFieldLevelEncryption
readList :: ReadS [GetFieldLevelEncryption]
$creadList :: ReadS [GetFieldLevelEncryption]
readsPrec :: Int -> ReadS GetFieldLevelEncryption
$creadsPrec :: Int -> ReadS GetFieldLevelEncryption
Prelude.Read, Int -> GetFieldLevelEncryption -> ShowS
[GetFieldLevelEncryption] -> ShowS
GetFieldLevelEncryption -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetFieldLevelEncryption] -> ShowS
$cshowList :: [GetFieldLevelEncryption] -> ShowS
show :: GetFieldLevelEncryption -> String
$cshow :: GetFieldLevelEncryption -> String
showsPrec :: Int -> GetFieldLevelEncryption -> ShowS
$cshowsPrec :: Int -> GetFieldLevelEncryption -> ShowS
Prelude.Show, forall x. Rep GetFieldLevelEncryption x -> GetFieldLevelEncryption
forall x. GetFieldLevelEncryption -> Rep GetFieldLevelEncryption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetFieldLevelEncryption x -> GetFieldLevelEncryption
$cfrom :: forall x. GetFieldLevelEncryption -> Rep GetFieldLevelEncryption x
Prelude.Generic)

-- |
-- Create a value of 'GetFieldLevelEncryption' 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:
--
-- 'id', 'getFieldLevelEncryption_id' - Request the ID for the field-level encryption configuration information.
newGetFieldLevelEncryption ::
  -- | 'id'
  Prelude.Text ->
  GetFieldLevelEncryption
newGetFieldLevelEncryption :: Text -> GetFieldLevelEncryption
newGetFieldLevelEncryption Text
pId_ =
  GetFieldLevelEncryption' {$sel:id:GetFieldLevelEncryption' :: Text
id = Text
pId_}

-- | Request the ID for the field-level encryption configuration information.
getFieldLevelEncryption_id :: Lens.Lens' GetFieldLevelEncryption Prelude.Text
getFieldLevelEncryption_id :: Lens' GetFieldLevelEncryption Text
getFieldLevelEncryption_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFieldLevelEncryption' {Text
id :: Text
$sel:id:GetFieldLevelEncryption' :: GetFieldLevelEncryption -> Text
id} -> Text
id) (\s :: GetFieldLevelEncryption
s@GetFieldLevelEncryption' {} Text
a -> GetFieldLevelEncryption
s {$sel:id:GetFieldLevelEncryption' :: Text
id = Text
a} :: GetFieldLevelEncryption)

instance Core.AWSRequest GetFieldLevelEncryption where
  type
    AWSResponse GetFieldLevelEncryption =
      GetFieldLevelEncryptionResponse
  request :: (Service -> Service)
-> GetFieldLevelEncryption -> Request GetFieldLevelEncryption
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetFieldLevelEncryption
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetFieldLevelEncryption)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text
-> Maybe FieldLevelEncryption
-> Int
-> GetFieldLevelEncryptionResponse
GetFieldLevelEncryptionResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Data..#? HeaderName
"ETag")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall a. FromXML a => [Node] -> Either String a
Data.parseXML [Node]
x)
            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 GetFieldLevelEncryption where
  hashWithSalt :: Int -> GetFieldLevelEncryption -> Int
hashWithSalt Int
_salt GetFieldLevelEncryption' {Text
id :: Text
$sel:id:GetFieldLevelEncryption' :: GetFieldLevelEncryption -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

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

instance Data.ToHeaders GetFieldLevelEncryption where
  toHeaders :: GetFieldLevelEncryption -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath GetFieldLevelEncryption where
  toPath :: GetFieldLevelEncryption -> ByteString
toPath GetFieldLevelEncryption' {Text
id :: Text
$sel:id:GetFieldLevelEncryption' :: GetFieldLevelEncryption -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2020-05-31/field-level-encryption/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
id]

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

-- | /See:/ 'newGetFieldLevelEncryptionResponse' smart constructor.
data GetFieldLevelEncryptionResponse = GetFieldLevelEncryptionResponse'
  { -- | The current version of the field level encryption configuration. For
    -- example: @E2QWRUHAPOMQZL@.
    GetFieldLevelEncryptionResponse -> Maybe Text
eTag :: Prelude.Maybe Prelude.Text,
    -- | Return the field-level encryption configuration information.
    GetFieldLevelEncryptionResponse -> Maybe FieldLevelEncryption
fieldLevelEncryption :: Prelude.Maybe FieldLevelEncryption,
    -- | The response's http status code.
    GetFieldLevelEncryptionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetFieldLevelEncryptionResponse
-> GetFieldLevelEncryptionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetFieldLevelEncryptionResponse
-> GetFieldLevelEncryptionResponse -> Bool
$c/= :: GetFieldLevelEncryptionResponse
-> GetFieldLevelEncryptionResponse -> Bool
== :: GetFieldLevelEncryptionResponse
-> GetFieldLevelEncryptionResponse -> Bool
$c== :: GetFieldLevelEncryptionResponse
-> GetFieldLevelEncryptionResponse -> Bool
Prelude.Eq, ReadPrec [GetFieldLevelEncryptionResponse]
ReadPrec GetFieldLevelEncryptionResponse
Int -> ReadS GetFieldLevelEncryptionResponse
ReadS [GetFieldLevelEncryptionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetFieldLevelEncryptionResponse]
$creadListPrec :: ReadPrec [GetFieldLevelEncryptionResponse]
readPrec :: ReadPrec GetFieldLevelEncryptionResponse
$creadPrec :: ReadPrec GetFieldLevelEncryptionResponse
readList :: ReadS [GetFieldLevelEncryptionResponse]
$creadList :: ReadS [GetFieldLevelEncryptionResponse]
readsPrec :: Int -> ReadS GetFieldLevelEncryptionResponse
$creadsPrec :: Int -> ReadS GetFieldLevelEncryptionResponse
Prelude.Read, Int -> GetFieldLevelEncryptionResponse -> ShowS
[GetFieldLevelEncryptionResponse] -> ShowS
GetFieldLevelEncryptionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetFieldLevelEncryptionResponse] -> ShowS
$cshowList :: [GetFieldLevelEncryptionResponse] -> ShowS
show :: GetFieldLevelEncryptionResponse -> String
$cshow :: GetFieldLevelEncryptionResponse -> String
showsPrec :: Int -> GetFieldLevelEncryptionResponse -> ShowS
$cshowsPrec :: Int -> GetFieldLevelEncryptionResponse -> ShowS
Prelude.Show, forall x.
Rep GetFieldLevelEncryptionResponse x
-> GetFieldLevelEncryptionResponse
forall x.
GetFieldLevelEncryptionResponse
-> Rep GetFieldLevelEncryptionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetFieldLevelEncryptionResponse x
-> GetFieldLevelEncryptionResponse
$cfrom :: forall x.
GetFieldLevelEncryptionResponse
-> Rep GetFieldLevelEncryptionResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetFieldLevelEncryptionResponse' 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:
--
-- 'eTag', 'getFieldLevelEncryptionResponse_eTag' - The current version of the field level encryption configuration. For
-- example: @E2QWRUHAPOMQZL@.
--
-- 'fieldLevelEncryption', 'getFieldLevelEncryptionResponse_fieldLevelEncryption' - Return the field-level encryption configuration information.
--
-- 'httpStatus', 'getFieldLevelEncryptionResponse_httpStatus' - The response's http status code.
newGetFieldLevelEncryptionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetFieldLevelEncryptionResponse
newGetFieldLevelEncryptionResponse :: Int -> GetFieldLevelEncryptionResponse
newGetFieldLevelEncryptionResponse Int
pHttpStatus_ =
  GetFieldLevelEncryptionResponse'
    { $sel:eTag:GetFieldLevelEncryptionResponse' :: Maybe Text
eTag =
        forall a. Maybe a
Prelude.Nothing,
      $sel:fieldLevelEncryption:GetFieldLevelEncryptionResponse' :: Maybe FieldLevelEncryption
fieldLevelEncryption = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetFieldLevelEncryptionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The current version of the field level encryption configuration. For
-- example: @E2QWRUHAPOMQZL@.
getFieldLevelEncryptionResponse_eTag :: Lens.Lens' GetFieldLevelEncryptionResponse (Prelude.Maybe Prelude.Text)
getFieldLevelEncryptionResponse_eTag :: Lens' GetFieldLevelEncryptionResponse (Maybe Text)
getFieldLevelEncryptionResponse_eTag = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFieldLevelEncryptionResponse' {Maybe Text
eTag :: Maybe Text
$sel:eTag:GetFieldLevelEncryptionResponse' :: GetFieldLevelEncryptionResponse -> Maybe Text
eTag} -> Maybe Text
eTag) (\s :: GetFieldLevelEncryptionResponse
s@GetFieldLevelEncryptionResponse' {} Maybe Text
a -> GetFieldLevelEncryptionResponse
s {$sel:eTag:GetFieldLevelEncryptionResponse' :: Maybe Text
eTag = Maybe Text
a} :: GetFieldLevelEncryptionResponse)

-- | Return the field-level encryption configuration information.
getFieldLevelEncryptionResponse_fieldLevelEncryption :: Lens.Lens' GetFieldLevelEncryptionResponse (Prelude.Maybe FieldLevelEncryption)
getFieldLevelEncryptionResponse_fieldLevelEncryption :: Lens' GetFieldLevelEncryptionResponse (Maybe FieldLevelEncryption)
getFieldLevelEncryptionResponse_fieldLevelEncryption = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFieldLevelEncryptionResponse' {Maybe FieldLevelEncryption
fieldLevelEncryption :: Maybe FieldLevelEncryption
$sel:fieldLevelEncryption:GetFieldLevelEncryptionResponse' :: GetFieldLevelEncryptionResponse -> Maybe FieldLevelEncryption
fieldLevelEncryption} -> Maybe FieldLevelEncryption
fieldLevelEncryption) (\s :: GetFieldLevelEncryptionResponse
s@GetFieldLevelEncryptionResponse' {} Maybe FieldLevelEncryption
a -> GetFieldLevelEncryptionResponse
s {$sel:fieldLevelEncryption:GetFieldLevelEncryptionResponse' :: Maybe FieldLevelEncryption
fieldLevelEncryption = Maybe FieldLevelEncryption
a} :: GetFieldLevelEncryptionResponse)

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

instance
  Prelude.NFData
    GetFieldLevelEncryptionResponse
  where
  rnf :: GetFieldLevelEncryptionResponse -> ()
rnf GetFieldLevelEncryptionResponse' {Int
Maybe Text
Maybe FieldLevelEncryption
httpStatus :: Int
fieldLevelEncryption :: Maybe FieldLevelEncryption
eTag :: Maybe Text
$sel:httpStatus:GetFieldLevelEncryptionResponse' :: GetFieldLevelEncryptionResponse -> Int
$sel:fieldLevelEncryption:GetFieldLevelEncryptionResponse' :: GetFieldLevelEncryptionResponse -> Maybe FieldLevelEncryption
$sel:eTag:GetFieldLevelEncryptionResponse' :: GetFieldLevelEncryptionResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
eTag
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FieldLevelEncryption
fieldLevelEncryption
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus