{-# 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.Lightsail.Types.ContainerServiceEndpoint
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Lightsail.Types.ContainerServiceEndpoint where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Lightsail.Types.ContainerServiceHealthCheckConfig
import qualified Amazonka.Prelude as Prelude

-- | Describes the public endpoint configuration of a deployment of an Amazon
-- Lightsail container service.
--
-- /See:/ 'newContainerServiceEndpoint' smart constructor.
data ContainerServiceEndpoint = ContainerServiceEndpoint'
  { -- | The name of the container entry of the deployment that the endpoint
    -- configuration applies to.
    ContainerServiceEndpoint -> Maybe Text
containerName :: Prelude.Maybe Prelude.Text,
    -- | The port of the specified container to which traffic is forwarded to.
    ContainerServiceEndpoint -> Maybe Int
containerPort :: Prelude.Maybe Prelude.Int,
    -- | An object that describes the health check configuration of the
    -- container.
    ContainerServiceEndpoint -> Maybe ContainerServiceHealthCheckConfig
healthCheck :: Prelude.Maybe ContainerServiceHealthCheckConfig
  }
  deriving (ContainerServiceEndpoint -> ContainerServiceEndpoint -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContainerServiceEndpoint -> ContainerServiceEndpoint -> Bool
$c/= :: ContainerServiceEndpoint -> ContainerServiceEndpoint -> Bool
== :: ContainerServiceEndpoint -> ContainerServiceEndpoint -> Bool
$c== :: ContainerServiceEndpoint -> ContainerServiceEndpoint -> Bool
Prelude.Eq, ReadPrec [ContainerServiceEndpoint]
ReadPrec ContainerServiceEndpoint
Int -> ReadS ContainerServiceEndpoint
ReadS [ContainerServiceEndpoint]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContainerServiceEndpoint]
$creadListPrec :: ReadPrec [ContainerServiceEndpoint]
readPrec :: ReadPrec ContainerServiceEndpoint
$creadPrec :: ReadPrec ContainerServiceEndpoint
readList :: ReadS [ContainerServiceEndpoint]
$creadList :: ReadS [ContainerServiceEndpoint]
readsPrec :: Int -> ReadS ContainerServiceEndpoint
$creadsPrec :: Int -> ReadS ContainerServiceEndpoint
Prelude.Read, Int -> ContainerServiceEndpoint -> ShowS
[ContainerServiceEndpoint] -> ShowS
ContainerServiceEndpoint -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContainerServiceEndpoint] -> ShowS
$cshowList :: [ContainerServiceEndpoint] -> ShowS
show :: ContainerServiceEndpoint -> String
$cshow :: ContainerServiceEndpoint -> String
showsPrec :: Int -> ContainerServiceEndpoint -> ShowS
$cshowsPrec :: Int -> ContainerServiceEndpoint -> ShowS
Prelude.Show, forall x.
Rep ContainerServiceEndpoint x -> ContainerServiceEndpoint
forall x.
ContainerServiceEndpoint -> Rep ContainerServiceEndpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ContainerServiceEndpoint x -> ContainerServiceEndpoint
$cfrom :: forall x.
ContainerServiceEndpoint -> Rep ContainerServiceEndpoint x
Prelude.Generic)

-- |
-- Create a value of 'ContainerServiceEndpoint' 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:
--
-- 'containerName', 'containerServiceEndpoint_containerName' - The name of the container entry of the deployment that the endpoint
-- configuration applies to.
--
-- 'containerPort', 'containerServiceEndpoint_containerPort' - The port of the specified container to which traffic is forwarded to.
--
-- 'healthCheck', 'containerServiceEndpoint_healthCheck' - An object that describes the health check configuration of the
-- container.
newContainerServiceEndpoint ::
  ContainerServiceEndpoint
newContainerServiceEndpoint :: ContainerServiceEndpoint
newContainerServiceEndpoint =
  ContainerServiceEndpoint'
    { $sel:containerName:ContainerServiceEndpoint' :: Maybe Text
containerName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:containerPort:ContainerServiceEndpoint' :: Maybe Int
containerPort = forall a. Maybe a
Prelude.Nothing,
      $sel:healthCheck:ContainerServiceEndpoint' :: Maybe ContainerServiceHealthCheckConfig
healthCheck = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the container entry of the deployment that the endpoint
-- configuration applies to.
containerServiceEndpoint_containerName :: Lens.Lens' ContainerServiceEndpoint (Prelude.Maybe Prelude.Text)
containerServiceEndpoint_containerName :: Lens' ContainerServiceEndpoint (Maybe Text)
containerServiceEndpoint_containerName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerServiceEndpoint' {Maybe Text
containerName :: Maybe Text
$sel:containerName:ContainerServiceEndpoint' :: ContainerServiceEndpoint -> Maybe Text
containerName} -> Maybe Text
containerName) (\s :: ContainerServiceEndpoint
s@ContainerServiceEndpoint' {} Maybe Text
a -> ContainerServiceEndpoint
s {$sel:containerName:ContainerServiceEndpoint' :: Maybe Text
containerName = Maybe Text
a} :: ContainerServiceEndpoint)

