{-# 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.FSx.Types.LustreLogCreateConfiguration
-- 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.FSx.Types.LustreLogCreateConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FSx.Types.LustreAccessAuditLogLevel
import qualified Amazonka.Prelude as Prelude

-- | The Lustre logging configuration used when creating or updating an
-- Amazon FSx for Lustre file system. An Amazon File Cache is created with
-- Lustre logging enabled by default, with a setting of @WARN_ERROR@ for
-- the logging events. which can\'t be changed.
--
-- Lustre logging writes the enabled logging events for your file system or
-- cache to Amazon CloudWatch Logs.
--
-- /See:/ 'newLustreLogCreateConfiguration' smart constructor.
data LustreLogCreateConfiguration = LustreLogCreateConfiguration'
  { -- | The Amazon Resource Name (ARN) that specifies the destination of the
    -- logs.
    --
    -- The destination can be any Amazon CloudWatch Logs log group ARN, with
    -- the following requirements:
    --
    -- -   The destination ARN that you provide must be in the same Amazon Web
    --     Services partition, Amazon Web Services Region, and Amazon Web
    --     Services account as your Amazon FSx file system.
    --
    -- -   The name of the Amazon CloudWatch Logs log group must begin with the
    --     @\/aws\/fsx@ prefix.
    --
    -- -   If you do not provide a destination, Amazon FSx will create and use
    --     a log stream in the CloudWatch Logs @\/aws\/fsx\/lustre@ log group
    --     (for Amazon FSx for Lustre) or @\/aws\/fsx\/filecache@ (for Amazon
    --     File Cache).
    --
    -- -   If @Destination@ is provided and the resource does not exist, the
    --     request will fail with a @BadRequest@ error.
    --
    -- -   If @Level@ is set to @DISABLED@, you cannot specify a destination in
    --     @Destination@.
    LustreLogCreateConfiguration -> Maybe Text
destination :: Prelude.Maybe Prelude.Text,
    -- | Sets which data repository events are logged by Amazon FSx.
    --
    -- -   @WARN_ONLY@ - only warning events are logged.
    --
    -- -   @ERROR_ONLY@ - only error events are logged.
    --
    -- -   @WARN_ERROR@ - both warning events and error events are logged.
    --
    -- -   @DISABLED@ - logging of data repository events is turned off.
    LustreLogCreateConfiguration -> LustreAccessAuditLogLevel
level :: LustreAccessAuditLogLevel
  }
  deriving (LustreLogCreateConfiguration
-> LustreLogCreateConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LustreLogCreateConfiguration
-> LustreLogCreateConfiguration -> Bool
$c/= :: LustreLogCreateConfiguration
-> LustreLogCreateConfiguration -> Bool
== :: LustreLogCreateConfiguration
-> LustreLogCreateConfiguration -> Bool
$c== :: LustreLogCreateConfiguration
-> LustreLogCreateConfiguration -> Bool
Prelude.Eq, ReadPrec [LustreLogCreateConfiguration]
ReadPrec LustreLogCreateConfiguration
Int -> ReadS LustreLogCreateConfiguration
ReadS [LustreLogCreateConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LustreLogCreateConfiguration]
$creadListPrec :: ReadPrec [LustreLogCreateConfiguration]
readPrec :: ReadPrec LustreLogCreateConfiguration
$creadPrec :: ReadPrec LustreLogCreateConfiguration
readList :: ReadS [LustreLogCreateConfiguration]
$creadList :: ReadS [LustreLogCreateConfiguration]
readsPrec :: Int -> ReadS LustreLogCreateConfiguration
$creadsPrec :: Int -> ReadS LustreLogCreateConfiguration
Prelude.Read, Int -> LustreLogCreateConfiguration -> ShowS
[LustreLogCreateConfiguration] -> ShowS
LustreLogCreateConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LustreLogCreateConfiguration] -> ShowS
$cshowList :: [LustreLogCreateConfiguration] -> ShowS
show :: LustreLogCreateConfiguration -> String
$cshow :: LustreLogCreateConfiguration -> String
showsPrec :: Int -> LustreLogCreateConfiguration -> ShowS
$cshowsPrec :: Int -> LustreLogCreateConfiguration -> ShowS
Prelude.Show, forall x.
Rep LustreLogCreateConfiguration x -> LustreLogCreateConfiguration
forall x.
LustreLogCreateConfiguration -> Rep LustreLogCreateConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LustreLogCreateConfiguration x -> LustreLogCreateConfiguration
$cfrom :: forall x.
LustreLogCreateConfiguration -> Rep LustreLogCreateConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'LustreLogCreateConfiguration' 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:
--
-- 'destination', 'lustreLogCreateConfiguration_destination' - The Amazon Resource Name (ARN) that specifies the destination of the
-- logs.
--
-- The destination can be any Amazon CloudWatch Logs log group ARN, with
-- the following requirements:
--
-- -   The destination ARN that you provide must be in the same Amazon Web
--     Services partition, Amazon Web Services Region, and Amazon Web
--     Services account as your Amazon FSx file system.
--
-- -   The name of the Amazon CloudWatch Logs log group must begin with the
--     @\/aws\/fsx@ prefix.
--
-- -   If you do not provide a destination, Amazon FSx will create and use
--     a log stream in the CloudWatch Logs @\/aws\/fsx\/lustre@ log group
--     (for Amazon FSx for Lustre) or @\/aws\/fsx\/filecache@ (for Amazon
--     File Cache).
--
-- -   If @Destination@ is provided and the resource does not exist, the
--     request will fail with a @BadRequest@ error.
--
-- -   If @Level@ is set to @DISABLED@, you cannot specify a destination in
--     @Destination@.
--
-- 'level', 'lustreLogCreateConfiguration_level' - Sets which data repository events are logged by Amazon FSx.
--
-- -   @WARN_ONLY@ - only warning events are logged.
--
-- -   @ERROR_ONLY@ - only error events are logged.
--
-- -   @WARN_ERROR@ - both warning events and error events are logged.
--
-- -   @DISABLED@ - logging of data repository events is turned off.
newLustreLogCreateConfiguration ::
  -- | 'level'
  LustreAccessAuditLogLevel ->
  LustreLogCreateConfiguration
newLustreLogCreateConfiguration :: LustreAccessAuditLogLevel -> LustreLogCreateConfiguration
newLustreLogCreateConfiguration LustreAccessAuditLogLevel
pLevel_ =
  LustreLogCreateConfiguration'
    { $sel:destination:LustreLogCreateConfiguration' :: Maybe Text
destination =
        forall a. Maybe a
Prelude.Nothing,
      $sel:level:LustreLogCreateConfiguration' :: LustreAccessAuditLogLevel
level = LustreAccessAuditLogLevel
pLevel_
    }

-- | The Amazon Resource Name (ARN) that specifies the destination of the
-- logs.
--
-- The destination can be any Amazon CloudWatch Logs log group ARN, with
-- the following requirements:
--
-- -   The destination ARN that you provide must be in the same Amazon Web
--     Services partition, Amazon Web Services Region, and Amazon Web
--     Services account as your Amazon FSx file system.
--
-- -   The name of the Amazon CloudWatch Logs log group must begin with the
--     @\/aws\/fsx@ prefix.
--
-- -   If you do not provide a destination, Amazon FSx will create and use
--     a log stream in the CloudWatch Logs @\/aws\/fsx\/lustre@ log group
--     (for Amazon FSx for Lustre) or @\/aws\/fsx\/filecache@ (for Amazon
--     File Cache).
--
-- -   If @Destination@ is provided and the resource does not exist, the
--     request will fail with a @BadRequest@ error.
--
-- -   If @Level@ is set to @DISABLED@, you cannot specify a destination in
--     @Destination@.
lustreLogCreateConfiguration_destination :: Lens.Lens' LustreLogCreateConfiguration (Prelude.Maybe Prelude.Text)
lustreLogCreateConfiguration_destination :: Lens' LustreLogCreateConfiguration (Maybe Text)
lustreLogCreateConfiguration_destination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LustreLogCreateConfiguration' {Maybe Text
destination :: Maybe Text
$sel:destination:LustreLogCreateConfiguration' :: LustreLogCreateConfiguration -> Maybe Text
destination} -> Maybe Text
destination) (\s :: LustreLogCreateConfiguration
s@LustreLogCreateConfiguration' {} Maybe Text
a -> LustreLogCreateConfiguration
s {$sel:destination:LustreLogCreateConfiguration' :: Maybe Text
destination = Maybe Text
a} :: LustreLogCreateConfiguration)

