{-# 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.Route53Resolver.PutFirewallRuleGroupPolicy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Attaches an Identity and Access Management (Amazon Web Services IAM)
-- policy for sharing the rule group. You can use the policy to share the
-- rule group using Resource Access Manager (RAM).
module Amazonka.Route53Resolver.PutFirewallRuleGroupPolicy
  ( -- * Creating a Request
    PutFirewallRuleGroupPolicy (..),
    newPutFirewallRuleGroupPolicy,

    -- * Request Lenses
    putFirewallRuleGroupPolicy_arn,
    putFirewallRuleGroupPolicy_firewallRuleGroupPolicy,

    -- * Destructuring the Response
    PutFirewallRuleGroupPolicyResponse (..),
    newPutFirewallRuleGroupPolicyResponse,

    -- * Response Lenses
    putFirewallRuleGroupPolicyResponse_returnValue,
    putFirewallRuleGroupPolicyResponse_httpStatus,
  )
where

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
import Amazonka.Route53Resolver.Types

-- | /See:/ 'newPutFirewallRuleGroupPolicy' smart constructor.
data PutFirewallRuleGroupPolicy = PutFirewallRuleGroupPolicy'
  { -- | The ARN (Amazon Resource Name) for the rule group that you want to
    -- share.
    PutFirewallRuleGroupPolicy -> Text
arn :: Prelude.Text,
    -- | The Identity and Access Management (Amazon Web Services IAM) policy to
    -- attach to the rule group.
    PutFirewallRuleGroupPolicy -> Text
firewallRuleGroupPolicy :: Prelude.Text
  }
  deriving (PutFirewallRuleGroupPolicy -> PutFirewallRuleGroupPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutFirewallRuleGroupPolicy -> PutFirewallRuleGroupPolicy -> Bool
$c/= :: PutFirewallRuleGroupPolicy -> PutFirewallRuleGroupPolicy -> Bool
== :: PutFirewallRuleGroupPolicy -> PutFirewallRuleGroupPolicy -> Bool
$c== :: PutFirewallRuleGroupPolicy -> PutFirewallRuleGroupPolicy -> Bool
Prelude.Eq, ReadPrec [PutFirewallRuleGroupPolicy]
ReadPrec PutFirewallRuleGroupPolicy
Int -> ReadS PutFirewallRuleGroupPolicy
ReadS [PutFirewallRuleGroupPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutFirewallRuleGroupPolicy]
$creadListPrec :: ReadPrec [PutFirewallRuleGroupPolicy]
readPrec :: ReadPrec PutFirewallRuleGroupPolicy
$creadPrec :: ReadPrec PutFirewallRuleGroupPolicy
readList :: ReadS [PutFirewallRuleGroupPolicy]
$creadList :: ReadS [PutFirewallRuleGroupPolicy]
readsPrec :: Int -> ReadS PutFirewallRuleGroupPolicy
$creadsPrec :: Int -> ReadS PutFirewallRuleGroupPolicy
Prelude.Read, Int -> PutFirewallRuleGroupPolicy -> ShowS
[PutFirewallRuleGroupPolicy] -> ShowS
PutFirewallRuleGroupPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutFirewallRuleGroupPolicy] -> ShowS
$cshowList :: [PutFirewallRuleGroupPolicy] -> ShowS
show :: PutFirewallRuleGroupPolicy -> String
$cshow :: PutFirewallRuleGroupPolicy -> String
showsPrec :: Int -> PutFirewallRuleGroupPolicy -> ShowS
$cshowsPrec :: Int -> PutFirewallRuleGroupPolicy -> ShowS
Prelude.Show, forall x.
Rep PutFirewallRuleGroupPolicy x -> PutFirewallRuleGroupPolicy
forall x.
PutFirewallRuleGroupPolicy -> Rep PutFirewallRuleGroupPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutFirewallRuleGroupPolicy x -> PutFirewallRuleGroupPolicy
$cfrom :: forall x.
PutFirewallRuleGroupPolicy -> Rep PutFirewallRuleGroupPolicy x
Prelude.Generic)

-- |
-- Create a value of 'PutFirewallRuleGroupPolicy' 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:
--
-- 'arn', 'putFirewallRuleGroupPolicy_arn' - The ARN (Amazon Resource Name) for the rule group that you want to
-- share.
--
-- 'firewallRuleGroupPolicy', 'putFirewallRuleGroupPolicy_firewallRuleGroupPolicy' - The Identity and Access Management (Amazon Web Services IAM) policy to
-- attach to the rule group.
newPutFirewallRuleGroupPolicy ::
  -- | 'arn'
  Prelude.Text ->
  -- | 'firewallRuleGroupPolicy'
  Prelude.Text ->
  PutFirewallRuleGroupPolicy
