{-# 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-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)
--
-- 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.Lens as Lens
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
(GetFieldLevelEncryption -> GetFieldLevelEncryption -> Bool)
-> (GetFieldLevelEncryption -> GetFieldLevelEncryption -> Bool)
-> Eq GetFieldLevelEncryption
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]
(Int -> ReadS GetFieldLevelEncryption)
-> ReadS [GetFieldLevelEncryption]
-> ReadPrec GetFieldLevelEncryption
-> ReadPrec [GetFieldLevelEncryption]
-> Read 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
(Int -> GetFieldLevelEncryption -> ShowS)
-> (GetFieldLevelEncryption -> String)
-> ([GetFieldLevelEncryption] -> ShowS)
-> Show GetFieldLevelEncryption
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.
 GetFieldLevelEncryption -> Rep GetFieldLevelEncryption x)
-> (forall x.
    Rep GetFieldLevelEncryption x -> GetFieldLevelEncryption)
-> Generic GetFieldLevelEncryption
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' :: Text -> GetFieldLevelEncryption
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 :: (Text -> f Text)
-> GetFieldLevelEncryption -> f GetFieldLevelEncryption
getFieldLevelEncryption_id = (GetFieldLevelEncryption -> Text)
-> (GetFieldLevelEncryption -> Text -> GetFieldLevelEncryption)
-> Lens GetFieldLevelEncryption GetFieldLevelEncryption Text Text
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 :: GetFieldLevelEncryption -> Request GetFieldLevelEncryption
request = Service
-> GetFieldLevelEncryption -> Request GetFieldLevelEncryption
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetFieldLevelEncryption
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetFieldLevelEncryption)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse GetFieldLevelEncryption))
-> Logger
-> Service
-> Proxy GetFieldLevelEncryption
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetFieldLevelEncryption)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> 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'
            (Maybe Text
 -> Maybe FieldLevelEncryption
 -> Int
 -> GetFieldLevelEncryptionResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe FieldLevelEncryption
      -> Int -> GetFieldLevelEncryptionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"ETag")
            Either
  String
  (Maybe FieldLevelEncryption
   -> Int -> GetFieldLevelEncryptionResponse)
-> Either String (Maybe FieldLevelEncryption)
-> Either String (Int -> GetFieldLevelEncryptionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node] -> Either String (Maybe FieldLevelEncryption)
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)
            Either String (Int -> GetFieldLevelEncryptionResponse)
-> Either String Int
-> Either String GetFieldLevelEncryptionResponse
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 GetFieldLevelEncryption

instance Prelude.NFData GetFieldLevelEncryption

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

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

instance Core.ToQuery GetFieldLevelEncryption where
  toQuery :: GetFieldLevelEncryption -> QueryString
toQuery = QueryString -> GetFieldLevelEncryption -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetFieldLevelEncryptionResponse
 -> GetFieldLevelEncryptionResponse -> Bool)
-> (GetFieldLevelEncryptionResponse
    -> GetFieldLevelEncryptionResponse -> Bool)
-> Eq GetFieldLevelEncryptionResponse
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]
(Int -> ReadS GetFieldLevelEncryptionResponse)
-> ReadS [GetFieldLevelEncryptionResponse]
-> ReadPrec GetFieldLevelEncryptionResponse
-> ReadPrec [GetFieldLevelEncryptionResponse]
-> Read 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
(Int -> GetFieldLevelEncryptionResponse -> ShowS)
-> (GetFieldLevelEncryptionResponse -> String)
-> ([GetFieldLevelEncryptionResponse] -> ShowS)
-> Show GetFieldLevelEncryptionResponse
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.
 GetFieldLevelEncryptionResponse
 -> Rep GetFieldLevelEncryptionResponse x)
-> (forall x.
    Rep GetFieldLevelEncryptionResponse x
    -> GetFieldLevelEncryptionResponse)
-> Generic GetFieldLevelEncryptionResponse
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' :: Maybe Text
-> Maybe FieldLevelEncryption
-> Int
-> GetFieldLevelEncryptionResponse
GetFieldLevelEncryptionResponse'
    { $sel:eTag:GetFieldLevelEncryptionResponse' :: Maybe Text
eTag =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fieldLevelEncryption:GetFieldLevelEncryptionResponse' :: Maybe FieldLevelEncryption
fieldLevelEncryption = Maybe 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 :: (Maybe Text -> f (Maybe Text))
-> GetFieldLevelEncryptionResponse
-> f GetFieldLevelEncryptionResponse
getFieldLevelEncryptionResponse_eTag = (GetFieldLevelEncryptionResponse -> Maybe Text)
-> (GetFieldLevelEncryptionResponse
    -> Maybe Text -> GetFieldLevelEncryptionResponse)
-> Lens
     GetFieldLevelEncryptionResponse
     GetFieldLevelEncryptionResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe FieldLevelEncryption -> f (Maybe FieldLevelEncryption))
-> GetFieldLevelEncryptionResponse
-> f GetFieldLevelEncryptionResponse
getFieldLevelEncryptionResponse_fieldLevelEncryption = (GetFieldLevelEncryptionResponse -> Maybe FieldLevelEncryption)
-> (GetFieldLevelEncryptionResponse
    -> Maybe FieldLevelEncryption -> GetFieldLevelEncryptionResponse)
-> Lens
     GetFieldLevelEncryptionResponse
     GetFieldLevelEncryptionResponse
     (Maybe FieldLevelEncryption)
     (Maybe 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 :: (Int -> f Int)
-> GetFieldLevelEncryptionResponse
-> f GetFieldLevelEncryptionResponse
getFieldLevelEncryptionResponse_httpStatus = (GetFieldLevelEncryptionResponse -> Int)
-> (GetFieldLevelEncryptionResponse
    -> Int -> GetFieldLevelEncryptionResponse)
-> Lens
     GetFieldLevelEncryptionResponse
     GetFieldLevelEncryptionResponse
     Int
     Int
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