-- | Sets which data repository events are logged by Amazon FSx.
--
-- -   @WARN_ONLY@ - only warning events are logged.
--
-- -   @ERROR_ONLY@ - only error events are logged.
--
-- -   @WARN_ERROR@ - both warning events and error events are logged.
--
-- -   @DISABLED@ - logging of data repository events is turned off.
lustreLogCreateConfiguration_level :: Lens.Lens' LustreLogCreateConfiguration LustreAccessAuditLogLevel
lustreLogCreateConfiguration_level :: Lens' LustreLogCreateConfiguration LustreAccessAuditLogLevel
lustreLogCreateConfiguration_level = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LustreLogCreateConfiguration' {LustreAccessAuditLogLevel
level :: LustreAccessAuditLogLevel
$sel:level:LustreLogCreateConfiguration' :: LustreLogCreateConfiguration -> LustreAccessAuditLogLevel
level} -> LustreAccessAuditLogLevel
level) (\s :: LustreLogCreateConfiguration
s@LustreLogCreateConfiguration' {} LustreAccessAuditLogLevel
a -> LustreLogCreateConfiguration
s {$sel:level:LustreLogCreateConfiguration' :: LustreAccessAuditLogLevel
level = LustreAccessAuditLogLevel
a} :: LustreLogCreateConfiguration)