newPutFirewallRuleGroupPolicy :: Text -> Text -> PutFirewallRuleGroupPolicy
newPutFirewallRuleGroupPolicy
  Text
pArn_
  Text
pFirewallRuleGroupPolicy_ =
    PutFirewallRuleGroupPolicy'
      { $sel:arn:PutFirewallRuleGroupPolicy' :: Text
arn = Text
pArn_,
        $sel:firewallRuleGroupPolicy:PutFirewallRuleGroupPolicy' :: Text
firewallRuleGroupPolicy =
          Text
pFirewallRuleGroupPolicy_
      }

-- | The ARN (Amazon Resource Name) for the rule group that you want to
-- share.
putFirewallRuleGroupPolicy_arn :: Lens.Lens' PutFirewallRuleGroupPolicy Prelude.Text
putFirewallRuleGroupPolicy_arn :: Lens' PutFirewallRuleGroupPolicy Text
putFirewallRuleGroupPolicy_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFirewallRuleGroupPolicy' {Text
arn :: Text
$sel:arn:PutFirewallRuleGroupPolicy' :: PutFirewallRuleGroupPolicy -> Text
arn} -> Text
arn) (\s :: PutFirewallRuleGroupPolicy
s@PutFirewallRuleGroupPolicy' {} Text
a -> PutFirewallRuleGroupPolicy
s {$sel:arn:PutFirewallRuleGroupPolicy' :: Text
arn = Text
a} :: PutFirewallRuleGroupPolicy)

-- | The Identity and Access Management (Amazon Web Services IAM) policy to
-- attach to the rule group.
putFirewallRuleGroupPolicy_firewallRuleGroupPolicy :: Lens.Lens' PutFirewallRuleGroupPolicy Prelude.Text
putFirewallRuleGroupPolicy_firewallRuleGroupPolicy :: Lens' PutFirewallRuleGroupPolicy Text
putFirewallRuleGroupPolicy_firewallRuleGroupPolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFirewallRuleGroupPolicy' {Text
firewallRuleGroupPolicy :: Text
$sel:firewallRuleGroupPolicy:PutFirewallRuleGroupPolicy' :: PutFirewallRuleGroupPolicy -> Text
firewallRuleGroupPolicy} -> Text
firewallRuleGroupPolicy) (\s :: PutFirewallRuleGroupPolicy
s@PutFirewallRuleGroupPolicy' {} Text
a -> PutFirewallRuleGroupPolicy
s {$sel:firewallRuleGroupPolicy:PutFirewallRuleGroupPolicy' :: Text
firewallRuleGroupPolicy = Text
a} :: PutFirewallRuleGroupPolicy)

instance Core.AWSRequest PutFirewallRuleGroupPolicy where
  type
    AWSResponse PutFirewallRuleGroupPolicy =
      PutFirewallRuleGroupPolicyResponse
  request :: (Service -> Service)
-> PutFirewallRuleGroupPolicy -> Request PutFirewallRuleGroupPolicy
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PutFirewallRuleGroupPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutFirewallRuleGroupPolicy)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Bool -> Int -> PutFirewallRuleGroupPolicyResponse
PutFirewallRuleGroupPolicyResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ReturnValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable PutFirewallRuleGroupPolicy where
  hashWithSalt :: Int -> PutFirewallRuleGroupPolicy -> Int
hashWithSalt Int
_salt PutFirewallRuleGroupPolicy' {Text
firewallRuleGroupPolicy :: Text
arn :: Text
$sel:firewallRuleGroupPolicy:PutFirewallRuleGroupPolicy' :: PutFirewallRuleGroupPolicy -> Text
$sel:arn:PutFirewallRuleGroupPolicy' :: PutFirewallRuleGroupPolicy -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
firewallRuleGroupPolicy

instance Prelude.NFData PutFirewallRuleGroupPolicy where
  rnf :: PutFirewallRuleGroupPolicy -> ()
