{-# 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.CreateResolverRule
-- 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)
--
-- For DNS queries that originate in your VPCs, specifies which Resolver
-- endpoint the queries pass through, one domain name that you want to
-- forward to your network, and the IP addresses of the DNS resolvers in
-- your network.
module Amazonka.Route53Resolver.CreateResolverRule
  ( -- * Creating a Request
    CreateResolverRule (..),
    newCreateResolverRule,

    -- * Request Lenses
    createResolverRule_resolverEndpointId,
    createResolverRule_targetIps,
    createResolverRule_name,
    createResolverRule_tags,
    createResolverRule_creatorRequestId,
    createResolverRule_ruleType,
    createResolverRule_domainName,

    -- * Destructuring the Response
    CreateResolverRuleResponse (..),
    newCreateResolverRuleResponse,

    -- * Response Lenses
    createResolverRuleResponse_resolverRule,
    createResolverRuleResponse_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.Route53Resolver.Types

-- | /See:/ 'newCreateResolverRule' smart constructor.
data CreateResolverRule = CreateResolverRule'
  { -- | The ID of the outbound Resolver endpoint that you want to use to route
    -- DNS queries to the IP addresses that you specify in @TargetIps@.
    CreateResolverRule -> Maybe Text
resolverEndpointId :: Prelude.Maybe Prelude.Text,
    -- | The IPs that you want Resolver to forward DNS queries to. You can
    -- specify only IPv4 addresses. Separate IP addresses with a space.
    --
    -- @TargetIps@ is available only when the value of @Rule type@ is
    -- @FORWARD@.
    CreateResolverRule -> Maybe (NonEmpty TargetAddress)
targetIps :: Prelude.Maybe (Prelude.NonEmpty TargetAddress),
    -- | A friendly name that lets you easily find a rule in the Resolver
    -- dashboard in the Route 53 console.
    CreateResolverRule -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A list of the tag keys and values that you want to associate with the
    -- endpoint.
    CreateResolverRule -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | A unique string that identifies the request and that allows failed
    -- requests to be retried without the risk of running the operation twice.
    -- @CreatorRequestId@ can be any unique string, for example, a date\/time
    -- stamp.
    CreateResolverRule -> Text
creatorRequestId :: Prelude.Text,
    -- | When you want to forward DNS queries for specified domain name to
    -- resolvers on your network, specify @FORWARD@.
    --
    -- When you have a forwarding rule to forward DNS queries for a domain to
    -- your network and you want Resolver to process queries for a subdomain of
    -- that domain, specify @SYSTEM@.
    --
    -- For example, to forward DNS queries for example.com to resolvers on your
    -- network, you create a rule and specify @FORWARD@ for @RuleType@. To then
    -- have Resolver process queries for apex.example.com, you create a rule
    -- and specify @SYSTEM@ for @RuleType@.
    --
    -- Currently, only Resolver can create rules that have a value of
    -- @RECURSIVE@ for @RuleType@.
    CreateResolverRule -> RuleTypeOption
ruleType :: RuleTypeOption,
    -- | DNS queries for this domain name are forwarded to the IP addresses that
    -- you specify in @TargetIps@. If a query matches multiple Resolver rules
    -- (example.com and www.example.com), outbound DNS queries are routed using
    -- the Resolver rule that contains the most specific domain name
    -- (www.example.com).
    CreateResolverRule -> Text
domainName :: Prelude.Text
  }
  deriving (CreateResolverRule -> CreateResolverRule -> Bool
(CreateResolverRule -> CreateResolverRule -> Bool)
-> (CreateResolverRule -> CreateResolverRule -> Bool)
-> Eq CreateResolverRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateResolverRule -> CreateResolverRule -> Bool
$c/= :: CreateResolverRule -> CreateResolverRule -> Bool
== :: CreateResolverRule -> CreateResolverRule -> Bool
$c== :: CreateResolverRule -> CreateResolverRule -> Bool
Prelude.Eq, ReadPrec [CreateResolverRule]
ReadPrec CreateResolverRule
Int -> ReadS CreateResolverRule
ReadS [CreateResolverRule]
(Int -> ReadS CreateResolverRule)
-> ReadS [CreateResolverRule]
-> ReadPrec CreateResolverRule
-> ReadPrec [CreateResolverRule]
-> Read CreateResolverRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateResolverRule]
$creadListPrec :: ReadPrec [CreateResolverRule]
readPrec :: ReadPrec CreateResolverRule
$creadPrec :: ReadPrec CreateResolverRule
readList :: ReadS [CreateResolverRule]
$creadList :: ReadS [CreateResolverRule]
readsPrec :: Int -> ReadS CreateResolverRule
$creadsPrec :: Int -> ReadS CreateResolverRule
Prelude.Read, Int -> CreateResolverRule -> ShowS
[CreateResolverRule] -> ShowS
CreateResolverRule -> String
(Int -> CreateResolverRule -> ShowS)
-> (CreateResolverRule -> String)
-> ([CreateResolverRule] -> ShowS)
-> Show CreateResolverRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateResolverRule] -> ShowS
$cshowList :: [CreateResolverRule] -> ShowS
show :: CreateResolverRule -> String
$cshow :: CreateResolverRule -> String
showsPrec :: Int -> CreateResolverRule -> ShowS
$cshowsPrec :: Int -> CreateResolverRule -> ShowS
Prelude.Show, (forall x. CreateResolverRule -> Rep CreateResolverRule x)
-> (forall x. Rep CreateResolverRule x -> CreateResolverRule)
-> Generic CreateResolverRule
forall x. Rep CreateResolverRule x -> CreateResolverRule
forall x. CreateResolverRule -> Rep CreateResolverRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateResolverRule x -> CreateResolverRule
$cfrom :: forall x. CreateResolverRule -> Rep CreateResolverRule x
Prelude.Generic)

