{-# 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.IoTSiteWise.DescribeDefaultEncryptionConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves information about the default encryption configuration for the
-- Amazon Web Services account in the default or specified Region. For more
-- information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/key-management.html Key management>
-- in the /IoT SiteWise User Guide/.
module Amazonka.IoTSiteWise.DescribeDefaultEncryptionConfiguration
  ( -- * Creating a Request
    DescribeDefaultEncryptionConfiguration (..),
    newDescribeDefaultEncryptionConfiguration,

    -- * Destructuring the Response
    DescribeDefaultEncryptionConfigurationResponse (..),
    newDescribeDefaultEncryptionConfigurationResponse,

    -- * Response Lenses
    describeDefaultEncryptionConfigurationResponse_kmsKeyArn,
    describeDefaultEncryptionConfigurationResponse_httpStatus,
    describeDefaultEncryptionConfigurationResponse_encryptionType,
    describeDefaultEncryptionConfigurationResponse_configurationStatus,
  )
where

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

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

-- |
-- Create a value of 'DescribeDefaultEncryptionConfiguration' 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.
newDescribeDefaultEncryptionConfiguration ::
  DescribeDefaultEncryptionConfiguration
newDescribeDefaultEncryptionConfiguration :: DescribeDefaultEncryptionConfiguration
newDescribeDefaultEncryptionConfiguration =
  DescribeDefaultEncryptionConfiguration
DescribeDefaultEncryptionConfiguration'

instance
  Core.AWSRequest
    DescribeDefaultEncryptionConfiguration
  where
  type
    AWSResponse
      DescribeDefaultEncryptionConfiguration =
      DescribeDefaultEncryptionConfigurationResponse
  request :: (Service -> Service)
-> DescribeDefaultEncryptionConfiguration
-> Request DescribeDefaultEncryptionConfiguration
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 DescribeDefaultEncryptionConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse DescribeDefaultEncryptionConfiguration)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Int
-> EncryptionType
-> ConfigurationStatus
-> DescribeDefaultEncryptionConfigurationResponse
DescribeDefaultEncryptionConfigurationResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"kmsKeyArn")
            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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"encryptionType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"configurationStatus")
      )

instance
  Prelude.Hashable
    DescribeDefaultEncryptionConfiguration
  where
  hashWithSalt :: Int -> DescribeDefaultEncryptionConfiguration -> Int
hashWithSalt Int
_salt DescribeDefaultEncryptionConfiguration
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

instance
  Prelude.NFData
    DescribeDefaultEncryptionConfiguration
  where
  rnf :: DescribeDefaultEncryptionConfiguration -> ()
rnf DescribeDefaultEncryptionConfiguration
_ = ()

instance
  Data.ToHeaders
    DescribeDefaultEncryptionConfiguration
  where
  toHeaders :: DescribeDefaultEncryptionConfiguration -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance
  Data.ToPath
    DescribeDefaultEncryptionConfiguration
  where
  toPath :: DescribeDefaultEncryptionConfiguration -> ByteString
toPath =
    forall a b. a -> b -> a
Prelude.const ByteString
"/configuration/account/encryption"

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

