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

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

-- | An object representing a change in state for a managed agent.
--
-- /See:/ 'newManagedAgentStateChange' smart constructor.
data ManagedAgentStateChange = ManagedAgentStateChange'
  { -- | The reason for the status of the managed agent.
    ManagedAgentStateChange -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The name of the container associated with the managed agent.
    ManagedAgentStateChange -> Text
containerName :: Prelude.Text,
    -- | The name of the managed agent.
    ManagedAgentStateChange -> ManagedAgentName
managedAgentName :: ManagedAgentName,
    -- | The status of the managed agent.
    ManagedAgentStateChange -> Text
status :: Prelude.Text
  }
  deriving (ManagedAgentStateChange -> ManagedAgentStateChange -> Bool
(ManagedAgentStateChange -> ManagedAgentStateChange -> Bool)
-> (ManagedAgentStateChange -> ManagedAgentStateChange -> Bool)
-> Eq ManagedAgentStateChange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ManagedAgentStateChange -> ManagedAgentStateChange -> Bool
$c/= :: ManagedAgentStateChange -> ManagedAgentStateChange -> Bool
== :: ManagedAgentStateChange -> ManagedAgentStateChange -> Bool
$c== :: ManagedAgentStateChange -> ManagedAgentStateChange -> Bool
Prelude.Eq, ReadPrec [ManagedAgentStateChange]
ReadPrec ManagedAgentStateChange
Int -> ReadS ManagedAgentStateChange
ReadS [ManagedAgentStateChange]
(Int -> ReadS ManagedAgentStateChange)
-> ReadS [ManagedAgentStateChange]
-> ReadPrec ManagedAgentStateChange
-> ReadPrec [ManagedAgentStateChange]
-> Read ManagedAgentStateChange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ManagedAgentStateChange]
$creadListPrec :: ReadPrec [ManagedAgentStateChange]
readPrec :: ReadPrec ManagedAgentStateChange
$creadPrec :: ReadPrec ManagedAgentStateChange
readList :: ReadS [ManagedAgentStateChange]
$creadList :: ReadS [ManagedAgentStateChange]
readsPrec :: Int -> ReadS ManagedAgentStateChange
$creadsPrec :: Int -> ReadS ManagedAgentStateChange
Prelude.Read, Int -> ManagedAgentStateChange -> ShowS
[ManagedAgentStateChange] -> ShowS
ManagedAgentStateChange -> String
(Int -> ManagedAgentStateChange -> ShowS)
-> (ManagedAgentStateChange -> String)
-> ([ManagedAgentStateChange] -> ShowS)
-> Show ManagedAgentStateChange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ManagedAgentStateChange] -> ShowS
$cshowList :: [ManagedAgentStateChange] -> ShowS
show :: ManagedAgentStateChange -> String
$cshow :: ManagedAgentStateChange -> String
showsPrec :: Int -> ManagedAgentStateChange -> ShowS
$cshowsPrec :: Int -> ManagedAgentStateChange -> ShowS
Prelude.Show, (forall x.
 ManagedAgentStateChange -> Rep ManagedAgentStateChange x)
-> (forall x.
    Rep ManagedAgentStateChange x -> ManagedAgentStateChange)
-> Generic ManagedAgentStateChange
forall x. Rep ManagedAgentStateChange x -> ManagedAgentStateChange
forall x. ManagedAgentStateChange -> Rep ManagedAgentStateChange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ManagedAgentStateChange x -> ManagedAgentStateChange
$cfrom :: forall x. ManagedAgentStateChange -> Rep ManagedAgentStateChange x
Prelude.Generic)

-- |
-- Create a value of 'ManagedAgentStateChange' 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:
--
-- 'reason', 'managedAgentStateChange_reason' - The reason for the status of the managed agent.
--
-- 'containerName', 'managedAgentStateChange_containerName' - The name of the container associated with the managed agent.
--
-- 'managedAgentName', 'managedAgentStateChange_managedAgentName' - The name of the managed agent.
--
-- 'status', 'managedAgentStateChange_status' - The status of the managed agent.
newManagedAgentStateChange ::
  -- | 'containerName'
  Prelude.Text ->
  -- | 'managedAgentName'
  ManagedAgentName ->
  -- | 'status'
  Prelude.Text ->
  ManagedAgentStateChange
newManagedAgentStateChange :: Text -> ManagedAgentName -> Text -> ManagedAgentStateChange
newManagedAgentStateChange
  Text
pContainerName_
  ManagedAgentName
pManagedAgentName_
  Text
pStatus_ =
    ManagedAgentStateChange' :: Maybe Text
-> Text -> ManagedAgentName -> Text -> ManagedAgentStateChange
ManagedAgentStateChange'
      { $sel:reason:ManagedAgentStateChange' :: Maybe Text
reason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:containerName:ManagedAgentStateChange' :: Text
containerName = Text
pContainerName_,
        $sel:managedAgentName:ManagedAgentStateChange' :: ManagedAgentName
managedAgentName = ManagedAgentName
pManagedAgentName_,
        $sel:status:ManagedAgentStateChange' :: Text
status = Text
pStatus_
      }

