{-# 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.AccessAnalyzer.ApplyArchiveRule
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retroactively applies the archive rule to existing findings that meet
-- the archive rule criteria.
module Amazonka.AccessAnalyzer.ApplyArchiveRule
  ( -- * Creating a Request
    ApplyArchiveRule (..),
    newApplyArchiveRule,

    -- * Request Lenses
    applyArchiveRule_clientToken,
    applyArchiveRule_analyzerArn,
    applyArchiveRule_ruleName,

    -- * Destructuring the Response
    ApplyArchiveRuleResponse (..),
    newApplyArchiveRuleResponse,
  )
where

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

-- | Retroactively applies an archive rule.
--
-- /See:/ 'newApplyArchiveRule' smart constructor.
data ApplyArchiveRule = ApplyArchiveRule'
  { -- | A client token.
    ApplyArchiveRule -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon resource name (ARN) of the analyzer.
    ApplyArchiveRule -> Text
analyzerArn :: Prelude.Text,
    -- | The name of the rule to apply.
    ApplyArchiveRule -> Text
ruleName :: Prelude.Text
  }
  deriving (ApplyArchiveRule -> ApplyArchiveRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplyArchiveRule -> ApplyArchiveRule -> Bool
$c/= :: ApplyArchiveRule -> ApplyArchiveRule -> Bool
== :: ApplyArchiveRule -> ApplyArchiveRule -> Bool
$c== :: ApplyArchiveRule -> ApplyArchiveRule -> Bool
Prelude.Eq, ReadPrec [ApplyArchiveRule]
ReadPrec ApplyArchiveRule
Int -> ReadS ApplyArchiveRule
ReadS [ApplyArchiveRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApplyArchiveRule]
$creadListPrec :: ReadPrec [ApplyArchiveRule]
readPrec :: ReadPrec ApplyArchiveRule
$creadPrec :: ReadPrec ApplyArchiveRule
readList :: ReadS [ApplyArchiveRule]
$creadList :: ReadS [ApplyArchiveRule]
readsPrec :: Int -> ReadS ApplyArchiveRule
$creadsPrec :: Int -> ReadS ApplyArchiveRule
Prelude.Read, Int -> ApplyArchiveRule -> ShowS
[ApplyArchiveRule] -> ShowS
ApplyArchiveRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplyArchiveRule] -> ShowS
$cshowList :: [ApplyArchiveRule] -> ShowS
show :: ApplyArchiveRule -> String
$cshow :: ApplyArchiveRule -> String
showsPrec :: Int -> ApplyArchiveRule -> ShowS
$cshowsPrec :: Int -> ApplyArchiveRule -> ShowS
Prelude.Show, forall x. Rep ApplyArchiveRule x -> ApplyArchiveRule
forall x. ApplyArchiveRule -> Rep ApplyArchiveRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ApplyArchiveRule x -> ApplyArchiveRule
$cfrom :: forall x. ApplyArchiveRule -> Rep ApplyArchiveRule x
Prelude.Generic)

-- |
-- Create a value of 'ApplyArchiveRule' 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:
--
-- 'clientToken', 'applyArchiveRule_clientToken' - A client token.
--
-- 'analyzerArn', 'applyArchiveRule_analyzerArn' - The Amazon resource name (ARN) of the analyzer.
--
-- 'ruleName', 'applyArchiveRule_ruleName' - The name of the rule to apply.
newApplyArchiveRule ::
  -- | 'analyzerArn'
  Prelude.Text ->
  -- | 'ruleName'
  Prelude.Text ->
  ApplyArchiveRule
newApplyArchiveRule :: Text -> Text -> ApplyArchiveRule
newApplyArchiveRule Text
pAnalyzerArn_ Text
pRuleName_ =
  ApplyArchiveRule'
    { $sel:clientToken:ApplyArchiveRule' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
      $sel:analyzerArn:ApplyArchiveRule' :: Text
analyzerArn = Text
pAnalyzerArn_,
      $sel:ruleName:ApplyArchiveRule' :: Text
ruleName = Text
pRuleName_
    }

