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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types.Container
import Amazonka.Lightsail.Types.ContainerServiceDeploymentState
import Amazonka.Lightsail.Types.ContainerServiceEndpoint
import qualified Amazonka.Prelude as Prelude

-- | Describes a container deployment configuration of an Amazon Lightsail
-- container service.
--
-- A deployment specifies the settings, such as the ports and launch
-- command, of containers that are deployed to your container service.
--
-- /See:/ 'newContainerServiceDeployment' smart constructor.
data ContainerServiceDeployment = ContainerServiceDeployment'
  { -- | The state of the deployment.
    --
    -- A deployment can be in one of the following states:
    --
    -- -   @Activating@ - The deployment is being created.
    --
    -- -   @Active@ - The deployment was successfully created, and it\'s
    --     currently running on the container service. The container service
    --     can have only one deployment in an active state at a time.
    --
    -- -   @Inactive@ - The deployment was previously successfully created, but
    --     it is not currently running on the container service.
    --
    -- -   @Failed@ - The deployment failed. Use the @GetContainerLog@ action
    --     to view the log events for the containers in the deployment to try
    --     to determine the reason for the failure.
    ContainerServiceDeployment -> Maybe ContainerServiceDeploymentState
state :: Prelude.Maybe ContainerServiceDeploymentState,
    -- | An object that describes the endpoint of the deployment.
    ContainerServiceDeployment -> Maybe ContainerServiceEndpoint
publicEndpoint :: Prelude.Maybe ContainerServiceEndpoint,
    -- | The timestamp when the deployment was created.
    ContainerServiceDeployment -> Maybe POSIX
createdAt :: Prelude.Maybe Core.POSIX,
    -- | An object that describes the configuration for the containers of the
    -- deployment.
    ContainerServiceDeployment -> Maybe (HashMap Text Container)
containers :: Prelude.Maybe (Prelude.HashMap Prelude.Text Container),
    -- | The version number of the deployment.
    ContainerServiceDeployment -> Maybe Int
version :: Prelude.Maybe Prelude.Int
  }
  deriving (ContainerServiceDeployment -> ContainerServiceDeployment -> Bool
(ContainerServiceDeployment -> ContainerServiceDeployment -> Bool)
-> (ContainerServiceDeployment
    -> ContainerServiceDeployment -> Bool)
-> Eq ContainerServiceDeployment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContainerServiceDeployment -> ContainerServiceDeployment -> Bool
$c/= :: ContainerServiceDeployment -> ContainerServiceDeployment -> Bool
== :: ContainerServiceDeployment -> ContainerServiceDeployment -> Bool
$c== :: ContainerServiceDeployment -> ContainerServiceDeployment -> Bool
Prelude.Eq, ReadPrec [ContainerServiceDeployment]
ReadPrec ContainerServiceDeployment
Int -> ReadS ContainerServiceDeployment
ReadS [ContainerServiceDeployment]
(Int -> ReadS ContainerServiceDeployment)
-> ReadS [ContainerServiceDeployment]
-> ReadPrec ContainerServiceDeployment
-> ReadPrec [ContainerServiceDeployment]
-> Read ContainerServiceDeployment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContainerServiceDeployment]
$creadListPrec :: ReadPrec [ContainerServiceDeployment]
readPrec :: ReadPrec ContainerServiceDeployment
$creadPrec :: ReadPrec ContainerServiceDeployment
readList :: ReadS [ContainerServiceDeployment]
$creadList :: ReadS [ContainerServiceDeployment]
readsPrec :: Int -> ReadS ContainerServiceDeployment
$creadsPrec :: Int -> ReadS ContainerServiceDeployment
Prelude.Read, Int -> ContainerServiceDeployment -> ShowS
[ContainerServiceDeployment] -> ShowS
ContainerServiceDeployment -> String
(Int -> ContainerServiceDeployment -> ShowS)
-> (ContainerServiceDeployment -> String)
-> ([ContainerServiceDeployment] -> ShowS)
-> Show ContainerServiceDeployment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContainerServiceDeployment] -> ShowS
$cshowList :: [ContainerServiceDeployment] -> ShowS
show :: ContainerServiceDeployment -> String
$cshow :: ContainerServiceDeployment -> String
showsPrec :: Int -> ContainerServiceDeployment -> ShowS
$cshowsPrec :: Int -> ContainerServiceDeployment -> ShowS
Prelude.Show, (forall x.
 ContainerServiceDeployment -> Rep ContainerServiceDeployment x)
-> (forall x.
    Rep ContainerServiceDeployment x -> ContainerServiceDeployment)
