{-# 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.XRay.Types.ResponseTimeRootCause
-- 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.XRay.Types.ResponseTimeRootCause where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.XRay.Types.ResponseTimeRootCauseService

-- | The root cause information for a response time warning.
--
-- /See:/ 'newResponseTimeRootCause' smart constructor.
data ResponseTimeRootCause = ResponseTimeRootCause'
  { -- | A flag that denotes that the root cause impacts the trace client.
    ResponseTimeRootCause -> Maybe Bool
clientImpacting :: Prelude.Maybe Prelude.Bool,
    -- | A list of corresponding services. A service identifies a segment and
    -- contains a name, account ID, type, and inferred flag.
    ResponseTimeRootCause -> Maybe [ResponseTimeRootCauseService]
services :: Prelude.Maybe [ResponseTimeRootCauseService]
  }
  deriving (ResponseTimeRootCause -> ResponseTimeRootCause -> Bool
(ResponseTimeRootCause -> ResponseTimeRootCause -> Bool)
-> (ResponseTimeRootCause -> ResponseTimeRootCause -> Bool)
-> Eq ResponseTimeRootCause
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResponseTimeRootCause -> ResponseTimeRootCause -> Bool
$c/= :: ResponseTimeRootCause -> ResponseTimeRootCause -> Bool
== :: ResponseTimeRootCause -> ResponseTimeRootCause -> Bool
$c== :: ResponseTimeRootCause -> ResponseTimeRootCause -> Bool
Prelude.Eq, ReadPrec [ResponseTimeRootCause]
ReadPrec ResponseTimeRootCause
Int -> ReadS ResponseTimeRootCause
ReadS [ResponseTimeRootCause]
(Int -> ReadS ResponseTimeRootCause)
-> ReadS [ResponseTimeRootCause]
-> ReadPrec ResponseTimeRootCause
-> ReadPrec [ResponseTimeRootCause]
-> Read ResponseTimeRootCause
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResponseTimeRootCause]
$creadListPrec :: ReadPrec [ResponseTimeRootCause]
readPrec :: ReadPrec ResponseTimeRootCause
$creadPrec :: ReadPrec ResponseTimeRootCause
readList :: ReadS [ResponseTimeRootCause]
$creadList :: ReadS [ResponseTimeRootCause]
readsPrec :: Int -> ReadS ResponseTimeRootCause
$creadsPrec :: Int -> ReadS ResponseTimeRootCause
Prelude.Read, Int -> ResponseTimeRootCause -> ShowS
[ResponseTimeRootCause] -> ShowS
ResponseTimeRootCause -> String
(Int -> ResponseTimeRootCause -> ShowS)
-> (ResponseTimeRootCause -> String)
-> ([ResponseTimeRootCause] -> ShowS)
-> Show ResponseTimeRootCause
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResponseTimeRootCause] -> ShowS
$cshowList :: [ResponseTimeRootCause] -> ShowS
show :: ResponseTimeRootCause -> String
$cshow :: ResponseTimeRootCause -> String
showsPrec :: Int -> ResponseTimeRootCause -> ShowS
$cshowsPrec :: Int -> ResponseTimeRootCause -> ShowS
Prelude.Show, (forall x. ResponseTimeRootCause -> Rep ResponseTimeRootCause x)
-> (forall x. Rep ResponseTimeRootCause x -> ResponseTimeRootCause)
-> Generic ResponseTimeRootCause
forall x. Rep ResponseTimeRootCause x -> ResponseTimeRootCause
forall x. ResponseTimeRootCause -> Rep ResponseTimeRootCause x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResponseTimeRootCause x -> ResponseTimeRootCause
$cfrom :: forall x. ResponseTimeRootCause -> Rep ResponseTimeRootCause x
Prelude.Generic)

-- |
-- Create a value of 'ResponseTimeRootCause' 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:
--
-- 'clientImpacting', 'responseTimeRootCause_clientImpacting' - A flag that denotes that the root cause impacts the trace client.
--
-- 'services', 'responseTimeRootCause_services' - A list of corresponding services. A service identifies a segment and
-- contains a name, account ID, type, and inferred flag.
newResponseTimeRootCause ::
  ResponseTimeRootCause
newResponseTimeRootCause :: ResponseTimeRootCause
newResponseTimeRootCause =
  ResponseTimeRootCause' :: Maybe Bool
-> Maybe [ResponseTimeRootCauseService] -> ResponseTimeRootCause
ResponseTimeRootCause'
    { $sel:clientImpacting:ResponseTimeRootCause' :: Maybe Bool
clientImpacting =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:services:ResponseTimeRootCause' :: Maybe [ResponseTimeRootCauseService]
services = Maybe [ResponseTimeRootCauseService]
forall a. Maybe a
Prelude.Nothing
    }

