{-# 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-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.Lightsail.Types.ContainerServiceEndpoint where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | An object that describes the health check configuration of the
    -- container.
    ContainerServiceEndpoint -> Maybe ContainerServiceHealthCheckConfig
healthCheck :: Prelude.Maybe ContainerServiceHealthCheckConfig,
    -- | 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
  }
  deriving (ContainerServiceEndpoint -> ContainerServiceEndpoint -> Bool
(ContainerServiceEndpoint -> ContainerServiceEndpoint -> Bool)
-> (ContainerServiceEndpoint -> ContainerServiceEndpoint -> Bool)
-> Eq ContainerServiceEndpoint
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]
(Int -> ReadS ContainerServiceEndpoint)
-> ReadS [ContainerServiceEndpoint]
-> ReadPrec ContainerServiceEndpoint
-> ReadPrec [ContainerServiceEndpoint]
-> Read 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
(Int -> ContainerServiceEndpoint -> ShowS)
-> (ContainerServiceEndpoint -> String)
-> ([ContainerServiceEndpoint] -> ShowS)
-> Show ContainerServiceEndpoint
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.
 ContainerServiceEndpoint -> Rep ContainerServiceEndpoint x)
-> (forall x.
    Rep ContainerServiceEndpoint x -> ContainerServiceEndpoint)
-> Generic ContainerServiceEndpoint
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:
--
-- 'healthCheck', 'containerServiceEndpoint_healthCheck' - An object that describes the health check configuration of the
-- container.
--
-- '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.
newContainerServiceEndpoint ::
  ContainerServiceEndpoint
newContainerServiceEndpoint :: ContainerServiceEndpoint
newContainerServiceEndpoint =
  ContainerServiceEndpoint' :: Maybe ContainerServiceHealthCheckConfig
-> Maybe Text -> Maybe Int -> ContainerServiceEndpoint
ContainerServiceEndpoint'
    { $sel:healthCheck:ContainerServiceEndpoint' :: Maybe ContainerServiceHealthCheckConfig
healthCheck =
        Maybe ContainerServiceHealthCheckConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:containerName:ContainerServiceEndpoint' :: Maybe Text
containerName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:containerPort:ContainerServiceEndpoint' :: Maybe Int
containerPort = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | An object that describes the health check configuration of the
-- container.
containerServiceEndpoint_healthCheck :: Lens.Lens' ContainerServiceEndpoint (Prelude.Maybe ContainerServiceHealthCheckConfig)
containerServiceEndpoint_healthCheck :: (Maybe ContainerServiceHealthCheckConfig
 -> f (Maybe ContainerServiceHealthCheckConfig))
-> ContainerServiceEndpoint -> f ContainerServiceEndpoint
containerServiceEndpoint_healthCheck = (ContainerServiceEndpoint
 -> Maybe ContainerServiceHealthCheckConfig)
-> (ContainerServiceEndpoint
    -> Maybe ContainerServiceHealthCheckConfig
    -> ContainerServiceEndpoint)
-> Lens
     ContainerServiceEndpoint
     ContainerServiceEndpoint
     (Maybe ContainerServiceHealthCheckConfig)
     (Maybe ContainerServiceHealthCheckConfig)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> ContainerServiceEndpoint -> f ContainerServiceEndpoint
containerServiceEndpoint_containerName = (ContainerServiceEndpoint -> Maybe Text)
-> (ContainerServiceEndpoint
    -> Maybe Text -> ContainerServiceEndpoint)
-> Lens
     ContainerServiceEndpoint
     ContainerServiceEndpoint
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe Int -> f (Maybe Int))
-> ContainerServiceEndpoint -> f ContainerServiceEndpoint
containerServiceEndpoint_containerPort = (ContainerServiceEndpoint -> Maybe Int)
-> (ContainerServiceEndpoint
    -> Maybe Int -> ContainerServiceEndpoint)
-> Lens
     ContainerServiceEndpoint
     ContainerServiceEndpoint
     (Maybe Int)
     (Maybe Int)
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)

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

instance Prelude.Hashable ContainerServiceEndpoint

instance Prelude.NFData ContainerServiceEndpoint