-> Generic ContainerServiceDeployment
forall x.
Rep ContainerServiceDeployment x -> ContainerServiceDeployment
forall x.
ContainerServiceDeployment -> Rep ContainerServiceDeployment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ContainerServiceDeployment x -> ContainerServiceDeployment
$cfrom :: forall x.
ContainerServiceDeployment -> Rep ContainerServiceDeployment x
Prelude.Generic)

-- |
-- Create a value of 'ContainerServiceDeployment' 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:
--
-- 'state', 'containerServiceDeployment_state' - The state of the deployment.
--
-- A deployment can be in one of the following states:
--
-- -   @Activating@ - The deployment is being created.
--
-- -   @Active@ - The deployment was successfully created, and it\'s
--     currently running on the container service. The container service
--     can have only one deployment in an active state at a time.
--
-- -   @Inactive@ - The deployment was previously successfully created, but
--     it is not currently running on the container service.
--
-- -   @Failed@ - The deployment failed. Use the @GetContainerLog@ action
--     to view the log events for the containers in the deployment to try
--     to determine the reason for the failure.
--
-- 'publicEndpoint', 'containerServiceDeployment_publicEndpoint' - An object that describes the endpoint of the deployment.
--
-- 'createdAt', 'containerServiceDeployment_createdAt' - The timestamp when the deployment was created.
--
-- 'containers', 'containerServiceDeployment_containers' - An object that describes the configuration for the containers of the
-- deployment.
--
-- 'version', 'containerServiceDeployment_version' - The version number of the deployment.
newContainerServiceDeployment ::
  ContainerServiceDeployment
newContainerServiceDeployment :: ContainerServiceDeployment
newContainerServiceDeployment =
  ContainerServiceDeployment' :: Maybe ContainerServiceDeploymentState
-> Maybe ContainerServiceEndpoint
-> Maybe POSIX
-> Maybe (HashMap Text Container)
-> Maybe Int
-> ContainerServiceDeployment
ContainerServiceDeployment'
    { $sel:state:ContainerServiceDeployment' :: Maybe ContainerServiceDeploymentState
state =
        Maybe ContainerServiceDeploymentState
forall a. Maybe a
Prelude.Nothing,
      $sel:publicEndpoint:ContainerServiceDeployment' :: Maybe ContainerServiceEndpoint
publicEndpoint = Maybe ContainerServiceEndpoint
forall a. Maybe a
Prelude.Nothing,
      $sel:createdAt:ContainerServiceDeployment' :: Maybe POSIX
createdAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:containers:ContainerServiceDeployment' :: Maybe (HashMap Text Container)
containers = Maybe (HashMap Text Container)
forall a. Maybe a
Prelude.Nothing,
      $sel:version:ContainerServiceDeployment' :: Maybe Int
version = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The state of the deployment.
--
-- A deployment can be in one of the following states:
--
-- -   @Activating@ - The deployment is being created.
--
-- -   @Active@ - The deployment was successfully created, and it\'s
--     currently running on the container service. The container service
--     can have only one deployment in an active state at a time.
--
-- -   @Inactive@ - The deployment was previously successfully created, but
--     it is not currently running on the container service.
--
-- -   @Failed@ - The deployment failed. Use the @GetContainerLog@ action
--     to view the log events for the containers in the deployment to try
--     to determine the reason for the failure.
containerServiceDeployment_state :: Lens.Lens' ContainerServiceDeployment (Prelude.Maybe ContainerServiceDeploymentState)
containerServiceDeployment_state :: (Maybe ContainerServiceDeploymentState
 -> f (Maybe ContainerServiceDeploymentState))
-> ContainerServiceDeployment -> f ContainerServiceDeployment
containerServiceDeployment_state = (ContainerServiceDeployment
 -> Maybe ContainerServiceDeploymentState)
-> (ContainerServiceDeployment
    -> Maybe ContainerServiceDeploymentState
    -> ContainerServiceDeployment)
-> Lens
     ContainerServiceDeployment
     ContainerServiceDeployment
     (Maybe ContainerServiceDeploymentState)
     (Maybe ContainerServiceDeploymentState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerServiceDeployment' {Maybe ContainerServiceDeploymentState
state :: Maybe ContainerServiceDeploymentState
$sel:state:ContainerServiceDeployment' :: ContainerServiceDeployment -> Maybe ContainerServiceDeploymentState
state} -> Maybe ContainerServiceDeploymentState
state) (\s :: ContainerServiceDeployment
s@ContainerServiceDeployment' {} Maybe ContainerServiceDeploymentState
a -> ContainerServiceDeployment
s {$sel:state:ContainerServiceDeployment' :: Maybe ContainerServiceDeploymentState
state = Maybe ContainerServiceDeploymentState
a} :: ContainerServiceDeployment)

