{-# 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.SecurityHub.Types.AwsApiGatewayAccessLogSettings
-- 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.SecurityHub.Types.AwsApiGatewayAccessLogSettings where

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

-- | Contains information about settings for logging access for the stage.
--
-- /See:/ 'newAwsApiGatewayAccessLogSettings' smart constructor.
data AwsApiGatewayAccessLogSettings = AwsApiGatewayAccessLogSettings'
  { -- | A single-line format of the access logs of data, as specified by
    -- selected @$context@ variables. The format must include at least
    -- @$context.requestId@.
    AwsApiGatewayAccessLogSettings -> Maybe Text
format :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the CloudWatch Logs log group that receives the access logs.
    AwsApiGatewayAccessLogSettings -> Maybe Text
destinationArn :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsApiGatewayAccessLogSettings
-> AwsApiGatewayAccessLogSettings -> Bool
(AwsApiGatewayAccessLogSettings
 -> AwsApiGatewayAccessLogSettings -> Bool)
-> (AwsApiGatewayAccessLogSettings
    -> AwsApiGatewayAccessLogSettings -> Bool)
-> Eq AwsApiGatewayAccessLogSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsApiGatewayAccessLogSettings
-> AwsApiGatewayAccessLogSettings -> Bool
$c/= :: AwsApiGatewayAccessLogSettings
-> AwsApiGatewayAccessLogSettings -> Bool
== :: AwsApiGatewayAccessLogSettings
-> AwsApiGatewayAccessLogSettings -> Bool
$c== :: AwsApiGatewayAccessLogSettings
-> AwsApiGatewayAccessLogSettings -> Bool
Prelude.Eq, ReadPrec [AwsApiGatewayAccessLogSettings]
ReadPrec AwsApiGatewayAccessLogSettings
Int -> ReadS AwsApiGatewayAccessLogSettings
ReadS [AwsApiGatewayAccessLogSettings]
(Int -> ReadS AwsApiGatewayAccessLogSettings)
-> ReadS [AwsApiGatewayAccessLogSettings]
-> ReadPrec AwsApiGatewayAccessLogSettings
-> ReadPrec [AwsApiGatewayAccessLogSettings]
-> Read AwsApiGatewayAccessLogSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsApiGatewayAccessLogSettings]
$creadListPrec :: ReadPrec [AwsApiGatewayAccessLogSettings]
readPrec :: ReadPrec AwsApiGatewayAccessLogSettings
$creadPrec :: ReadPrec AwsApiGatewayAccessLogSettings
readList :: ReadS [AwsApiGatewayAccessLogSettings]
$creadList :: ReadS [AwsApiGatewayAccessLogSettings]
readsPrec :: Int -> ReadS AwsApiGatewayAccessLogSettings
$creadsPrec :: Int -> ReadS AwsApiGatewayAccessLogSettings
Prelude.Read, Int -> AwsApiGatewayAccessLogSettings -> ShowS
[AwsApiGatewayAccessLogSettings] -> ShowS
AwsApiGatewayAccessLogSettings -> String
(Int -> AwsApiGatewayAccessLogSettings -> ShowS)
-> (AwsApiGatewayAccessLogSettings -> String)
-> ([AwsApiGatewayAccessLogSettings] -> ShowS)
-> Show AwsApiGatewayAccessLogSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsApiGatewayAccessLogSettings] -> ShowS
$cshowList :: [AwsApiGatewayAccessLogSettings] -> ShowS
show :: AwsApiGatewayAccessLogSettings -> String
$cshow :: AwsApiGatewayAccessLogSettings -> String
showsPrec :: Int -> AwsApiGatewayAccessLogSettings -> ShowS
$cshowsPrec :: Int -> AwsApiGatewayAccessLogSettings -> ShowS
Prelude.Show, (forall x.
 AwsApiGatewayAccessLogSettings
 -> Rep AwsApiGatewayAccessLogSettings x)
-> (forall x.
    Rep AwsApiGatewayAccessLogSettings x
    -> AwsApiGatewayAccessLogSettings)
-> Generic AwsApiGatewayAccessLogSettings
forall x.
Rep AwsApiGatewayAccessLogSettings x
-> AwsApiGatewayAccessLogSettings
forall x.
AwsApiGatewayAccessLogSettings
-> Rep AwsApiGatewayAccessLogSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsApiGatewayAccessLogSettings x
-> AwsApiGatewayAccessLogSettings
$cfrom :: forall x.
AwsApiGatewayAccessLogSettings
-> Rep AwsApiGatewayAccessLogSettings x
Prelude.Generic)

