{-# 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.EC2.GetEbsEncryptionByDefault
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describes whether EBS encryption by default is enabled for your account
-- in the current Region.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html Amazon EBS encryption>
-- in the /Amazon Elastic Compute Cloud User Guide/.
module Amazonka.EC2.GetEbsEncryptionByDefault
  ( -- * Creating a Request
    GetEbsEncryptionByDefault (..),
    newGetEbsEncryptionByDefault,

    -- * Request Lenses
    getEbsEncryptionByDefault_dryRun,

    -- * Destructuring the Response
    GetEbsEncryptionByDefaultResponse (..),
    newGetEbsEncryptionByDefaultResponse,

    -- * Response Lenses
    getEbsEncryptionByDefaultResponse_ebsEncryptionByDefault,
    getEbsEncryptionByDefaultResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetEbsEncryptionByDefault' smart constructor.
data GetEbsEncryptionByDefault = GetEbsEncryptionByDefault'
  { -- | Checks whether you have the required permissions for the action, without
    -- actually making the request, and provides an error response. If you have
    -- the required permissions, the error response is @DryRunOperation@.
    -- Otherwise, it is @UnauthorizedOperation@.
    GetEbsEncryptionByDefault -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool
  }
  deriving (GetEbsEncryptionByDefault -> GetEbsEncryptionByDefault -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEbsEncryptionByDefault -> GetEbsEncryptionByDefault -> Bool
$c/= :: GetEbsEncryptionByDefault -> GetEbsEncryptionByDefault -> Bool
== :: GetEbsEncryptionByDefault -> GetEbsEncryptionByDefault -> Bool
$c== :: GetEbsEncryptionByDefault -> GetEbsEncryptionByDefault -> Bool
Prelude.Eq, ReadPrec [GetEbsEncryptionByDefault]
ReadPrec GetEbsEncryptionByDefault
Int -> ReadS GetEbsEncryptionByDefault
ReadS [GetEbsEncryptionByDefault]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEbsEncryptionByDefault]
$creadListPrec :: ReadPrec [GetEbsEncryptionByDefault]
readPrec :: ReadPrec GetEbsEncryptionByDefault
$creadPrec :: ReadPrec GetEbsEncryptionByDefault
readList :: ReadS [GetEbsEncryptionByDefault]
$creadList :: ReadS [GetEbsEncryptionByDefault]
readsPrec :: Int -> ReadS GetEbsEncryptionByDefault
$creadsPrec :: Int -> ReadS GetEbsEncryptionByDefault
Prelude.Read, Int -> GetEbsEncryptionByDefault -> ShowS
[GetEbsEncryptionByDefault] -> ShowS
GetEbsEncryptionByDefault -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEbsEncryptionByDefault] -> ShowS
$cshowList :: [GetEbsEncryptionByDefault] -> ShowS
show :: GetEbsEncryptionByDefault -> String
$cshow :: GetEbsEncryptionByDefault -> String
showsPrec :: Int -> GetEbsEncryptionByDefault -> ShowS
$cshowsPrec :: Int -> GetEbsEncryptionByDefault -> ShowS
Prelude.Show, forall x.
Rep GetEbsEncryptionByDefault x -> GetEbsEncryptionByDefault
forall x.
GetEbsEncryptionByDefault -> Rep GetEbsEncryptionByDefault x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetEbsEncryptionByDefault x -> GetEbsEncryptionByDefault
$cfrom :: forall x.
GetEbsEncryptionByDefault -> Rep GetEbsEncryptionByDefault x
Prelude.Generic)

-- |
-- Create a value of 'GetEbsEncryptionByDefault' 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:
--
-- 'dryRun', 'getEbsEncryptionByDefault_dryRun' - Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
newGetEbsEncryptionByDefault ::
  GetEbsEncryptionByDefault
newGetEbsEncryptionByDefault :: GetEbsEncryptionByDefault
newGetEbsEncryptionByDefault =
  GetEbsEncryptionByDefault'
    { $sel:dryRun:GetEbsEncryptionByDefault' :: Maybe Bool
dryRun =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
getEbsEncryptionByDefault_dryRun :: Lens.Lens' GetEbsEncryptionByDefault (Prelude.Maybe Prelude.Bool)
getEbsEncryptionByDefault_dryRun :: Lens' GetEbsEncryptionByDefault (Maybe Bool)
getEbsEncryptionByDefault_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEbsEncryptionByDefault' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:GetEbsEncryptionByDefault' :: GetEbsEncryptionByDefault -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: GetEbsEncryptionByDefault
s@GetEbsEncryptionByDefault' {} Maybe Bool
a -> GetEbsEncryptionByDefault
s {$sel:dryRun:GetEbsEncryptionByDefault' :: Maybe Bool
dryRun = Maybe Bool
a} :: GetEbsEncryptionByDefault)