-- | The port of the specified container to which traffic is forwarded to.
containerServiceEndpoint_containerPort :: Lens.Lens' ContainerServiceEndpoint (Prelude.Maybe Prelude.Int)
containerServiceEndpoint_containerPort :: Lens' ContainerServiceEndpoint (Maybe Int)
containerServiceEndpoint_containerPort = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerServiceEndpoint' {Maybe Int
containerPort :: Maybe Int
$sel:containerPort:ContainerServiceEndpoint' :: ContainerServiceEndpoint -> Maybe Int
containerPort} -> Maybe Int
containerPort) (\s :: ContainerServiceEndpoint
s@ContainerServiceEndpoint' {} Maybe Int
a -> ContainerServiceEndpoint
s {$sel:containerPort:ContainerServiceEndpoint' :: Maybe Int
containerPort = Maybe Int
a} :: ContainerServiceEndpoint)

-- | An object that describes the health check configuration of the
-- container.
containerServiceEndpoint_healthCheck :: Lens.Lens' ContainerServiceEndpoint (Prelude.Maybe ContainerServiceHealthCheckConfig)
containerServiceEndpoint_healthCheck :: Lens'
  ContainerServiceEndpoint (Maybe ContainerServiceHealthCheckConfig)
containerServiceEndpoint_healthCheck = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerServiceEndpoint' {Maybe ContainerServiceHealthCheckConfig
healthCheck :: Maybe ContainerServiceHealthCheckConfig
$sel:healthCheck:ContainerServiceEndpoint' :: ContainerServiceEndpoint -> Maybe ContainerServiceHealthCheckConfig
healthCheck} -> Maybe ContainerServiceHealthCheckConfig
healthCheck) (\s :: ContainerServiceEndpoint
s@ContainerServiceEndpoint' {} Maybe ContainerServiceHealthCheckConfig
a -> ContainerServiceEndpoint
s {$sel:healthCheck:ContainerServiceEndpoint' :: Maybe ContainerServiceHealthCheckConfig
healthCheck = Maybe ContainerServiceHealthCheckConfig
a} :: ContainerServiceEndpoint)

instance Data.FromJSON ContainerServiceEndpoint where
  parseJSON :: Value -> Parser ContainerServiceEndpoint
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ContainerServiceEndpoint"
      ( \Object
x ->
          Maybe Text
-> Maybe Int
-> Maybe ContainerServiceHealthCheckConfig
-> ContainerServiceEndpoint
ContainerServiceEndpoint'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"containerName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"containerPort")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"healthCheck")
      )

instance Prelude.Hashable ContainerServiceEndpoint where
  hashWithSalt :: Int -> ContainerServiceEndpoint -> Int
hashWithSalt Int
_salt ContainerServiceEndpoint' {Maybe Int
Maybe Text
Maybe ContainerServiceHealthCheckConfig
healthCheck :: Maybe ContainerServiceHealthCheckConfig
containerPort :: Maybe Int
containerName :: Maybe Text
$sel:healthCheck:ContainerServiceEndpoint' :: ContainerServiceEndpoint -> Maybe ContainerServiceHealthCheckConfig
$sel:containerPort:ContainerServiceEndpoint' :: ContainerServiceEndpoint -> Maybe Int
$sel:containerName:ContainerServiceEndpoint' :: ContainerServiceEndpoint -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
containerName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
containerPort
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ContainerServiceHealthCheckConfig
healthCheck

instance Prelude.NFData ContainerServiceEndpoint where
  rnf :: ContainerServiceEndpoint -> ()
rnf ContainerServiceEndpoint' {Maybe Int
Maybe Text
Maybe ContainerServiceHealthCheckConfig
healthCheck :: Maybe ContainerServiceHealthCheckConfig
containerPort :: Maybe Int
containerName :: Maybe Text
$sel:healthCheck:ContainerServiceEndpoint' :: ContainerServiceEndpoint -> Maybe ContainerServiceHealthCheckConfig
$sel:containerPort:ContainerServiceEndpoint' :: ContainerServiceEndpoint -> Maybe Int
$sel:containerName:ContainerServiceEndpoint' :: ContainerServiceEndpoint -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
containerName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
containerPort
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ContainerServiceHealthCheckConfig
healthCheck