{-# 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.DirectoryService.Types.ConditionalForwarder
-- 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.DirectoryService.Types.ConditionalForwarder where

import qualified Amazonka.Core as Core
import Amazonka.DirectoryService.Types.ReplicationScope
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Points to a remote domain with which you are setting up a trust
-- relationship. Conditional forwarders are required in order to set up a
-- trust relationship with another domain.
--
-- /See:/ 'newConditionalForwarder' smart constructor.
data ConditionalForwarder = ConditionalForwarder'
  { -- | The IP addresses of the remote DNS server associated with
    -- RemoteDomainName. This is the IP address of the DNS server that your
    -- conditional forwarder points to.
    ConditionalForwarder -> Maybe [Text]
dnsIpAddrs :: Prelude.Maybe [Prelude.Text],
    -- | The fully qualified domain name (FQDN) of the remote domains pointed to
    -- by the conditional forwarder.
    ConditionalForwarder -> Maybe Text
remoteDomainName :: Prelude.Maybe Prelude.Text,
    -- | The replication scope of the conditional forwarder. The only allowed
    -- value is @Domain@, which will replicate the conditional forwarder to all
    -- of the domain controllers for your Amazon Web Services directory.
    ConditionalForwarder -> Maybe ReplicationScope
replicationScope :: Prelude.Maybe ReplicationScope
  }
  deriving (ConditionalForwarder -> ConditionalForwarder -> Bool
(ConditionalForwarder -> ConditionalForwarder -> Bool)
-> (ConditionalForwarder -> ConditionalForwarder -> Bool)
-> Eq ConditionalForwarder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConditionalForwarder -> ConditionalForwarder -> Bool
$c/= :: ConditionalForwarder -> ConditionalForwarder -> Bool
== :: ConditionalForwarder -> ConditionalForwarder -> Bool
$c== :: ConditionalForwarder -> ConditionalForwarder -> Bool
Prelude.Eq, ReadPrec [ConditionalForwarder]
ReadPrec ConditionalForwarder
Int -> ReadS ConditionalForwarder
ReadS [ConditionalForwarder]
(Int -> ReadS ConditionalForwarder)
-> ReadS [ConditionalForwarder]
-> ReadPrec ConditionalForwarder
-> ReadPrec [ConditionalForwarder]
-> Read ConditionalForwarder
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConditionalForwarder]
$creadListPrec :: ReadPrec [ConditionalForwarder]
readPrec :: ReadPrec ConditionalForwarder
$creadPrec :: ReadPrec ConditionalForwarder
readList :: ReadS [ConditionalForwarder]
$creadList :: ReadS [ConditionalForwarder]
readsPrec :: Int -> ReadS ConditionalForwarder
$creadsPrec :: Int -> ReadS ConditionalForwarder
Prelude.Read, Int -> ConditionalForwarder -> ShowS
[ConditionalForwarder] -> ShowS
ConditionalForwarder -> String
(Int -> ConditionalForwarder -> ShowS)
-> (ConditionalForwarder -> String)
-> ([ConditionalForwarder] -> ShowS)
-> Show ConditionalForwarder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConditionalForwarder] -> ShowS
$cshowList :: [ConditionalForwarder] -> ShowS
show :: ConditionalForwarder -> String
$cshow :: ConditionalForwarder -> String
showsPrec :: Int -> ConditionalForwarder -> ShowS
$cshowsPrec :: Int -> ConditionalForwarder -> ShowS
Prelude.Show, (forall x. ConditionalForwarder -> Rep ConditionalForwarder x)
-> (forall x. Rep ConditionalForwarder x -> ConditionalForwarder)
-> Generic ConditionalForwarder
forall x. Rep ConditionalForwarder x -> ConditionalForwarder
forall x. ConditionalForwarder -> Rep ConditionalForwarder x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConditionalForwarder x -> ConditionalForwarder
$cfrom :: forall x. ConditionalForwarder -> Rep ConditionalForwarder x
Prelude.Generic)

-- |
-- Create a value of 'ConditionalForwarder' 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:
--
-- 'dnsIpAddrs', 'conditionalForwarder_dnsIpAddrs' - The IP addresses of the remote DNS server associated with
-- RemoteDomainName. This is the IP address of the DNS server that your
-- conditional forwarder points to.
--
-- 'remoteDomainName', 'conditionalForwarder_remoteDomainName' - The fully qualified domain name (FQDN) of the remote domains pointed to
-- by the conditional forwarder.
--
-- 'replicationScope', 'conditionalForwarder_replicationScope' - The replication scope of the conditional forwarder. The only allowed
-- value is @Domain@, which will replicate the conditional forwarder to all
-- of the domain controllers for your Amazon Web Services directory.
newConditionalForwarder ::
  ConditionalForwarder
newConditionalForwarder :: ConditionalForwarder
newConditionalForwarder =
  ConditionalForwarder' :: Maybe [Text]
-> Maybe Text -> Maybe ReplicationScope -> ConditionalForwarder
ConditionalForwarder'
    { $sel:dnsIpAddrs:ConditionalForwarder' :: Maybe [Text]
dnsIpAddrs = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:remoteDomainName:ConditionalForwarder' :: Maybe Text
remoteDomainName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:replicationScope:ConditionalForwarder' :: Maybe ReplicationScope
replicationScope = Maybe ReplicationScope
forall a. Maybe a
Prelude.Nothing
    }

