{-# 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.ECS.Types.ContainerStateChange
-- 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.ECS.Types.ContainerStateChange where

import qualified Amazonka.Core as Core
import Amazonka.ECS.Types.NetworkBinding
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object representing a change in state for a container.
--
-- /See:/ 'newContainerStateChange' smart constructor.
data ContainerStateChange = ContainerStateChange'
  { -- | Any network bindings associated with the container.
    ContainerStateChange -> Maybe [NetworkBinding]
networkBindings :: Prelude.Maybe [NetworkBinding],
    -- | The status of the container.
    ContainerStateChange -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The name of the container.
    ContainerStateChange -> Maybe Text
containerName :: Prelude.Maybe Prelude.Text,
    -- | The reason for the state change.
    ContainerStateChange -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The container image SHA 256 digest.
    ContainerStateChange -> Maybe Text
imageDigest :: Prelude.Maybe Prelude.Text,
    -- | The exit code for the container, if the state change is a result of the
    -- container exiting.
    ContainerStateChange -> Maybe Int
exitCode :: Prelude.Maybe Prelude.Int,
    -- | The ID of the Docker container.
    ContainerStateChange -> Maybe Text
runtimeId :: Prelude.Maybe Prelude.Text
  }
  deriving (ContainerStateChange -> ContainerStateChange -> Bool
(ContainerStateChange -> ContainerStateChange -> Bool)
-> (ContainerStateChange -> ContainerStateChange -> Bool)
-> Eq ContainerStateChange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContainerStateChange -> ContainerStateChange -> Bool
$c/= :: ContainerStateChange -> ContainerStateChange -> Bool
== :: ContainerStateChange -> ContainerStateChange -> Bool
$c== :: ContainerStateChange -> ContainerStateChange -> Bool
Prelude.Eq, ReadPrec [ContainerStateChange]
ReadPrec ContainerStateChange
Int -> ReadS ContainerStateChange
ReadS [ContainerStateChange]
(Int -> ReadS ContainerStateChange)
-> ReadS [ContainerStateChange]
-> ReadPrec ContainerStateChange
-> ReadPrec [ContainerStateChange]
-> Read ContainerStateChange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContainerStateChange]
$creadListPrec :: ReadPrec [ContainerStateChange]
readPrec :: ReadPrec ContainerStateChange
$creadPrec :: ReadPrec ContainerStateChange
readList :: ReadS [ContainerStateChange]
$creadList :: ReadS [ContainerStateChange]
readsPrec :: Int -> ReadS ContainerStateChange
$creadsPrec :: Int -> ReadS ContainerStateChange
Prelude.Read, Int -> ContainerStateChange -> ShowS
[ContainerStateChange] -> ShowS
ContainerStateChange -> String
(Int -> ContainerStateChange -> ShowS)
-> (ContainerStateChange -> String)
-> ([ContainerStateChange] -> ShowS)
-> Show ContainerStateChange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContainerStateChange] -> ShowS
$cshowList :: [ContainerStateChange] -> ShowS
show :: ContainerStateChange -> String
$cshow :: ContainerStateChange -> String
showsPrec :: Int -> ContainerStateChange -> ShowS
$cshowsPrec :: Int -> ContainerStateChange -> ShowS
Prelude.Show, (forall x. ContainerStateChange -> Rep ContainerStateChange x)
-> (forall x. Rep ContainerStateChange x -> ContainerStateChange)
-> Generic ContainerStateChange
forall x. Rep ContainerStateChange x -> ContainerStateChange
forall x. ContainerStateChange -> Rep ContainerStateChange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ContainerStateChange x -> ContainerStateChange
$cfrom :: forall x. ContainerStateChange -> Rep ContainerStateChange x
Prelude.Generic)

-- |
-- Create a value of 'ContainerStateChange' 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:
--
-- 'networkBindings', 'containerStateChange_networkBindings' - Any network bindings associated with the container.
--
-- 'status', 'containerStateChange_status' - The status of the container.
--
-- 'containerName', 'containerStateChange_containerName' - The name of the container.
--
-- 'reason', 'containerStateChange_reason' - The reason for the state change.
--
-- 'imageDigest', 'containerStateChange_imageDigest' - The container image SHA 256 digest.
--
-- 'exitCode', 'containerStateChange_exitCode' - The exit code for the container, if the state change is a result of the
-- container exiting.
--
-- 'runtimeId', 'containerStateChange_runtimeId' - The ID of the Docker container.
newContainerStateChange ::
  ContainerStateChange
newContainerStateChange :: ContainerStateChange
newContainerStateChange =
  ContainerStateChange' :: Maybe [NetworkBinding]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> ContainerStateChange
