{-# 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.UpdateArchiveRule
-- 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)
--
-- Updates the criteria and values for the specified archive rule.
module Amazonka.AccessAnalyzer.UpdateArchiveRule
  ( -- * Creating a Request
    UpdateArchiveRule (..),
    newUpdateArchiveRule,

    -- * Request Lenses
    updateArchiveRule_clientToken,
    updateArchiveRule_analyzerName,
    updateArchiveRule_filter,
    updateArchiveRule_ruleName,

    -- * Destructuring the Response
    UpdateArchiveRuleResponse (..),
    newUpdateArchiveRuleResponse,
  )
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

-- | Updates the specified archive rule.
--
-- /See:/ 'newUpdateArchiveRule' smart constructor.
data UpdateArchiveRule = UpdateArchiveRule'
  { -- | A client token.
    UpdateArchiveRule -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the analyzer to update the archive rules for.
    UpdateArchiveRule -> Text
analyzerName :: Prelude.Text,
    -- | A filter to match for the rules to update. Only rules that match the
    -- filter are updated.
    UpdateArchiveRule -> HashMap Text Criterion
filter' :: Prelude.HashMap Prelude.Text Criterion,
    -- | The name of the rule to update.
    UpdateArchiveRule -> Text
ruleName :: Prelude.Text
  }
  deriving (UpdateArchiveRule -> UpdateArchiveRule -> Bool
(UpdateArchiveRule -> UpdateArchiveRule -> Bool)
-> (UpdateArchiveRule -> UpdateArchiveRule -> Bool)
-> Eq UpdateArchiveRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateArchiveRule -> UpdateArchiveRule -> Bool
$c/= :: UpdateArchiveRule -> UpdateArchiveRule -> Bool
== :: UpdateArchiveRule -> UpdateArchiveRule -> Bool
$c== :: UpdateArchiveRule -> UpdateArchiveRule -> Bool
Prelude.Eq, ReadPrec [UpdateArchiveRule]
ReadPrec UpdateArchiveRule
Int -> ReadS UpdateArchiveRule
ReadS [UpdateArchiveRule]
(Int -> ReadS UpdateArchiveRule)
-> ReadS [UpdateArchiveRule]
-> ReadPrec UpdateArchiveRule
-> ReadPrec [UpdateArchiveRule]
-> Read UpdateArchiveRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateArchiveRule]
$creadListPrec :: ReadPrec [UpdateArchiveRule]
readPrec :: ReadPrec UpdateArchiveRule
$creadPrec :: ReadPrec UpdateArchiveRule
readList :: ReadS [UpdateArchiveRule]
$creadList :: ReadS [UpdateArchiveRule]
readsPrec :: Int -> ReadS UpdateArchiveRule
$creadsPrec :: Int -> ReadS UpdateArchiveRule
Prelude.Read, Int -> UpdateArchiveRule -> ShowS
[UpdateArchiveRule] -> ShowS
UpdateArchiveRule -> String
(Int -> UpdateArchiveRule -> ShowS)
-> (UpdateArchiveRule -> String)
-> ([UpdateArchiveRule] -> ShowS)
-> Show UpdateArchiveRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateArchiveRule] -> ShowS
$cshowList :: [UpdateArchiveRule] -> ShowS
show :: UpdateArchiveRule -> String
$cshow :: UpdateArchiveRule -> String
showsPrec :: Int -> UpdateArchiveRule -> ShowS
$cshowsPrec :: Int -> UpdateArchiveRule -> ShowS
Prelude.Show, (forall x. UpdateArchiveRule -> Rep UpdateArchiveRule x)
-> (forall x. Rep UpdateArchiveRule x -> UpdateArchiveRule)
-> Generic UpdateArchiveRule
forall x. Rep UpdateArchiveRule x -> UpdateArchiveRule
forall x. UpdateArchiveRule -> Rep UpdateArchiveRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateArchiveRule x -> UpdateArchiveRule
$cfrom :: forall x. UpdateArchiveRule -> Rep UpdateArchiveRule x
Prelude.Generic)

-- |
-- Create a value of 'UpdateArchiveRule' 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', 'updateArchiveRule_clientToken' - A client token.
--
-- 'analyzerName', 'updateArchiveRule_analyzerName' - The name of the analyzer to update the archive rules for.
--
-- 'filter'', 'updateArchiveRule_filter' - A filter to match for the rules to update. Only rules that match the
-- filter are updated.
--
-- 'ruleName', 'updateArchiveRule_ruleName' - The name of the rule to update.
newUpdateArchiveRule ::
  -- | 'analyzerName'
  Prelude.Text ->
  -- | 'ruleName'
  Prelude.Text ->
  UpdateArchiveRule
newUpdateArchiveRule :: Text -> Text -> UpdateArchiveRule
newUpdateArchiveRule Text
pAnalyzerName_ Text
pRuleName_ =
  UpdateArchiveRule' :: Maybe Text
