{-# 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.ServiceId
-- 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.ServiceId 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

-- |
--
-- /See:/ 'newServiceId' smart constructor.
data ServiceId = ServiceId'
  { ServiceId -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    ServiceId -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    ServiceId -> Maybe [Text]
names :: Prelude.Maybe [Prelude.Text],
    ServiceId -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (ServiceId -> ServiceId -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServiceId -> ServiceId -> Bool
$c/= :: ServiceId -> ServiceId -> Bool
== :: ServiceId -> ServiceId -> Bool
$c== :: ServiceId -> ServiceId -> Bool
Prelude.Eq, ReadPrec [ServiceId]
ReadPrec ServiceId
Int -> ReadS ServiceId
ReadS [ServiceId]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServiceId]
$creadListPrec :: ReadPrec [ServiceId]
readPrec :: ReadPrec ServiceId
$creadPrec :: ReadPrec ServiceId
readList :: ReadS [ServiceId]
$creadList :: ReadS [ServiceId]
readsPrec :: Int -> ReadS ServiceId
$creadsPrec :: Int -> ReadS ServiceId
Prelude.Read, Int -> ServiceId -> ShowS
[ServiceId] -> ShowS
ServiceId -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServiceId] -> ShowS
$cshowList :: [ServiceId] -> ShowS
show :: ServiceId -> String
$cshow :: ServiceId -> String
showsPrec :: Int -> ServiceId -> ShowS
$cshowsPrec :: Int -> ServiceId -> ShowS
Prelude.Show, forall x. Rep ServiceId x -> ServiceId
forall x. ServiceId -> Rep ServiceId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ServiceId x -> ServiceId
$cfrom :: forall x. ServiceId -> Rep ServiceId x
Prelude.Generic)

-- |
-- Create a value of 'ServiceId' 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:
--
-- 'accountId', 'serviceId_accountId' -
--
-- 'name', 'serviceId_name' -
--
-- 'names', 'serviceId_names' -
--
-- 'type'', 'serviceId_type' -
newServiceId ::
  ServiceId
newServiceId :: ServiceId
newServiceId =
  ServiceId'
    { $sel:accountId:ServiceId' :: Maybe Text
accountId = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ServiceId' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:names:ServiceId' :: Maybe [Text]
names = forall a. Maybe a
Prelude.Nothing,
      $sel:type':ServiceId' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing
    }

serviceId_accountId :: Lens.Lens' ServiceId (Prelude.Maybe Prelude.Text)
serviceId_accountId :: Lens' ServiceId (Maybe Text)
serviceId_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceId' {Maybe Text
accountId :: Maybe Text
$sel:accountId:ServiceId' :: ServiceId -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: ServiceId
s@ServiceId' {} Maybe Text
a -> ServiceId
s {$sel:accountId:ServiceId' :: Maybe Text
accountId = Maybe Text
a} :: ServiceId)

serviceId_name :: Lens.Lens' ServiceId (Prelude.Maybe Prelude.Text)
serviceId_name :: Lens' ServiceId (Maybe Text)
serviceId_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceId' {Maybe Text
name :: Maybe Text
$sel:name:ServiceId' :: ServiceId -> Maybe Text
name} -> Maybe Text
name) (\s :: ServiceId
s@ServiceId' {} Maybe Text
a -> ServiceId
s {$sel:name:ServiceId' :: Maybe Text
name = Maybe Text
a} :: ServiceId)

serviceId_names :: Lens.Lens' ServiceId (Prelude.Maybe [Prelude.Text])
serviceId_names :: Lens' ServiceId (Maybe [Text])
serviceId_names = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceId' {Maybe [Text]
names :: Maybe [Text]
$sel:names:ServiceId' :: ServiceId -> Maybe [Text]
names} -> Maybe [Text]
names) (\s :: ServiceId
s@ServiceId' {} Maybe [Text]
a -> ServiceId
s {$sel:names:ServiceId' :: Maybe [Text]
names = Maybe [Text]
a} :: ServiceId) 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

serviceId_type :: Lens.Lens' ServiceId (Prelude.Maybe Prelude.Text)
serviceId_type :: Lens' ServiceId (Maybe Text)
serviceId_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceId' {Maybe Text
type' :: Maybe Text
$sel:type':ServiceId' :: ServiceId -> Maybe Text
type'} -> Maybe Text
type') (\s :: ServiceId
s@ServiceId' {} Maybe Text
a -> ServiceId
s {$sel:type':ServiceId' :: Maybe Text
type' = Maybe Text
a} :: ServiceId)

instance Data.FromJSON ServiceId where
  parseJSON :: Value -> Parser ServiceId
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ServiceId"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe [Text] -> Maybe Text -> ServiceId
ServiceId'
            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
"AccountId")
            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
"Name")
            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
"Names" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"Type")
      )

instance Prelude.Hashable ServiceId where
  hashWithSalt :: Int -> ServiceId -> Int
hashWithSalt Int
_salt ServiceId' {Maybe [Text]
Maybe Text
type' :: Maybe Text
names :: Maybe [Text]
name :: Maybe Text
accountId :: Maybe Text
$sel:type':ServiceId' :: ServiceId -> Maybe Text
$sel:names:ServiceId' :: ServiceId -> Maybe [Text]
$sel:name:ServiceId' :: ServiceId -> Maybe Text
$sel:accountId:ServiceId' :: ServiceId -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
names
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
type'

instance Prelude.NFData ServiceId where
  rnf :: ServiceId -> ()
rnf ServiceId' {Maybe [Text]
Maybe Text
type' :: Maybe Text
names :: Maybe [Text]
name :: Maybe Text
accountId :: Maybe Text
$sel:type':ServiceId' :: ServiceId -> Maybe Text
$sel:names:ServiceId' :: ServiceId -> Maybe [Text]
$sel:name:ServiceId' :: ServiceId -> Maybe Text
$sel:accountId:ServiceId' :: ServiceId -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
names
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
type'