-- | The reason for the status of the managed agent.
managedAgentStateChange_reason :: Lens.Lens' ManagedAgentStateChange (Prelude.Maybe Prelude.Text)
managedAgentStateChange_reason :: (Maybe Text -> f (Maybe Text))
-> ManagedAgentStateChange -> f ManagedAgentStateChange
managedAgentStateChange_reason = (ManagedAgentStateChange -> Maybe Text)
-> (ManagedAgentStateChange
    -> Maybe Text -> ManagedAgentStateChange)
-> Lens
     ManagedAgentStateChange
     ManagedAgentStateChange
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedAgentStateChange' {Maybe Text
reason :: Maybe Text
$sel:reason:ManagedAgentStateChange' :: ManagedAgentStateChange -> Maybe Text
reason} -> Maybe Text
reason) (\s :: ManagedAgentStateChange
s@ManagedAgentStateChange' {} Maybe Text
a -> ManagedAgentStateChange
s {$sel:reason:ManagedAgentStateChange' :: Maybe Text
reason = Maybe Text
a} :: ManagedAgentStateChange)

-- | The name of the container associated with the managed agent.
managedAgentStateChange_containerName :: Lens.Lens' ManagedAgentStateChange Prelude.Text
managedAgentStateChange_containerName :: (Text -> f Text)
-> ManagedAgentStateChange -> f ManagedAgentStateChange
managedAgentStateChange_containerName = (ManagedAgentStateChange -> Text)
-> (ManagedAgentStateChange -> Text -> ManagedAgentStateChange)
-> Lens ManagedAgentStateChange ManagedAgentStateChange Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedAgentStateChange' {Text
containerName :: Text
$sel:containerName:ManagedAgentStateChange' :: ManagedAgentStateChange -> Text
containerName} -> Text
containerName) (\s :: ManagedAgentStateChange
s@ManagedAgentStateChange' {} Text
a -> ManagedAgentStateChange
s {$sel:containerName:ManagedAgentStateChange' :: Text
containerName = Text
a} :: ManagedAgentStateChange)

-- | The name of the managed agent.
managedAgentStateChange_managedAgentName :: Lens.Lens' ManagedAgentStateChange ManagedAgentName
managedAgentStateChange_managedAgentName :: (ManagedAgentName -> f ManagedAgentName)
-> ManagedAgentStateChange -> f ManagedAgentStateChange
managedAgentStateChange_managedAgentName = (ManagedAgentStateChange -> ManagedAgentName)
-> (ManagedAgentStateChange
    -> ManagedAgentName -> ManagedAgentStateChange)
-> Lens
     ManagedAgentStateChange
     ManagedAgentStateChange
     ManagedAgentName
     ManagedAgentName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedAgentStateChange' {ManagedAgentName
managedAgentName :: ManagedAgentName
$sel:managedAgentName:ManagedAgentStateChange' :: ManagedAgentStateChange -> ManagedAgentName
managedAgentName} -> ManagedAgentName
managedAgentName) (\s :: ManagedAgentStateChange
s@ManagedAgentStateChange' {} ManagedAgentName
a -> ManagedAgentStateChange
s {$sel:managedAgentName:ManagedAgentStateChange' :: ManagedAgentName
managedAgentName = ManagedAgentName
a} :: ManagedAgentStateChange)

-- | The status of the managed agent.
managedAgentStateChange_status :: Lens.Lens' ManagedAgentStateChange Prelude.Text
managedAgentStateChange_status :: (Text -> f Text)
-> ManagedAgentStateChange -> f ManagedAgentStateChange
managedAgentStateChange_status = (ManagedAgentStateChange -> Text)
-> (ManagedAgentStateChange -> Text -> ManagedAgentStateChange)
-> Lens ManagedAgentStateChange ManagedAgentStateChange Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedAgentStateChange' {Text
status :: Text
$sel:status:ManagedAgentStateChange' :: ManagedAgentStateChange -> Text
status} -> Text
status) (\s :: ManagedAgentStateChange
s@ManagedAgentStateChange' {} Text
a -> ManagedAgentStateChange
s {$sel:status:ManagedAgentStateChange' :: Text
status = Text
a} :: ManagedAgentStateChange)

instance Prelude.Hashable ManagedAgentStateChange

instance Prelude.NFData ManagedAgentStateChange

instance Core.ToJSON ManagedAgentStateChange where
  toJSON :: ManagedAgentStateChange -> Value
toJSON ManagedAgentStateChange' {Maybe Text
Text
ManagedAgentName
status :: Text
managedAgentName :: ManagedAgentName
containerName :: Text
reason :: Maybe Text
$sel:status:ManagedAgentStateChange' :: ManagedAgentStateChange -> Text
$sel:managedAgentName:ManagedAgentStateChange' :: ManagedAgentStateChange -> ManagedAgentName
$sel:containerName:ManagedAgentStateChange' :: ManagedAgentStateChange -> Text
$sel:reason:ManagedAgentStateChange' :: ManagedAgentStateChange -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"containerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
containerName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"managedAgentName" Text -> ManagedAgentName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ManagedAgentName
managedAgentName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"status" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
status)
          ]
      )