instance
  Prelude.Hashable
    LustreLogCreateConfiguration
  where
  hashWithSalt :: Int -> LustreLogCreateConfiguration -> Int
hashWithSalt Int
_salt LustreLogCreateConfiguration' {Maybe Text
LustreAccessAuditLogLevel
level :: LustreAccessAuditLogLevel
destination :: Maybe Text
$sel:level:LustreLogCreateConfiguration' :: LustreLogCreateConfiguration -> LustreAccessAuditLogLevel
$sel:destination:LustreLogCreateConfiguration' :: LustreLogCreateConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
destination
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` LustreAccessAuditLogLevel
level

instance Prelude.NFData LustreLogCreateConfiguration where
  rnf :: LustreLogCreateConfiguration -> ()
rnf LustreLogCreateConfiguration' {Maybe Text
LustreAccessAuditLogLevel
level :: LustreAccessAuditLogLevel
destination :: Maybe Text
$sel:level:LustreLogCreateConfiguration' :: LustreLogCreateConfiguration -> LustreAccessAuditLogLevel
$sel:destination:LustreLogCreateConfiguration' :: LustreLogCreateConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
destination
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf LustreAccessAuditLogLevel
level

instance Data.ToJSON LustreLogCreateConfiguration where
  toJSON :: LustreLogCreateConfiguration -> Value
toJSON LustreLogCreateConfiguration' {Maybe Text
LustreAccessAuditLogLevel
level :: LustreAccessAuditLogLevel
destination :: Maybe Text
$sel:level:LustreLogCreateConfiguration' :: LustreLogCreateConfiguration -> LustreAccessAuditLogLevel
$sel:destination:LustreLogCreateConfiguration' :: LustreLogCreateConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Destination" 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 Text
destination,
            forall a. a -> Maybe a
Prelude.Just (Key
"Level" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= LustreAccessAuditLogLevel
level)
          ]
      )