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

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

-- | Information about a user recorded in segment documents.
--
-- /See:/ 'newTraceUser' smart constructor.
data TraceUser = TraceUser'
  { -- | Services that the user\'s request hit.
    TraceUser -> Maybe [ServiceId]
serviceIds :: Prelude.Maybe [ServiceId],
    -- | The user\'s name.
    TraceUser -> Maybe Text
userName :: Prelude.Maybe Prelude.Text
  }
  deriving (TraceUser -> TraceUser -> Bool
(TraceUser -> TraceUser -> Bool)
-> (TraceUser -> TraceUser -> Bool) -> Eq TraceUser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TraceUser -> TraceUser -> Bool
$c/= :: TraceUser -> TraceUser -> Bool
== :: TraceUser -> TraceUser -> Bool
$c== :: TraceUser -> TraceUser -> Bool
Prelude.Eq, ReadPrec [TraceUser]
ReadPrec TraceUser
Int -> ReadS TraceUser
ReadS [TraceUser]
(Int -> ReadS TraceUser)
-> ReadS [TraceUser]
-> ReadPrec TraceUser
-> ReadPrec [TraceUser]
-> Read TraceUser
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TraceUser]
$creadListPrec :: ReadPrec [TraceUser]
readPrec :: ReadPrec TraceUser
$creadPrec :: ReadPrec TraceUser
readList :: ReadS [TraceUser]
$creadList :: ReadS [TraceUser]
readsPrec :: Int -> ReadS TraceUser
$creadsPrec :: Int -> ReadS TraceUser
Prelude.Read, Int -> TraceUser -> ShowS
[TraceUser] -> ShowS
TraceUser -> String
(Int -> TraceUser -> ShowS)
-> (TraceUser -> String)
-> ([TraceUser] -> ShowS)
-> Show TraceUser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TraceUser] -> ShowS
$cshowList :: [TraceUser] -> ShowS
show :: TraceUser -> String
$cshow :: TraceUser -> String
showsPrec :: Int -> TraceUser -> ShowS
$cshowsPrec :: Int -> TraceUser -> ShowS
Prelude.Show, (forall x. TraceUser -> Rep TraceUser x)
-> (forall x. Rep TraceUser x -> TraceUser) -> Generic TraceUser
forall x. Rep TraceUser x -> TraceUser
forall x. TraceUser -> Rep TraceUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TraceUser x -> TraceUser
$cfrom :: forall x. TraceUser -> Rep TraceUser x
Prelude.Generic)

-- |
-- Create a value of 'TraceUser' 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:
--
-- 'serviceIds', 'traceUser_serviceIds' - Services that the user\'s request hit.
--
-- 'userName', 'traceUser_userName' - The user\'s name.
newTraceUser ::
  TraceUser
newTraceUser :: TraceUser
newTraceUser =
  TraceUser' :: Maybe [ServiceId] -> Maybe Text -> TraceUser
TraceUser'
    { $sel:serviceIds:TraceUser' :: Maybe [ServiceId]
serviceIds = Maybe [ServiceId]
forall a. Maybe a
Prelude.Nothing,
      $sel:userName:TraceUser' :: Maybe Text
userName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Services that the user\'s request hit.
traceUser_serviceIds :: Lens.Lens' TraceUser (Prelude.Maybe [ServiceId])
traceUser_serviceIds :: (Maybe [ServiceId] -> f (Maybe [ServiceId]))
-> TraceUser -> f TraceUser
traceUser_serviceIds = (TraceUser -> Maybe [ServiceId])
-> (TraceUser -> Maybe [ServiceId] -> TraceUser)
-> Lens TraceUser TraceUser (Maybe [ServiceId]) (Maybe [ServiceId])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TraceUser' {Maybe [ServiceId]
serviceIds :: Maybe [ServiceId]
$sel:serviceIds:TraceUser' :: TraceUser -> Maybe [ServiceId]
serviceIds} -> Maybe [ServiceId]
serviceIds) (\s :: TraceUser
s@TraceUser' {} Maybe [ServiceId]
a -> TraceUser
s {$sel:serviceIds:TraceUser' :: Maybe [ServiceId]
serviceIds = Maybe [ServiceId]
a} :: TraceUser) ((Maybe [ServiceId] -> f (Maybe [ServiceId]))
 -> TraceUser -> f TraceUser)
-> ((Maybe [ServiceId] -> f (Maybe [ServiceId]))
    -> Maybe [ServiceId] -> f (Maybe [ServiceId]))
-> (Maybe [ServiceId] -> f (Maybe [ServiceId]))
-> TraceUser
-> f TraceUser
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ServiceId] [ServiceId] [ServiceId] [ServiceId]
-> Iso
     (Maybe [ServiceId])
     (Maybe [ServiceId])
     (Maybe [ServiceId])
     (Maybe [ServiceId])
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 [ServiceId] [ServiceId] [ServiceId] [ServiceId]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The user\'s name.
traceUser_userName :: Lens.Lens' TraceUser (Prelude.Maybe Prelude.Text)
traceUser_userName :: (Maybe Text -> f (Maybe Text)) -> TraceUser -> f TraceUser
traceUser_userName = (TraceUser -> Maybe Text)
-> (TraceUser -> Maybe Text -> TraceUser)
-> Lens TraceUser TraceUser (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TraceUser' {Maybe Text
userName :: Maybe Text
$sel:userName:TraceUser' :: TraceUser -> Maybe Text
userName} -> Maybe Text
userName) (\s :: TraceUser
s@TraceUser' {} Maybe Text
a -> TraceUser
s {$sel:userName:TraceUser' :: Maybe Text
userName = Maybe Text
a} :: TraceUser)

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

instance Prelude.Hashable TraceUser

instance Prelude.NFData TraceUser