-- |
-- Create a value of 'CreateResolverRule' 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:
--
-- 'resolverEndpointId', 'createResolverRule_resolverEndpointId' - The ID of the outbound Resolver endpoint that you want to use to route
-- DNS queries to the IP addresses that you specify in @TargetIps@.
--
-- 'targetIps', 'createResolverRule_targetIps' - The IPs that you want Resolver to forward DNS queries to. You can
-- specify only IPv4 addresses. Separate IP addresses with a space.
--
-- @TargetIps@ is available only when the value of @Rule type@ is
-- @FORWARD@.
--
-- 'name', 'createResolverRule_name' - A friendly name that lets you easily find a rule in the Resolver
-- dashboard in the Route 53 console.
--
-- 'tags', 'createResolverRule_tags' - A list of the tag keys and values that you want to associate with the
-- endpoint.
--
-- 'creatorRequestId', 'createResolverRule_creatorRequestId' - A unique string that identifies the request and that allows failed
-- requests to be retried without the risk of running the operation twice.
-- @CreatorRequestId@ can be any unique string, for example, a date\/time
-- stamp.
--
-- 'ruleType', 'createResolverRule_ruleType' - When you want to forward DNS queries for specified domain name to
-- resolvers on your network, specify @FORWARD@.
--
-- When you have a forwarding rule to forward DNS queries for a domain to
-- your network and you want Resolver to process queries for a subdomain of
-- that domain, specify @SYSTEM@.
--
-- For example, to forward DNS queries for example.com to resolvers on your
-- network, you create a rule and specify @FORWARD@ for @RuleType@. To then
-- have Resolver process queries for apex.example.com, you create a rule
-- and specify @SYSTEM@ for @RuleType@.
--
-- Currently, only Resolver can create rules that have a value of
-- @RECURSIVE@ for @RuleType@.
--
-- 'domainName', 'createResolverRule_domainName' - DNS queries for this domain name are forwarded to the IP addresses that
-- you specify in @TargetIps@. If a query matches multiple Resolver rules
-- (example.com and www.example.com), outbound DNS queries are routed using
-- the Resolver rule that contains the most specific domain name
-- (www.example.com).
newCreateResolverRule ::
  -- | 'creatorRequestId'
  Prelude.Text ->
  -- | 'ruleType'
  RuleTypeOption ->
  -- | 'domainName'
  Prelude.Text ->
  CreateResolverRule