ContainerStateChange'
    { $sel:networkBindings:ContainerStateChange' :: Maybe [NetworkBinding]
networkBindings =
        Maybe [NetworkBinding]
forall a. Maybe a
Prelude.Nothing,
      $sel:status:ContainerStateChange' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:containerName:ContainerStateChange' :: Maybe Text
containerName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:reason:ContainerStateChange' :: Maybe Text
reason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:imageDigest:ContainerStateChange' :: Maybe Text
imageDigest = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:exitCode:ContainerStateChange' :: Maybe Int
exitCode = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:runtimeId:ContainerStateChange' :: Maybe Text
runtimeId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Any network bindings associated with the container.
containerStateChange_networkBindings :: Lens.Lens' ContainerStateChange (Prelude.Maybe [NetworkBinding])
containerStateChange_networkBindings :: (Maybe [NetworkBinding] -> f (Maybe [NetworkBinding]))
-> ContainerStateChange -> f ContainerStateChange
containerStateChange_networkBindings = (ContainerStateChange -> Maybe [NetworkBinding])
-> (ContainerStateChange
    -> Maybe [NetworkBinding] -> ContainerStateChange)
-> Lens
     ContainerStateChange
     ContainerStateChange
     (Maybe [NetworkBinding])
     (Maybe [NetworkBinding])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerStateChange' {Maybe [NetworkBinding]
networkBindings :: Maybe [NetworkBinding]
$sel:networkBindings:ContainerStateChange' :: ContainerStateChange -> Maybe [NetworkBinding]
networkBindings} -> Maybe [NetworkBinding]
networkBindings) (\s :: ContainerStateChange
s@ContainerStateChange' {} Maybe [NetworkBinding]
a -> ContainerStateChange
s {$sel:networkBindings:ContainerStateChange' :: Maybe [NetworkBinding]
networkBindings = Maybe [NetworkBinding]
a} :: ContainerStateChange) ((Maybe [NetworkBinding] -> f (Maybe [NetworkBinding]))
 -> ContainerStateChange -> f ContainerStateChange)
-> ((Maybe [NetworkBinding] -> f (Maybe [NetworkBinding]))
    -> Maybe [NetworkBinding] -> f (Maybe [NetworkBinding]))
-> (Maybe [NetworkBinding] -> f (Maybe [NetworkBinding]))
-> ContainerStateChange
-> f ContainerStateChange
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [NetworkBinding] [NetworkBinding] [NetworkBinding] [NetworkBinding]
-> Iso
     (Maybe [NetworkBinding])
     (Maybe [NetworkBinding])
     (Maybe [NetworkBinding])
     (Maybe [NetworkBinding])
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
  [NetworkBinding] [NetworkBinding] [NetworkBinding] [NetworkBinding]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The status of the container.
containerStateChange_status :: Lens.Lens' ContainerStateChange (Prelude.Maybe Prelude.Text)
containerStateChange_status :: (Maybe Text -> f (Maybe Text))
-> ContainerStateChange -> f ContainerStateChange
containerStateChange_status = (ContainerStateChange -> Maybe Text)
-> (ContainerStateChange -> Maybe Text -> ContainerStateChange)
-> Lens
     ContainerStateChange ContainerStateChange (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerStateChange' {Maybe Text
status :: Maybe Text
$sel:status:ContainerStateChange' :: ContainerStateChange -> Maybe Text
status} -> Maybe Text
status) (\s :: ContainerStateChange
s@ContainerStateChange' {} Maybe Text
a -> ContainerStateChange
s {$sel:status:ContainerStateChange' :: Maybe Text
status = Maybe Text
a} :: ContainerStateChange)

-- | The name of the container.
containerStateChange_containerName :: Lens.Lens' ContainerStateChange (Prelude.Maybe Prelude.Text)
containerStateChange_containerName :: (Maybe Text -> f (Maybe Text))
-> ContainerStateChange -> f ContainerStateChange
containerStateChange_containerName = (ContainerStateChange -> Maybe Text)
-> (ContainerStateChange -> Maybe Text -> ContainerStateChange)
-> Lens
     ContainerStateChange ContainerStateChange (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerStateChange' {Maybe Text
containerName :: Maybe Text
$sel:containerName:ContainerStateChange' :: ContainerStateChange -> Maybe Text
containerName} -> Maybe Text
containerName) (\s :: ContainerStateChange
s@ContainerStateChange' {} Maybe Text
a -> ContainerStateChange
s {$sel:containerName:ContainerStateChange' :: Maybe Text
containerName = Maybe Text
a} :: ContainerStateChange)

-- | The reason for the state change.
containerStateChange_reason :: Lens.Lens' ContainerStateChange (Prelude.Maybe Prelude.Text)
containerStateChange_reason :: (Maybe Text -> f (Maybe Text))
-> ContainerStateChange -> f ContainerStateChange
containerStateChange_reason = (ContainerStateChange -> Maybe Text)
-> (ContainerStateChange -> Maybe Text -> ContainerStateChange)
-> Lens
     ContainerStateChange ContainerStateChange (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerStateChange' {Maybe Text
reason :: Maybe Text
$sel:reason:ContainerStateChange' :: ContainerStateChange -> Maybe Text
reason} -> Maybe Text
reason) (\s :: ContainerStateChange
s@ContainerStateChange' {} Maybe Text
a -> ContainerStateChange
s {$sel:reason:ContainerStateChange' :: Maybe Text
reason = Maybe Text
a} :: ContainerStateChange)

