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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | Services to which the annotation applies.
    ValueWithServiceIds -> Maybe [ServiceId]
serviceIds :: Prelude.Maybe [ServiceId],
    -- | Values of the annotation.
    ValueWithServiceIds -> Maybe AnnotationValue
annotationValue :: Prelude.Maybe AnnotationValue
  }
  deriving (ValueWithServiceIds -> ValueWithServiceIds -> Bool
(ValueWithServiceIds -> ValueWithServiceIds -> Bool)
-> (ValueWithServiceIds -> ValueWithServiceIds -> Bool)
-> Eq ValueWithServiceIds
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]
(Int -> ReadS ValueWithServiceIds)
-> ReadS [ValueWithServiceIds]
-> ReadPrec ValueWithServiceIds
-> ReadPrec [ValueWithServiceIds]
-> Read 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
(Int -> ValueWithServiceIds -> ShowS)
-> (ValueWithServiceIds -> String)
-> ([ValueWithServiceIds] -> ShowS)
-> Show ValueWithServiceIds
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. ValueWithServiceIds -> Rep ValueWithServiceIds x)
-> (forall x. Rep ValueWithServiceIds x -> ValueWithServiceIds)
-> Generic ValueWithServiceIds
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:
--
-- 'serviceIds', 'valueWithServiceIds_serviceIds' - Services to which the annotation applies.
--
-- 'annotationValue', 'valueWithServiceIds_annotationValue' - Values of the annotation.
newValueWithServiceIds ::
  ValueWithServiceIds
newValueWithServiceIds :: ValueWithServiceIds
newValueWithServiceIds =
  ValueWithServiceIds' :: Maybe [ServiceId] -> Maybe AnnotationValue -> ValueWithServiceIds
ValueWithServiceIds'
    { $sel:serviceIds:ValueWithServiceIds' :: Maybe [ServiceId]
serviceIds = Maybe [ServiceId]
forall a. Maybe a
Prelude.Nothing,
      $sel:annotationValue:ValueWithServiceIds' :: Maybe AnnotationValue
annotationValue = Maybe AnnotationValue
forall a. Maybe a
Prelude.Nothing
    }

-- | Services to which the annotation applies.
valueWithServiceIds_serviceIds :: Lens.Lens' ValueWithServiceIds (Prelude.Maybe [ServiceId])
valueWithServiceIds_serviceIds :: (Maybe [ServiceId] -> f (Maybe [ServiceId]))
-> ValueWithServiceIds -> f ValueWithServiceIds
valueWithServiceIds_serviceIds = (ValueWithServiceIds -> Maybe [ServiceId])
-> (ValueWithServiceIds
    -> Maybe [ServiceId] -> ValueWithServiceIds)
-> Lens
     ValueWithServiceIds
     ValueWithServiceIds
     (Maybe [ServiceId])
     (Maybe [ServiceId])
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) ((Maybe [ServiceId] -> f (Maybe [ServiceId]))
 -> ValueWithServiceIds -> f ValueWithServiceIds)
-> ((Maybe [ServiceId] -> f (Maybe [ServiceId]))
    -> Maybe [ServiceId] -> f (Maybe [ServiceId]))
-> (Maybe [ServiceId] -> f (Maybe [ServiceId]))
-> ValueWithServiceIds
-> f ValueWithServiceIds
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

-- | Values of the annotation.
valueWithServiceIds_annotationValue :: Lens.Lens' ValueWithServiceIds (Prelude.Maybe AnnotationValue)
valueWithServiceIds_annotationValue :: (Maybe AnnotationValue -> f (Maybe AnnotationValue))
-> ValueWithServiceIds -> f ValueWithServiceIds
valueWithServiceIds_annotationValue = (ValueWithServiceIds -> Maybe AnnotationValue)
-> (ValueWithServiceIds
    -> Maybe AnnotationValue -> ValueWithServiceIds)
-> Lens
     ValueWithServiceIds
     ValueWithServiceIds
     (Maybe AnnotationValue)
     (Maybe 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)

instance Core.FromJSON ValueWithServiceIds where
  parseJSON :: Value -> Parser ValueWithServiceIds
parseJSON =
    String
-> (Object -> Parser ValueWithServiceIds)
-> Value
-> Parser ValueWithServiceIds
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ValueWithServiceIds"
      ( \Object
x ->
          Maybe [ServiceId] -> Maybe AnnotationValue -> ValueWithServiceIds
ValueWithServiceIds'
            (Maybe [ServiceId] -> Maybe AnnotationValue -> ValueWithServiceIds)
-> Parser (Maybe [ServiceId])
-> Parser (Maybe AnnotationValue -> ValueWithServiceIds)
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 AnnotationValue -> ValueWithServiceIds)
-> Parser (Maybe AnnotationValue) -> Parser ValueWithServiceIds
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AnnotationValue)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AnnotationValue")
      )

instance Prelude.Hashable ValueWithServiceIds

instance Prelude.NFData ValueWithServiceIds