newCreateResolverRule :: Text -> RuleTypeOption -> Text -> CreateResolverRule
newCreateResolverRule
  Text
pCreatorRequestId_
  RuleTypeOption
pRuleType_
  Text
pDomainName_ =
    CreateResolverRule' :: Maybe Text
-> Maybe (NonEmpty TargetAddress)
-> Maybe Text
-> Maybe [Tag]
-> Text
-> RuleTypeOption
-> Text
-> CreateResolverRule
CreateResolverRule'
      { $sel:resolverEndpointId:CreateResolverRule' :: Maybe Text
resolverEndpointId =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:targetIps:CreateResolverRule' :: Maybe (NonEmpty TargetAddress)
targetIps = Maybe (NonEmpty TargetAddress)
forall a. Maybe a
Prelude.Nothing,
        $sel:name:CreateResolverRule' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateResolverRule' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
        $sel:creatorRequestId:CreateResolverRule' :: Text
creatorRequestId = Text
pCreatorRequestId_,
        $sel:ruleType:CreateResolverRule' :: RuleTypeOption
ruleType = RuleTypeOption
pRuleType_,
        $sel:domainName:CreateResolverRule' :: Text
domainName = Text
pDomainName_
      }

-- | The ID of the outbound Resolver endpoint that you want to use to route
-- DNS queries to the IP addresses that you specify in @TargetIps@.
createResolverRule_resolverEndpointId :: Lens.Lens' CreateResolverRule (Prelude.Maybe Prelude.Text)
createResolverRule_resolverEndpointId :: (Maybe Text -> f (Maybe Text))
-> CreateResolverRule -> f CreateResolverRule
createResolverRule_resolverEndpointId = (CreateResolverRule -> Maybe Text)
-> (CreateResolverRule -> Maybe Text -> CreateResolverRule)
-> Lens
     CreateResolverRule CreateResolverRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolverRule' {Maybe Text
resolverEndpointId :: Maybe Text
$sel:resolverEndpointId:CreateResolverRule' :: CreateResolverRule -> Maybe Text
resolverEndpointId} -> Maybe Text
resolverEndpointId) (\s :: CreateResolverRule
s@CreateResolverRule' {} Maybe Text
a -> CreateResolverRule
s {$sel:resolverEndpointId:CreateResolverRule' :: Maybe Text
resolverEndpointId = Maybe Text
a} :: CreateResolverRule)

-- | The IPs that you want Resolver to forward DNS queries to. You can
-- specify only IPv4 addresses. Separate IP addresses with a space.
--
-- @TargetIps@ is available only when the value of @Rule type@ is
-- @FORWARD@.
createResolverRule_targetIps :: Lens.Lens' CreateResolverRule (Prelude.Maybe (Prelude.NonEmpty TargetAddress))
createResolverRule_targetIps :: (Maybe (NonEmpty TargetAddress)
 -> f (Maybe (NonEmpty TargetAddress)))
-> CreateResolverRule -> f CreateResolverRule
createResolverRule_targetIps = (CreateResolverRule -> Maybe (NonEmpty TargetAddress))
-> (CreateResolverRule
    -> Maybe (NonEmpty TargetAddress) -> CreateResolverRule)
-> Lens
     CreateResolverRule
     CreateResolverRule
     (Maybe (NonEmpty TargetAddress))
     (Maybe (NonEmpty TargetAddress))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolverRule' {Maybe (NonEmpty TargetAddress)