instance Core.AWSRequest GetEbsEncryptionByDefault where
  type
    AWSResponse GetEbsEncryptionByDefault =
      GetEbsEncryptionByDefaultResponse
  request :: (Service -> Service)
-> GetEbsEncryptionByDefault -> Request GetEbsEncryptionByDefault
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetEbsEncryptionByDefault
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetEbsEncryptionByDefault)))
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 Bool -> Int -> GetEbsEncryptionByDefaultResponse
GetEbsEncryptionByDefaultResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ebsEncryptionByDefault")
            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 GetEbsEncryptionByDefault where
  hashWithSalt :: Int -> GetEbsEncryptionByDefault -> Int
hashWithSalt Int
_salt GetEbsEncryptionByDefault' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:GetEbsEncryptionByDefault' :: GetEbsEncryptionByDefault -> Maybe Bool
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
dryRun

instance Prelude.NFData GetEbsEncryptionByDefault where
  rnf :: GetEbsEncryptionByDefault -> ()
rnf GetEbsEncryptionByDefault' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:GetEbsEncryptionByDefault' :: GetEbsEncryptionByDefault -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
dryRun

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

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

instance Data.ToQuery GetEbsEncryptionByDefault where
  toQuery :: GetEbsEncryptionByDefault -> QueryString
toQuery GetEbsEncryptionByDefault' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:GetEbsEncryptionByDefault' :: GetEbsEncryptionByDefault -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"GetEbsEncryptionByDefault" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2016-11-15" :: Prelude.ByteString),
        ByteString
"DryRun" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
dryRun
      ]

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

-- |
-- Create a value of 'GetEbsEncryptionByDefaultResponse' 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:
--
-- 'ebsEncryptionByDefault', 'getEbsEncryptionByDefaultResponse_ebsEncryptionByDefault' - Indicates whether encryption by default is enabled.
--
-- 'httpStatus', 'getEbsEncryptionByDefaultResponse_httpStatus' - The response's http status code.
newGetEbsEncryptionByDefaultResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetEbsEncryptionByDefaultResponse
newGetEbsEncryptionByDefaultResponse :: Int -> GetEbsEncryptionByDefaultResponse
newGetEbsEncryptionByDefaultResponse Int
pHttpStatus_ =
  GetEbsEncryptionByDefaultResponse'
    { $sel:ebsEncryptionByDefault:GetEbsEncryptionByDefaultResponse' :: Maybe Bool
ebsEncryptionByDefault =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetEbsEncryptionByDefaultResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Indicates whether encryption by default is enabled.
getEbsEncryptionByDefaultResponse_ebsEncryptionByDefault :: Lens.Lens' GetEbsEncryptionByDefaultResponse (Prelude.Maybe Prelude.Bool)
getEbsEncryptionByDefaultResponse_ebsEncryptionByDefault :: Lens' GetEbsEncryptionByDefaultResponse (Maybe Bool)
getEbsEncryptionByDefaultResponse_ebsEncryptionByDefault = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEbsEncryptionByDefaultResponse' {Maybe Bool
ebsEncryptionByDefault :: Maybe Bool
$sel:ebsEncryptionByDefault:GetEbsEncryptionByDefaultResponse' :: GetEbsEncryptionByDefaultResponse -> Maybe Bool
ebsEncryptionByDefault} -> Maybe Bool
ebsEncryptionByDefault) (\s :: GetEbsEncryptionByDefaultResponse
s@GetEbsEncryptionByDefaultResponse' {} Maybe Bool
a -> GetEbsEncryptionByDefaultResponse
s {$sel:ebsEncryptionByDefault:GetEbsEncryptionByDefaultResponse' :: Maybe Bool
ebsEncryptionByDefault = Maybe Bool
a} :: GetEbsEncryptionByDefaultResponse)

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

instance
  Prelude.NFData
    GetEbsEncryptionByDefaultResponse
  where
  rnf :: GetEbsEncryptionByDefaultResponse -> ()
rnf GetEbsEncryptionByDefaultResponse' {Int
Maybe Bool
httpStatus :: Int
ebsEncryptionByDefault :: Maybe Bool
$sel:httpStatus:GetEbsEncryptionByDefaultResponse' :: GetEbsEncryptionByDefaultResponse -> Int
$sel:ebsEncryptionByDefault:GetEbsEncryptionByDefaultResponse' :: GetEbsEncryptionByDefaultResponse -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
ebsEncryptionByDefault
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus