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

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.AssetModelState
import Amazonka.IoTSiteWise.Types.ErrorDetails
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains current status information for an asset model. For more
-- information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/asset-and-model-states.html Asset and model states>
-- in the /IoT SiteWise User Guide/.
--
-- /See:/ 'newAssetModelStatus' smart constructor.
data AssetModelStatus = AssetModelStatus'
  { -- | Contains associated error information, if any.
    AssetModelStatus -> Maybe ErrorDetails
error :: Prelude.Maybe ErrorDetails,
    -- | The current state of the asset model.
    AssetModelStatus -> AssetModelState
state :: AssetModelState
  }
  deriving (AssetModelStatus -> AssetModelStatus -> Bool
(AssetModelStatus -> AssetModelStatus -> Bool)
-> (AssetModelStatus -> AssetModelStatus -> Bool)
-> Eq AssetModelStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetModelStatus -> AssetModelStatus -> Bool
$c/= :: AssetModelStatus -> AssetModelStatus -> Bool
== :: AssetModelStatus -> AssetModelStatus -> Bool
$c== :: AssetModelStatus -> AssetModelStatus -> Bool
Prelude.Eq, ReadPrec [AssetModelStatus]
ReadPrec AssetModelStatus
Int -> ReadS AssetModelStatus
ReadS [AssetModelStatus]
(Int -> ReadS AssetModelStatus)
-> ReadS [AssetModelStatus]
-> ReadPrec AssetModelStatus
-> ReadPrec [AssetModelStatus]
-> Read AssetModelStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetModelStatus]
$creadListPrec :: ReadPrec [AssetModelStatus]
readPrec :: ReadPrec AssetModelStatus
$creadPrec :: ReadPrec AssetModelStatus
readList :: ReadS [AssetModelStatus]
$creadList :: ReadS [AssetModelStatus]
readsPrec :: Int -> ReadS AssetModelStatus
$creadsPrec :: Int -> ReadS AssetModelStatus
Prelude.Read, Int -> AssetModelStatus -> ShowS
[AssetModelStatus] -> ShowS
AssetModelStatus -> String
(Int -> AssetModelStatus -> ShowS)
-> (AssetModelStatus -> String)
-> ([AssetModelStatus] -> ShowS)
-> Show AssetModelStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetModelStatus] -> ShowS
$cshowList :: [AssetModelStatus] -> ShowS
show :: AssetModelStatus -> String
$cshow :: AssetModelStatus -> String
showsPrec :: Int -> AssetModelStatus -> ShowS
$cshowsPrec :: Int -> AssetModelStatus -> ShowS
Prelude.Show, (forall x. AssetModelStatus -> Rep AssetModelStatus x)
-> (forall x. Rep AssetModelStatus x -> AssetModelStatus)
-> Generic AssetModelStatus
forall x. Rep AssetModelStatus x -> AssetModelStatus
forall x. AssetModelStatus -> Rep AssetModelStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssetModelStatus x -> AssetModelStatus
$cfrom :: forall x. AssetModelStatus -> Rep AssetModelStatus x
Prelude.Generic)

-- |
-- Create a value of 'AssetModelStatus' 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', 'assetModelStatus_error' - Contains associated error information, if any.
--
-- 'state', 'assetModelStatus_state' - The current state of the asset model.
newAssetModelStatus ::
  -- | 'state'
  AssetModelState ->
  AssetModelStatus
newAssetModelStatus :: AssetModelState -> AssetModelStatus
newAssetModelStatus AssetModelState
pState_ =
  AssetModelStatus' :: Maybe ErrorDetails -> AssetModelState -> AssetModelStatus
AssetModelStatus'
    { $sel:error:AssetModelStatus' :: Maybe ErrorDetails
error = Maybe ErrorDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:state:AssetModelStatus' :: AssetModelState
state = AssetModelState
pState_
    }

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

-- | The current state of the asset model.
assetModelStatus_state :: Lens.Lens' AssetModelStatus AssetModelState
assetModelStatus_state :: (AssetModelState -> f AssetModelState)
-> AssetModelStatus -> f AssetModelStatus
assetModelStatus_state = (AssetModelStatus -> AssetModelState)
-> (AssetModelStatus -> AssetModelState -> AssetModelStatus)
-> Lens
     AssetModelStatus AssetModelStatus AssetModelState AssetModelState
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelStatus' {AssetModelState
state :: AssetModelState
$sel:state:AssetModelStatus' :: AssetModelStatus -> AssetModelState
state} -> AssetModelState
state) (\s :: AssetModelStatus
s@AssetModelStatus' {} AssetModelState
a -> AssetModelStatus
s {$sel:state:AssetModelStatus' :: AssetModelState
state = AssetModelState
a} :: AssetModelStatus)

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

instance Prelude.Hashable AssetModelStatus

instance Prelude.NFData AssetModelStatus