-- | The container image SHA 256 digest.
containerStateChange_imageDigest :: Lens.Lens' ContainerStateChange (Prelude.Maybe Prelude.Text)
containerStateChange_imageDigest :: (Maybe Text -> f (Maybe Text))
-> ContainerStateChange -> f ContainerStateChange
containerStateChange_imageDigest = (ContainerStateChange -> Maybe Text)
-> (ContainerStateChange -> Maybe Text -> ContainerStateChange)
-> Lens
     ContainerStateChange ContainerStateChange (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerStateChange' {Maybe Text
imageDigest :: Maybe Text
$sel:imageDigest:ContainerStateChange' :: ContainerStateChange -> Maybe Text
imageDigest} -> Maybe Text
imageDigest) (\s :: ContainerStateChange
s@ContainerStateChange' {} Maybe Text
a -> ContainerStateChange
s {$sel:imageDigest:ContainerStateChange' :: Maybe Text
imageDigest = Maybe Text
a} :: ContainerStateChange)

-- | The exit code for the container, if the state change is a result of the
-- container exiting.
containerStateChange_exitCode :: Lens.Lens' ContainerStateChange (Prelude.Maybe Prelude.Int)
containerStateChange_exitCode :: (Maybe Int -> f (Maybe Int))
-> ContainerStateChange -> f ContainerStateChange
containerStateChange_exitCode = (ContainerStateChange -> Maybe Int)
-> (ContainerStateChange -> Maybe Int -> ContainerStateChange)
-> Lens
     ContainerStateChange ContainerStateChange (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerStateChange' {Maybe Int
exitCode :: Maybe Int
$sel:exitCode:ContainerStateChange' :: ContainerStateChange -> Maybe Int
exitCode} -> Maybe Int
exitCode) (\s :: ContainerStateChange
s@ContainerStateChange' {} Maybe Int
a -> ContainerStateChange
s {$sel:exitCode:ContainerStateChange' :: Maybe Int
exitCode = Maybe Int
a} :: ContainerStateChange)

-- | The ID of the Docker container.
containerStateChange_runtimeId :: Lens.Lens' ContainerStateChange (Prelude.Maybe Prelude.Text)
containerStateChange_runtimeId :: (Maybe Text -> f (Maybe Text))
-> ContainerStateChange -> f ContainerStateChange
containerStateChange_runtimeId = (ContainerStateChange -> Maybe Text)
-> (ContainerStateChange -> Maybe Text -> ContainerStateChange)
-> Lens
     ContainerStateChange ContainerStateChange (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerStateChange' {Maybe Text
runtimeId :: Maybe Text
$sel:runtimeId:ContainerStateChange' :: ContainerStateChange -> Maybe Text
runtimeId} -> Maybe Text
runtimeId) (\s :: ContainerStateChange
s@ContainerStateChange' {} Maybe Text
a -> ContainerStateChange
s {$sel:runtimeId:ContainerStateChange' :: Maybe Text
runtimeId = Maybe Text
a} :: ContainerStateChange)

instance Prelude.Hashable ContainerStateChange

instance Prelude.NFData ContainerStateChange

instance Core.ToJSON ContainerStateChange where
  toJSON :: ContainerStateChange -> Value
toJSON ContainerStateChange' {Maybe Int
Maybe [NetworkBinding]
Maybe Text
runtimeId :: Maybe Text
exitCode :: Maybe Int
imageDigest :: Maybe Text
reason :: Maybe Text
containerName :: Maybe Text
status :: Maybe Text
networkBindings :: Maybe [NetworkBinding]
$sel:runtimeId:ContainerStateChange' :: ContainerStateChange -> Maybe Text
$sel:exitCode:ContainerStateChange' :: ContainerStateChange -> Maybe Int
$sel:imageDigest:ContainerStateChange' :: ContainerStateChange -> Maybe Text
$sel:reason:ContainerStateChange' :: ContainerStateChange -> Maybe Text
$sel:containerName:ContainerStateChange' :: ContainerStateChange -> Maybe Text
$sel:status:ContainerStateChange' :: ContainerStateChange -> Maybe Text
$sel:networkBindings:ContainerStateChange' :: ContainerStateChange -> Maybe [NetworkBinding]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"networkBindings" Text -> [NetworkBinding] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([NetworkBinding] -> Pair) -> Maybe [NetworkBinding] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [NetworkBinding]
networkBindings,
            (Text
"status" 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
status,
            (Text
"containerName" 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
containerName,
            (Text
"reason" 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
reason,
            (Text
"imageDigest" 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
imageDigest,
            (Text
"exitCode" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
exitCode,
            (Text
"runtimeId" 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
runtimeId
          ]
      )