{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.ResolverRuleConfig
-- 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)
module Amazonka.Route53Resolver.Types.ResolverRuleConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Route53Resolver.Types.TargetAddress

-- | In an
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_route53resolver_UpdateResolverRule.html UpdateResolverRule>
-- request, information about the changes that you want to make.
--
-- /See:/ 'newResolverRuleConfig' smart constructor.
data ResolverRuleConfig = ResolverRuleConfig'
  { -- | The ID of the new outbound Resolver endpoint that you want to use to
    -- route DNS queries to the IP addresses that you specify in @TargetIps@.
    ResolverRuleConfig -> Maybe Text
resolverEndpointId :: Prelude.Maybe Prelude.Text,
    -- | For DNS queries that originate in your VPC, the new IP addresses that
    -- you want to route outbound DNS queries to.
    ResolverRuleConfig -> Maybe (NonEmpty TargetAddress)
targetIps :: Prelude.Maybe (Prelude.NonEmpty TargetAddress),
    -- | The new name for the Resolver rule. The name that you specify appears in
    -- the Resolver dashboard in the Route 53 console.
    ResolverRuleConfig -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (ResolverRuleConfig -> ResolverRuleConfig -> Bool
(ResolverRuleConfig -> ResolverRuleConfig -> Bool)
-> (ResolverRuleConfig -> ResolverRuleConfig -> Bool)
-> Eq ResolverRuleConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResolverRuleConfig -> ResolverRuleConfig -> Bool
$c/= :: ResolverRuleConfig -> ResolverRuleConfig -> Bool
== :: ResolverRuleConfig -> ResolverRuleConfig -> Bool
$c== :: ResolverRuleConfig -> ResolverRuleConfig -> Bool
Prelude.Eq, ReadPrec [ResolverRuleConfig]
ReadPrec ResolverRuleConfig
Int -> ReadS ResolverRuleConfig
ReadS [ResolverRuleConfig]
(Int -> ReadS ResolverRuleConfig)
-> ReadS [ResolverRuleConfig]
-> ReadPrec ResolverRuleConfig
-> ReadPrec [ResolverRuleConfig]
-> Read ResolverRuleConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResolverRuleConfig]
$creadListPrec :: ReadPrec [ResolverRuleConfig]
readPrec :: ReadPrec ResolverRuleConfig
$creadPrec :: ReadPrec ResolverRuleConfig
readList :: ReadS [ResolverRuleConfig]
$creadList :: ReadS [ResolverRuleConfig]
readsPrec :: Int -> ReadS ResolverRuleConfig
$creadsPrec :: Int -> ReadS ResolverRuleConfig
Prelude.Read, Int -> ResolverRuleConfig -> ShowS
[ResolverRuleConfig] -> ShowS
ResolverRuleConfig -> String
(Int -> ResolverRuleConfig -> ShowS)
-> (ResolverRuleConfig -> String)
-> ([ResolverRuleConfig] -> ShowS)
-> Show ResolverRuleConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResolverRuleConfig] -> ShowS
$cshowList :: [ResolverRuleConfig] -> ShowS
show :: ResolverRuleConfig -> String
$cshow :: ResolverRuleConfig -> String
showsPrec :: Int -> ResolverRuleConfig -> ShowS
$cshowsPrec :: Int -> ResolverRuleConfig -> ShowS
Prelude.Show, (forall x. ResolverRuleConfig -> Rep ResolverRuleConfig x)
-> (forall x. Rep ResolverRuleConfig x -> ResolverRuleConfig)
-> Generic ResolverRuleConfig
forall x. Rep ResolverRuleConfig x -> ResolverRuleConfig
forall x. ResolverRuleConfig -> Rep ResolverRuleConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResolverRuleConfig x -> ResolverRuleConfig
$cfrom :: forall x. ResolverRuleConfig -> Rep ResolverRuleConfig x
Prelude.Generic)

-- |
-- Create a value of 'ResolverRuleConfig' 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', 'resolverRuleConfig_resolverEndpointId' - The ID of the new outbound Resolver endpoint that you want to use to
-- route DNS queries to the IP addresses that you specify in @TargetIps@.
--
-- 'targetIps', 'resolverRuleConfig_targetIps' - For DNS queries that originate in your VPC, the new IP addresses that
-- you want to route outbound DNS queries to.
--
-- 'name', 'resolverRuleConfig_name' - The new name for the Resolver rule. The name that you specify appears in
-- the Resolver dashboard in the Route 53 console.
newResolverRuleConfig ::
  ResolverRuleConfig
newResolverRuleConfig :: ResolverRuleConfig
newResolverRuleConfig =
  ResolverRuleConfig' :: Maybe Text
