{-# 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.IoTSiteWise.Types.ConfigurationStatus
-- 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.IoTSiteWise.Types.ConfigurationStatus where

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.ConfigurationErrorDetails
import Amazonka.IoTSiteWise.Types.ConfigurationState
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains current status information for the configuration.
--
-- /See:/ 'newConfigurationStatus' smart constructor.
data ConfigurationStatus = ConfigurationStatus'
  { -- | Contains associated error information, if any.
    ConfigurationStatus -> Maybe ConfigurationErrorDetails
error :: Prelude.Maybe ConfigurationErrorDetails,
    -- | The current state of the configuration.
    ConfigurationStatus -> ConfigurationState
state :: ConfigurationState
  }
  deriving (ConfigurationStatus -> ConfigurationStatus -> Bool
(ConfigurationStatus -> ConfigurationStatus -> Bool)
-> (ConfigurationStatus -> ConfigurationStatus -> Bool)
-> Eq ConfigurationStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfigurationStatus -> ConfigurationStatus -> Bool
$c/= :: ConfigurationStatus -> ConfigurationStatus -> Bool
== :: ConfigurationStatus -> ConfigurationStatus -> Bool
$c== :: ConfigurationStatus -> ConfigurationStatus -> Bool
Prelude.Eq, ReadPrec [ConfigurationStatus]
ReadPrec ConfigurationStatus
Int -> ReadS ConfigurationStatus
ReadS [ConfigurationStatus]
(Int -> ReadS ConfigurationStatus)
-> ReadS [ConfigurationStatus]
-> ReadPrec ConfigurationStatus
-> ReadPrec [ConfigurationStatus]
-> Read ConfigurationStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfigurationStatus]
$creadListPrec :: ReadPrec [ConfigurationStatus]
readPrec :: ReadPrec ConfigurationStatus
$creadPrec :: ReadPrec ConfigurationStatus
readList :: ReadS [ConfigurationStatus]
$creadList :: ReadS [ConfigurationStatus]
readsPrec :: Int -> ReadS ConfigurationStatus
$creadsPrec :: Int -> ReadS ConfigurationStatus
Prelude.Read, Int -> ConfigurationStatus -> ShowS
[ConfigurationStatus] -> ShowS
ConfigurationStatus -> String
(Int -> ConfigurationStatus -> ShowS)
-> (ConfigurationStatus -> String)
-> ([ConfigurationStatus] -> ShowS)
-> Show ConfigurationStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfigurationStatus] -> ShowS
$cshowList :: [ConfigurationStatus] -> ShowS
show :: ConfigurationStatus -> String
$cshow :: ConfigurationStatus -> String
showsPrec :: Int -> ConfigurationStatus -> ShowS
$cshowsPrec :: Int -> ConfigurationStatus -> ShowS
Prelude.Show, (forall x. ConfigurationStatus -> Rep ConfigurationStatus x)
-> (forall x. Rep ConfigurationStatus x -> ConfigurationStatus)
-> Generic ConfigurationStatus
forall x. Rep ConfigurationStatus x -> ConfigurationStatus
forall x. ConfigurationStatus -> Rep ConfigurationStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConfigurationStatus x -> ConfigurationStatus
$cfrom :: forall x. ConfigurationStatus -> Rep ConfigurationStatus x
Prelude.Generic)

-- |
-- Create a value of 'ConfigurationStatus' 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:
--
-- 'error', 'configurationStatus_error' - Contains associated error information, if any.
--
-- 'state', 'configurationStatus_state' - The current state of the configuration.
newConfigurationStatus ::
  -- | 'state'
  ConfigurationState ->
  ConfigurationStatus
newConfigurationStatus :: ConfigurationState -> ConfigurationStatus
newConfigurationStatus ConfigurationState
pState_ =
  ConfigurationStatus' :: Maybe ConfigurationErrorDetails
-> ConfigurationState -> ConfigurationStatus
ConfigurationStatus'
    { $sel:error:ConfigurationStatus' :: Maybe ConfigurationErrorDetails
error = Maybe ConfigurationErrorDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:state:ConfigurationStatus' :: ConfigurationState
state = ConfigurationState
pState_
    }

-- | Contains associated error information, if any.
configurationStatus_error :: Lens.Lens' ConfigurationStatus (Prelude.Maybe ConfigurationErrorDetails)
configurationStatus_error :: (Maybe ConfigurationErrorDetails
 -> f (Maybe ConfigurationErrorDetails))
-> ConfigurationStatus -> f ConfigurationStatus
configurationStatus_error = (ConfigurationStatus -> Maybe ConfigurationErrorDetails)
-> (ConfigurationStatus
    -> Maybe ConfigurationErrorDetails -> ConfigurationStatus)
-> Lens
     ConfigurationStatus
     ConfigurationStatus
     (Maybe ConfigurationErrorDetails)
     (Maybe ConfigurationErrorDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationStatus' {Maybe ConfigurationErrorDetails
error :: Maybe ConfigurationErrorDetails
$sel:error:ConfigurationStatus' :: ConfigurationStatus -> Maybe ConfigurationErrorDetails
error} -> Maybe ConfigurationErrorDetails
error) (\s :: ConfigurationStatus
s@ConfigurationStatus' {} Maybe ConfigurationErrorDetails
a -> ConfigurationStatus
s {$sel:error:ConfigurationStatus' :: Maybe ConfigurationErrorDetails
error = Maybe ConfigurationErrorDetails
a} :: ConfigurationStatus)

-- | The current state of the configuration.
configurationStatus_state :: Lens.Lens' ConfigurationStatus ConfigurationState
configurationStatus_state :: (ConfigurationState -> f ConfigurationState)
-> ConfigurationStatus -> f ConfigurationStatus
configurationStatus_state = (ConfigurationStatus -> ConfigurationState)
-> (ConfigurationStatus
    -> ConfigurationState -> ConfigurationStatus)
-> Lens
     ConfigurationStatus
     ConfigurationStatus
     ConfigurationState
     ConfigurationState
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationStatus' {ConfigurationState
state :: ConfigurationState
$sel:state:ConfigurationStatus' :: ConfigurationStatus -> ConfigurationState
state} -> ConfigurationState
state) (\s :: ConfigurationStatus
s@ConfigurationStatus' {} ConfigurationState
a -> ConfigurationStatus
s {$sel:state:ConfigurationStatus' :: ConfigurationState
state = ConfigurationState
a} :: ConfigurationStatus)

instance Core.FromJSON ConfigurationStatus where
  parseJSON :: Value -> Parser ConfigurationStatus
parseJSON =
    String
-> (Object -> Parser ConfigurationStatus)
-> Value
-> Parser ConfigurationStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConfigurationStatus"
      ( \Object
x ->
          Maybe ConfigurationErrorDetails
-> ConfigurationState -> ConfigurationStatus
ConfigurationStatus'
            (Maybe ConfigurationErrorDetails
 -> ConfigurationState -> ConfigurationStatus)
-> Parser (Maybe ConfigurationErrorDetails)
-> Parser (ConfigurationState -> ConfigurationStatus)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ConfigurationErrorDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"error") Parser (ConfigurationState -> ConfigurationStatus)
-> Parser ConfigurationState -> Parser ConfigurationStatus
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ConfigurationState
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"state")
      )

instance Prelude.Hashable ConfigurationStatus

instance Prelude.NFData ConfigurationStatus