targetIps :: Maybe (NonEmpty TargetAddress)
$sel:targetIps:CreateResolverRule' :: CreateResolverRule -> Maybe (NonEmpty TargetAddress)
targetIps} -> Maybe (NonEmpty TargetAddress)
targetIps) (\s :: CreateResolverRule
s@CreateResolverRule' {} Maybe (NonEmpty TargetAddress)
a -> CreateResolverRule
s {$sel:targetIps:CreateResolverRule' :: Maybe (NonEmpty TargetAddress)
targetIps = Maybe (NonEmpty TargetAddress)
a} :: CreateResolverRule) ((Maybe (NonEmpty TargetAddress)
  -> f (Maybe (NonEmpty TargetAddress)))
 -> CreateResolverRule -> f CreateResolverRule)
-> ((Maybe (NonEmpty TargetAddress)
     -> f (Maybe (NonEmpty TargetAddress)))
    -> Maybe (NonEmpty TargetAddress)
    -> f (Maybe (NonEmpty TargetAddress)))
-> (Maybe (NonEmpty TargetAddress)
    -> f (Maybe (NonEmpty TargetAddress)))
-> CreateResolverRule
-> f CreateResolverRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty TargetAddress)
  (NonEmpty TargetAddress)
  (NonEmpty TargetAddress)
  (NonEmpty TargetAddress)
-> Iso
     (Maybe (NonEmpty TargetAddress))
     (Maybe (NonEmpty TargetAddress))
     (Maybe (NonEmpty TargetAddress))
     (Maybe (NonEmpty TargetAddress))
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 TargetAddress)
  (NonEmpty TargetAddress)
  (NonEmpty TargetAddress)
  (NonEmpty TargetAddress)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A friendly name that lets you easily find a rule in the Resolver
-- dashboard in the Route 53 console.
createResolverRule_name :: Lens.Lens' CreateResolverRule (Prelude.Maybe Prelude.Text)
createResolverRule_name :: (Maybe Text -> f (Maybe Text))
-> CreateResolverRule -> f CreateResolverRule
createResolverRule_name = (CreateResolverRule -> Maybe Text)
-> (CreateResolverRule -> Maybe Text -> CreateResolverRule)
-> Lens
     CreateResolverRule CreateResolverRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolverRule' {Maybe Text
name :: Maybe Text
$sel:name:CreateResolverRule' :: CreateResolverRule -> Maybe Text
name} -> Maybe Text
name) (\s :: CreateResolverRule
s@CreateResolverRule' {} Maybe Text
a -> CreateResolverRule
s {$sel:name:CreateResolverRule' :: Maybe Text
name = Maybe Text
a} :: CreateResolverRule)

-- | A list of the tag keys and values that you want to associate with the
-- endpoint.
createResolverRule_tags :: Lens.Lens' CreateResolverRule (Prelude.Maybe [Tag])
createResolverRule_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateResolverRule -> f CreateResolverRule
createResolverRule_tags = (CreateResolverRule -> Maybe [Tag])
-> (CreateResolverRule -> Maybe [Tag] -> CreateResolverRule)
-> Lens
     CreateResolverRule CreateResolverRule (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolverRule' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateResolverRule' :: CreateResolverRule -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateResolverRule
s@CreateResolverRule' {} Maybe [Tag]
a -> CreateResolverRule
s {$sel:tags:CreateResolverRule' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateResolverRule) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateResolverRule -> f CreateResolverRule)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateResolverRule
-> f CreateResolverRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A unique string that identifies the request and that allows failed
-- requests to be retried without the risk of running the operation twice.
-- @CreatorRequestId@ can be any unique string, for example, a date\/time
-- stamp.
createResolverRule_creatorRequestId :: Lens.Lens' CreateResolverRule Prelude.Text
createResolverRule_creatorRequestId :: (Text -> f Text) -> CreateResolverRule -> f CreateResolverRule
createResolverRule_creatorRequestId = (CreateResolverRule -> Text)
-> (CreateResolverRule -> Text -> CreateResolverRule)
-> Lens CreateResolverRule CreateResolverRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolverRule' {Text
creatorRequestId :: Text
$sel:creatorRequestId:CreateResolverRule' :: CreateResolverRule -> Text
creatorRequestId} -> Text
creatorRequestId) (\s :: CreateResolverRule
s@CreateResolverRule' {} Text
a -> CreateResolverRule
s {$sel:creatorRequestId:CreateResolverRule' :: Text
creatorRequestId = Text
a} :: CreateResolverRule)