-- | /See:/ 'newDescribeDefaultEncryptionConfigurationResponse' smart constructor.
data DescribeDefaultEncryptionConfigurationResponse = DescribeDefaultEncryptionConfigurationResponse'
  { -- | The key ARN of the customer managed key used for KMS encryption if you
    -- use @KMS_BASED_ENCRYPTION@.
    DescribeDefaultEncryptionConfigurationResponse -> Maybe Text
kmsKeyArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeDefaultEncryptionConfigurationResponse -> Int
httpStatus :: Prelude.Int,
    -- | The type of encryption used for the encryption configuration.
    DescribeDefaultEncryptionConfigurationResponse -> EncryptionType
encryptionType :: EncryptionType,
    -- | The status of the account configuration. This contains the
    -- @ConfigurationState@. If there\'s an error, it also contains the
    -- @ErrorDetails@.
    DescribeDefaultEncryptionConfigurationResponse
-> ConfigurationStatus
configurationStatus :: ConfigurationStatus
  }
  deriving (DescribeDefaultEncryptionConfigurationResponse
-> DescribeDefaultEncryptionConfigurationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeDefaultEncryptionConfigurationResponse
-> DescribeDefaultEncryptionConfigurationResponse -> Bool
$c/= :: DescribeDefaultEncryptionConfigurationResponse
-> DescribeDefaultEncryptionConfigurationResponse -> Bool
== :: DescribeDefaultEncryptionConfigurationResponse
-> DescribeDefaultEncryptionConfigurationResponse -> Bool
$c== :: DescribeDefaultEncryptionConfigurationResponse
-> DescribeDefaultEncryptionConfigurationResponse -> Bool
Prelude.Eq, ReadPrec [DescribeDefaultEncryptionConfigurationResponse]
ReadPrec DescribeDefaultEncryptionConfigurationResponse
Int -> ReadS DescribeDefaultEncryptionConfigurationResponse
ReadS [DescribeDefaultEncryptionConfigurationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeDefaultEncryptionConfigurationResponse]
$creadListPrec :: ReadPrec [DescribeDefaultEncryptionConfigurationResponse]
readPrec :: ReadPrec DescribeDefaultEncryptionConfigurationResponse
$creadPrec :: ReadPrec DescribeDefaultEncryptionConfigurationResponse
readList :: ReadS [DescribeDefaultEncryptionConfigurationResponse]
$creadList :: ReadS [DescribeDefaultEncryptionConfigurationResponse]
readsPrec :: Int -> ReadS DescribeDefaultEncryptionConfigurationResponse
$creadsPrec :: Int -> ReadS DescribeDefaultEncryptionConfigurationResponse
Prelude.Read, Int -> DescribeDefaultEncryptionConfigurationResponse -> ShowS
[DescribeDefaultEncryptionConfigurationResponse] -> ShowS
DescribeDefaultEncryptionConfigurationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeDefaultEncryptionConfigurationResponse] -> ShowS
$cshowList :: [DescribeDefaultEncryptionConfigurationResponse] -> ShowS
show :: DescribeDefaultEncryptionConfigurationResponse -> String
$cshow :: DescribeDefaultEncryptionConfigurationResponse -> String
showsPrec :: Int -> DescribeDefaultEncryptionConfigurationResponse -> ShowS
$cshowsPrec :: Int -> DescribeDefaultEncryptionConfigurationResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeDefaultEncryptionConfigurationResponse x
-> DescribeDefaultEncryptionConfigurationResponse
forall x.
DescribeDefaultEncryptionConfigurationResponse
-> Rep DescribeDefaultEncryptionConfigurationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeDefaultEncryptionConfigurationResponse x
-> DescribeDefaultEncryptionConfigurationResponse
$cfrom :: forall x.
DescribeDefaultEncryptionConfigurationResponse
-> Rep DescribeDefaultEncryptionConfigurationResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeDefaultEncryptionConfigurationResponse' 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:
--
-- 'kmsKeyArn', 'describeDefaultEncryptionConfigurationResponse_kmsKeyArn' - The key ARN of the customer managed key used for KMS encryption if you
-- use @KMS_BASED_ENCRYPTION@.
--
-- 'httpStatus', 'describeDefaultEncryptionConfigurationResponse_httpStatus' - The response's http status code.
--
-- 'encryptionType', 'describeDefaultEncryptionConfigurationResponse_encryptionType' - The type of encryption used for the encryption configuration.
--
-- 'configurationStatus', 'describeDefaultEncryptionConfigurationResponse_configurationStatus' - The status of the account configuration. This contains the
-- @ConfigurationState@. If there\'s an error, it also contains the
-- @ErrorDetails@.
newDescribeDefaultEncryptionConfigurationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'encryptionType'
  EncryptionType ->
  -- | 'configurationStatus'
  ConfigurationStatus ->
  DescribeDefaultEncryptionConfigurationResponse
newDescribeDefaultEncryptionConfigurationResponse :: Int
-> EncryptionType
-> ConfigurationStatus
-> DescribeDefaultEncryptionConfigurationResponse
newDescribeDefaultEncryptionConfigurationResponse
  Int
pHttpStatus_
  EncryptionType
pEncryptionType_
  ConfigurationStatus
pConfigurationStatus_ =
    DescribeDefaultEncryptionConfigurationResponse'
      { $sel:kmsKeyArn:DescribeDefaultEncryptionConfigurationResponse' :: Maybe Text
kmsKeyArn =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeDefaultEncryptionConfigurationResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:encryptionType:DescribeDefaultEncryptionConfigurationResponse' :: EncryptionType
encryptionType =
          EncryptionType
pEncryptionType_,
        $sel:configurationStatus:DescribeDefaultEncryptionConfigurationResponse' :: ConfigurationStatus
configurationStatus =
          ConfigurationStatus
pConfigurationStatus_
      }

