{-# 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.ResetInstanceAttribute
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Resets an attribute of an instance to its default value. To reset the
-- @kernel@ or @ramdisk@, the instance must be in a stopped state. To reset
-- the @sourceDestCheck@, the instance can be either running or stopped.
--
-- The @sourceDestCheck@ attribute controls whether source\/destination
-- checking is enabled. The default value is @true@, which means checking
-- is enabled. This value must be @false@ for a NAT instance to perform
-- NAT. For more information, see
-- <https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_NAT_Instance.html NAT Instances>
-- in the /Amazon VPC User Guide/.
module Amazonka.EC2.ResetInstanceAttribute
  ( -- * Creating a Request
    ResetInstanceAttribute (..),
    newResetInstanceAttribute,

    -- * Request Lenses
    resetInstanceAttribute_dryRun,
    resetInstanceAttribute_attribute,
    resetInstanceAttribute_instanceId,

    -- * Destructuring the Response
    ResetInstanceAttributeResponse (..),
    newResetInstanceAttributeResponse,
  )
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:/ 'newResetInstanceAttribute' smart constructor.
data ResetInstanceAttribute = ResetInstanceAttribute'
  { -- | 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@.
    ResetInstanceAttribute -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The attribute to reset.
    --
    -- You can only reset the following attributes: @kernel@ | @ramdisk@ |
    -- @sourceDestCheck@.
    ResetInstanceAttribute -> InstanceAttributeName
attribute :: InstanceAttributeName,
    -- | The ID of the instance.
    ResetInstanceAttribute -> Text
instanceId :: Prelude.Text
  }
  deriving (ResetInstanceAttribute -> ResetInstanceAttribute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResetInstanceAttribute -> ResetInstanceAttribute -> Bool
$c/= :: ResetInstanceAttribute -> ResetInstanceAttribute -> Bool
== :: ResetInstanceAttribute -> ResetInstanceAttribute -> Bool
$c== :: ResetInstanceAttribute -> ResetInstanceAttribute -> Bool
Prelude.Eq, ReadPrec [ResetInstanceAttribute]
ReadPrec ResetInstanceAttribute
Int -> ReadS ResetInstanceAttribute
ReadS [ResetInstanceAttribute]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResetInstanceAttribute]
$creadListPrec :: ReadPrec [ResetInstanceAttribute]
readPrec :: ReadPrec ResetInstanceAttribute
$creadPrec :: ReadPrec ResetInstanceAttribute
readList :: ReadS [ResetInstanceAttribute]
$creadList :: ReadS [ResetInstanceAttribute]
readsPrec :: Int -> ReadS ResetInstanceAttribute
$creadsPrec :: Int -> ReadS ResetInstanceAttribute
Prelude.Read, Int -> ResetInstanceAttribute -> ShowS
[ResetInstanceAttribute] -> ShowS
ResetInstanceAttribute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResetInstanceAttribute] -> ShowS
$cshowList :: [ResetInstanceAttribute] -> ShowS
show :: ResetInstanceAttribute -> String
$cshow :: ResetInstanceAttribute -> String
showsPrec :: Int -> ResetInstanceAttribute -> ShowS
$cshowsPrec :: Int -> ResetInstanceAttribute -> ShowS
Prelude.Show, forall x. Rep ResetInstanceAttribute x -> ResetInstanceAttribute
forall x. ResetInstanceAttribute -> Rep ResetInstanceAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResetInstanceAttribute x -> ResetInstanceAttribute
$cfrom :: forall x. ResetInstanceAttribute -> Rep ResetInstanceAttribute x
Prelude.Generic)

-- |
-- Create a value of 'ResetInstanceAttribute' 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', 'resetInstanceAttribute_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@.
--
-- 'attribute', 'resetInstanceAttribute_attribute' - The attribute to reset.
--
-- You can only reset the following attributes: @kernel@ | @ramdisk@ |
-- @sourceDestCheck@.
--
-- 'instanceId', 'resetInstanceAttribute_instanceId' - The ID of the instance.
newResetInstanceAttribute ::
  -- | 'attribute'
  InstanceAttributeName ->
  -- | 'instanceId'
  Prelude.Text ->
  ResetInstanceAttribute
newResetInstanceAttribute :: InstanceAttributeName -> Text -> ResetInstanceAttribute
newResetInstanceAttribute InstanceAttributeName
pAttribute_ Text
pInstanceId_ =
  ResetInstanceAttribute'
    { $sel:dryRun:ResetInstanceAttribute' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:attribute:ResetInstanceAttribute' :: InstanceAttributeName
attribute = InstanceAttributeName
pAttribute_,
      $sel:instanceId:ResetInstanceAttribute' :: Text
instanceId = Text
pInstanceId_
    }

