{-# 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.ResetSnapshotAttribute
-- 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 permission settings for the specified snapshot.
--
-- For more information about modifying snapshot permissions, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-modifying-snapshot-permissions.html Share a snapshot>
-- in the /Amazon Elastic Compute Cloud User Guide/.
module Amazonka.EC2.ResetSnapshotAttribute
  ( -- * Creating a Request
    ResetSnapshotAttribute (..),
    newResetSnapshotAttribute,

    -- * Request Lenses
    resetSnapshotAttribute_dryRun,
    resetSnapshotAttribute_attribute,
    resetSnapshotAttribute_snapshotId,

    -- * Destructuring the Response
    ResetSnapshotAttributeResponse (..),
    newResetSnapshotAttributeResponse,
  )
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:/ 'newResetSnapshotAttribute' smart constructor.
data ResetSnapshotAttribute = ResetSnapshotAttribute'
  { -- | 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@.
    ResetSnapshotAttribute -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The attribute to reset. Currently, only the attribute for permission to
    -- create volumes can be reset.
    ResetSnapshotAttribute -> SnapshotAttributeName
attribute :: SnapshotAttributeName,
    -- | The ID of the snapshot.
    ResetSnapshotAttribute -> Text
snapshotId :: Prelude.Text
  }
  deriving (ResetSnapshotAttribute -> ResetSnapshotAttribute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResetSnapshotAttribute -> ResetSnapshotAttribute -> Bool
$c/= :: ResetSnapshotAttribute -> ResetSnapshotAttribute -> Bool
== :: ResetSnapshotAttribute -> ResetSnapshotAttribute -> Bool
$c== :: ResetSnapshotAttribute -> ResetSnapshotAttribute -> Bool
Prelude.Eq, ReadPrec [ResetSnapshotAttribute]
ReadPrec ResetSnapshotAttribute
Int -> ReadS ResetSnapshotAttribute
ReadS [ResetSnapshotAttribute]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResetSnapshotAttribute]
$creadListPrec :: ReadPrec [ResetSnapshotAttribute]
readPrec :: ReadPrec ResetSnapshotAttribute
$creadPrec :: ReadPrec ResetSnapshotAttribute
readList :: ReadS [ResetSnapshotAttribute]
$creadList :: ReadS [ResetSnapshotAttribute]
readsPrec :: Int -> ReadS ResetSnapshotAttribute
$creadsPrec :: Int -> ReadS ResetSnapshotAttribute
Prelude.Read, Int -> ResetSnapshotAttribute -> ShowS
[ResetSnapshotAttribute] -> ShowS
ResetSnapshotAttribute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResetSnapshotAttribute] -> ShowS
$cshowList :: [ResetSnapshotAttribute] -> ShowS
show :: ResetSnapshotAttribute -> String
$cshow :: ResetSnapshotAttribute -> String
showsPrec :: Int -> ResetSnapshotAttribute -> ShowS
$cshowsPrec :: Int -> ResetSnapshotAttribute -> ShowS
Prelude.Show, forall x. Rep ResetSnapshotAttribute x -> ResetSnapshotAttribute
forall x. ResetSnapshotAttribute -> Rep ResetSnapshotAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResetSnapshotAttribute x -> ResetSnapshotAttribute
$cfrom :: forall x. ResetSnapshotAttribute -> Rep ResetSnapshotAttribute x
Prelude.Generic)

-- |
-- Create a value of 'ResetSnapshotAttribute' 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', 'resetSnapshotAttribute_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', 'resetSnapshotAttribute_attribute' - The attribute to reset. Currently, only the attribute for permission to
-- create volumes can be reset.
--
-- 'snapshotId', 'resetSnapshotAttribute_snapshotId' - The ID of the snapshot.
newResetSnapshotAttribute ::
  -- | 'attribute'
  SnapshotAttributeName ->
  -- | 'snapshotId'
  Prelude.Text ->
  ResetSnapshotAttribute
