{-# 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.GreengrassV2.Types.CloudComponentStatus
-- 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.GreengrassV2.Types.CloudComponentStatus where

import qualified Amazonka.Core as Core
import Amazonka.GreengrassV2.Types.CloudComponentState
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the status of a component in the IoT Greengrass service.
--
-- /See:/ 'newCloudComponentStatus' smart constructor.
data CloudComponentStatus = CloudComponentStatus'
  { -- | The state of the component.
    CloudComponentStatus -> Maybe CloudComponentState
componentState :: Prelude.Maybe CloudComponentState,
    -- | A message that communicates details, such as errors, about the status of
    -- the component.
    CloudComponentStatus -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | A dictionary of errors that communicate why the component is in an error
    -- state. For example, if IoT Greengrass can\'t access an artifact for the
    -- component, then @errors@ contains the artifact\'s URI as a key, and the
    -- error message as the value for that key.
    CloudComponentStatus -> Maybe (HashMap Text Text)
errors :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (CloudComponentStatus -> CloudComponentStatus -> Bool
(CloudComponentStatus -> CloudComponentStatus -> Bool)
-> (CloudComponentStatus -> CloudComponentStatus -> Bool)
-> Eq CloudComponentStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CloudComponentStatus -> CloudComponentStatus -> Bool
$c/= :: CloudComponentStatus -> CloudComponentStatus -> Bool
== :: CloudComponentStatus -> CloudComponentStatus -> Bool
$c== :: CloudComponentStatus -> CloudComponentStatus -> Bool
Prelude.Eq, ReadPrec [CloudComponentStatus]
ReadPrec CloudComponentStatus
Int -> ReadS CloudComponentStatus
ReadS [CloudComponentStatus]
(Int -> ReadS CloudComponentStatus)
-> ReadS [CloudComponentStatus]
-> ReadPrec CloudComponentStatus
-> ReadPrec [CloudComponentStatus]
-> Read CloudComponentStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CloudComponentStatus]
$creadListPrec :: ReadPrec [CloudComponentStatus]
readPrec :: ReadPrec CloudComponentStatus
$creadPrec :: ReadPrec CloudComponentStatus
readList :: ReadS [CloudComponentStatus]
$creadList :: ReadS [CloudComponentStatus]
readsPrec :: Int -> ReadS CloudComponentStatus
$creadsPrec :: Int -> ReadS CloudComponentStatus
Prelude.Read, Int -> CloudComponentStatus -> ShowS
[CloudComponentStatus] -> ShowS
CloudComponentStatus -> String
(Int -> CloudComponentStatus -> ShowS)
-> (CloudComponentStatus -> String)
-> ([CloudComponentStatus] -> ShowS)
-> Show CloudComponentStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CloudComponentStatus] -> ShowS
$cshowList :: [CloudComponentStatus] -> ShowS
show :: CloudComponentStatus -> String
$cshow :: CloudComponentStatus -> String
showsPrec :: Int -> CloudComponentStatus -> ShowS
$cshowsPrec :: Int -> CloudComponentStatus -> ShowS
Prelude.Show, (forall x. CloudComponentStatus -> Rep CloudComponentStatus x)
-> (forall x. Rep CloudComponentStatus x -> CloudComponentStatus)
-> Generic CloudComponentStatus
forall x. Rep CloudComponentStatus x -> CloudComponentStatus
forall x. CloudComponentStatus -> Rep CloudComponentStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CloudComponentStatus x -> CloudComponentStatus
$cfrom :: forall x. CloudComponentStatus -> Rep CloudComponentStatus x
Prelude.Generic)

-- |
-- Create a value of 'CloudComponentStatus' 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:
--
-- 'componentState', 'cloudComponentStatus_componentState' - The state of the component.
--
-- 'message', 'cloudComponentStatus_message' - A message that communicates details, such as errors, about the status of
-- the component.
--
-- 'errors', 'cloudComponentStatus_errors' - A dictionary of errors that communicate why the component is in an error
-- state. For example, if IoT Greengrass can\'t access an artifact for the
-- component, then @errors@ contains the artifact\'s URI as a key, and the
-- error message as the value for that key.
newCloudComponentStatus ::
  CloudComponentStatus
newCloudComponentStatus :: CloudComponentStatus
newCloudComponentStatus =
  CloudComponentStatus' :: Maybe CloudComponentState