-- | The IP addresses of the remote DNS server associated with
-- RemoteDomainName. This is the IP address of the DNS server that your
-- conditional forwarder points to.
conditionalForwarder_dnsIpAddrs :: Lens.Lens' ConditionalForwarder (Prelude.Maybe [Prelude.Text])
conditionalForwarder_dnsIpAddrs :: (Maybe [Text] -> f (Maybe [Text]))
-> ConditionalForwarder -> f ConditionalForwarder
conditionalForwarder_dnsIpAddrs = (ConditionalForwarder -> Maybe [Text])
-> (ConditionalForwarder -> Maybe [Text] -> ConditionalForwarder)
-> Lens
     ConditionalForwarder
     ConditionalForwarder
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConditionalForwarder' {Maybe [Text]
dnsIpAddrs :: Maybe [Text]
$sel:dnsIpAddrs:ConditionalForwarder' :: ConditionalForwarder -> Maybe [Text]
dnsIpAddrs} -> Maybe [Text]
dnsIpAddrs) (\s :: ConditionalForwarder
s@ConditionalForwarder' {} Maybe [Text]
a -> ConditionalForwarder
s {$sel:dnsIpAddrs:ConditionalForwarder' :: Maybe [Text]
dnsIpAddrs = Maybe [Text]
a} :: ConditionalForwarder) ((Maybe [Text] -> f (Maybe [Text]))
 -> ConditionalForwarder -> f ConditionalForwarder)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ConditionalForwarder
-> f ConditionalForwarder
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The fully qualified domain name (FQDN) of the remote domains pointed to
-- by the conditional forwarder.
conditionalForwarder_remoteDomainName :: Lens.Lens' ConditionalForwarder (Prelude.Maybe Prelude.Text)
conditionalForwarder_remoteDomainName :: (Maybe Text -> f (Maybe Text))
-> ConditionalForwarder -> f ConditionalForwarder
conditionalForwarder_remoteDomainName = (ConditionalForwarder -> Maybe Text)
-> (ConditionalForwarder -> Maybe Text -> ConditionalForwarder)
-> Lens
     ConditionalForwarder ConditionalForwarder (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConditionalForwarder' {Maybe Text
remoteDomainName :: Maybe Text
$sel:remoteDomainName:ConditionalForwarder' :: ConditionalForwarder -> Maybe Text
remoteDomainName} -> Maybe Text
remoteDomainName) (\s :: ConditionalForwarder
s@ConditionalForwarder' {} Maybe Text
a -> ConditionalForwarder
s {$sel:remoteDomainName:ConditionalForwarder' :: Maybe Text
remoteDomainName = Maybe Text
a} :: ConditionalForwarder)

-- | The replication scope of the conditional forwarder. The only allowed
-- value is @Domain@, which will replicate the conditional forwarder to all
-- of the domain controllers for your Amazon Web Services directory.
conditionalForwarder_replicationScope :: Lens.Lens' ConditionalForwarder (Prelude.Maybe ReplicationScope)
conditionalForwarder_replicationScope :: (Maybe ReplicationScope -> f (Maybe ReplicationScope))
-> ConditionalForwarder -> f ConditionalForwarder
conditionalForwarder_replicationScope = (ConditionalForwarder -> Maybe ReplicationScope)
-> (ConditionalForwarder
    -> Maybe ReplicationScope -> ConditionalForwarder)
-> Lens
     ConditionalForwarder
     ConditionalForwarder
     (Maybe ReplicationScope)
     (Maybe ReplicationScope)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConditionalForwarder' {Maybe ReplicationScope
replicationScope :: Maybe ReplicationScope
$sel:replicationScope:ConditionalForwarder' :: ConditionalForwarder -> Maybe ReplicationScope
replicationScope} -> Maybe ReplicationScope
replicationScope) (\s :: ConditionalForwarder
s@ConditionalForwarder' {} Maybe ReplicationScope
a -> ConditionalForwarder
s {$sel:replicationScope:ConditionalForwarder' :: Maybe ReplicationScope
replicationScope = Maybe ReplicationScope
a} :: ConditionalForwarder)

instance Core.FromJSON ConditionalForwarder where
  parseJSON :: Value -> Parser ConditionalForwarder
parseJSON =
    String
-> (Object -> Parser ConditionalForwarder)
-> Value
-> Parser ConditionalForwarder
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConditionalForwarder"
      ( \Object
x ->
          Maybe [Text]
-> Maybe Text -> Maybe ReplicationScope -> ConditionalForwarder
ConditionalForwarder'
            (Maybe [Text]
 -> Maybe Text -> Maybe ReplicationScope -> ConditionalForwarder)
-> Parser (Maybe [Text])
-> Parser
     (Maybe Text -> Maybe ReplicationScope -> ConditionalForwarder)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DnsIpAddrs" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text -> Maybe ReplicationScope -> ConditionalForwarder)
-> Parser (Maybe Text)
-> Parser (Maybe ReplicationScope -> ConditionalForwarder)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RemoteDomainName")
            Parser (Maybe ReplicationScope -> ConditionalForwarder)
-> Parser (Maybe ReplicationScope) -> Parser ConditionalForwarder
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ReplicationScope)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ReplicationScope")
      )

instance Prelude.Hashable ConditionalForwarder

instance Prelude.NFData ConditionalForwarder