rnf PutFirewallRuleGroupPolicy' {Text
firewallRuleGroupPolicy :: Text
arn :: Text
$sel:firewallRuleGroupPolicy:PutFirewallRuleGroupPolicy' :: PutFirewallRuleGroupPolicy -> Text
$sel:arn:PutFirewallRuleGroupPolicy' :: PutFirewallRuleGroupPolicy -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
firewallRuleGroupPolicy

instance Data.ToHeaders PutFirewallRuleGroupPolicy where
  toHeaders :: PutFirewallRuleGroupPolicy -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"Route53Resolver.PutFirewallRuleGroupPolicy" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON PutFirewallRuleGroupPolicy where
  toJSON :: PutFirewallRuleGroupPolicy -> Value
toJSON PutFirewallRuleGroupPolicy' {Text
firewallRuleGroupPolicy :: Text
arn :: Text
$sel:firewallRuleGroupPolicy:PutFirewallRuleGroupPolicy' :: PutFirewallRuleGroupPolicy -> Text
$sel:arn:PutFirewallRuleGroupPolicy' :: PutFirewallRuleGroupPolicy -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Arn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
arn),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"FirewallRuleGroupPolicy"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
firewallRuleGroupPolicy
              )
          ]
      )

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

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

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

-- |
-- Create a value of 'PutFirewallRuleGroupPolicyResponse' 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:
--
-- 'returnValue', 'putFirewallRuleGroupPolicyResponse_returnValue' -
--
-- 'httpStatus', 'putFirewallRuleGroupPolicyResponse_httpStatus' - The response's http status code.
newPutFirewallRuleGroupPolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutFirewallRuleGroupPolicyResponse
newPutFirewallRuleGroupPolicyResponse :: Int -> PutFirewallRuleGroupPolicyResponse
newPutFirewallRuleGroupPolicyResponse Int
pHttpStatus_ =
  PutFirewallRuleGroupPolicyResponse'
    { $sel:returnValue:PutFirewallRuleGroupPolicyResponse' :: Maybe Bool
returnValue =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutFirewallRuleGroupPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

putFirewallRuleGroupPolicyResponse_returnValue :: Lens.Lens' PutFirewallRuleGroupPolicyResponse (Prelude.Maybe Prelude.Bool)
putFirewallRuleGroupPolicyResponse_returnValue :: Lens' PutFirewallRuleGroupPolicyResponse (Maybe Bool)
putFirewallRuleGroupPolicyResponse_returnValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFirewallRuleGroupPolicyResponse' {Maybe Bool
returnValue :: Maybe Bool
$sel:returnValue:PutFirewallRuleGroupPolicyResponse' :: PutFirewallRuleGroupPolicyResponse -> Maybe Bool
returnValue} -> Maybe Bool
returnValue) (\s :: PutFirewallRuleGroupPolicyResponse
s@PutFirewallRuleGroupPolicyResponse' {} Maybe Bool
a -> PutFirewallRuleGroupPolicyResponse
s {$sel:returnValue:PutFirewallRuleGroupPolicyResponse' :: Maybe Bool
returnValue = Maybe Bool
a} :: PutFirewallRuleGroupPolicyResponse)

-- | The response's http status code.
putFirewallRuleGroupPolicyResponse_httpStatus :: Lens.Lens' PutFirewallRuleGroupPolicyResponse Prelude.Int
putFirewallRuleGroupPolicyResponse_httpStatus :: Lens' PutFirewallRuleGroupPolicyResponse Int
putFirewallRuleGroupPolicyResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFirewallRuleGroupPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutFirewallRuleGroupPolicyResponse' :: PutFirewallRuleGroupPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutFirewallRuleGroupPolicyResponse
s@PutFirewallRuleGroupPolicyResponse' {} Int
a -> PutFirewallRuleGroupPolicyResponse
s {$sel:httpStatus:PutFirewallRuleGroupPolicyResponse' :: Int
httpStatus = Int
a} :: PutFirewallRuleGroupPolicyResponse)

instance
  Prelude.NFData
    PutFirewallRuleGroupPolicyResponse
  where
  rnf :: PutFirewallRuleGroupPolicyResponse -> ()
rnf PutFirewallRuleGroupPolicyResponse' {Int
Maybe Bool
httpStatus :: Int
returnValue :: Maybe Bool
$sel:httpStatus:PutFirewallRuleGroupPolicyResponse' :: PutFirewallRuleGroupPolicyResponse -> Int
$sel:returnValue:PutFirewallRuleGroupPolicyResponse' :: PutFirewallRuleGroupPolicyResponse -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
returnValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus