{-# 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.WAF.CreateRule
-- 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)
--
-- This is __AWS WAF Classic__ documentation. For more information, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/classic-waf-chapter.html AWS WAF Classic>
-- in the developer guide.
--
-- __For the latest version of AWS WAF__, use the AWS WAFV2 API and see the
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html AWS WAF Developer Guide>.
-- With the latest version, AWS WAF has a single set of endpoints for
-- regional and global use.
--
-- Creates a @Rule@, which contains the @IPSet@ objects, @ByteMatchSet@
-- objects, and other predicates that identify the requests that you want
-- to block. If you add more than one predicate to a @Rule@, a request must
-- match all of the specifications to be allowed or blocked. For example,
-- suppose that you add the following to a @Rule@:
--
-- -   An @IPSet@ that matches the IP address @192.0.2.44\/32@
--
-- -   A @ByteMatchSet@ that matches @BadBot@ in the @User-Agent@ header
--
-- You then add the @Rule@ to a @WebACL@ and specify that you want to
-- blocks requests that satisfy the @Rule@. For a request to be blocked, it
-- must come from the IP address 192.0.2.44 /and/ the @User-Agent@ header
-- in the request must contain the value @BadBot@.
--
-- To create and configure a @Rule@, perform the following steps:
--
-- 1.  Create and update the predicates that you want to include in the
--     @Rule@. For more information, see CreateByteMatchSet, CreateIPSet,
--     and CreateSqlInjectionMatchSet.
--
-- 2.  Use GetChangeToken to get the change token that you provide in the
--     @ChangeToken@ parameter of a @CreateRule@ request.
--
-- 3.  Submit a @CreateRule@ request.
--
-- 4.  Use @GetChangeToken@ to get the change token that you provide in the
--     @ChangeToken@ parameter of an UpdateRule request.
--
-- 5.  Submit an @UpdateRule@ request to specify the predicates that you
--     want to include in the @Rule@.
--
-- 6.  Create and update a @WebACL@ that contains the @Rule@. For more
--     information, see CreateWebACL.
--
-- For more information about how to use the AWS WAF API to allow or block
-- HTTP requests, see the
-- <https://docs.aws.amazon.com/waf/latest/developerguide/ AWS WAF Developer Guide>.
module Amazonka.WAF.CreateRule
  ( -- * Creating a Request
    CreateRule (..),
    newCreateRule,

    -- * Request Lenses
    createRule_tags,
    createRule_name,
    createRule_metricName,
    createRule_changeToken,

    -- * Destructuring the Response
    CreateRuleResponse (..),
    newCreateRuleResponse,

    -- * Response Lenses
    createRuleResponse_rule,
    createRuleResponse_changeToken,
    createRuleResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateRule' smart constructor.
data CreateRule = CreateRule'
  { CreateRule -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | A friendly name or description of the Rule. You can\'t change the name
    -- of a @Rule@ after you create it.
    CreateRule -> Text
name :: Prelude.Text,
    -- | A friendly name or description for the metrics for this @Rule@. The name
    -- can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum
    -- length 128 and minimum length one. It can\'t contain whitespace or
    -- metric names reserved for AWS WAF, including \"All\" and
    -- \"Default_Action.\" You can\'t change the name of the metric after you
    -- create the @Rule@.
    CreateRule -> Text
metricName :: Prelude.Text,
    -- | The value returned by the most recent call to GetChangeToken.
    CreateRule -> Text
changeToken :: Prelude.Text
  }
  deriving (CreateRule -> CreateRule -> Bool
(CreateRule -> CreateRule -> Bool)
-> (CreateRule -> CreateRule -> Bool) -> Eq CreateRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRule -> CreateRule -> Bool
$c/= :: CreateRule -> CreateRule -> Bool
== :: CreateRule -> CreateRule -> Bool
$c== :: CreateRule -> CreateRule -> Bool
Prelude.Eq, ReadPrec [CreateRule]
ReadPrec CreateRule
Int -> ReadS CreateRule
ReadS [CreateRule]
(Int -> ReadS CreateRule)
-> ReadS [CreateRule]
-> ReadPrec CreateRule
-> ReadPrec [CreateRule]
-> Read CreateRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRule]
$creadListPrec :: ReadPrec [CreateRule]
readPrec :: ReadPrec CreateRule
$creadPrec :: ReadPrec CreateRule
readList :: ReadS [CreateRule]
$creadList :: ReadS [CreateRule]
readsPrec :: Int -> ReadS CreateRule
$creadsPrec :: Int -> ReadS CreateRule
Prelude.Read, Int -> CreateRule -> ShowS
[CreateRule] -> ShowS
CreateRule -> String
(Int -> CreateRule -> ShowS)
-> (CreateRule -> String)
-> ([CreateRule] -> ShowS)
-> Show CreateRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRule] -> ShowS
$cshowList :: [CreateRule] -> ShowS
show :: CreateRule -> String
$cshow :: CreateRule -> String
showsPrec :: Int -> CreateRule -> ShowS
$cshowsPrec :: Int -> CreateRule -> ShowS
Prelude.Show, (forall x. CreateRule -> Rep CreateRule x)
-> (forall x. Rep CreateRule x -> CreateRule) -> Generic CreateRule
forall x. Rep CreateRule x -> CreateRule
forall x. CreateRule -> Rep CreateRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRule x -> CreateRule
$cfrom :: forall x. CreateRule -> Rep CreateRule x
Prelude.Generic)

-- |
-- Create a value of 'CreateRule' 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:
--
-- 'tags', 'createRule_tags' -
--
-- 'name', 'createRule_name' - A friendly name or description of the Rule. You can\'t change the name
-- of a @Rule@ after you create it.
--
-- 'metricName', 'createRule_metricName' - A friendly name or description for the metrics for this @Rule@. The name
-- can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum
-- length 128 and minimum length one. It can\'t contain whitespace or
-- metric names reserved for AWS WAF, including \"All\" and
-- \"Default_Action.\" You can\'t change the name of the metric after you
-- create the @Rule@.
--
-- 'changeToken', 'createRule_changeToken' - The value returned by the most recent call to GetChangeToken.
newCreateRule ::
  -- | 'name'
  Prelude.Text ->
  -- | 'metricName'
  Prelude.Text ->
  -- | 'changeToken'
  Prelude.Text ->
  CreateRule
newCreateRule :: Text -> Text -> Text -> CreateRule
newCreateRule Text
pName_ Text
pMetricName_ Text
pChangeToken_ =
  CreateRule' :: Maybe (NonEmpty Tag) -> Text -> Text -> Text -> CreateRule
CreateRule'
    { $sel:tags:CreateRule' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateRule' :: Text
name = Text
pName_,
      $sel:metricName:CreateRule' :: Text
metricName = Text
pMetricName_,
      $sel:changeToken:CreateRule' :: Text
changeToken = Text
pChangeToken_
    }

-- |
createRule_tags :: Lens.Lens' CreateRule (Prelude.Maybe (Prelude.NonEmpty Tag))
createRule_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateRule -> f CreateRule
createRule_tags = (CreateRule -> Maybe (NonEmpty Tag))
-> (CreateRule -> Maybe (NonEmpty Tag) -> CreateRule)
-> Lens
     CreateRule CreateRule (Maybe (NonEmpty Tag)) (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateRule' :: CreateRule -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateRule
s@CreateRule' {} Maybe (NonEmpty Tag)
a -> CreateRule
s {$sel:tags:CreateRule' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateRule) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> CreateRule -> f CreateRule)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateRule
-> f CreateRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
-> Iso
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A friendly name or description of the Rule. You can\'t change the name
-- of a @Rule@ after you create it.
createRule_name :: Lens.Lens' CreateRule Prelude.Text
createRule_name :: (Text -> f Text) -> CreateRule -> f CreateRule
createRule_name = (CreateRule -> Text)
-> (CreateRule -> Text -> CreateRule)
-> Lens CreateRule CreateRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Text
name :: Text
$sel:name:CreateRule' :: CreateRule -> Text
name} -> Text
name) (\s :: CreateRule
s@CreateRule' {} Text
a -> CreateRule
s {$sel:name:CreateRule' :: Text
name = Text
a} :: CreateRule)

-- | A friendly name or description for the metrics for this @Rule@. The name
-- can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum
-- length 128 and minimum length one. It can\'t contain whitespace or
-- metric names reserved for AWS WAF, including \"All\" and
-- \"Default_Action.\" You can\'t change the name of the metric after you
-- create the @Rule@.
createRule_metricName :: Lens.Lens' CreateRule Prelude.Text
createRule_metricName :: (Text -> f Text) -> CreateRule -> f CreateRule
createRule_metricName = (CreateRule -> Text)
-> (CreateRule -> Text -> CreateRule)
-> Lens CreateRule CreateRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Text
metricName :: Text
$sel:metricName:CreateRule' :: CreateRule -> Text
metricName} -> Text
metricName) (\s :: CreateRule
s@CreateRule' {} Text
a -> CreateRule
s {$sel:metricName:CreateRule' :: Text
metricName = Text
a} :: CreateRule)

-- | The value returned by the most recent call to GetChangeToken.
createRule_changeToken :: Lens.Lens' CreateRule Prelude.Text
createRule_changeToken :: (Text -> f Text) -> CreateRule -> f CreateRule
createRule_changeToken = (CreateRule -> Text)
-> (CreateRule -> Text -> CreateRule)
-> Lens CreateRule CreateRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Text
changeToken :: Text
$sel:changeToken:CreateRule' :: CreateRule -> Text
changeToken} -> Text
changeToken) (\s :: CreateRule
s@CreateRule' {} Text
a -> CreateRule
s {$sel:changeToken:CreateRule' :: Text
changeToken = Text
a} :: CreateRule)

instance Core.AWSRequest CreateRule where
  type AWSResponse CreateRule = CreateRuleResponse
  request :: CreateRule -> Request CreateRule
request = Service -> CreateRule -> Request CreateRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateRule)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateRule))
-> Logger
-> Service
-> Proxy CreateRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateRule)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Rule -> Maybe Text -> Int -> CreateRuleResponse
CreateRuleResponse'
            (Maybe Rule -> Maybe Text -> Int -> CreateRuleResponse)
-> Either String (Maybe Rule)
-> Either String (Maybe Text -> Int -> CreateRuleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Rule)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Rule")
            Either String (Maybe Text -> Int -> CreateRuleResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateRuleResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ChangeToken")
            Either String (Int -> CreateRuleResponse)
-> Either String Int -> Either String CreateRuleResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateRule

instance Prelude.NFData CreateRule

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

instance Core.ToJSON CreateRule where
  toJSON :: CreateRule -> Value
toJSON CreateRule' {Maybe (NonEmpty Tag)
Text
changeToken :: Text
metricName :: Text
name :: Text
tags :: Maybe (NonEmpty Tag)
$sel:changeToken:CreateRule' :: CreateRule -> Text
$sel:metricName:CreateRule' :: CreateRule -> Text
$sel:name:CreateRule' :: CreateRule -> Text
$sel:tags:CreateRule' :: CreateRule -> Maybe (NonEmpty Tag)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Tags" Text -> NonEmpty Tag -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Tag -> Pair) -> Maybe (NonEmpty Tag) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Tag)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MetricName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
metricName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ChangeToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
changeToken)
          ]
      )

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

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