-- | 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@.
resetInstanceAttribute_dryRun :: Lens.Lens' ResetInstanceAttribute (Prelude.Maybe Prelude.Bool)
resetInstanceAttribute_dryRun :: Lens' ResetInstanceAttribute (Maybe Bool)
resetInstanceAttribute_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResetInstanceAttribute' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:ResetInstanceAttribute' :: ResetInstanceAttribute -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: ResetInstanceAttribute
s@ResetInstanceAttribute' {} Maybe Bool
a -> ResetInstanceAttribute
s {$sel:dryRun:ResetInstanceAttribute' :: Maybe Bool
dryRun = Maybe Bool
a} :: ResetInstanceAttribute)

-- | The attribute to reset.
--
-- You can only reset the following attributes: @kernel@ | @ramdisk@ |
-- @sourceDestCheck@.
resetInstanceAttribute_attribute :: Lens.Lens' ResetInstanceAttribute InstanceAttributeName
resetInstanceAttribute_attribute :: Lens' ResetInstanceAttribute InstanceAttributeName
resetInstanceAttribute_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResetInstanceAttribute' {InstanceAttributeName
attribute :: InstanceAttributeName
$sel:attribute:ResetInstanceAttribute' :: ResetInstanceAttribute -> InstanceAttributeName
attribute} -> InstanceAttributeName
attribute) (\s :: ResetInstanceAttribute
s@ResetInstanceAttribute' {} InstanceAttributeName
a -> ResetInstanceAttribute
s {$sel:attribute:ResetInstanceAttribute' :: InstanceAttributeName
attribute = InstanceAttributeName
a} :: ResetInstanceAttribute)

-- | The ID of the instance.
resetInstanceAttribute_instanceId :: Lens.Lens' ResetInstanceAttribute Prelude.Text
resetInstanceAttribute_instanceId :: Lens' ResetInstanceAttribute Text
resetInstanceAttribute_instanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResetInstanceAttribute' {Text
instanceId :: Text
$sel:instanceId:ResetInstanceAttribute' :: ResetInstanceAttribute -> Text
instanceId} -> Text
instanceId) (\s :: ResetInstanceAttribute
s@ResetInstanceAttribute' {} Text
a -> ResetInstanceAttribute
s {$sel:instanceId:ResetInstanceAttribute' :: Text
instanceId = Text
a} :: ResetInstanceAttribute)

instance Core.AWSRequest ResetInstanceAttribute where
  type
    AWSResponse ResetInstanceAttribute =
      ResetInstanceAttributeResponse
  request :: (Service -> Service)
-> ResetInstanceAttribute -> Request ResetInstanceAttribute
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 ResetInstanceAttribute
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ResetInstanceAttribute)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      ResetInstanceAttributeResponse
ResetInstanceAttributeResponse'

instance Prelude.Hashable ResetInstanceAttribute where
  hashWithSalt :: Int -> ResetInstanceAttribute -> Int
hashWithSalt Int
_salt ResetInstanceAttribute' {Maybe Bool
Text
InstanceAttributeName
instanceId :: Text
attribute :: InstanceAttributeName
dryRun :: Maybe Bool
$sel:instanceId:ResetInstanceAttribute' :: ResetInstanceAttribute -> Text
$sel:attribute:ResetInstanceAttribute' :: ResetInstanceAttribute -> InstanceAttributeName
$sel:dryRun:ResetInstanceAttribute' :: ResetInstanceAttribute -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
dryRun
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` InstanceAttributeName
attribute
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceId

instance Prelude.NFData ResetInstanceAttribute where
  rnf :: ResetInstanceAttribute -> ()
rnf ResetInstanceAttribute' {Maybe Bool
Text
InstanceAttributeName
instanceId :: Text
attribute :: InstanceAttributeName
dryRun :: Maybe Bool
$sel:instanceId:ResetInstanceAttribute' :: ResetInstanceAttribute -> Text
$sel:attribute:ResetInstanceAttribute' :: ResetInstanceAttribute -> InstanceAttributeName
$sel:dryRun:ResetInstanceAttribute' :: ResetInstanceAttribute -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
dryRun
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf InstanceAttributeName
attribute
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
instanceId

instance Data.ToHeaders ResetInstanceAttribute where
  toHeaders :: ResetInstanceAttribute -> [Header]
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery ResetInstanceAttribute where
  toQuery :: ResetInstanceAttribute -> QueryString
toQuery ResetInstanceAttribute' {Maybe Bool
Text
InstanceAttributeName
instanceId :: Text
attribute :: InstanceAttributeName
dryRun :: Maybe Bool
$sel:instanceId:ResetInstanceAttribute' :: ResetInstanceAttribute -> Text
$sel:attribute:ResetInstanceAttribute' :: ResetInstanceAttribute -> InstanceAttributeName
$sel:dryRun:ResetInstanceAttribute' :: ResetInstanceAttribute -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"ResetInstanceAttribute" :: 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,
        ByteString
"Attribute" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: InstanceAttributeName
attribute,
        ByteString
"InstanceId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
instanceId
      ]

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

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

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