{-# 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.DisableEbsEncryptionByDefault
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disables EBS encryption by default for your account in the current
-- Region.
--
-- After you disable encryption by default, you can still create encrypted
-- volumes by enabling encryption when you create each volume.
--
-- Disabling encryption by default does not change the encryption status of
-- your existing volumes.
--
-- 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.DisableEbsEncryptionByDefault
  ( -- * Creating a Request
    DisableEbsEncryptionByDefault (..),
    newDisableEbsEncryptionByDefault,

    -- * Request Lenses
    disableEbsEncryptionByDefault_dryRun,

    -- * Destructuring the Response
    DisableEbsEncryptionByDefaultResponse (..),
    newDisableEbsEncryptionByDefaultResponse,

    -- * Response Lenses
    disableEbsEncryptionByDefaultResponse_ebsEncryptionByDefault,
    disableEbsEncryptionByDefaultResponse_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:/ 'newDisableEbsEncryptionByDefault' smart constructor.
data DisableEbsEncryptionByDefault = DisableEbsEncryptionByDefault'
  { -- | 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@.
    DisableEbsEncryptionByDefault -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool
  }
  deriving (DisableEbsEncryptionByDefault
-> DisableEbsEncryptionByDefault -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableEbsEncryptionByDefault
-> DisableEbsEncryptionByDefault -> Bool
$c/= :: DisableEbsEncryptionByDefault
-> DisableEbsEncryptionByDefault -> Bool
== :: DisableEbsEncryptionByDefault
-> DisableEbsEncryptionByDefault -> Bool
$c== :: DisableEbsEncryptionByDefault
-> DisableEbsEncryptionByDefault -> Bool
Prelude.Eq, ReadPrec [DisableEbsEncryptionByDefault]
ReadPrec DisableEbsEncryptionByDefault
Int -> ReadS DisableEbsEncryptionByDefault
ReadS [DisableEbsEncryptionByDefault]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableEbsEncryptionByDefault]
$creadListPrec :: ReadPrec [DisableEbsEncryptionByDefault]
readPrec :: ReadPrec DisableEbsEncryptionByDefault
$creadPrec :: ReadPrec DisableEbsEncryptionByDefault
readList :: ReadS [DisableEbsEncryptionByDefault]
$creadList :: ReadS [DisableEbsEncryptionByDefault]
readsPrec :: Int -> ReadS DisableEbsEncryptionByDefault
$creadsPrec :: Int -> ReadS DisableEbsEncryptionByDefault
Prelude.Read, Int -> DisableEbsEncryptionByDefault -> ShowS
[DisableEbsEncryptionByDefault] -> ShowS
DisableEbsEncryptionByDefault -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableEbsEncryptionByDefault] -> ShowS
$cshowList :: [DisableEbsEncryptionByDefault] -> ShowS
show :: DisableEbsEncryptionByDefault -> String
$cshow :: DisableEbsEncryptionByDefault -> String
showsPrec :: Int -> DisableEbsEncryptionByDefault -> ShowS
$cshowsPrec :: Int -> DisableEbsEncryptionByDefault -> ShowS
Prelude.Show, forall x.
Rep DisableEbsEncryptionByDefault x
-> DisableEbsEncryptionByDefault
forall x.
DisableEbsEncryptionByDefault
-> Rep DisableEbsEncryptionByDefault x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisableEbsEncryptionByDefault x
-> DisableEbsEncryptionByDefault
$cfrom :: forall x.
DisableEbsEncryptionByDefault
-> Rep DisableEbsEncryptionByDefault x
Prelude.Generic)

-- |
-- Create a value of 'DisableEbsEncryptionByDefault' 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', 'disableEbsEncryptionByDefault_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@.
newDisableEbsEncryptionByDefault ::
  DisableEbsEncryptionByDefault
newDisableEbsEncryptionByDefault :: DisableEbsEncryptionByDefault
newDisableEbsEncryptionByDefault =
  DisableEbsEncryptionByDefault'
    { $sel:dryRun:DisableEbsEncryptionByDefault' :: 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@.
disableEbsEncryptionByDefault_dryRun :: Lens.Lens' DisableEbsEncryptionByDefault (Prelude.Maybe Prelude.Bool)
disableEbsEncryptionByDefault_dryRun :: Lens' DisableEbsEncryptionByDefault (Maybe Bool)
disableEbsEncryptionByDefault_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableEbsEncryptionByDefault' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:DisableEbsEncryptionByDefault' :: DisableEbsEncryptionByDefault -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: DisableEbsEncryptionByDefault
s@DisableEbsEncryptionByDefault' {} Maybe Bool
a -> DisableEbsEncryptionByDefault
s {$sel:dryRun:DisableEbsEncryptionByDefault' :: Maybe Bool
dryRun = Maybe Bool
a} :: DisableEbsEncryptionByDefault)

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

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

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

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

instance Data.ToQuery DisableEbsEncryptionByDefault where
  toQuery :: DisableEbsEncryptionByDefault -> QueryString
