{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.XRay.Types.ResponseTimeRootCause where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:clientImpacting:ResponseTimeRootCause' :: Maybe Bool
clientImpacting =
        forall a. Maybe a
Prelude.Nothing,
      $sel:services:ResponseTimeRootCause' :: Maybe [ResponseTimeRootCauseService]
services = 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 :: Lens' ResponseTimeRootCause (Maybe Bool)
responseTimeRootCause_clientImpacting = 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 :: Lens' ResponseTimeRootCause (Maybe [ResponseTimeRootCauseService])
responseTimeRootCause_services = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ResponseTimeRootCause where
  parseJSON :: Value -> Parser ResponseTimeRootCause
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResponseTimeRootCause"
      ( \Object
x ->
          Maybe Bool
-> Maybe [ResponseTimeRootCauseService] -> ResponseTimeRootCause
ResponseTimeRootCause'
            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
"ClientImpacting")
            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
"Services" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ResponseTimeRootCause where
  hashWithSalt :: Int -> ResponseTimeRootCause -> Int
hashWithSalt Int
_salt ResponseTimeRootCause' {Maybe Bool
Maybe [ResponseTimeRootCauseService]
services :: Maybe [ResponseTimeRootCauseService]
clientImpacting :: Maybe Bool
$sel:services:ResponseTimeRootCause' :: ResponseTimeRootCause -> Maybe [ResponseTimeRootCauseService]
$sel:clientImpacting:ResponseTimeRootCause' :: ResponseTimeRootCause -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
clientImpacting
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ResponseTimeRootCauseService]
services

instance Prelude.NFData ResponseTimeRootCause where
  rnf :: ResponseTimeRootCause -> ()
rnf ResponseTimeRootCause' {Maybe Bool
Maybe [ResponseTimeRootCauseService]
services :: Maybe [ResponseTimeRootCauseService]
clientImpacting :: Maybe Bool
$sel:services:ResponseTimeRootCause' :: ResponseTimeRootCause -> Maybe [ResponseTimeRootCauseService]
$sel:clientImpacting:ResponseTimeRootCause' :: ResponseTimeRootCause -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
clientImpacting
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ResponseTimeRootCauseService]
services