{-# 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.ValueWithServiceIds
-- 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.ValueWithServiceIds 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.AnnotationValue
import Amazonka.XRay.Types.ServiceId

-- | Information about a segment annotation.
--
-- /See:/ 'newValueWithServiceIds' smart constructor.
data ValueWithServiceIds = ValueWithServiceIds'
  { -- | Values of the annotation.
    ValueWithServiceIds -> Maybe AnnotationValue
annotationValue :: Prelude.Maybe AnnotationValue,
    -- | Services to which the annotation applies.
    ValueWithServiceIds -> Maybe [ServiceId]
serviceIds :: Prelude.Maybe [ServiceId]
  }
  deriving (ValueWithServiceIds -> ValueWithServiceIds -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ValueWithServiceIds -> ValueWithServiceIds -> Bool
$c/= :: ValueWithServiceIds -> ValueWithServiceIds -> Bool
== :: ValueWithServiceIds -> ValueWithServiceIds -> Bool
$c== :: ValueWithServiceIds -> ValueWithServiceIds -> Bool
Prelude.Eq, ReadPrec [ValueWithServiceIds]
ReadPrec ValueWithServiceIds
Int -> ReadS ValueWithServiceIds
ReadS [ValueWithServiceIds]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ValueWithServiceIds]
$creadListPrec :: ReadPrec [ValueWithServiceIds]
readPrec :: ReadPrec ValueWithServiceIds
$creadPrec :: ReadPrec ValueWithServiceIds
readList :: ReadS [ValueWithServiceIds]
$creadList :: ReadS [ValueWithServiceIds]
readsPrec :: Int -> ReadS ValueWithServiceIds
$creadsPrec :: Int -> ReadS ValueWithServiceIds
Prelude.Read, Int -> ValueWithServiceIds -> ShowS
[ValueWithServiceIds] -> ShowS
ValueWithServiceIds -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ValueWithServiceIds] -> ShowS
$cshowList :: [ValueWithServiceIds] -> ShowS
show :: ValueWithServiceIds -> String
$cshow :: ValueWithServiceIds -> String
showsPrec :: Int -> ValueWithServiceIds -> ShowS
$cshowsPrec :: Int -> ValueWithServiceIds -> ShowS
Prelude.Show, forall x. Rep ValueWithServiceIds x -> ValueWithServiceIds
forall x. ValueWithServiceIds -> Rep ValueWithServiceIds x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ValueWithServiceIds x -> ValueWithServiceIds
$cfrom :: forall x. ValueWithServiceIds -> Rep ValueWithServiceIds x
Prelude.Generic)

-- |
-- Create a value of 'ValueWithServiceIds' 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:
--
-- 'annotationValue', 'valueWithServiceIds_annotationValue' - Values of the annotation.
--
-- 'serviceIds', 'valueWithServiceIds_serviceIds' - Services to which the annotation applies.
newValueWithServiceIds ::
  ValueWithServiceIds
newValueWithServiceIds :: ValueWithServiceIds
newValueWithServiceIds =
  ValueWithServiceIds'
    { $sel:annotationValue:ValueWithServiceIds' :: Maybe AnnotationValue
annotationValue =
        forall a. Maybe a
Prelude.Nothing,
      $sel:serviceIds:ValueWithServiceIds' :: Maybe [ServiceId]
serviceIds = forall a. Maybe a
Prelude.Nothing
    }

-- | Values of the annotation.
valueWithServiceIds_annotationValue :: Lens.Lens' ValueWithServiceIds (Prelude.Maybe AnnotationValue)
valueWithServiceIds_annotationValue :: Lens' ValueWithServiceIds (Maybe AnnotationValue)
valueWithServiceIds_annotationValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValueWithServiceIds' {Maybe AnnotationValue
annotationValue :: Maybe AnnotationValue
$sel:annotationValue:ValueWithServiceIds' :: ValueWithServiceIds -> Maybe AnnotationValue
annotationValue} -> Maybe AnnotationValue
annotationValue) (\s :: ValueWithServiceIds
s@ValueWithServiceIds' {} Maybe AnnotationValue
a -> ValueWithServiceIds
s {$sel:annotationValue:ValueWithServiceIds' :: Maybe AnnotationValue
annotationValue = Maybe AnnotationValue
a} :: ValueWithServiceIds)

-- | Services to which the annotation applies.
valueWithServiceIds_serviceIds :: Lens.Lens' ValueWithServiceIds (Prelude.Maybe [ServiceId])
valueWithServiceIds_serviceIds :: Lens' ValueWithServiceIds (Maybe [ServiceId])
valueWithServiceIds_serviceIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValueWithServiceIds' {Maybe [ServiceId]
serviceIds :: Maybe [ServiceId]
$sel:serviceIds:ValueWithServiceIds' :: ValueWithServiceIds -> Maybe [ServiceId]
serviceIds} -> Maybe [ServiceId]
serviceIds) (\s :: ValueWithServiceIds
s@ValueWithServiceIds' {} Maybe [ServiceId]
a -> ValueWithServiceIds
s {$sel:serviceIds:ValueWithServiceIds' :: Maybe [ServiceId]
serviceIds = Maybe [ServiceId]
a} :: ValueWithServiceIds) 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 ValueWithServiceIds where
  parseJSON :: Value -> Parser ValueWithServiceIds
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ValueWithServiceIds"
      ( \Object
x ->
          Maybe AnnotationValue -> Maybe [ServiceId] -> ValueWithServiceIds
ValueWithServiceIds'
            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
"AnnotationValue")
            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
"ServiceIds" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ValueWithServiceIds where
  hashWithSalt :: Int -> ValueWithServiceIds -> Int
hashWithSalt Int
_salt ValueWithServiceIds' {Maybe [ServiceId]
Maybe AnnotationValue
serviceIds :: Maybe [ServiceId]
annotationValue :: Maybe AnnotationValue
$sel:serviceIds:ValueWithServiceIds' :: ValueWithServiceIds -> Maybe [ServiceId]
$sel:annotationValue:ValueWithServiceIds' :: ValueWithServiceIds -> Maybe AnnotationValue
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AnnotationValue
annotationValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ServiceId]
serviceIds

instance Prelude.NFData ValueWithServiceIds where
  rnf :: ValueWithServiceIds -> ()
rnf ValueWithServiceIds' {Maybe [ServiceId]
Maybe AnnotationValue
serviceIds :: Maybe [ServiceId]
annotationValue :: Maybe AnnotationValue
$sel:serviceIds:ValueWithServiceIds' :: ValueWithServiceIds -> Maybe [ServiceId]
$sel:annotationValue:ValueWithServiceIds' :: ValueWithServiceIds -> Maybe AnnotationValue
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AnnotationValue
annotationValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ServiceId]
serviceIds