toQuery DisableEbsEncryptionByDefault' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:DisableEbsEncryptionByDefault' :: DisableEbsEncryptionByDefault -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: ( ByteString
"DisableEbsEncryptionByDefault" ::
                      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:/ 'newDisableEbsEncryptionByDefaultResponse' smart constructor.
data DisableEbsEncryptionByDefaultResponse = DisableEbsEncryptionByDefaultResponse'
  { -- | The updated status of encryption by default.
    DisableEbsEncryptionByDefaultResponse -> Maybe Bool
ebsEncryptionByDefault :: Prelude.Maybe Prelude.Bool,
    -- | The response's http status code.
    DisableEbsEncryptionByDefaultResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DisableEbsEncryptionByDefaultResponse
-> DisableEbsEncryptionByDefaultResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableEbsEncryptionByDefaultResponse
-> DisableEbsEncryptionByDefaultResponse -> Bool
$c/= :: DisableEbsEncryptionByDefaultResponse
-> DisableEbsEncryptionByDefaultResponse -> Bool
== :: DisableEbsEncryptionByDefaultResponse
-> DisableEbsEncryptionByDefaultResponse -> Bool
$c== :: DisableEbsEncryptionByDefaultResponse
-> DisableEbsEncryptionByDefaultResponse -> Bool
Prelude.Eq, ReadPrec [DisableEbsEncryptionByDefaultResponse]
ReadPrec DisableEbsEncryptionByDefaultResponse
Int -> ReadS DisableEbsEncryptionByDefaultResponse
ReadS [DisableEbsEncryptionByDefaultResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableEbsEncryptionByDefaultResponse]
$creadListPrec :: ReadPrec [DisableEbsEncryptionByDefaultResponse]
readPrec :: ReadPrec DisableEbsEncryptionByDefaultResponse
$creadPrec :: ReadPrec DisableEbsEncryptionByDefaultResponse
readList :: ReadS [DisableEbsEncryptionByDefaultResponse]
$creadList :: ReadS [DisableEbsEncryptionByDefaultResponse]
readsPrec :: Int -> ReadS DisableEbsEncryptionByDefaultResponse
$creadsPrec :: Int -> ReadS DisableEbsEncryptionByDefaultResponse
Prelude.Read, Int -> DisableEbsEncryptionByDefaultResponse -> ShowS
[DisableEbsEncryptionByDefaultResponse] -> ShowS
DisableEbsEncryptionByDefaultResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableEbsEncryptionByDefaultResponse] -> ShowS
$cshowList :: [DisableEbsEncryptionByDefaultResponse] -> ShowS
show :: DisableEbsEncryptionByDefaultResponse -> String
$cshow :: DisableEbsEncryptionByDefaultResponse -> String
showsPrec :: Int -> DisableEbsEncryptionByDefaultResponse -> ShowS
$cshowsPrec :: Int -> DisableEbsEncryptionByDefaultResponse -> ShowS
Prelude.Show, forall x.
Rep DisableEbsEncryptionByDefaultResponse x
-> DisableEbsEncryptionByDefaultResponse
forall x.
DisableEbsEncryptionByDefaultResponse
-> Rep DisableEbsEncryptionByDefaultResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisableEbsEncryptionByDefaultResponse x
-> DisableEbsEncryptionByDefaultResponse
$cfrom :: forall x.
DisableEbsEncryptionByDefaultResponse
-> Rep DisableEbsEncryptionByDefaultResponse x
Prelude.Generic)

-- |
-- Create a value of 'DisableEbsEncryptionByDefaultResponse' 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', 'disableEbsEncryptionByDefaultResponse_ebsEncryptionByDefault' - The updated status of encryption by default.
--
-- 'httpStatus', 'disableEbsEncryptionByDefaultResponse_httpStatus' - The response's http status code.
newDisableEbsEncryptionByDefaultResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisableEbsEncryptionByDefaultResponse
newDisableEbsEncryptionByDefaultResponse :: Int -> DisableEbsEncryptionByDefaultResponse
newDisableEbsEncryptionByDefaultResponse Int
pHttpStatus_ =
  DisableEbsEncryptionByDefaultResponse'
    { $sel:ebsEncryptionByDefault:DisableEbsEncryptionByDefaultResponse' :: Maybe Bool
ebsEncryptionByDefault =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisableEbsEncryptionByDefaultResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The updated status of encryption by default.
disableEbsEncryptionByDefaultResponse_ebsEncryptionByDefault :: Lens.Lens' DisableEbsEncryptionByDefaultResponse (Prelude.Maybe Prelude.Bool)
disableEbsEncryptionByDefaultResponse_ebsEncryptionByDefault :: Lens' DisableEbsEncryptionByDefaultResponse (Maybe Bool)
disableEbsEncryptionByDefaultResponse_ebsEncryptionByDefault = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableEbsEncryptionByDefaultResponse' {Maybe Bool
ebsEncryptionByDefault :: Maybe Bool
$sel:ebsEncryptionByDefault:DisableEbsEncryptionByDefaultResponse' :: DisableEbsEncryptionByDefaultResponse -> Maybe Bool
ebsEncryptionByDefault} -> Maybe Bool
ebsEncryptionByDefault) (\s :: DisableEbsEncryptionByDefaultResponse
s@DisableEbsEncryptionByDefaultResponse' {} Maybe Bool
a -> DisableEbsEncryptionByDefaultResponse
s {$sel:ebsEncryptionByDefault:DisableEbsEncryptionByDefaultResponse' :: Maybe Bool
ebsEncryptionByDefault = Maybe Bool
a} :: DisableEbsEncryptionByDefaultResponse)

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

instance
  Prelude.NFData
    DisableEbsEncryptionByDefaultResponse
  where
  rnf :: DisableEbsEncryptionByDefaultResponse -> ()
rnf DisableEbsEncryptionByDefaultResponse' {Int
Maybe Bool
httpStatus :: Int
ebsEncryptionByDefault :: Maybe Bool
$sel:httpStatus:DisableEbsEncryptionByDefaultResponse' :: DisableEbsEncryptionByDefaultResponse -> Int
$sel:ebsEncryptionByDefault:DisableEbsEncryptionByDefaultResponse' :: DisableEbsEncryptionByDefaultResponse -> 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