-- |
-- Create a value of 'AwsApiGatewayAccessLogSettings' 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:
--
-- 'format', 'awsApiGatewayAccessLogSettings_format' - A single-line format of the access logs of data, as specified by
-- selected @$context@ variables. The format must include at least
-- @$context.requestId@.
--
-- 'destinationArn', 'awsApiGatewayAccessLogSettings_destinationArn' - The ARN of the CloudWatch Logs log group that receives the access logs.
newAwsApiGatewayAccessLogSettings ::
  AwsApiGatewayAccessLogSettings
newAwsApiGatewayAccessLogSettings :: AwsApiGatewayAccessLogSettings
newAwsApiGatewayAccessLogSettings =
  AwsApiGatewayAccessLogSettings' :: Maybe Text -> Maybe Text -> AwsApiGatewayAccessLogSettings
AwsApiGatewayAccessLogSettings'
    { $sel:format:AwsApiGatewayAccessLogSettings' :: Maybe Text
format =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:destinationArn:AwsApiGatewayAccessLogSettings' :: Maybe Text
destinationArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A single-line format of the access logs of data, as specified by
-- selected @$context@ variables. The format must include at least
-- @$context.requestId@.
awsApiGatewayAccessLogSettings_format :: Lens.Lens' AwsApiGatewayAccessLogSettings (Prelude.Maybe Prelude.Text)
awsApiGatewayAccessLogSettings_format :: (Maybe Text -> f (Maybe Text))
-> AwsApiGatewayAccessLogSettings
-> f AwsApiGatewayAccessLogSettings
awsApiGatewayAccessLogSettings_format = (AwsApiGatewayAccessLogSettings -> Maybe Text)
-> (AwsApiGatewayAccessLogSettings
    -> Maybe Text -> AwsApiGatewayAccessLogSettings)
-> Lens
     AwsApiGatewayAccessLogSettings
     AwsApiGatewayAccessLogSettings
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsApiGatewayAccessLogSettings' {Maybe Text
format :: Maybe Text
$sel:format:AwsApiGatewayAccessLogSettings' :: AwsApiGatewayAccessLogSettings -> Maybe Text
format} -> Maybe Text
format) (\s :: AwsApiGatewayAccessLogSettings
s@AwsApiGatewayAccessLogSettings' {} Maybe Text
a -> AwsApiGatewayAccessLogSettings
s {$sel:format:AwsApiGatewayAccessLogSettings' :: Maybe Text
format = Maybe Text
a} :: AwsApiGatewayAccessLogSettings)

-- | The ARN of the CloudWatch Logs log group that receives the access logs.
awsApiGatewayAccessLogSettings_destinationArn :: Lens.Lens' AwsApiGatewayAccessLogSettings (Prelude.Maybe Prelude.Text)
awsApiGatewayAccessLogSettings_destinationArn :: (Maybe Text -> f (Maybe Text))
-> AwsApiGatewayAccessLogSettings
-> f AwsApiGatewayAccessLogSettings
awsApiGatewayAccessLogSettings_destinationArn = (AwsApiGatewayAccessLogSettings -> Maybe Text)
-> (AwsApiGatewayAccessLogSettings
    -> Maybe Text -> AwsApiGatewayAccessLogSettings)
-> Lens
     AwsApiGatewayAccessLogSettings
     AwsApiGatewayAccessLogSettings
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsApiGatewayAccessLogSettings' {Maybe Text
destinationArn :: Maybe Text
$sel:destinationArn:AwsApiGatewayAccessLogSettings' :: AwsApiGatewayAccessLogSettings -> Maybe Text
destinationArn} -> Maybe Text
destinationArn) (\s :: AwsApiGatewayAccessLogSettings
s@AwsApiGatewayAccessLogSettings' {} Maybe Text
a -> AwsApiGatewayAccessLogSettings
s {$sel:destinationArn:AwsApiGatewayAccessLogSettings' :: Maybe Text
destinationArn = Maybe Text
a} :: AwsApiGatewayAccessLogSettings)

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

instance
  Prelude.Hashable
    AwsApiGatewayAccessLogSettings

instance
  Prelude.NFData
    AwsApiGatewayAccessLogSettings

instance Core.ToJSON AwsApiGatewayAccessLogSettings where
  toJSON :: AwsApiGatewayAccessLogSettings -> Value
toJSON AwsApiGatewayAccessLogSettings' {Maybe Text
destinationArn :: Maybe Text
format :: Maybe Text
$sel:destinationArn:AwsApiGatewayAccessLogSettings' :: AwsApiGatewayAccessLogSettings -> Maybe Text
$sel:format:AwsApiGatewayAccessLogSettings' :: AwsApiGatewayAccessLogSettings -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Format" 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
format,
            (Text
"DestinationArn" 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
destinationArn
          ]
      )