{-# 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.IpRoute
-- 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.IpRoute where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | IP address block. This is often the address block of the DNS server used
-- for your self-managed domain.
--
-- /See:/ 'newIpRoute' smart constructor.
data IpRoute = IpRoute'
  { -- | IP address block using CIDR format, for example 10.0.0.0\/24. This is
    -- often the address block of the DNS server used for your self-managed
    -- domain. For a single IP address use a CIDR address block with \/32. For
    -- example 10.0.0.0\/32.
    IpRoute -> Maybe Text
cidrIp :: Prelude.Maybe Prelude.Text,
    -- | Description of the address block.
    IpRoute -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (IpRoute -> IpRoute -> Bool
(IpRoute -> IpRoute -> Bool)
-> (IpRoute -> IpRoute -> Bool) -> Eq IpRoute
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IpRoute -> IpRoute -> Bool
$c/= :: IpRoute -> IpRoute -> Bool
== :: IpRoute -> IpRoute -> Bool
$c== :: IpRoute -> IpRoute -> Bool
Prelude.Eq, ReadPrec [IpRoute]
ReadPrec IpRoute
Int -> ReadS IpRoute
ReadS [IpRoute]
(Int -> ReadS IpRoute)
-> ReadS [IpRoute]
-> ReadPrec IpRoute
-> ReadPrec [IpRoute]
-> Read IpRoute
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IpRoute]
$creadListPrec :: ReadPrec [IpRoute]
readPrec :: ReadPrec IpRoute
$creadPrec :: ReadPrec IpRoute
readList :: ReadS [IpRoute]
$creadList :: ReadS [IpRoute]
readsPrec :: Int -> ReadS IpRoute
$creadsPrec :: Int -> ReadS IpRoute
Prelude.Read, Int -> IpRoute -> ShowS
[IpRoute] -> ShowS
IpRoute -> String
(Int -> IpRoute -> ShowS)
-> (IpRoute -> String) -> ([IpRoute] -> ShowS) -> Show IpRoute
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IpRoute] -> ShowS
$cshowList :: [IpRoute] -> ShowS
show :: IpRoute -> String
$cshow :: IpRoute -> String
showsPrec :: Int -> IpRoute -> ShowS
$cshowsPrec :: Int -> IpRoute -> ShowS
Prelude.Show, (forall x. IpRoute -> Rep IpRoute x)
-> (forall x. Rep IpRoute x -> IpRoute) -> Generic IpRoute
forall x. Rep IpRoute x -> IpRoute
forall x. IpRoute -> Rep IpRoute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IpRoute x -> IpRoute
$cfrom :: forall x. IpRoute -> Rep IpRoute x
Prelude.Generic)

-- |
-- Create a value of 'IpRoute' 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:
--
-- 'cidrIp', 'ipRoute_cidrIp' - IP address block using CIDR format, for example 10.0.0.0\/24. This is
-- often the address block of the DNS server used for your self-managed
-- domain. For a single IP address use a CIDR address block with \/32. For
-- example 10.0.0.0\/32.
--
-- 'description', 'ipRoute_description' - Description of the address block.
newIpRoute ::
  IpRoute
newIpRoute :: IpRoute
newIpRoute =
  IpRoute' :: Maybe Text -> Maybe Text -> IpRoute
IpRoute'
    { $sel:cidrIp:IpRoute' :: Maybe Text
cidrIp = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:IpRoute' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | IP address block using CIDR format, for example 10.0.0.0\/24. This is
-- often the address block of the DNS server used for your self-managed
-- domain. For a single IP address use a CIDR address block with \/32. For
-- example 10.0.0.0\/32.
ipRoute_cidrIp :: Lens.Lens' IpRoute (Prelude.Maybe Prelude.Text)
ipRoute_cidrIp :: (Maybe Text -> f (Maybe Text)) -> IpRoute -> f IpRoute
ipRoute_cidrIp = (IpRoute -> Maybe Text)
-> (IpRoute -> Maybe Text -> IpRoute)
-> Lens IpRoute IpRoute (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpRoute' {Maybe Text
cidrIp :: Maybe Text
$sel:cidrIp:IpRoute' :: IpRoute -> Maybe Text
cidrIp} -> Maybe Text
cidrIp) (\s :: IpRoute
s@IpRoute' {} Maybe Text
a -> IpRoute
s {$sel:cidrIp:IpRoute' :: Maybe Text
cidrIp = Maybe Text
a} :: IpRoute)

-- | Description of the address block.
ipRoute_description :: Lens.Lens' IpRoute (Prelude.Maybe Prelude.Text)
ipRoute_description :: (Maybe Text -> f (Maybe Text)) -> IpRoute -> f IpRoute
ipRoute_description = (IpRoute -> Maybe Text)
-> (IpRoute -> Maybe Text -> IpRoute)
-> Lens IpRoute IpRoute (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpRoute' {Maybe Text
description :: Maybe Text
$sel:description:IpRoute' :: IpRoute -> Maybe Text
description} -> Maybe Text
description) (\s :: IpRoute
s@IpRoute' {} Maybe Text
a -> IpRoute
s {$sel:description:IpRoute' :: Maybe Text
description = Maybe Text
a} :: IpRoute)

instance Prelude.Hashable IpRoute

instance Prelude.NFData IpRoute

instance Core.ToJSON IpRoute where
  toJSON :: IpRoute -> Value
toJSON IpRoute' {Maybe Text
description :: Maybe Text
cidrIp :: Maybe Text
$sel:description:IpRoute' :: IpRoute -> Maybe Text
$sel:cidrIp:IpRoute' :: IpRoute -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CidrIp" 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
cidrIp,
            (Text
"Description" 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
description
          ]
      )