-> Maybe Text -> Maybe (HashMap Text Text) -> CloudComponentStatus
CloudComponentStatus'
    { $sel:componentState:CloudComponentStatus' :: Maybe CloudComponentState
componentState =
        Maybe CloudComponentState
forall a. Maybe a
Prelude.Nothing,
      $sel:message:CloudComponentStatus' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errors:CloudComponentStatus' :: Maybe (HashMap Text Text)
errors = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | The state of the component.
cloudComponentStatus_componentState :: Lens.Lens' CloudComponentStatus (Prelude.Maybe CloudComponentState)
cloudComponentStatus_componentState :: (Maybe CloudComponentState -> f (Maybe CloudComponentState))
-> CloudComponentStatus -> f CloudComponentStatus
cloudComponentStatus_componentState = (CloudComponentStatus -> Maybe CloudComponentState)
-> (CloudComponentStatus
    -> Maybe CloudComponentState -> CloudComponentStatus)
-> Lens
     CloudComponentStatus
     CloudComponentStatus
     (Maybe CloudComponentState)
     (Maybe CloudComponentState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudComponentStatus' {Maybe CloudComponentState
componentState :: Maybe CloudComponentState
$sel:componentState:CloudComponentStatus' :: CloudComponentStatus -> Maybe CloudComponentState
componentState} -> Maybe CloudComponentState
componentState) (\s :: CloudComponentStatus
s@CloudComponentStatus' {} Maybe CloudComponentState
a -> CloudComponentStatus
s {$sel:componentState:CloudComponentStatus' :: Maybe CloudComponentState
componentState = Maybe CloudComponentState
a} :: CloudComponentStatus)

-- | A message that communicates details, such as errors, about the status of
-- the component.
cloudComponentStatus_message :: Lens.Lens' CloudComponentStatus (Prelude.Maybe Prelude.Text)
cloudComponentStatus_message :: (Maybe Text -> f (Maybe Text))
-> CloudComponentStatus -> f CloudComponentStatus
cloudComponentStatus_message = (CloudComponentStatus -> Maybe Text)
-> (CloudComponentStatus -> Maybe Text -> CloudComponentStatus)
-> Lens
     CloudComponentStatus CloudComponentStatus (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudComponentStatus' {Maybe Text
message :: Maybe Text
$sel:message:CloudComponentStatus' :: CloudComponentStatus -> Maybe Text
message} -> Maybe Text
message) (\s :: CloudComponentStatus
s@CloudComponentStatus' {} Maybe Text
a -> CloudComponentStatus
s {$sel:message:CloudComponentStatus' :: Maybe Text
message = Maybe Text
a} :: CloudComponentStatus)

-- | A dictionary of errors that communicate why the component is in an error
-- state. For example, if IoT Greengrass can\'t access an artifact for the
-- component, then @errors@ contains the artifact\'s URI as a key, and the
-- error message as the value for that key.
cloudComponentStatus_errors :: Lens.Lens' CloudComponentStatus (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
cloudComponentStatus_errors :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CloudComponentStatus -> f CloudComponentStatus
cloudComponentStatus_errors = (CloudComponentStatus -> Maybe (HashMap Text Text))
-> (CloudComponentStatus
    -> Maybe (HashMap Text Text) -> CloudComponentStatus)
-> Lens
     CloudComponentStatus
     CloudComponentStatus
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudComponentStatus' {Maybe (HashMap Text Text)
errors :: Maybe (HashMap Text Text)
$sel:errors:CloudComponentStatus' :: CloudComponentStatus -> Maybe (HashMap Text Text)
errors} -> Maybe (HashMap Text Text)
errors) (\s :: CloudComponentStatus
s@CloudComponentStatus' {} Maybe (HashMap Text Text)
a -> CloudComponentStatus
s {$sel:errors:CloudComponentStatus' :: Maybe (HashMap Text Text)
errors = Maybe (HashMap Text Text)
a} :: CloudComponentStatus) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CloudComponentStatus -> f CloudComponentStatus)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CloudComponentStatus
-> f CloudComponentStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON CloudComponentStatus where
  parseJSON :: Value -> Parser CloudComponentStatus
parseJSON =
    String
-> (Object -> Parser CloudComponentStatus)
-> Value
-> Parser CloudComponentStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CloudComponentStatus"
      ( \Object
x ->
          Maybe CloudComponentState
-> Maybe Text -> Maybe (HashMap Text Text) -> CloudComponentStatus
CloudComponentStatus'
            (Maybe CloudComponentState
 -> Maybe Text -> Maybe (HashMap Text Text) -> CloudComponentStatus)
-> Parser (Maybe CloudComponentState)
-> Parser
     (Maybe Text -> Maybe (HashMap Text Text) -> CloudComponentStatus)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe CloudComponentState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"componentState")
            Parser
  (Maybe Text -> Maybe (HashMap Text Text) -> CloudComponentStatus)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text Text) -> CloudComponentStatus)
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
"message")
            Parser (Maybe (HashMap Text Text) -> CloudComponentStatus)
-> Parser (Maybe (HashMap Text Text))
-> Parser CloudComponentStatus
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"errors" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable CloudComponentStatus

instance Prelude.NFData CloudComponentStatus