{-# 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.DynamoDB.Types.Endpoint
-- 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.DynamoDB.Types.Endpoint where

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

-- | An endpoint information details.
--
-- /See:/ 'newEndpoint' smart constructor.
data Endpoint = Endpoint'
  { -- | IP address of the endpoint.
    Endpoint -> Text
address :: Prelude.Text,
    -- | Endpoint cache time to live (TTL) value.
    Endpoint -> Integer
cachePeriodInMinutes :: Prelude.Integer
  }
  deriving (Endpoint -> Endpoint -> Bool
(Endpoint -> Endpoint -> Bool)
-> (Endpoint -> Endpoint -> Bool) -> Eq Endpoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Endpoint -> Endpoint -> Bool
$c/= :: Endpoint -> Endpoint -> Bool
== :: Endpoint -> Endpoint -> Bool
$c== :: Endpoint -> Endpoint -> Bool
Prelude.Eq, ReadPrec [Endpoint]
ReadPrec Endpoint
Int -> ReadS Endpoint
ReadS [Endpoint]
(Int -> ReadS Endpoint)
-> ReadS [Endpoint]
-> ReadPrec Endpoint
-> ReadPrec [Endpoint]
-> Read Endpoint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Endpoint]
$creadListPrec :: ReadPrec [Endpoint]
readPrec :: ReadPrec Endpoint
$creadPrec :: ReadPrec Endpoint
readList :: ReadS [Endpoint]
$creadList :: ReadS [Endpoint]
readsPrec :: Int -> ReadS Endpoint
$creadsPrec :: Int -> ReadS Endpoint
Prelude.Read, Int -> Endpoint -> ShowS
[Endpoint] -> ShowS
Endpoint -> String
(Int -> Endpoint -> ShowS)
-> (Endpoint -> String) -> ([Endpoint] -> ShowS) -> Show Endpoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Endpoint] -> ShowS
$cshowList :: [Endpoint] -> ShowS
show :: Endpoint -> String
$cshow :: Endpoint -> String
showsPrec :: Int -> Endpoint -> ShowS
$cshowsPrec :: Int -> Endpoint -> ShowS
Prelude.Show, (forall x. Endpoint -> Rep Endpoint x)
-> (forall x. Rep Endpoint x -> Endpoint) -> Generic Endpoint
forall x. Rep Endpoint x -> Endpoint
forall x. Endpoint -> Rep Endpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Endpoint x -> Endpoint
$cfrom :: forall x. Endpoint -> Rep Endpoint x
Prelude.Generic)

-- |
-- Create a value of 'Endpoint' 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:
--
-- 'address', 'endpoint_address' - IP address of the endpoint.
--
-- 'cachePeriodInMinutes', 'endpoint_cachePeriodInMinutes' - Endpoint cache time to live (TTL) value.
newEndpoint ::
  -- | 'address'
  Prelude.Text ->
  -- | 'cachePeriodInMinutes'
  Prelude.Integer ->
  Endpoint
newEndpoint :: Text -> Integer -> Endpoint
newEndpoint Text
pAddress_ Integer
pCachePeriodInMinutes_ =
  Endpoint' :: Text -> Integer -> Endpoint
Endpoint'
    { $sel:address:Endpoint' :: Text
address = Text
pAddress_,
      $sel:cachePeriodInMinutes:Endpoint' :: Integer
cachePeriodInMinutes = Integer
pCachePeriodInMinutes_
    }

-- | IP address of the endpoint.
endpoint_address :: Lens.Lens' Endpoint Prelude.Text
endpoint_address :: (Text -> f Text) -> Endpoint -> f Endpoint
endpoint_address = (Endpoint -> Text)
-> (Endpoint -> Text -> Endpoint)
-> Lens Endpoint Endpoint Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Endpoint' {Text
address :: Text
$sel:address:Endpoint' :: Endpoint -> Text
address} -> Text
address) (\s :: Endpoint
s@Endpoint' {} Text
a -> Endpoint
s {$sel:address:Endpoint' :: Text
address = Text
a} :: Endpoint)

-- | Endpoint cache time to live (TTL) value.
endpoint_cachePeriodInMinutes :: Lens.Lens' Endpoint Prelude.Integer
endpoint_cachePeriodInMinutes :: (Integer -> f Integer) -> Endpoint -> f Endpoint
endpoint_cachePeriodInMinutes = (Endpoint -> Integer)
-> (Endpoint -> Integer -> Endpoint)
-> Lens Endpoint Endpoint Integer Integer
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Endpoint' {Integer
cachePeriodInMinutes :: Integer
$sel:cachePeriodInMinutes:Endpoint' :: Endpoint -> Integer
cachePeriodInMinutes} -> Integer
cachePeriodInMinutes) (\s :: Endpoint
s@Endpoint' {} Integer
a -> Endpoint
s {$sel:cachePeriodInMinutes:Endpoint' :: Integer
cachePeriodInMinutes = Integer
a} :: Endpoint)

instance Core.FromJSON Endpoint where
  parseJSON :: Value -> Parser Endpoint
parseJSON =
    String -> (Object -> Parser Endpoint) -> Value -> Parser Endpoint
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Endpoint"
      ( \Object
x ->
          Text -> Integer -> Endpoint
Endpoint'
            (Text -> Integer -> Endpoint)
-> Parser Text -> Parser (Integer -> Endpoint)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Address")
            Parser (Integer -> Endpoint) -> Parser Integer -> Parser Endpoint
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Integer
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"CachePeriodInMinutes")
      )

instance Prelude.Hashable Endpoint

instance Prelude.NFData Endpoint