-- | An object that describes the endpoint of the deployment.
containerServiceDeployment_publicEndpoint :: Lens.Lens' ContainerServiceDeployment (Prelude.Maybe ContainerServiceEndpoint)
containerServiceDeployment_publicEndpoint :: (Maybe ContainerServiceEndpoint
 -> f (Maybe ContainerServiceEndpoint))
-> ContainerServiceDeployment -> f ContainerServiceDeployment
containerServiceDeployment_publicEndpoint = (ContainerServiceDeployment -> Maybe ContainerServiceEndpoint)
-> (ContainerServiceDeployment
    -> Maybe ContainerServiceEndpoint -> ContainerServiceDeployment)
-> Lens
     ContainerServiceDeployment
     ContainerServiceDeployment
     (Maybe ContainerServiceEndpoint)
     (Maybe ContainerServiceEndpoint)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerServiceDeployment' {Maybe ContainerServiceEndpoint
publicEndpoint :: Maybe ContainerServiceEndpoint
$sel:publicEndpoint:ContainerServiceDeployment' :: ContainerServiceDeployment -> Maybe ContainerServiceEndpoint
publicEndpoint} -> Maybe ContainerServiceEndpoint
publicEndpoint) (\s :: ContainerServiceDeployment
s@ContainerServiceDeployment' {} Maybe ContainerServiceEndpoint
a -> ContainerServiceDeployment
s {$sel:publicEndpoint:ContainerServiceDeployment' :: Maybe ContainerServiceEndpoint
publicEndpoint = Maybe ContainerServiceEndpoint
a} :: ContainerServiceDeployment)

-- | The timestamp when the deployment was created.
containerServiceDeployment_createdAt :: Lens.Lens' ContainerServiceDeployment (Prelude.Maybe Prelude.UTCTime)
containerServiceDeployment_createdAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ContainerServiceDeployment -> f ContainerServiceDeployment
containerServiceDeployment_createdAt = (ContainerServiceDeployment -> Maybe POSIX)
-> (ContainerServiceDeployment
    -> Maybe POSIX -> ContainerServiceDeployment)
-> Lens
     ContainerServiceDeployment
     ContainerServiceDeployment
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerServiceDeployment' {Maybe POSIX
createdAt :: Maybe POSIX
$sel:createdAt:ContainerServiceDeployment' :: ContainerServiceDeployment -> Maybe POSIX
createdAt} -> Maybe POSIX
createdAt) (\s :: ContainerServiceDeployment
s@ContainerServiceDeployment' {} Maybe POSIX
a -> ContainerServiceDeployment
s {$sel:createdAt:ContainerServiceDeployment' :: Maybe POSIX
createdAt = Maybe POSIX
a} :: ContainerServiceDeployment) ((Maybe POSIX -> f (Maybe POSIX))
 -> ContainerServiceDeployment -> f ContainerServiceDeployment)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ContainerServiceDeployment
-> f ContainerServiceDeployment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | An object that describes the configuration for the containers of the
-- deployment.
containerServiceDeployment_containers :: Lens.Lens' ContainerServiceDeployment (Prelude.Maybe (Prelude.HashMap Prelude.Text Container))
containerServiceDeployment_containers :: (Maybe (HashMap Text Container)
 -> f (Maybe (HashMap Text Container)))
-> ContainerServiceDeployment -> f ContainerServiceDeployment
containerServiceDeployment_containers = (ContainerServiceDeployment -> Maybe (HashMap Text Container))
-> (ContainerServiceDeployment
    -> Maybe (HashMap Text Container) -> ContainerServiceDeployment)
-> Lens
     ContainerServiceDeployment
     ContainerServiceDeployment
     (Maybe (HashMap Text Container))
     (Maybe (HashMap Text Container))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerServiceDeployment' {Maybe (HashMap Text Container)
containers :: Maybe (HashMap Text Container)
$sel:containers:ContainerServiceDeployment' :: ContainerServiceDeployment -> Maybe (HashMap Text Container)
containers} -> Maybe (HashMap Text Container)
containers) (\s :: ContainerServiceDeployment
s@ContainerServiceDeployment' {} Maybe (HashMap Text Container)
a -> ContainerServiceDeployment
s {$sel:containers:ContainerServiceDeployment' :: Maybe (HashMap Text Container)
containers = Maybe (HashMap Text Container)
a} :: ContainerServiceDeployment) ((Maybe (HashMap Text Container)
  -> f (Maybe (HashMap Text Container)))
 -> ContainerServiceDeployment -> f ContainerServiceDeployment)