-- | The key ARN of the customer managed key used for KMS encryption if you
-- use @KMS_BASED_ENCRYPTION@.
describeDefaultEncryptionConfigurationResponse_kmsKeyArn :: Lens.Lens' DescribeDefaultEncryptionConfigurationResponse (Prelude.Maybe Prelude.Text)
describeDefaultEncryptionConfigurationResponse_kmsKeyArn :: Lens' DescribeDefaultEncryptionConfigurationResponse (Maybe Text)
describeDefaultEncryptionConfigurationResponse_kmsKeyArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDefaultEncryptionConfigurationResponse' {Maybe Text
kmsKeyArn :: Maybe Text
$sel:kmsKeyArn:DescribeDefaultEncryptionConfigurationResponse' :: DescribeDefaultEncryptionConfigurationResponse -> Maybe Text
kmsKeyArn} -> Maybe Text
kmsKeyArn) (\s :: DescribeDefaultEncryptionConfigurationResponse
s@DescribeDefaultEncryptionConfigurationResponse' {} Maybe Text
a -> DescribeDefaultEncryptionConfigurationResponse
s {$sel:kmsKeyArn:DescribeDefaultEncryptionConfigurationResponse' :: Maybe Text
kmsKeyArn = Maybe Text
a} :: DescribeDefaultEncryptionConfigurationResponse)

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

-- | The type of encryption used for the encryption configuration.
describeDefaultEncryptionConfigurationResponse_encryptionType :: Lens.Lens' DescribeDefaultEncryptionConfigurationResponse EncryptionType
describeDefaultEncryptionConfigurationResponse_encryptionType :: Lens' DescribeDefaultEncryptionConfigurationResponse EncryptionType
describeDefaultEncryptionConfigurationResponse_encryptionType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDefaultEncryptionConfigurationResponse' {EncryptionType
encryptionType :: EncryptionType
$sel:encryptionType:DescribeDefaultEncryptionConfigurationResponse' :: DescribeDefaultEncryptionConfigurationResponse -> EncryptionType
encryptionType} -> EncryptionType
encryptionType) (\s :: DescribeDefaultEncryptionConfigurationResponse
s@DescribeDefaultEncryptionConfigurationResponse' {} EncryptionType
a -> DescribeDefaultEncryptionConfigurationResponse
s {$sel:encryptionType:DescribeDefaultEncryptionConfigurationResponse' :: EncryptionType
encryptionType = EncryptionType
a} :: DescribeDefaultEncryptionConfigurationResponse)

-- | The status of the account configuration. This contains the
-- @ConfigurationState@. If there\'s an error, it also contains the
-- @ErrorDetails@.
describeDefaultEncryptionConfigurationResponse_configurationStatus :: Lens.Lens' DescribeDefaultEncryptionConfigurationResponse ConfigurationStatus
describeDefaultEncryptionConfigurationResponse_configurationStatus :: Lens'
  DescribeDefaultEncryptionConfigurationResponse ConfigurationStatus
describeDefaultEncryptionConfigurationResponse_configurationStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDefaultEncryptionConfigurationResponse' {ConfigurationStatus
configurationStatus :: ConfigurationStatus
$sel:configurationStatus:DescribeDefaultEncryptionConfigurationResponse' :: DescribeDefaultEncryptionConfigurationResponse
-> ConfigurationStatus
configurationStatus} -> ConfigurationStatus
configurationStatus) (\s :: DescribeDefaultEncryptionConfigurationResponse
s@DescribeDefaultEncryptionConfigurationResponse' {} ConfigurationStatus
a -> DescribeDefaultEncryptionConfigurationResponse
s {$sel:configurationStatus:DescribeDefaultEncryptionConfigurationResponse' :: ConfigurationStatus
configurationStatus = ConfigurationStatus
a} :: DescribeDefaultEncryptionConfigurationResponse)

instance
  Prelude.NFData
    DescribeDefaultEncryptionConfigurationResponse
  where
  rnf :: DescribeDefaultEncryptionConfigurationResponse -> ()
rnf
    DescribeDefaultEncryptionConfigurationResponse' {Int
Maybe Text
EncryptionType
ConfigurationStatus
configurationStatus :: ConfigurationStatus
encryptionType :: EncryptionType
httpStatus :: Int
kmsKeyArn :: Maybe Text
$sel:configurationStatus:DescribeDefaultEncryptionConfigurationResponse' :: DescribeDefaultEncryptionConfigurationResponse
-> ConfigurationStatus
$sel:encryptionType:DescribeDefaultEncryptionConfigurationResponse' :: DescribeDefaultEncryptionConfigurationResponse -> EncryptionType
$sel:httpStatus:DescribeDefaultEncryptionConfigurationResponse' :: DescribeDefaultEncryptionConfigurationResponse -> Int
$sel:kmsKeyArn:DescribeDefaultEncryptionConfigurationResponse' :: DescribeDefaultEncryptionConfigurationResponse -> Maybe Text
..} =
      forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyArn
        seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
        seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf EncryptionType
encryptionType
        seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ConfigurationStatus
configurationStatus