-> Text -> HashMap Text Criterion -> Text -> UpdateArchiveRule
UpdateArchiveRule'
    { $sel:clientToken:UpdateArchiveRule' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:analyzerName:UpdateArchiveRule' :: Text
analyzerName = Text
pAnalyzerName_,
      $sel:filter':UpdateArchiveRule' :: HashMap Text Criterion
filter' = HashMap Text Criterion
forall a. Monoid a => a
Prelude.mempty,
      $sel:ruleName:UpdateArchiveRule' :: Text
ruleName = Text
pRuleName_
    }

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

-- | The name of the analyzer to update the archive rules for.
updateArchiveRule_analyzerName :: Lens.Lens' UpdateArchiveRule Prelude.Text
updateArchiveRule_analyzerName :: (Text -> f Text) -> UpdateArchiveRule -> f UpdateArchiveRule
updateArchiveRule_analyzerName = (UpdateArchiveRule -> Text)
-> (UpdateArchiveRule -> Text -> UpdateArchiveRule)
-> Lens UpdateArchiveRule UpdateArchiveRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateArchiveRule' {Text
analyzerName :: Text
$sel:analyzerName:UpdateArchiveRule' :: UpdateArchiveRule -> Text
analyzerName} -> Text
analyzerName) (\s :: UpdateArchiveRule
s@UpdateArchiveRule' {} Text
a -> UpdateArchiveRule
s {$sel:analyzerName:UpdateArchiveRule' :: Text
analyzerName = Text
a} :: UpdateArchiveRule)

-- | A filter to match for the rules to update. Only rules that match the
-- filter are updated.
updateArchiveRule_filter :: Lens.Lens' UpdateArchiveRule (Prelude.HashMap Prelude.Text Criterion)
updateArchiveRule_filter :: (HashMap Text Criterion -> f (HashMap Text Criterion))
-> UpdateArchiveRule -> f UpdateArchiveRule
updateArchiveRule_filter = (UpdateArchiveRule -> HashMap Text Criterion)
-> (UpdateArchiveRule
    -> HashMap Text Criterion -> UpdateArchiveRule)
-> Lens
     UpdateArchiveRule
     UpdateArchiveRule
     (HashMap Text Criterion)
     (HashMap Text Criterion)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateArchiveRule' {HashMap Text Criterion
filter' :: HashMap Text Criterion
$sel:filter':UpdateArchiveRule' :: UpdateArchiveRule -> HashMap Text Criterion
filter'} -> HashMap Text Criterion
filter') (\s :: UpdateArchiveRule
s@UpdateArchiveRule' {} HashMap Text Criterion
a -> UpdateArchiveRule
s {$sel:filter':UpdateArchiveRule' :: HashMap Text Criterion
filter' = HashMap Text Criterion
a} :: UpdateArchiveRule) ((HashMap Text Criterion -> f (HashMap Text Criterion))
 -> UpdateArchiveRule -> f UpdateArchiveRule)
-> ((HashMap Text Criterion -> f (HashMap Text Criterion))
    -> HashMap Text Criterion -> f (HashMap Text Criterion))
-> (HashMap Text Criterion -> f (HashMap Text Criterion))
-> UpdateArchiveRule
-> f UpdateArchiveRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Criterion -> f (HashMap Text Criterion))
-> HashMap Text Criterion -> f (HashMap Text Criterion)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

instance Prelude.Hashable UpdateArchiveRule

instance Prelude.NFData UpdateArchiveRule

instance Core.ToHeaders UpdateArchiveRule where
  toHeaders :: UpdateArchiveRule -> [Header]
toHeaders =
    [Header] -> UpdateArchiveRule -> [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 UpdateArchiveRule where
  toJSON :: UpdateArchiveRule -> Value
toJSON UpdateArchiveRule' {Maybe Text
Text
HashMap Text Criterion
ruleName :: Text
filter' :: HashMap Text Criterion
analyzerName :: Text
clientToken :: Maybe Text
$sel:ruleName:UpdateArchiveRule' :: UpdateArchiveRule -> Text
$sel:filter':UpdateArchiveRule' :: UpdateArchiveRule -> HashMap Text Criterion
$sel:analyzerName:UpdateArchiveRule' :: UpdateArchiveRule -> Text
$sel:clientToken:UpdateArchiveRule' :: UpdateArchiveRule -> 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
"filter" Text -> HashMap Text Criterion -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text Criterion
filter')
          ]
      )

instance Core.ToPath UpdateArchiveRule where
  toPath :: UpdateArchiveRule -> ByteString
toPath UpdateArchiveRule' {Maybe Text
Text
HashMap Text Criterion
ruleName :: Text
filter' :: HashMap Text Criterion
analyzerName :: Text
clientToken :: Maybe Text
$sel:ruleName:UpdateArchiveRule' :: UpdateArchiveRule -> Text
$sel:filter':UpdateArchiveRule' :: UpdateArchiveRule -> HashMap Text Criterion
$sel:analyzerName:UpdateArchiveRule' :: UpdateArchiveRule -> Text
$sel:clientToken:UpdateArchiveRule' :: UpdateArchiveRule -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/analyzer/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
analyzerName,
        ByteString
"/archive-rule/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
ruleName
      ]

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

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

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

instance Prelude.NFData UpdateArchiveRuleResponse