{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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.Lens as Lens
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
(ApplyArchiveRule -> ApplyArchiveRule -> Bool)
-> (ApplyArchiveRule -> ApplyArchiveRule -> Bool)
-> Eq ApplyArchiveRule
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]
(Int -> ReadS ApplyArchiveRule)
-> ReadS [ApplyArchiveRule]
-> ReadPrec ApplyArchiveRule
-> ReadPrec [ApplyArchiveRule]
-> Read 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
(Int -> ApplyArchiveRule -> ShowS)
-> (ApplyArchiveRule -> String)
-> ([ApplyArchiveRule] -> ShowS)
-> Show ApplyArchiveRule
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. ApplyArchiveRule -> Rep ApplyArchiveRule x)
-> (forall x. Rep ApplyArchiveRule x -> ApplyArchiveRule)
-> Generic ApplyArchiveRule
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' :: Maybe Text -> Text -> Text -> ApplyArchiveRule
ApplyArchiveRule'
    { $sel:clientToken:ApplyArchiveRule' :: Maybe Text
clientToken = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> ApplyArchiveRule -> f ApplyArchiveRule
applyArchiveRule_clientToken = (ApplyArchiveRule -> Maybe Text)
-> (ApplyArchiveRule -> Maybe Text -> ApplyArchiveRule)
-> Lens ApplyArchiveRule ApplyArchiveRule (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> ApplyArchiveRule -> f ApplyArchiveRule
applyArchiveRule_analyzerArn = (ApplyArchiveRule -> Text)
-> (ApplyArchiveRule -> Text -> ApplyArchiveRule)
-> Lens ApplyArchiveRule ApplyArchiveRule Text Text
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 :: (Text -> f Text) -> ApplyArchiveRule -> f ApplyArchiveRule
applyArchiveRule_ruleName = (ApplyArchiveRule -> Text)
-> (ApplyArchiveRule -> Text -> ApplyArchiveRule)
-> Lens ApplyArchiveRule ApplyArchiveRule Text Text
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 :: ApplyArchiveRule -> Request ApplyArchiveRule
request = Service -> ApplyArchiveRule -> Request ApplyArchiveRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ApplyArchiveRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ApplyArchiveRule)))
response =
    AWSResponse ApplyArchiveRule
-> Logger
-> Service
-> Proxy ApplyArchiveRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ApplyArchiveRule)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse ApplyArchiveRule
ApplyArchiveRuleResponse
ApplyArchiveRuleResponse'

instance Prelude.Hashable ApplyArchiveRule

instance Prelude.NFData ApplyArchiveRule

instance Core.ToHeaders ApplyArchiveRule where
  toHeaders :: ApplyArchiveRule -> [Header]
toHeaders =
    [Header] -> ApplyArchiveRule -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"clientToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"analyzerArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
analyzerArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ruleName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
ruleName)
          ]
      )

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

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

-- | /See:/ 'newApplyArchiveRuleResponse' smart constructor.
data ApplyArchiveRuleResponse = ApplyArchiveRuleResponse'
  {
  }
  deriving (ApplyArchiveRuleResponse -> ApplyArchiveRuleResponse -> Bool
(ApplyArchiveRuleResponse -> ApplyArchiveRuleResponse -> Bool)
-> (ApplyArchiveRuleResponse -> ApplyArchiveRuleResponse -> Bool)
-> Eq ApplyArchiveRuleResponse
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]
(Int -> ReadS ApplyArchiveRuleResponse)
-> ReadS [ApplyArchiveRuleResponse]
-> ReadPrec ApplyArchiveRuleResponse
-> ReadPrec [ApplyArchiveRuleResponse]
-> Read 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
(Int -> ApplyArchiveRuleResponse -> ShowS)
-> (ApplyArchiveRuleResponse -> String)
-> ([ApplyArchiveRuleResponse] -> ShowS)
-> Show ApplyArchiveRuleResponse
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.
 ApplyArchiveRuleResponse -> Rep ApplyArchiveRuleResponse x)
-> (forall x.
    Rep ApplyArchiveRuleResponse x -> ApplyArchiveRuleResponse)
-> Generic ApplyArchiveRuleResponse
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