-- | A client token.
applyArchiveRule_clientToken :: Lens.Lens' ApplyArchiveRule (Prelude.Maybe Prelude.Text)
applyArchiveRule_clientToken :: Lens' ApplyArchiveRule (Maybe Text)
applyArchiveRule_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplyArchiveRule' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:ApplyArchiveRule' :: ApplyArchiveRule -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: ApplyArchiveRule
s@ApplyArchiveRule' {} Maybe Text
a -> ApplyArchiveRule
s {$sel:clientToken:ApplyArchiveRule' :: Maybe Text
clientToken = Maybe Text
a} :: ApplyArchiveRule)

-- | The Amazon resource name (ARN) of the analyzer.
applyArchiveRule_analyzerArn :: Lens.Lens' ApplyArchiveRule Prelude.Text
applyArchiveRule_analyzerArn :: Lens' ApplyArchiveRule Text
applyArchiveRule_analyzerArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplyArchiveRule' {Text
analyzerArn :: Text
$sel:analyzerArn:ApplyArchiveRule' :: ApplyArchiveRule -> Text
analyzerArn} -> Text
analyzerArn) (\s :: ApplyArchiveRule
s@ApplyArchiveRule' {} Text
a -> ApplyArchiveRule
s {$sel:analyzerArn:ApplyArchiveRule' :: Text
analyzerArn = Text
a} :: ApplyArchiveRule)

-- | The name of the rule to apply.
applyArchiveRule_ruleName :: Lens.Lens' ApplyArchiveRule Prelude.Text
applyArchiveRule_ruleName :: Lens' ApplyArchiveRule Text
applyArchiveRule_ruleName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplyArchiveRule' {Text
ruleName :: Text
$sel:ruleName:ApplyArchiveRule' :: ApplyArchiveRule -> Text
ruleName} -> Text
ruleName) (\s :: ApplyArchiveRule
s@ApplyArchiveRule' {} Text
a -> ApplyArchiveRule
s {$sel:ruleName:ApplyArchiveRule' :: Text
ruleName = Text
a} :: ApplyArchiveRule)

instance Core.AWSRequest ApplyArchiveRule where
  type
    AWSResponse ApplyArchiveRule =
      ApplyArchiveRuleResponse
  request :: (Service -> Service)
-> ApplyArchiveRule -> Request ApplyArchiveRule
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ApplyArchiveRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ApplyArchiveRule)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull ApplyArchiveRuleResponse
ApplyArchiveRuleResponse'

instance Prelude.Hashable ApplyArchiveRule where
  hashWithSalt :: Int -> ApplyArchiveRule -> Int
hashWithSalt Int
_salt ApplyArchiveRule' {Maybe Text
Text
ruleName :: Text
analyzerArn :: Text
clientToken :: Maybe Text
$sel:ruleName:ApplyArchiveRule' :: ApplyArchiveRule -> Text
$sel:analyzerArn:ApplyArchiveRule' :: ApplyArchiveRule -> Text
$sel:clientToken:ApplyArchiveRule' :: ApplyArchiveRule -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
analyzerArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ruleName

instance Prelude.NFData ApplyArchiveRule where
  rnf :: ApplyArchiveRule -> ()
rnf ApplyArchiveRule' {Maybe Text
Text
ruleName :: Text
analyzerArn :: Text
clientToken :: Maybe Text
$sel:ruleName:ApplyArchiveRule' :: ApplyArchiveRule -> Text
$sel:analyzerArn:ApplyArchiveRule' :: ApplyArchiveRule -> Text
$sel:clientToken:ApplyArchiveRule' :: ApplyArchiveRule -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
analyzerArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
ruleName

instance Data.ToHeaders ApplyArchiveRule where
  toHeaders :: ApplyArchiveRule -> [Header]
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 -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON ApplyArchiveRule where
  toJSON :: ApplyArchiveRule -> Value
toJSON ApplyArchiveRule' {Maybe Text
Text
ruleName :: Text
analyzerArn :: Text
clientToken :: Maybe Text
$sel:ruleName:ApplyArchiveRule' :: ApplyArchiveRule -> Text
$sel:analyzerArn:ApplyArchiveRule' :: ApplyArchiveRule -> Text
$sel:clientToken:ApplyArchiveRule' :: ApplyArchiveRule -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"clientToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken,
            forall a. a -> Maybe a
Prelude.Just (Key
"analyzerArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
analyzerArn),
            forall a. a -> Maybe a
Prelude.Just (Key
"ruleName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
ruleName)
          ]
      )

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

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

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

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

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