{-# 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.IotTwinMaker.Types.Status
-- 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.IotTwinMaker.Types.Status where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IotTwinMaker.Types.ErrorDetails
import Amazonka.IotTwinMaker.Types.State
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the status of an entity, component, component
-- type, or workspace.
--
-- /See:/ 'newStatus' smart constructor.
data Status = Status'
  { -- | The error message.
    Status -> Maybe ErrorDetails
error :: Prelude.Maybe ErrorDetails,
    -- | The current state of the entity, component, component type, or
    -- workspace.
    Status -> Maybe State
state :: Prelude.Maybe State
  }
  deriving (Status -> Status -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Status -> Status -> Bool
$c/= :: Status -> Status -> Bool
== :: Status -> Status -> Bool
$c== :: Status -> Status -> Bool
Prelude.Eq, ReadPrec [Status]
ReadPrec Status
Int -> ReadS Status
ReadS [Status]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Status]
$creadListPrec :: ReadPrec [Status]
readPrec :: ReadPrec Status
$creadPrec :: ReadPrec Status
readList :: ReadS [Status]
$creadList :: ReadS [Status]
readsPrec :: Int -> ReadS Status
$creadsPrec :: Int -> ReadS Status
Prelude.Read, Int -> Status -> ShowS
[Status] -> ShowS
Status -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Status] -> ShowS
$cshowList :: [Status] -> ShowS
show :: Status -> String
$cshow :: Status -> String
showsPrec :: Int -> Status -> ShowS
$cshowsPrec :: Int -> Status -> ShowS
Prelude.Show, forall x. Rep Status x -> Status
forall x. Status -> Rep Status x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Status x -> Status
$cfrom :: forall x. Status -> Rep Status x
Prelude.Generic)

-- |
-- Create a value of 'Status' 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', 'status_error' - The error message.
--
-- 'state', 'status_state' - The current state of the entity, component, component type, or
-- workspace.
newStatus ::
  Status
newStatus :: Status
newStatus =
  Status'
    { $sel:error:Status' :: Maybe ErrorDetails
error = forall a. Maybe a
Prelude.Nothing,
      $sel:state:Status' :: Maybe State
state = forall a. Maybe a
Prelude.Nothing
    }

-- | The error message.
status_error :: Lens.Lens' Status (Prelude.Maybe ErrorDetails)
status_error :: Lens' Status (Maybe ErrorDetails)
status_error = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Status' {Maybe ErrorDetails
error :: Maybe ErrorDetails
$sel:error:Status' :: Status -> Maybe ErrorDetails
error} -> Maybe ErrorDetails
error) (\s :: Status
s@Status' {} Maybe ErrorDetails
a -> Status
s {$sel:error:Status' :: Maybe ErrorDetails
error = Maybe ErrorDetails
a} :: Status)

-- | The current state of the entity, component, component type, or
-- workspace.
status_state :: Lens.Lens' Status (Prelude.Maybe State)
status_state :: Lens' Status (Maybe State)
status_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Status' {Maybe State
state :: Maybe State
$sel:state:Status' :: Status -> Maybe State
state} -> Maybe State
state) (\s :: Status
s@Status' {} Maybe State
a -> Status
s {$sel:state:Status' :: Maybe State
state = Maybe State
a} :: Status)

instance Data.FromJSON Status where
  parseJSON :: Value -> Parser Status
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Status"
      ( \Object
x ->
          Maybe ErrorDetails -> Maybe State -> Status
Status'
            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
"error")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"state")
      )

instance Prelude.Hashable Status where
  hashWithSalt :: Int -> Status -> Int
hashWithSalt Int
_salt Status' {Maybe ErrorDetails
Maybe State
state :: Maybe State
error :: Maybe ErrorDetails
$sel:state:Status' :: Status -> Maybe State
$sel:error:Status' :: Status -> Maybe ErrorDetails
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ErrorDetails
error
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe State
state

instance Prelude.NFData Status where
  rnf :: Status -> ()
rnf Status' {Maybe ErrorDetails
Maybe State
state :: Maybe State
error :: Maybe ErrorDetails
$sel:state:Status' :: Status -> Maybe State
$sel:error:Status' :: Status -> Maybe ErrorDetails
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ErrorDetails
error seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe State
state