{-# 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.DevOpsGuru.Types.ServiceHealth
-- 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.DevOpsGuru.Types.ServiceHealth where

import qualified Amazonka.Core as Core
import Amazonka.DevOpsGuru.Types.ServiceInsightHealth
import Amazonka.DevOpsGuru.Types.ServiceName
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents the health of an AWS service.
--
-- /See:/ 'newServiceHealth' smart constructor.
data ServiceHealth = ServiceHealth'
  { -- | Represents the health of an AWS service. This is a
    -- @ServiceInsightHealth@ that contains the number of open proactive and
    -- reactive insights for this service.
    ServiceHealth -> Maybe ServiceInsightHealth
insight :: Prelude.Maybe ServiceInsightHealth,
    -- | The name of the AWS service.
    ServiceHealth -> Maybe ServiceName
serviceName :: Prelude.Maybe ServiceName
  }
  deriving (ServiceHealth -> ServiceHealth -> Bool
(ServiceHealth -> ServiceHealth -> Bool)
-> (ServiceHealth -> ServiceHealth -> Bool) -> Eq ServiceHealth
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServiceHealth -> ServiceHealth -> Bool
$c/= :: ServiceHealth -> ServiceHealth -> Bool
== :: ServiceHealth -> ServiceHealth -> Bool
$c== :: ServiceHealth -> ServiceHealth -> Bool
Prelude.Eq, ReadPrec [ServiceHealth]
ReadPrec ServiceHealth
Int -> ReadS ServiceHealth
ReadS [ServiceHealth]
(Int -> ReadS ServiceHealth)
-> ReadS [ServiceHealth]
-> ReadPrec ServiceHealth
-> ReadPrec [ServiceHealth]
-> Read ServiceHealth
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServiceHealth]
$creadListPrec :: ReadPrec [ServiceHealth]
readPrec :: ReadPrec ServiceHealth
$creadPrec :: ReadPrec ServiceHealth
readList :: ReadS [ServiceHealth]
$creadList :: ReadS [ServiceHealth]
readsPrec :: Int -> ReadS ServiceHealth
$creadsPrec :: Int -> ReadS ServiceHealth
Prelude.Read, Int -> ServiceHealth -> ShowS
[ServiceHealth] -> ShowS
ServiceHealth -> String
(Int -> ServiceHealth -> ShowS)
-> (ServiceHealth -> String)
-> ([ServiceHealth] -> ShowS)
-> Show ServiceHealth
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServiceHealth] -> ShowS
$cshowList :: [ServiceHealth] -> ShowS
show :: ServiceHealth -> String
$cshow :: ServiceHealth -> String
showsPrec :: Int -> ServiceHealth -> ShowS
$cshowsPrec :: Int -> ServiceHealth -> ShowS
Prelude.Show, (forall x. ServiceHealth -> Rep ServiceHealth x)
-> (forall x. Rep ServiceHealth x -> ServiceHealth)
-> Generic ServiceHealth
forall x. Rep ServiceHealth x -> ServiceHealth
forall x. ServiceHealth -> Rep ServiceHealth x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ServiceHealth x -> ServiceHealth
$cfrom :: forall x. ServiceHealth -> Rep ServiceHealth x
Prelude.Generic)

-- |
-- Create a value of 'ServiceHealth' 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:
--
-- 'insight', 'serviceHealth_insight' - Represents the health of an AWS service. This is a
-- @ServiceInsightHealth@ that contains the number of open proactive and
-- reactive insights for this service.
--
-- 'serviceName', 'serviceHealth_serviceName' - The name of the AWS service.
newServiceHealth ::
  ServiceHealth
newServiceHealth :: ServiceHealth
newServiceHealth =
  ServiceHealth' :: Maybe ServiceInsightHealth -> Maybe ServiceName -> ServiceHealth
ServiceHealth'
    { $sel:insight:ServiceHealth' :: Maybe ServiceInsightHealth
insight = Maybe ServiceInsightHealth
forall a. Maybe a
Prelude.Nothing,
      $sel:serviceName:ServiceHealth' :: Maybe ServiceName
serviceName = Maybe ServiceName
forall a. Maybe a
Prelude.Nothing
    }

-- | Represents the health of an AWS service. This is a
-- @ServiceInsightHealth@ that contains the number of open proactive and
-- reactive insights for this service.
serviceHealth_insight :: Lens.Lens' ServiceHealth (Prelude.Maybe ServiceInsightHealth)
serviceHealth_insight :: (Maybe ServiceInsightHealth -> f (Maybe ServiceInsightHealth))
-> ServiceHealth -> f ServiceHealth
serviceHealth_insight = (ServiceHealth -> Maybe ServiceInsightHealth)
-> (ServiceHealth -> Maybe ServiceInsightHealth -> ServiceHealth)
-> Lens
     ServiceHealth
     ServiceHealth
     (Maybe ServiceInsightHealth)
     (Maybe ServiceInsightHealth)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceHealth' {Maybe ServiceInsightHealth
insight :: Maybe ServiceInsightHealth
$sel:insight:ServiceHealth' :: ServiceHealth -> Maybe ServiceInsightHealth
insight} -> Maybe ServiceInsightHealth
insight) (\s :: ServiceHealth
s@ServiceHealth' {} Maybe ServiceInsightHealth
a -> ServiceHealth
s {$sel:insight:ServiceHealth' :: Maybe ServiceInsightHealth
insight = Maybe ServiceInsightHealth
a} :: ServiceHealth)

-- | The name of the AWS service.
serviceHealth_serviceName :: Lens.Lens' ServiceHealth (Prelude.Maybe ServiceName)
serviceHealth_serviceName :: (Maybe ServiceName -> f (Maybe ServiceName))
-> ServiceHealth -> f ServiceHealth
serviceHealth_serviceName = (ServiceHealth -> Maybe ServiceName)
-> (ServiceHealth -> Maybe ServiceName -> ServiceHealth)
-> Lens
     ServiceHealth ServiceHealth (Maybe ServiceName) (Maybe ServiceName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceHealth' {Maybe ServiceName
serviceName :: Maybe ServiceName
$sel:serviceName:ServiceHealth' :: ServiceHealth -> Maybe ServiceName
serviceName} -> Maybe ServiceName
serviceName) (\s :: ServiceHealth
s@ServiceHealth' {} Maybe ServiceName
a -> ServiceHealth
s {$sel:serviceName:ServiceHealth' :: Maybe ServiceName
serviceName = Maybe ServiceName
a} :: ServiceHealth)

instance Core.FromJSON ServiceHealth where
  parseJSON :: Value -> Parser ServiceHealth
parseJSON =
    String
-> (Object -> Parser ServiceHealth)
-> Value
-> Parser ServiceHealth
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ServiceHealth"
      ( \Object
x ->
          Maybe ServiceInsightHealth -> Maybe ServiceName -> ServiceHealth
ServiceHealth'
            (Maybe ServiceInsightHealth -> Maybe ServiceName -> ServiceHealth)
-> Parser (Maybe ServiceInsightHealth)
-> Parser (Maybe ServiceName -> ServiceHealth)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ServiceInsightHealth)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Insight")
            Parser (Maybe ServiceName -> ServiceHealth)
-> Parser (Maybe ServiceName) -> Parser ServiceHealth
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ServiceName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ServiceName")
      )

instance Prelude.Hashable ServiceHealth

instance Prelude.NFData ServiceHealth