-- | A flag that denotes that the root cause impacts the trace client.
responseTimeRootCause_clientImpacting :: Lens.Lens' ResponseTimeRootCause (Prelude.Maybe Prelude.Bool)
responseTimeRootCause_clientImpacting :: (Maybe Bool -> f (Maybe Bool))
-> ResponseTimeRootCause -> f ResponseTimeRootCause
responseTimeRootCause_clientImpacting = (ResponseTimeRootCause -> Maybe Bool)
-> (ResponseTimeRootCause -> Maybe Bool -> ResponseTimeRootCause)
-> Lens
     ResponseTimeRootCause
     ResponseTimeRootCause
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseTimeRootCause' {Maybe Bool
clientImpacting :: Maybe Bool
$sel:clientImpacting:ResponseTimeRootCause' :: ResponseTimeRootCause -> Maybe Bool
clientImpacting} -> Maybe Bool
clientImpacting) (\s :: ResponseTimeRootCause
s@ResponseTimeRootCause' {} Maybe Bool
a -> ResponseTimeRootCause
s {$sel:clientImpacting:ResponseTimeRootCause' :: Maybe Bool
clientImpacting = Maybe Bool
a} :: ResponseTimeRootCause)

-- | A list of corresponding services. A service identifies a segment and
-- contains a name, account ID, type, and inferred flag.
responseTimeRootCause_services :: Lens.Lens' ResponseTimeRootCause (Prelude.Maybe [ResponseTimeRootCauseService])
responseTimeRootCause_services :: (Maybe [ResponseTimeRootCauseService]
 -> f (Maybe [ResponseTimeRootCauseService]))
-> ResponseTimeRootCause -> f ResponseTimeRootCause
responseTimeRootCause_services = (ResponseTimeRootCause -> Maybe [ResponseTimeRootCauseService])
-> (ResponseTimeRootCause
    -> Maybe [ResponseTimeRootCauseService] -> ResponseTimeRootCause)
-> Lens
     ResponseTimeRootCause
     ResponseTimeRootCause
     (Maybe [ResponseTimeRootCauseService])
     (Maybe [ResponseTimeRootCauseService])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseTimeRootCause' {Maybe [ResponseTimeRootCauseService]
services :: Maybe [ResponseTimeRootCauseService]
$sel:services:ResponseTimeRootCause' :: ResponseTimeRootCause -> Maybe [ResponseTimeRootCauseService]
services} -> Maybe [ResponseTimeRootCauseService]
services) (\s :: ResponseTimeRootCause
s@ResponseTimeRootCause' {} Maybe [ResponseTimeRootCauseService]
a -> ResponseTimeRootCause
s {$sel:services:ResponseTimeRootCause' :: Maybe [ResponseTimeRootCauseService]
services = Maybe [ResponseTimeRootCauseService]
a} :: ResponseTimeRootCause) ((Maybe [ResponseTimeRootCauseService]
  -> f (Maybe [ResponseTimeRootCauseService]))
 -> ResponseTimeRootCause -> f ResponseTimeRootCause)
-> ((Maybe [ResponseTimeRootCauseService]
     -> f (Maybe [ResponseTimeRootCauseService]))
    -> Maybe [ResponseTimeRootCauseService]
    -> f (Maybe [ResponseTimeRootCauseService]))
-> (Maybe [ResponseTimeRootCauseService]
    -> f (Maybe [ResponseTimeRootCauseService]))
-> ResponseTimeRootCause
-> f ResponseTimeRootCause
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ResponseTimeRootCauseService]
  [ResponseTimeRootCauseService]
  [ResponseTimeRootCauseService]
  [ResponseTimeRootCauseService]
-> Iso
     (Maybe [ResponseTimeRootCauseService])
     (Maybe [ResponseTimeRootCauseService])
     (Maybe [ResponseTimeRootCauseService])
     (Maybe [ResponseTimeRootCauseService])
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
  [ResponseTimeRootCauseService]
  [ResponseTimeRootCauseService]
  [ResponseTimeRootCauseService]
  [ResponseTimeRootCauseService]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ResponseTimeRootCause where
  parseJSON :: Value -> Parser ResponseTimeRootCause
parseJSON =
    String
-> (Object -> Parser ResponseTimeRootCause)
-> Value
-> Parser ResponseTimeRootCause
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResponseTimeRootCause"
      ( \Object
x ->
          Maybe Bool
-> Maybe [ResponseTimeRootCauseService] -> ResponseTimeRootCause
ResponseTimeRootCause'
            (Maybe Bool
 -> Maybe [ResponseTimeRootCauseService] -> ResponseTimeRootCause)
-> Parser (Maybe Bool)
-> Parser
     (Maybe [ResponseTimeRootCauseService] -> ResponseTimeRootCause)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ClientImpacting")
            Parser
  (Maybe [ResponseTimeRootCauseService] -> ResponseTimeRootCause)
-> Parser (Maybe [ResponseTimeRootCauseService])
-> Parser ResponseTimeRootCause
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe (Maybe [ResponseTimeRootCauseService]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Services" Parser (Maybe (Maybe [ResponseTimeRootCauseService]))
-> Maybe [ResponseTimeRootCauseService]
-> Parser (Maybe [ResponseTimeRootCauseService])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ResponseTimeRootCauseService]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ResponseTimeRootCause

instance Prelude.NFData ResponseTimeRootCause