-- | When you want to forward DNS queries for specified domain name to
-- resolvers on your network, specify @FORWARD@.
--
-- When you have a forwarding rule to forward DNS queries for a domain to
-- your network and you want Resolver to process queries for a subdomain of
-- that domain, specify @SYSTEM@.
--
-- For example, to forward DNS queries for example.com to resolvers on your
-- network, you create a rule and specify @FORWARD@ for @RuleType@. To then
-- have Resolver process queries for apex.example.com, you create a rule
-- and specify @SYSTEM@ for @RuleType@.
--
-- Currently, only Resolver can create rules that have a value of
-- @RECURSIVE@ for @RuleType@.
createResolverRule_ruleType :: Lens.Lens' CreateResolverRule RuleTypeOption
createResolverRule_ruleType :: (RuleTypeOption -> f RuleTypeOption)
-> CreateResolverRule -> f CreateResolverRule
createResolverRule_ruleType = (CreateResolverRule -> RuleTypeOption)
-> (CreateResolverRule -> RuleTypeOption -> CreateResolverRule)
-> Lens
     CreateResolverRule CreateResolverRule RuleTypeOption RuleTypeOption
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolverRule' {RuleTypeOption
ruleType :: RuleTypeOption
$sel:ruleType:CreateResolverRule' :: CreateResolverRule -> RuleTypeOption
ruleType} -> RuleTypeOption
ruleType) (\s :: CreateResolverRule
s@CreateResolverRule' {} RuleTypeOption
a -> CreateResolverRule
s {$sel:ruleType:CreateResolverRule' :: RuleTypeOption
ruleType = RuleTypeOption
a} :: CreateResolverRule)

-- | DNS queries for this domain name are forwarded to the IP addresses that
-- you specify in @TargetIps@. If a query matches multiple Resolver rules
-- (example.com and www.example.com), outbound DNS queries are routed using
-- the Resolver rule that contains the most specific domain name
-- (www.example.com).
createResolverRule_domainName :: Lens.Lens' CreateResolverRule Prelude.Text
createResolverRule_domainName :: (Text -> f Text) -> CreateResolverRule -> f CreateResolverRule
createResolverRule_domainName = (CreateResolverRule -> Text)
-> (CreateResolverRule -> Text -> CreateResolverRule)
-> Lens CreateResolverRule CreateResolverRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolverRule' {Text
domainName :: Text
$sel:domainName:CreateResolverRule' :: CreateResolverRule -> Text
domainName} -> Text
domainName) (\s :: CreateResolverRule
s@CreateResolverRule' {} Text
a -> CreateResolverRule
s {$sel:domainName:CreateResolverRule' :: Text
domainName = Text
a} :: CreateResolverRule)

instance Core.AWSRequest CreateResolverRule where
  type
    AWSResponse CreateResolverRule =
      CreateResolverRuleResponse
  request :: CreateResolverRule -> Request CreateResolverRule
request = Service -> CreateResolverRule -> Request CreateResolverRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateResolverRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateResolverRule)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateResolverRule))
-> Logger
-> Service
-> Proxy CreateResolverRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateResolverRule)))
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 ResolverRule -> Int -> CreateResolverRuleResponse
CreateResolverRuleResponse'
            (Maybe ResolverRule -> Int -> CreateResolverRuleResponse)
-> Either String (Maybe ResolverRule)
-> Either String (Int -> CreateResolverRuleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ResolverRule)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ResolverRule")
            Either String (Int -> CreateResolverRuleResponse)
-> Either String Int -> Either String CreateResolverRuleResponse
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 CreateResolverRule

instance Prelude.NFData CreateResolverRule

instance Core.ToHeaders CreateResolverRule where
  toHeaders :: CreateResolverRule -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateResolverRule -> 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
