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

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

-- | In a
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_route53resolver_CreateResolverEndpoint.html CreateResolverEndpoint>
-- request, the IP address that DNS queries originate from (for outbound
-- endpoints) or that you forward DNS queries to (for inbound endpoints).
-- @IpAddressRequest@ also includes the ID of the subnet that contains the
-- IP address.
--
-- /See:/ 'newIpAddressRequest' smart constructor.
data IpAddressRequest = IpAddressRequest'
  { -- | The IP address that you want to use for DNS queries.
    IpAddressRequest -> Maybe Text
ip :: Prelude.Maybe Prelude.Text,
    -- | The ID of the subnet that contains the IP address.
    IpAddressRequest -> Text
subnetId :: Prelude.Text
  }
  deriving (IpAddressRequest -> IpAddressRequest -> Bool
(IpAddressRequest -> IpAddressRequest -> Bool)
-> (IpAddressRequest -> IpAddressRequest -> Bool)
-> Eq IpAddressRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IpAddressRequest -> IpAddressRequest -> Bool
$c/= :: IpAddressRequest -> IpAddressRequest -> Bool
== :: IpAddressRequest -> IpAddressRequest -> Bool
$c== :: IpAddressRequest -> IpAddressRequest -> Bool
Prelude.Eq, ReadPrec [IpAddressRequest]
ReadPrec IpAddressRequest
Int -> ReadS IpAddressRequest
ReadS [IpAddressRequest]
(Int -> ReadS IpAddressRequest)
-> ReadS [IpAddressRequest]
-> ReadPrec IpAddressRequest
-> ReadPrec [IpAddressRequest]
-> Read IpAddressRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IpAddressRequest]
$creadListPrec :: ReadPrec [IpAddressRequest]
readPrec :: ReadPrec IpAddressRequest
$creadPrec :: ReadPrec IpAddressRequest
readList :: ReadS [IpAddressRequest]
$creadList :: ReadS [IpAddressRequest]
readsPrec :: Int -> ReadS IpAddressRequest
$creadsPrec :: Int -> ReadS IpAddressRequest
Prelude.Read, Int -> IpAddressRequest -> ShowS
[IpAddressRequest] -> ShowS
IpAddressRequest -> String
(Int -> IpAddressRequest -> ShowS)
-> (IpAddressRequest -> String)
-> ([IpAddressRequest] -> ShowS)
-> Show IpAddressRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IpAddressRequest] -> ShowS
$cshowList :: [IpAddressRequest] -> ShowS
show :: IpAddressRequest -> String
$cshow :: IpAddressRequest -> String
showsPrec :: Int -> IpAddressRequest -> ShowS
$cshowsPrec :: Int -> IpAddressRequest -> ShowS
Prelude.Show, (forall x. IpAddressRequest -> Rep IpAddressRequest x)
-> (forall x. Rep IpAddressRequest x -> IpAddressRequest)
-> Generic IpAddressRequest
forall x. Rep IpAddressRequest x -> IpAddressRequest
forall x. IpAddressRequest -> Rep IpAddressRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IpAddressRequest x -> IpAddressRequest
$cfrom :: forall x. IpAddressRequest -> Rep IpAddressRequest x
Prelude.Generic)

-- |
-- Create a value of 'IpAddressRequest' 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:
--
-- 'ip', 'ipAddressRequest_ip' - The IP address that you want to use for DNS queries.
--
-- 'subnetId', 'ipAddressRequest_subnetId' - The ID of the subnet that contains the IP address.
newIpAddressRequest ::
  -- | 'subnetId'
  Prelude.Text ->
  IpAddressRequest
newIpAddressRequest :: Text -> IpAddressRequest
newIpAddressRequest Text
pSubnetId_ =
  IpAddressRequest' :: Maybe Text -> Text -> IpAddressRequest
IpAddressRequest'
    { $sel:ip:IpAddressRequest' :: Maybe Text
ip = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subnetId:IpAddressRequest' :: Text
subnetId = Text
pSubnetId_
    }

-- | The IP address that you want to use for DNS queries.
ipAddressRequest_ip :: Lens.Lens' IpAddressRequest (Prelude.Maybe Prelude.Text)
ipAddressRequest_ip :: (Maybe Text -> f (Maybe Text))
-> IpAddressRequest -> f IpAddressRequest
ipAddressRequest_ip = (IpAddressRequest -> Maybe Text)
-> (IpAddressRequest -> Maybe Text -> IpAddressRequest)
-> Lens IpAddressRequest IpAddressRequest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpAddressRequest' {Maybe Text
ip :: Maybe Text
$sel:ip:IpAddressRequest' :: IpAddressRequest -> Maybe Text
ip} -> Maybe Text
ip) (\s :: IpAddressRequest
s@IpAddressRequest' {} Maybe Text
a -> IpAddressRequest
s {$sel:ip:IpAddressRequest' :: Maybe Text
ip = Maybe Text
a} :: IpAddressRequest)

-- | The ID of the subnet that contains the IP address.
ipAddressRequest_subnetId :: Lens.Lens' IpAddressRequest Prelude.Text
ipAddressRequest_subnetId :: (Text -> f Text) -> IpAddressRequest -> f IpAddressRequest
ipAddressRequest_subnetId = (IpAddressRequest -> Text)
-> (IpAddressRequest -> Text -> IpAddressRequest)
-> Lens IpAddressRequest IpAddressRequest Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpAddressRequest' {Text
subnetId :: Text
$sel:subnetId:IpAddressRequest' :: IpAddressRequest -> Text
subnetId} -> Text
subnetId) (\s :: IpAddressRequest
s@IpAddressRequest' {} Text
a -> IpAddressRequest
s {$sel:subnetId:IpAddressRequest' :: Text
subnetId = Text
a} :: IpAddressRequest)

instance Prelude.Hashable IpAddressRequest

instance Prelude.NFData IpAddressRequest

instance Core.ToJSON IpAddressRequest where
  toJSON :: IpAddressRequest -> Value
toJSON IpAddressRequest' {Maybe Text
Text
subnetId :: Text
ip :: Maybe Text
$sel:subnetId:IpAddressRequest' :: IpAddressRequest -> Text
$sel:ip:IpAddressRequest' :: IpAddressRequest -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Ip" 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
ip,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SubnetId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
subnetId)
          ]
      )