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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the association.
--
-- /See:/ 'newAssociationOverview' smart constructor.
data AssociationOverview = AssociationOverview'
  { -- | A detailed status of the association.
    AssociationOverview -> Maybe Text
detailedStatus :: Prelude.Maybe Prelude.Text,
    -- | The status of the association. Status can be: Pending, Success, or
    -- Failed.
    AssociationOverview -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | Returns the number of targets for the association status. For example,
    -- if you created an association with two instances, and one of them was
    -- successful, this would return the count of instances by status.
    AssociationOverview -> Maybe (HashMap Text Int)
associationStatusAggregatedCount :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Int)
  }
  deriving (AssociationOverview -> AssociationOverview -> Bool
(AssociationOverview -> AssociationOverview -> Bool)
-> (AssociationOverview -> AssociationOverview -> Bool)
-> Eq AssociationOverview
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociationOverview -> AssociationOverview -> Bool
$c/= :: AssociationOverview -> AssociationOverview -> Bool
== :: AssociationOverview -> AssociationOverview -> Bool
$c== :: AssociationOverview -> AssociationOverview -> Bool
Prelude.Eq, ReadPrec [AssociationOverview]
ReadPrec AssociationOverview
Int -> ReadS AssociationOverview
ReadS [AssociationOverview]
(Int -> ReadS AssociationOverview)
-> ReadS [AssociationOverview]
-> ReadPrec AssociationOverview
-> ReadPrec [AssociationOverview]
-> Read AssociationOverview
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociationOverview]
$creadListPrec :: ReadPrec [AssociationOverview]
readPrec :: ReadPrec AssociationOverview
$creadPrec :: ReadPrec AssociationOverview
readList :: ReadS [AssociationOverview]
$creadList :: ReadS [AssociationOverview]
readsPrec :: Int -> ReadS AssociationOverview
$creadsPrec :: Int -> ReadS AssociationOverview
Prelude.Read, Int -> AssociationOverview -> ShowS
[AssociationOverview] -> ShowS
AssociationOverview -> String
(Int -> AssociationOverview -> ShowS)
-> (AssociationOverview -> String)
-> ([AssociationOverview] -> ShowS)
-> Show AssociationOverview
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociationOverview] -> ShowS
$cshowList :: [AssociationOverview] -> ShowS
show :: AssociationOverview -> String
$cshow :: AssociationOverview -> String
showsPrec :: Int -> AssociationOverview -> ShowS
$cshowsPrec :: Int -> AssociationOverview -> ShowS
Prelude.Show, (forall x. AssociationOverview -> Rep AssociationOverview x)
-> (forall x. Rep AssociationOverview x -> AssociationOverview)
-> Generic AssociationOverview
forall x. Rep AssociationOverview x -> AssociationOverview
forall x. AssociationOverview -> Rep AssociationOverview x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociationOverview x -> AssociationOverview
$cfrom :: forall x. AssociationOverview -> Rep AssociationOverview x
Prelude.Generic)

-- |
-- Create a value of 'AssociationOverview' 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:
--
-- 'detailedStatus', 'associationOverview_detailedStatus' - A detailed status of the association.
--
-- 'status', 'associationOverview_status' - The status of the association. Status can be: Pending, Success, or
-- Failed.
--
-- 'associationStatusAggregatedCount', 'associationOverview_associationStatusAggregatedCount' - Returns the number of targets for the association status. For example,
-- if you created an association with two instances, and one of them was
-- successful, this would return the count of instances by status.
newAssociationOverview ::
  AssociationOverview
newAssociationOverview :: AssociationOverview
newAssociationOverview =
  AssociationOverview' :: Maybe Text
-> Maybe Text -> Maybe (HashMap Text Int) -> AssociationOverview
AssociationOverview'
    { $sel:detailedStatus:AssociationOverview' :: Maybe Text
detailedStatus =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:status:AssociationOverview' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:associationStatusAggregatedCount:AssociationOverview' :: Maybe (HashMap Text Int)
associationStatusAggregatedCount = Maybe (HashMap Text Int)
forall a. Maybe a
Prelude.Nothing
    }

-- | A detailed status of the association.
associationOverview_detailedStatus :: Lens.Lens' AssociationOverview (Prelude.Maybe Prelude.Text)
associationOverview_detailedStatus :: (Maybe Text -> f (Maybe Text))
-> AssociationOverview -> f AssociationOverview
associationOverview_detailedStatus = (AssociationOverview -> Maybe Text)
-> (AssociationOverview -> Maybe Text -> AssociationOverview)
-> Lens
     AssociationOverview AssociationOverview (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociationOverview' {Maybe Text
detailedStatus :: Maybe Text
$sel:detailedStatus:AssociationOverview' :: AssociationOverview -> Maybe Text
detailedStatus} -> Maybe Text
detailedStatus) (\s :: AssociationOverview
s@AssociationOverview' {} Maybe Text
a -> AssociationOverview
s {$sel:detailedStatus:AssociationOverview' :: Maybe Text
detailedStatus = Maybe Text
a} :: AssociationOverview)