-> ((Maybe (HashMap Text Container)
     -> f (Maybe (HashMap Text Container)))
    -> Maybe (HashMap Text Container)
    -> f (Maybe (HashMap Text Container)))
-> (Maybe (HashMap Text Container)
    -> f (Maybe (HashMap Text Container)))
-> ContainerServiceDeployment
-> f ContainerServiceDeployment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Container)
  (HashMap Text Container)
  (HashMap Text Container)
  (HashMap Text Container)
-> Iso
     (Maybe (HashMap Text Container))
     (Maybe (HashMap Text Container))
     (Maybe (HashMap Text Container))
     (Maybe (HashMap Text Container))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Container)
  (HashMap Text Container)
  (HashMap Text Container)
  (HashMap Text Container)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The version number of the deployment.
containerServiceDeployment_version :: Lens.Lens' ContainerServiceDeployment (Prelude.Maybe Prelude.Int)
containerServiceDeployment_version :: (Maybe Int -> f (Maybe Int))
-> ContainerServiceDeployment -> f ContainerServiceDeployment
containerServiceDeployment_version = (ContainerServiceDeployment -> Maybe Int)
-> (ContainerServiceDeployment
    -> Maybe Int -> ContainerServiceDeployment)
-> Lens
     ContainerServiceDeployment
     ContainerServiceDeployment
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerServiceDeployment' {Maybe Int
version :: Maybe Int
$sel:version:ContainerServiceDeployment' :: ContainerServiceDeployment -> Maybe Int
version} -> Maybe Int
version) (\s :: ContainerServiceDeployment
s@ContainerServiceDeployment' {} Maybe Int
a -> ContainerServiceDeployment
s {$sel:version:ContainerServiceDeployment' :: Maybe Int
version = Maybe Int
a} :: ContainerServiceDeployment)

instance Core.FromJSON ContainerServiceDeployment where
  parseJSON :: Value -> Parser ContainerServiceDeployment
parseJSON =
    String
-> (Object -> Parser ContainerServiceDeployment)
-> Value
-> Parser ContainerServiceDeployment
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ContainerServiceDeployment"
      ( \Object
x ->
          Maybe ContainerServiceDeploymentState
-> Maybe ContainerServiceEndpoint
-> Maybe POSIX
-> Maybe (HashMap Text Container)
-> Maybe Int
-> ContainerServiceDeployment
ContainerServiceDeployment'
            (Maybe ContainerServiceDeploymentState
 -> Maybe ContainerServiceEndpoint
 -> Maybe POSIX
 -> Maybe (HashMap Text Container)
 -> Maybe Int
 -> ContainerServiceDeployment)
-> Parser (Maybe ContainerServiceDeploymentState)
-> Parser
     (Maybe ContainerServiceEndpoint
      -> Maybe POSIX
      -> Maybe (HashMap Text Container)
      -> Maybe Int
      -> ContainerServiceDeployment)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ContainerServiceDeploymentState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"state")
            Parser
  (Maybe ContainerServiceEndpoint
   -> Maybe POSIX
   -> Maybe (HashMap Text Container)
   -> Maybe Int
   -> ContainerServiceDeployment)
-> Parser (Maybe ContainerServiceEndpoint)
-> Parser
     (Maybe POSIX
      -> Maybe (HashMap Text Container)
      -> Maybe Int
      -> ContainerServiceDeployment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ContainerServiceEndpoint)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"publicEndpoint")
            Parser
  (Maybe POSIX
   -> Maybe (HashMap Text Container)
   -> Maybe Int
   -> ContainerServiceDeployment)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe (HashMap Text Container)
      -> Maybe Int -> ContainerServiceDeployment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"createdAt")
            Parser
  (Maybe (HashMap Text Container)
   -> Maybe Int -> ContainerServiceDeployment)
-> Parser (Maybe (HashMap Text Container))
-> Parser (Maybe Int -> ContainerServiceDeployment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Container)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"containers" Parser (Maybe (Maybe (HashMap Text Container)))
-> Maybe (HashMap Text Container)
-> Parser (Maybe (HashMap Text Container))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Container)
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Int -> ContainerServiceDeployment)
-> Parser (Maybe Int) -> Parser ContainerServiceDeployment
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
"version")
      )

instance Prelude.Hashable ContainerServiceDeployment

instance Prelude.NFData ContainerServiceDeployment