-> Maybe (NonEmpty TargetAddress)
-> Maybe Text
-> ResolverRuleConfig
ResolverRuleConfig'
    { $sel:resolverEndpointId:ResolverRuleConfig' :: Maybe Text
resolverEndpointId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetIps:ResolverRuleConfig' :: Maybe (NonEmpty TargetAddress)
targetIps = Maybe (NonEmpty TargetAddress)
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ResolverRuleConfig' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | For DNS queries that originate in your VPC, the new IP addresses that
-- you want to route outbound DNS queries to.
resolverRuleConfig_targetIps :: Lens.Lens' ResolverRuleConfig (Prelude.Maybe (Prelude.NonEmpty TargetAddress))
resolverRuleConfig_targetIps :: (Maybe (NonEmpty TargetAddress)
 -> f (Maybe (NonEmpty TargetAddress)))
-> ResolverRuleConfig -> f ResolverRuleConfig
resolverRuleConfig_targetIps = (ResolverRuleConfig -> Maybe (NonEmpty TargetAddress))
-> (ResolverRuleConfig
    -> Maybe (NonEmpty TargetAddress) -> ResolverRuleConfig)
-> Lens
     ResolverRuleConfig
     ResolverRuleConfig
     (Maybe (NonEmpty TargetAddress))
     (Maybe (NonEmpty TargetAddress))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResolverRuleConfig' {Maybe (NonEmpty TargetAddress)
targetIps :: Maybe (NonEmpty TargetAddress)
$sel:targetIps:ResolverRuleConfig' :: ResolverRuleConfig -> Maybe (NonEmpty TargetAddress)
targetIps} -> Maybe (NonEmpty TargetAddress)
targetIps) (\s :: ResolverRuleConfig
s@ResolverRuleConfig' {} Maybe (NonEmpty TargetAddress)
a -> ResolverRuleConfig
s {$sel:targetIps:ResolverRuleConfig' :: Maybe (NonEmpty TargetAddress)
targetIps = Maybe (NonEmpty TargetAddress)
a} :: ResolverRuleConfig) ((Maybe (NonEmpty TargetAddress)
  -> f (Maybe (NonEmpty TargetAddress)))
 -> ResolverRuleConfig -> f ResolverRuleConfig)
-> ((Maybe (NonEmpty TargetAddress)
     -> f (Maybe (NonEmpty TargetAddress)))
    -> Maybe (NonEmpty TargetAddress)
    -> f (Maybe (NonEmpty TargetAddress)))
-> (Maybe (NonEmpty TargetAddress)
    -> f (Maybe (NonEmpty TargetAddress)))
-> ResolverRuleConfig
-> f ResolverRuleConfig
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

-- | The new name for the Resolver rule. The name that you specify appears in
-- the Resolver dashboard in the Route 53 console.
resolverRuleConfig_name :: Lens.Lens' ResolverRuleConfig (Prelude.Maybe Prelude.Text)
resolverRuleConfig_name :: (Maybe Text -> f (Maybe Text))
-> ResolverRuleConfig -> f ResolverRuleConfig
resolverRuleConfig_name = (ResolverRuleConfig -> Maybe Text)
-> (ResolverRuleConfig -> Maybe Text -> ResolverRuleConfig)
-> Lens
     ResolverRuleConfig ResolverRuleConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResolverRuleConfig' {Maybe Text
name :: Maybe Text
$sel:name:ResolverRuleConfig' :: ResolverRuleConfig -> Maybe Text
name} -> Maybe Text
name) (\s :: ResolverRuleConfig
s@ResolverRuleConfig' {} Maybe Text
a -> ResolverRuleConfig
s {$sel:name:ResolverRuleConfig' :: Maybe Text
name = Maybe Text
a} :: ResolverRuleConfig)

instance Prelude.Hashable ResolverRuleConfig

instance Prelude.NFData ResolverRuleConfig

instance Core.ToJSON ResolverRuleConfig where
  toJSON :: ResolverRuleConfig -> Value
toJSON ResolverRuleConfig' {Maybe (NonEmpty TargetAddress)
Maybe Text
name :: Maybe Text
targetIps :: Maybe (NonEmpty TargetAddress)
resolverEndpointId :: Maybe Text
$sel:name:ResolverRuleConfig' :: ResolverRuleConfig -> Maybe Text
$sel:targetIps:ResolverRuleConfig' :: ResolverRuleConfig -> Maybe (NonEmpty TargetAddress)
$sel:resolverEndpointId:ResolverRuleConfig' :: ResolverRuleConfig -> 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
          ]
      )