-- | /See:/ 'newCreateRuleResponse' smart constructor.
data CreateRuleResponse = CreateRuleResponse'
  { -- | The Rule returned in the @CreateRule@ response.
    CreateRuleResponse -> Maybe Rule
rule :: Prelude.Maybe Rule,
    -- | The @ChangeToken@ that you used to submit the @CreateRule@ request. You
    -- can also use this value to query the status of the request. For more
    -- information, see GetChangeTokenStatus.
    CreateRuleResponse -> Maybe Text
changeToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateRuleResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateRuleResponse -> CreateRuleResponse -> Bool
(CreateRuleResponse -> CreateRuleResponse -> Bool)
-> (CreateRuleResponse -> CreateRuleResponse -> Bool)
-> Eq CreateRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRuleResponse -> CreateRuleResponse -> Bool
$c/= :: CreateRuleResponse -> CreateRuleResponse -> Bool
== :: CreateRuleResponse -> CreateRuleResponse -> Bool
$c== :: CreateRuleResponse -> CreateRuleResponse -> Bool
Prelude.Eq, ReadPrec [CreateRuleResponse]
ReadPrec CreateRuleResponse
Int -> ReadS CreateRuleResponse
ReadS [CreateRuleResponse]
(Int -> ReadS CreateRuleResponse)
-> ReadS [CreateRuleResponse]
-> ReadPrec CreateRuleResponse
-> ReadPrec [CreateRuleResponse]
-> Read CreateRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRuleResponse]
$creadListPrec :: ReadPrec [CreateRuleResponse]
readPrec :: ReadPrec CreateRuleResponse
$creadPrec :: ReadPrec CreateRuleResponse
readList :: ReadS [CreateRuleResponse]
$creadList :: ReadS [CreateRuleResponse]
readsPrec :: Int -> ReadS CreateRuleResponse
$creadsPrec :: Int -> ReadS CreateRuleResponse
Prelude.Read, Int -> CreateRuleResponse -> ShowS
[CreateRuleResponse] -> ShowS
CreateRuleResponse -> String
(Int -> CreateRuleResponse -> ShowS)
-> (CreateRuleResponse -> String)
-> ([CreateRuleResponse] -> ShowS)
-> Show CreateRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRuleResponse] -> ShowS
$cshowList :: [CreateRuleResponse] -> ShowS
show :: CreateRuleResponse -> String
$cshow :: CreateRuleResponse -> String
showsPrec :: Int -> CreateRuleResponse -> ShowS
$cshowsPrec :: Int -> CreateRuleResponse -> ShowS
Prelude.Show, (forall x. CreateRuleResponse -> Rep CreateRuleResponse x)
-> (forall x. Rep CreateRuleResponse x -> CreateRuleResponse)
-> Generic CreateRuleResponse
forall x. Rep CreateRuleResponse x -> CreateRuleResponse
forall x. CreateRuleResponse -> Rep CreateRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRuleResponse x -> CreateRuleResponse
$cfrom :: forall x. CreateRuleResponse -> Rep CreateRuleResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateRuleResponse' 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:
--
-- 'rule', 'createRuleResponse_rule' - The Rule returned in the @CreateRule@ response.
--
-- 'changeToken', 'createRuleResponse_changeToken' - The @ChangeToken@ that you used to submit the @CreateRule@ request. You
-- can also use this value to query the status of the request. For more
-- information, see GetChangeTokenStatus.
--
-- 'httpStatus', 'createRuleResponse_httpStatus' - The response's http status code.
newCreateRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateRuleResponse
newCreateRuleResponse :: Int -> CreateRuleResponse
newCreateRuleResponse Int
pHttpStatus_ =
  CreateRuleResponse' :: Maybe Rule -> Maybe Text -> Int -> CreateRuleResponse
CreateRuleResponse'
    { $sel:rule:CreateRuleResponse' :: Maybe Rule
rule = Maybe Rule
forall a. Maybe a
Prelude.Nothing,
      $sel:changeToken:CreateRuleResponse' :: Maybe Text
changeToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Rule returned in the @CreateRule@ response.
createRuleResponse_rule :: Lens.Lens' CreateRuleResponse (Prelude.Maybe Rule)
createRuleResponse_rule :: (Maybe Rule -> f (Maybe Rule))
-> CreateRuleResponse -> f CreateRuleResponse
createRuleResponse_rule = (CreateRuleResponse -> Maybe Rule)
-> (CreateRuleResponse -> Maybe Rule -> CreateRuleResponse)
-> Lens
     CreateRuleResponse CreateRuleResponse (Maybe Rule) (Maybe Rule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleResponse' {Maybe Rule
rule :: Maybe Rule
$sel:rule:CreateRuleResponse' :: CreateRuleResponse -> Maybe Rule
rule} -> Maybe Rule
rule) (\s :: CreateRuleResponse
s@CreateRuleResponse' {} Maybe Rule
a -> CreateRuleResponse
s {$sel:rule:CreateRuleResponse' :: Maybe Rule
rule = Maybe Rule
a} :: CreateRuleResponse)

-- | The @ChangeToken@ that you used to submit the @CreateRule@ request. You
-- can also use this value to query the status of the request. For more
-- information, see GetChangeTokenStatus.
createRuleResponse_changeToken :: Lens.Lens' CreateRuleResponse (Prelude.Maybe Prelude.Text)
createRuleResponse_changeToken :: (Maybe Text -> f (Maybe Text))
-> CreateRuleResponse -> f CreateRuleResponse
createRuleResponse_changeToken = (CreateRuleResponse -> Maybe Text)
-> (CreateRuleResponse -> Maybe Text -> CreateRuleResponse)
-> Lens
     CreateRuleResponse CreateRuleResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleResponse' {Maybe Text
changeToken :: Maybe Text
$sel:changeToken:CreateRuleResponse' :: CreateRuleResponse -> Maybe Text
changeToken} -> Maybe Text
changeToken) (\s :: CreateRuleResponse
s@CreateRuleResponse' {} Maybe Text
a -> CreateRuleResponse
s {$sel:changeToken:CreateRuleResponse' :: Maybe Text
changeToken = Maybe Text
a} :: CreateRuleResponse)

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

instance Prelude.NFData CreateRuleResponse