{-# 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.DevOpsGuru.Types.ServiceCollection
-- 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.DevOpsGuru.Types.ServiceCollection where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DevOpsGuru.Types.ServiceName
import qualified Amazonka.Prelude as Prelude

-- | A collection of the names of Amazon Web Services services.
--
-- /See:/ 'newServiceCollection' smart constructor.
data ServiceCollection = ServiceCollection'
  { -- | An array of strings that each specifies the name of an Amazon Web
    -- Services service.
    ServiceCollection -> Maybe [ServiceName]
serviceNames :: Prelude.Maybe [ServiceName]
  }
  deriving (ServiceCollection -> ServiceCollection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServiceCollection -> ServiceCollection -> Bool
$c/= :: ServiceCollection -> ServiceCollection -> Bool
== :: ServiceCollection -> ServiceCollection -> Bool
$c== :: ServiceCollection -> ServiceCollection -> Bool
Prelude.Eq, ReadPrec [ServiceCollection]
ReadPrec ServiceCollection
Int -> ReadS ServiceCollection
ReadS [ServiceCollection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServiceCollection]
$creadListPrec :: ReadPrec [ServiceCollection]
readPrec :: ReadPrec ServiceCollection
$creadPrec :: ReadPrec ServiceCollection
readList :: ReadS [ServiceCollection]
$creadList :: ReadS [ServiceCollection]
readsPrec :: Int -> ReadS ServiceCollection
$creadsPrec :: Int -> ReadS ServiceCollection
Prelude.Read, Int -> ServiceCollection -> ShowS
[ServiceCollection] -> ShowS
ServiceCollection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServiceCollection] -> ShowS
$cshowList :: [ServiceCollection] -> ShowS
show :: ServiceCollection -> String
$cshow :: ServiceCollection -> String
showsPrec :: Int -> ServiceCollection -> ShowS
$cshowsPrec :: Int -> ServiceCollection -> ShowS
Prelude.Show, forall x. Rep ServiceCollection x -> ServiceCollection
forall x. ServiceCollection -> Rep ServiceCollection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ServiceCollection x -> ServiceCollection
$cfrom :: forall x. ServiceCollection -> Rep ServiceCollection x
Prelude.Generic)

-- |
-- Create a value of 'ServiceCollection' 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:
--
-- 'serviceNames', 'serviceCollection_serviceNames' - An array of strings that each specifies the name of an Amazon Web
-- Services service.
newServiceCollection ::
  ServiceCollection
newServiceCollection :: ServiceCollection
newServiceCollection =
  ServiceCollection' {$sel:serviceNames:ServiceCollection' :: Maybe [ServiceName]
serviceNames = forall a. Maybe a
Prelude.Nothing}

-- | An array of strings that each specifies the name of an Amazon Web
-- Services service.
serviceCollection_serviceNames :: Lens.Lens' ServiceCollection (Prelude.Maybe [ServiceName])
serviceCollection_serviceNames :: Lens' ServiceCollection (Maybe [ServiceName])
serviceCollection_serviceNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceCollection' {Maybe [ServiceName]
serviceNames :: Maybe [ServiceName]
$sel:serviceNames:ServiceCollection' :: ServiceCollection -> Maybe [ServiceName]
serviceNames} -> Maybe [ServiceName]
serviceNames) (\s :: ServiceCollection
s@ServiceCollection' {} Maybe [ServiceName]
a -> ServiceCollection
s {$sel:serviceNames:ServiceCollection' :: Maybe [ServiceName]
serviceNames = Maybe [ServiceName]
a} :: ServiceCollection) 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 ServiceCollection where
  parseJSON :: Value -> Parser ServiceCollection
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ServiceCollection"
      ( \Object
x ->
          Maybe [ServiceName] -> ServiceCollection
ServiceCollection'
            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
"ServiceNames" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ServiceCollection where
  hashWithSalt :: Int -> ServiceCollection -> Int
hashWithSalt Int
_salt ServiceCollection' {Maybe [ServiceName]
serviceNames :: Maybe [ServiceName]
$sel:serviceNames:ServiceCollection' :: ServiceCollection -> Maybe [ServiceName]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ServiceName]
serviceNames

instance Prelude.NFData ServiceCollection where
  rnf :: ServiceCollection -> ()
rnf ServiceCollection' {Maybe [ServiceName]
serviceNames :: Maybe [ServiceName]
$sel:serviceNames:ServiceCollection' :: ServiceCollection -> Maybe [ServiceName]
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe [ServiceName]
serviceNames

instance Data.ToJSON ServiceCollection where
  toJSON :: ServiceCollection -> Value
toJSON ServiceCollection' {Maybe [ServiceName]
serviceNames :: Maybe [ServiceName]
$sel:serviceNames:ServiceCollection' :: ServiceCollection -> Maybe [ServiceName]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"ServiceNames" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ServiceName]
serviceNames]
      )