newResetSnapshotAttribute :: SnapshotAttributeName -> Text -> ResetSnapshotAttribute
newResetSnapshotAttribute SnapshotAttributeName
pAttribute_ Text
pSnapshotId_ =
  ResetSnapshotAttribute'
    { $sel:dryRun:ResetSnapshotAttribute' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:attribute:ResetSnapshotAttribute' :: SnapshotAttributeName
attribute = SnapshotAttributeName
pAttribute_,
      $sel:snapshotId:ResetSnapshotAttribute' :: Text
snapshotId = Text
pSnapshotId_
    }

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

-- | The attribute to reset. Currently, only the attribute for permission to
-- create volumes can be reset.
resetSnapshotAttribute_attribute :: Lens.Lens' ResetSnapshotAttribute SnapshotAttributeName
resetSnapshotAttribute_attribute :: Lens' ResetSnapshotAttribute SnapshotAttributeName
resetSnapshotAttribute_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResetSnapshotAttribute' {SnapshotAttributeName
attribute :: SnapshotAttributeName
$sel:attribute:ResetSnapshotAttribute' :: ResetSnapshotAttribute -> SnapshotAttributeName
attribute} -> SnapshotAttributeName
attribute) (\s :: ResetSnapshotAttribute
s@ResetSnapshotAttribute' {} SnapshotAttributeName
a -> ResetSnapshotAttribute
s {$sel:attribute:ResetSnapshotAttribute' :: SnapshotAttributeName
attribute = SnapshotAttributeName
a} :: ResetSnapshotAttribute)

-- | The ID of the snapshot.
resetSnapshotAttribute_snapshotId :: Lens.Lens' ResetSnapshotAttribute Prelude.Text
resetSnapshotAttribute_snapshotId :: Lens' ResetSnapshotAttribute Text
resetSnapshotAttribute_snapshotId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResetSnapshotAttribute' {Text
snapshotId :: Text
$sel:snapshotId:ResetSnapshotAttribute' :: ResetSnapshotAttribute -> Text
snapshotId} -> Text
snapshotId) (\s :: ResetSnapshotAttribute
s@ResetSnapshotAttribute' {} Text
a -> ResetSnapshotAttribute
s {$sel:snapshotId:ResetSnapshotAttribute' :: Text
snapshotId = Text
a} :: ResetSnapshotAttribute)

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

instance Prelude.Hashable ResetSnapshotAttribute where
  hashWithSalt :: Int -> ResetSnapshotAttribute -> Int
hashWithSalt Int
_salt ResetSnapshotAttribute' {Maybe Bool
Text
SnapshotAttributeName
snapshotId :: Text
attribute :: SnapshotAttributeName
dryRun :: Maybe Bool
$sel:snapshotId:ResetSnapshotAttribute' :: ResetSnapshotAttribute -> Text
$sel:attribute:ResetSnapshotAttribute' :: ResetSnapshotAttribute -> SnapshotAttributeName
$sel:dryRun:ResetSnapshotAttribute' :: ResetSnapshotAttribute -> 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` SnapshotAttributeName
attribute
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
snapshotId

instance Prelude.NFData ResetSnapshotAttribute where
  rnf :: ResetSnapshotAttribute -> ()
rnf ResetSnapshotAttribute' {Maybe Bool
Text
SnapshotAttributeName
snapshotId :: Text
attribute :: SnapshotAttributeName
dryRun :: Maybe Bool
$sel:snapshotId:ResetSnapshotAttribute' :: ResetSnapshotAttribute -> Text
$sel:attribute:ResetSnapshotAttribute' :: ResetSnapshotAttribute -> SnapshotAttributeName
$sel:dryRun:ResetSnapshotAttribute' :: ResetSnapshotAttribute -> 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 SnapshotAttributeName
attribute
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
snapshotId

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

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

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

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

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

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