{-# 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.SSM.Types.AssociationStatus
-- 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.SSM.Types.AssociationStatus where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSM.Types.AssociationStatusName

-- | Describes an association status.
--
-- /See:/ 'newAssociationStatus' smart constructor.
data AssociationStatus = AssociationStatus'
  { -- | A user-defined string.
    AssociationStatus -> Maybe Text
additionalInfo :: Prelude.Maybe Prelude.Text,
    -- | The date when the status changed.
    AssociationStatus -> POSIX
date :: Data.POSIX,
    -- | The status.
    AssociationStatus -> AssociationStatusName
name :: AssociationStatusName,
    -- | The reason for the status.
    AssociationStatus -> Text
message :: Prelude.Text
  }
  deriving (AssociationStatus -> AssociationStatus -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociationStatus -> AssociationStatus -> Bool
$c/= :: AssociationStatus -> AssociationStatus -> Bool
== :: AssociationStatus -> AssociationStatus -> Bool
$c== :: AssociationStatus -> AssociationStatus -> Bool
Prelude.Eq, ReadPrec [AssociationStatus]
ReadPrec AssociationStatus
Int -> ReadS AssociationStatus
ReadS [AssociationStatus]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociationStatus]
$creadListPrec :: ReadPrec [AssociationStatus]
readPrec :: ReadPrec AssociationStatus
$creadPrec :: ReadPrec AssociationStatus
readList :: ReadS [AssociationStatus]
$creadList :: ReadS [AssociationStatus]
readsPrec :: Int -> ReadS AssociationStatus
$creadsPrec :: Int -> ReadS AssociationStatus
Prelude.Read, Int -> AssociationStatus -> ShowS
[AssociationStatus] -> ShowS
AssociationStatus -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociationStatus] -> ShowS
$cshowList :: [AssociationStatus] -> ShowS
show :: AssociationStatus -> String
$cshow :: AssociationStatus -> String
showsPrec :: Int -> AssociationStatus -> ShowS
$cshowsPrec :: Int -> AssociationStatus -> ShowS
Prelude.Show, forall x. Rep AssociationStatus x -> AssociationStatus
forall x. AssociationStatus -> Rep AssociationStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociationStatus x -> AssociationStatus
$cfrom :: forall x. AssociationStatus -> Rep AssociationStatus x
Prelude.Generic)

-- |
-- Create a value of 'AssociationStatus' 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:
--
-- 'additionalInfo', 'associationStatus_additionalInfo' - A user-defined string.
--
-- 'date', 'associationStatus_date' - The date when the status changed.
--
-- 'name', 'associationStatus_name' - The status.
--
-- 'message', 'associationStatus_message' - The reason for the status.
newAssociationStatus ::
  -- | 'date'
  Prelude.UTCTime ->
  -- | 'name'
  AssociationStatusName ->
  -- | 'message'
  Prelude.Text ->
  AssociationStatus
newAssociationStatus :: UTCTime -> AssociationStatusName -> Text -> AssociationStatus
newAssociationStatus UTCTime
pDate_ AssociationStatusName
pName_ Text
pMessage_ =
  AssociationStatus'
    { $sel:additionalInfo:AssociationStatus' :: Maybe Text
additionalInfo =
        forall a. Maybe a
Prelude.Nothing,
      $sel:date:AssociationStatus' :: POSIX
date = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pDate_,
      $sel:name:AssociationStatus' :: AssociationStatusName
name = AssociationStatusName
pName_,
      $sel:message:AssociationStatus' :: Text
message = Text
pMessage_
    }

-- | A user-defined string.
associationStatus_additionalInfo :: Lens.Lens' AssociationStatus (Prelude.Maybe Prelude.Text)
associationStatus_additionalInfo :: Lens' AssociationStatus (Maybe Text)
associationStatus_additionalInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociationStatus' {Maybe Text
additionalInfo :: Maybe Text
$sel:additionalInfo:AssociationStatus' :: AssociationStatus -> Maybe Text
additionalInfo} -> Maybe Text
additionalInfo) (\s :: AssociationStatus
s@AssociationStatus' {} Maybe Text
a -> AssociationStatus
s {$sel:additionalInfo:AssociationStatus' :: Maybe Text
additionalInfo = Maybe Text
a} :: AssociationStatus)