-- | The status of the association. Status can be: Pending, Success, or
-- Failed.
associationOverview_status :: Lens.Lens' AssociationOverview (Prelude.Maybe Prelude.Text)
associationOverview_status :: (Maybe Text -> f (Maybe Text))
-> AssociationOverview -> f AssociationOverview
associationOverview_status = (AssociationOverview -> Maybe Text)
-> (AssociationOverview -> Maybe Text -> AssociationOverview)
-> Lens
     AssociationOverview AssociationOverview (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociationOverview' {Maybe Text
status :: Maybe Text
$sel:status:AssociationOverview' :: AssociationOverview -> Maybe Text
status} -> Maybe Text
status) (\s :: AssociationOverview
s@AssociationOverview' {} Maybe Text
a -> AssociationOverview
s {$sel:status:AssociationOverview' :: Maybe Text
status = Maybe Text
a} :: AssociationOverview)

-- | Returns the number of targets for the association status. For example,
-- if you created an association with two instances, and one of them was
-- successful, this would return the count of instances by status.
associationOverview_associationStatusAggregatedCount :: Lens.Lens' AssociationOverview (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Int))
associationOverview_associationStatusAggregatedCount :: (Maybe (HashMap Text Int) -> f (Maybe (HashMap Text Int)))
-> AssociationOverview -> f AssociationOverview
associationOverview_associationStatusAggregatedCount = (AssociationOverview -> Maybe (HashMap Text Int))
-> (AssociationOverview
    -> Maybe (HashMap Text Int) -> AssociationOverview)
-> Lens
     AssociationOverview
     AssociationOverview
     (Maybe (HashMap Text Int))
     (Maybe (HashMap Text Int))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociationOverview' {Maybe (HashMap Text Int)
associationStatusAggregatedCount :: Maybe (HashMap Text Int)
$sel:associationStatusAggregatedCount:AssociationOverview' :: AssociationOverview -> Maybe (HashMap Text Int)
associationStatusAggregatedCount} -> Maybe (HashMap Text Int)
associationStatusAggregatedCount) (\s :: AssociationOverview
s@AssociationOverview' {} Maybe (HashMap Text Int)
a -> AssociationOverview
s {$sel:associationStatusAggregatedCount:AssociationOverview' :: Maybe (HashMap Text Int)
associationStatusAggregatedCount = Maybe (HashMap Text Int)
a} :: AssociationOverview) ((Maybe (HashMap Text Int) -> f (Maybe (HashMap Text Int)))
 -> AssociationOverview -> f AssociationOverview)
-> ((Maybe (HashMap Text Int) -> f (Maybe (HashMap Text Int)))
    -> Maybe (HashMap Text Int) -> f (Maybe (HashMap Text Int)))
-> (Maybe (HashMap Text Int) -> f (Maybe (HashMap Text Int)))
-> AssociationOverview
-> f AssociationOverview
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Int)
  (HashMap Text Int)
  (HashMap Text Int)
  (HashMap Text Int)
-> Iso
     (Maybe (HashMap Text Int))
     (Maybe (HashMap Text Int))
     (Maybe (HashMap Text Int))
     (Maybe (HashMap Text Int))
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 Int)
  (HashMap Text Int)
  (HashMap Text Int)
  (HashMap Text Int)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON AssociationOverview where
  parseJSON :: Value -> Parser AssociationOverview
parseJSON =
    String
-> (Object -> Parser AssociationOverview)
-> Value
-> Parser AssociationOverview
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AssociationOverview"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe (HashMap Text Int) -> AssociationOverview
AssociationOverview'
            (Maybe Text
 -> Maybe Text -> Maybe (HashMap Text Int) -> AssociationOverview)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe (HashMap Text Int) -> AssociationOverview)
forall (f :: * -> *) a b. Functor 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
"DetailedStatus")
            Parser
  (Maybe Text -> Maybe (HashMap Text Int) -> AssociationOverview)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text Int) -> AssociationOverview)
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
"Status")
            Parser (Maybe (HashMap Text Int) -> AssociationOverview)
-> Parser (Maybe (HashMap Text Int)) -> Parser AssociationOverview
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Int)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AssociationStatusAggregatedCount"
                            Parser (Maybe (Maybe (HashMap Text Int)))
-> Maybe (HashMap Text Int) -> Parser (Maybe (HashMap Text Int))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Int)
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable AssociationOverview

instance Prelude.NFData AssociationOverview