"Route53Resolver.CreateResolverRule" ::
                          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 CreateResolverRule where
  toJSON :: CreateResolverRule -> Value
toJSON CreateResolverRule' {Maybe [Tag]
Maybe (NonEmpty TargetAddress)
Maybe Text
Text
RuleTypeOption
domainName :: Text
ruleType :: RuleTypeOption
creatorRequestId :: Text
tags :: Maybe [Tag]
name :: Maybe Text
targetIps :: Maybe (NonEmpty TargetAddress)
resolverEndpointId :: Maybe Text
$sel:domainName:CreateResolverRule' :: CreateResolverRule -> Text
$sel:ruleType:CreateResolverRule' :: CreateResolverRule -> RuleTypeOption
$sel:creatorRequestId:CreateResolverRule' :: CreateResolverRule -> Text
$sel:tags:CreateResolverRule' :: CreateResolverRule -> Maybe [Tag]
$sel:name:CreateResolverRule' :: CreateResolverRule -> Maybe Text
$sel:targetIps:CreateResolverRule' :: CreateResolverRule -> Maybe (NonEmpty TargetAddress)
$sel:resolverEndpointId:CreateResolverRule' :: CreateResolverRule -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ResolverEndpointId" 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
resolverEndpointId,
            (Text
"TargetIps" Text -> NonEmpty TargetAddress -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty TargetAddress -> Pair)
-> Maybe (NonEmpty TargetAddress) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty TargetAddress)
targetIps,
            (Text
"Name" 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
name,
            (Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"CreatorRequestId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
creatorRequestId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RuleType" Text -> RuleTypeOption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RuleTypeOption
ruleType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DomainName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
domainName)
          ]
      )

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

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

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

-- |
-- Create a value of 'CreateResolverRuleResponse' 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:
--
-- 'resolverRule', 'createResolverRuleResponse_resolverRule' - Information about the @CreateResolverRule@ request, including the status
-- of the request.
--
-- 'httpStatus', 'createResolverRuleResponse_httpStatus' - The response's http status code.
newCreateResolverRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateResolverRuleResponse
newCreateResolverRuleResponse :: Int -> CreateResolverRuleResponse
newCreateResolverRuleResponse Int
pHttpStatus_ =
  CreateResolverRuleResponse' :: Maybe ResolverRule -> Int -> CreateResolverRuleResponse
CreateResolverRuleResponse'
    { $sel:resolverRule:CreateResolverRuleResponse' :: Maybe ResolverRule
resolverRule =
        Maybe ResolverRule
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateResolverRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the @CreateResolverRule@ request, including the status
-- of the request.
createResolverRuleResponse_resolverRule :: Lens.Lens' CreateResolverRuleResponse (Prelude.Maybe ResolverRule)
createResolverRuleResponse_resolverRule :: (Maybe ResolverRule -> f (Maybe ResolverRule))
-> CreateResolverRuleResponse -> f CreateResolverRuleResponse
createResolverRuleResponse_resolverRule = (CreateResolverRuleResponse -> Maybe ResolverRule)
-> (CreateResolverRuleResponse
    -> Maybe ResolverRule -> CreateResolverRuleResponse)
-> Lens
     CreateResolverRuleResponse
     CreateResolverRuleResponse
     (Maybe ResolverRule)
     (Maybe ResolverRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolverRuleResponse' {Maybe ResolverRule
resolverRule :: Maybe ResolverRule
$sel:resolverRule:CreateResolverRuleResponse' :: CreateResolverRuleResponse -> Maybe ResolverRule
resolverRule} -> Maybe ResolverRule
resolverRule) (\s :: CreateResolverRuleResponse
s@CreateResolverRuleResponse' {} Maybe ResolverRule
a -> CreateResolverRuleResponse
s {$sel:resolverRule:CreateResolverRuleResponse' :: Maybe ResolverRule
resolverRule = Maybe ResolverRule
a} :: CreateResolverRuleResponse)

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

instance Prelude.NFData CreateResolverRuleResponse