-- | The date when the status changed.
associationStatus_date :: Lens.Lens' AssociationStatus Prelude.UTCTime
associationStatus_date :: Lens' AssociationStatus UTCTime
associationStatus_date = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociationStatus' {POSIX
date :: POSIX
$sel:date:AssociationStatus' :: AssociationStatus -> POSIX
date} -> POSIX
date) (\s :: AssociationStatus
s@AssociationStatus' {} POSIX
a -> AssociationStatus
s {$sel:date:AssociationStatus' :: POSIX
date = POSIX
a} :: AssociationStatus) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The status.
associationStatus_name :: Lens.Lens' AssociationStatus AssociationStatusName
associationStatus_name :: Lens' AssociationStatus AssociationStatusName
associationStatus_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociationStatus' {AssociationStatusName
name :: AssociationStatusName
$sel:name:AssociationStatus' :: AssociationStatus -> AssociationStatusName
name} -> AssociationStatusName
name) (\s :: AssociationStatus
s@AssociationStatus' {} AssociationStatusName
a -> AssociationStatus
s {$sel:name:AssociationStatus' :: AssociationStatusName
name = AssociationStatusName
a} :: AssociationStatus)

-- | The reason for the status.
associationStatus_message :: Lens.Lens' AssociationStatus Prelude.Text
associationStatus_message :: Lens' AssociationStatus Text
associationStatus_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociationStatus' {Text
message :: Text
$sel:message:AssociationStatus' :: AssociationStatus -> Text
message} -> Text
message) (\s :: AssociationStatus
s@AssociationStatus' {} Text
a -> AssociationStatus
s {$sel:message:AssociationStatus' :: Text
message = Text
a} :: AssociationStatus)

instance Data.FromJSON AssociationStatus where
  parseJSON :: Value -> Parser AssociationStatus
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AssociationStatus"
      ( \Object
x ->
          Maybe Text
-> POSIX -> AssociationStatusName -> Text -> AssociationStatus
AssociationStatus'
            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
"AdditionalInfo")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Date")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Message")
      )

instance Prelude.Hashable AssociationStatus where
  hashWithSalt :: Int -> AssociationStatus -> Int
hashWithSalt Int
_salt AssociationStatus' {Maybe Text
Text
POSIX
AssociationStatusName
message :: Text
name :: AssociationStatusName
date :: POSIX
additionalInfo :: Maybe Text
$sel:message:AssociationStatus' :: AssociationStatus -> Text
$sel:name:AssociationStatus' :: AssociationStatus -> AssociationStatusName
$sel:date:AssociationStatus' :: AssociationStatus -> POSIX
$sel:additionalInfo:AssociationStatus' :: AssociationStatus -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
additionalInfo
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
date
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AssociationStatusName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
message

instance Prelude.NFData AssociationStatus where
  rnf :: AssociationStatus -> ()
rnf AssociationStatus' {Maybe Text
Text
POSIX
AssociationStatusName
message :: Text
name :: AssociationStatusName
date :: POSIX
additionalInfo :: Maybe Text
$sel:message:AssociationStatus' :: AssociationStatus -> Text
$sel:name:AssociationStatus' :: AssociationStatus -> AssociationStatusName
$sel:date:AssociationStatus' :: AssociationStatus -> POSIX
$sel:additionalInfo:AssociationStatus' :: AssociationStatus -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
additionalInfo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
date
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AssociationStatusName
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
message

instance Data.ToJSON AssociationStatus where
  toJSON :: AssociationStatus -> Value
toJSON AssociationStatus' {Maybe Text
Text
POSIX
AssociationStatusName
message :: Text
name :: AssociationStatusName
date :: POSIX
additionalInfo :: Maybe Text
$sel:message:AssociationStatus' :: AssociationStatus -> Text
$sel:name:AssociationStatus' :: AssociationStatus -> AssociationStatusName
$sel:date:AssociationStatus' :: AssociationStatus -> POSIX
$sel:additionalInfo:AssociationStatus' :: AssociationStatus -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AdditionalInfo" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
additionalInfo,
            forall a. a -> Maybe a
Prelude.Just (Key
"Date" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= POSIX
date),
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AssociationStatusName
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
message)
          ]
      )