{-# 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.AuditManager.Types.AWSService
-- 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.AuditManager.Types.AWSService where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An Amazon Web Service such as Amazon S3, CloudTrail, and so on.
--
-- /See:/ 'newAWSService' smart constructor.
data AWSService = AWSService'
  { -- | The name of the Amazon Web Service.
    AWSService -> Maybe Text
serviceName :: Prelude.Maybe Prelude.Text
  }
  deriving (AWSService -> AWSService -> Bool
(AWSService -> AWSService -> Bool)
-> (AWSService -> AWSService -> Bool) -> Eq AWSService
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AWSService -> AWSService -> Bool
$c/= :: AWSService -> AWSService -> Bool
== :: AWSService -> AWSService -> Bool
$c== :: AWSService -> AWSService -> Bool
Prelude.Eq, ReadPrec [AWSService]
ReadPrec AWSService
Int -> ReadS AWSService
ReadS [AWSService]
(Int -> ReadS AWSService)
-> ReadS [AWSService]
-> ReadPrec AWSService
-> ReadPrec [AWSService]
-> Read AWSService
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AWSService]
$creadListPrec :: ReadPrec [AWSService]
readPrec :: ReadPrec AWSService
$creadPrec :: ReadPrec AWSService
readList :: ReadS [AWSService]
$creadList :: ReadS [AWSService]
readsPrec :: Int -> ReadS AWSService
$creadsPrec :: Int -> ReadS AWSService
Prelude.Read, Int -> AWSService -> ShowS
[AWSService] -> ShowS
AWSService -> String
(Int -> AWSService -> ShowS)
-> (AWSService -> String)
-> ([AWSService] -> ShowS)
-> Show AWSService
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AWSService] -> ShowS
$cshowList :: [AWSService] -> ShowS
show :: AWSService -> String
$cshow :: AWSService -> String
showsPrec :: Int -> AWSService -> ShowS
$cshowsPrec :: Int -> AWSService -> ShowS
Prelude.Show, (forall x. AWSService -> Rep AWSService x)
-> (forall x. Rep AWSService x -> AWSService) -> Generic AWSService
forall x. Rep AWSService x -> AWSService
forall x. AWSService -> Rep AWSService x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AWSService x -> AWSService
$cfrom :: forall x. AWSService -> Rep AWSService x
Prelude.Generic)

-- |
-- Create a value of 'AWSService' 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:
--
-- 'serviceName', 'aWSService_serviceName' - The name of the Amazon Web Service.
newAWSService ::
  AWSService
newAWSService :: AWSService
newAWSService =
  AWSService' :: Maybe Text -> AWSService
AWSService' {$sel:serviceName:AWSService' :: Maybe Text
serviceName = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The name of the Amazon Web Service.
aWSService_serviceName :: Lens.Lens' AWSService (Prelude.Maybe Prelude.Text)
aWSService_serviceName :: (Maybe Text -> f (Maybe Text)) -> AWSService -> f AWSService
aWSService_serviceName = (AWSService -> Maybe Text)
-> (AWSService -> Maybe Text -> AWSService)
-> Lens AWSService AWSService (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AWSService' {Maybe Text
serviceName :: Maybe Text
$sel:serviceName:AWSService' :: AWSService -> Maybe Text
serviceName} -> Maybe Text
serviceName) (\s :: AWSService
s@AWSService' {} Maybe Text
a -> AWSService
s {$sel:serviceName:AWSService' :: Maybe Text
serviceName = Maybe Text
a} :: AWSService)

instance Core.FromJSON AWSService where
  parseJSON :: Value -> Parser AWSService
parseJSON =
    String
-> (Object -> Parser AWSService) -> Value -> Parser AWSService
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AWSService"
      ( \Object
x ->
          Maybe Text -> AWSService
AWSService' (Maybe Text -> AWSService)
-> Parser (Maybe Text) -> Parser AWSService
forall (f :: * -> *) a b. Functor 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
"serviceName")
      )

instance Prelude.Hashable AWSService

instance Prelude.NFData AWSService

instance Core.ToJSON AWSService where
  toJSON :: AWSService -> Value
toJSON AWSService' {Maybe Text
serviceName :: Maybe Text
$sel:serviceName:AWSService' :: AWSService -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"serviceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
serviceName]
      )