{-# 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.CompletionReport
-- 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.CompletionReport 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.ReportFormat
import Amazonka.FSx.Types.ReportScope
import qualified Amazonka.Prelude as Prelude

-- | Provides a report detailing the data repository task results of the
-- files processed that match the criteria specified in the report @Scope@
-- parameter. FSx delivers the report to the file system\'s linked data
-- repository in Amazon S3, using the path specified in the report @Path@
-- parameter. You can specify whether or not a report gets generated for a
-- task using the @Enabled@ parameter.
--
-- /See:/ 'newCompletionReport' smart constructor.
data CompletionReport = CompletionReport'
  { -- | Required if @Enabled@ is set to @true@. Specifies the format of the
    -- @CompletionReport@. @REPORT_CSV_20191124@ is the only format currently
    -- supported. When @Format@ is set to @REPORT_CSV_20191124@, the
    -- @CompletionReport@ is provided in CSV format, and is delivered to
    -- @{path}\/task-{id}\/failures.csv@.
    CompletionReport -> Maybe ReportFormat
format :: Prelude.Maybe ReportFormat,
    -- | Required if @Enabled@ is set to @true@. Specifies the location of the
    -- report on the file system\'s linked S3 data repository. An absolute path
    -- that defines where the completion report will be stored in the
    -- destination location. The @Path@ you provide must be located within the
    -- file system’s ExportPath. An example @Path@ value is
    -- \"s3:\/\/myBucket\/myExportPath\/optionalPrefix\". The report provides
    -- the following information for each file in the report: FilePath,
    -- FileStatus, and ErrorCode. To learn more about a file system\'s
    -- @ExportPath@, see .
    CompletionReport -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    -- | Required if @Enabled@ is set to @true@. Specifies the scope of the
    -- @CompletionReport@; @FAILED_FILES_ONLY@ is the only scope currently
    -- supported. When @Scope@ is set to @FAILED_FILES_ONLY@, the
    -- @CompletionReport@ only contains information about files that the data
    -- repository task failed to process.
    CompletionReport -> Maybe ReportScope
scope :: Prelude.Maybe ReportScope,
    -- | Set @Enabled@ to @True@ to generate a @CompletionReport@ when the task
    -- completes. If set to @true@, then you need to provide a report @Scope@,
    -- @Path@, and @Format@. Set @Enabled@ to @False@ if you do not want a
    -- @CompletionReport@ generated when the task completes.
    CompletionReport -> Bool
enabled :: Prelude.Bool
  }
  deriving (CompletionReport -> CompletionReport -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletionReport -> CompletionReport -> Bool
$c/= :: CompletionReport -> CompletionReport -> Bool
== :: CompletionReport -> CompletionReport -> Bool
$c== :: CompletionReport -> CompletionReport -> Bool
Prelude.Eq, ReadPrec [CompletionReport]
ReadPrec CompletionReport
Int -> ReadS CompletionReport
ReadS [CompletionReport]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletionReport]
$creadListPrec :: ReadPrec [CompletionReport]
readPrec :: ReadPrec CompletionReport
$creadPrec :: ReadPrec CompletionReport
readList :: ReadS [CompletionReport]
$creadList :: ReadS [CompletionReport]
readsPrec :: Int -> ReadS CompletionReport
$creadsPrec :: Int -> ReadS CompletionReport
Prelude.Read, Int -> CompletionReport -> ShowS
[CompletionReport] -> ShowS
CompletionReport -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletionReport] -> ShowS
$cshowList :: [CompletionReport] -> ShowS
show :: CompletionReport -> String
$cshow :: CompletionReport -> String
showsPrec :: Int -> CompletionReport -> ShowS
$cshowsPrec :: Int -> CompletionReport -> ShowS
Prelude.Show, forall x. Rep CompletionReport x -> CompletionReport
forall x. CompletionReport -> Rep CompletionReport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CompletionReport x -> CompletionReport
$cfrom :: forall x. CompletionReport -> Rep CompletionReport x
Prelude.Generic)

-- |
-- Create a value of 'CompletionReport' 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', 'completionReport_format' - Required if @Enabled@ is set to @true@. Specifies the format of the
-- @CompletionReport@. @REPORT_CSV_20191124@ is the only format currently
-- supported. When @Format@ is set to @REPORT_CSV_20191124@, the
-- @CompletionReport@ is provided in CSV format, and is delivered to
-- @{path}\/task-{id}\/failures.csv@.
--
-- 'path', 'completionReport_path' - Required if @Enabled@ is set to @true@. Specifies the location of the
-- report on the file system\'s linked S3 data repository. An absolute path
-- that defines where the completion report will be stored in the
-- destination location. The @Path@ you provide must be located within the
-- file system’s ExportPath. An example @Path@ value is
-- \"s3:\/\/myBucket\/myExportPath\/optionalPrefix\". The report provides
-- the following information for each file in the report: FilePath,
-- FileStatus, and ErrorCode. To learn more about a file system\'s
-- @ExportPath@, see .
--
-- 'scope', 'completionReport_scope' - Required if @Enabled@ is set to @true@. Specifies the scope of the
-- @CompletionReport@; @FAILED_FILES_ONLY@ is the only scope currently
-- supported. When @Scope@ is set to @FAILED_FILES_ONLY@, the
-- @CompletionReport@ only contains information about files that the data
-- repository task failed to process.
--
-- 'enabled', 'completionReport_enabled' - Set @Enabled@ to @True@ to generate a @CompletionReport@ when the task
-- completes. If set to @true@, then you need to provide a report @Scope@,
-- @Path@, and @Format@. Set @Enabled@ to @False@ if you do not want a
-- @CompletionReport@ generated when the task completes.
newCompletionReport ::
  -- | 'enabled'
  Prelude.Bool ->
  CompletionReport
newCompletionReport :: Bool -> CompletionReport
newCompletionReport Bool
pEnabled_ =
  CompletionReport'
    { $sel:format:CompletionReport' :: Maybe ReportFormat
format = forall a. Maybe a
Prelude.Nothing,
      $sel:path:CompletionReport' :: Maybe Text
path = forall a. Maybe a
Prelude.Nothing,
      $sel:scope:CompletionReport' :: Maybe ReportScope
scope = forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:CompletionReport' :: Bool
enabled = Bool
pEnabled_
    }

-- | Required if @Enabled@ is set to @true@. Specifies the format of the
-- @CompletionReport@. @REPORT_CSV_20191124@ is the only format currently
-- supported. When @Format@ is set to @REPORT_CSV_20191124@, the
-- @CompletionReport@ is provided in CSV format, and is delivered to
-- @{path}\/task-{id}\/failures.csv@.
completionReport_format :: Lens.Lens' CompletionReport (Prelude.Maybe ReportFormat)
completionReport_format :: Lens' CompletionReport (Maybe ReportFormat)
completionReport_format = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CompletionReport' {Maybe ReportFormat
format :: Maybe ReportFormat
$sel:format:CompletionReport' :: CompletionReport -> Maybe ReportFormat
format} -> Maybe ReportFormat
format) (\s :: CompletionReport
s@CompletionReport' {} Maybe ReportFormat
a -> CompletionReport
s {$sel:format:CompletionReport' :: Maybe ReportFormat
format = Maybe ReportFormat
a} :: CompletionReport)

-- | Required if @Enabled@ is set to @true@. Specifies the location of the
-- report on the file system\'s linked S3 data repository. An absolute path
-- that defines where the completion report will be stored in the
-- destination location. The @Path@ you provide must be located within the
-- file system’s ExportPath. An example @Path@ value is
-- \"s3:\/\/myBucket\/myExportPath\/optionalPrefix\". The report provides
-- the following information for each file in the report: FilePath,
-- FileStatus, and ErrorCode. To learn more about a file system\'s
-- @ExportPath@, see .
completionReport_path :: Lens.Lens' CompletionReport (Prelude.Maybe Prelude.Text)
completionReport_path :: Lens' CompletionReport (Maybe Text)
completionReport_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CompletionReport' {Maybe Text
path :: Maybe Text
$sel:path:CompletionReport' :: CompletionReport -> Maybe Text
path} -> Maybe Text
path) (\s :: CompletionReport
s@CompletionReport' {} Maybe Text
a -> CompletionReport
s {$sel:path:CompletionReport' :: Maybe Text
path = Maybe Text
a} :: CompletionReport)

-- | Required if @Enabled@ is set to @true@. Specifies the scope of the
-- @CompletionReport@; @FAILED_FILES_ONLY@ is the only scope currently
-- supported. When @Scope@ is set to @FAILED_FILES_ONLY@, the
-- @CompletionReport@ only contains information about files that the data
-- repository task failed to process.
completionReport_scope :: Lens.Lens' CompletionReport (Prelude.Maybe ReportScope)
completionReport_scope :: Lens' CompletionReport (Maybe ReportScope)
completionReport_scope = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CompletionReport' {Maybe ReportScope
scope :: Maybe ReportScope
$sel:scope:CompletionReport' :: CompletionReport -> Maybe ReportScope
scope} -> Maybe ReportScope
scope) (\s :: CompletionReport
s@CompletionReport' {} Maybe ReportScope
a -> CompletionReport
s {$sel:scope:CompletionReport' :: Maybe ReportScope
scope = Maybe ReportScope
a} :: CompletionReport)

-- | Set @Enabled@ to @True@ to generate a @CompletionReport@ when the task
-- completes. If set to @true@, then you need to provide a report @Scope@,
-- @Path@, and @Format@. Set @Enabled@ to @False@ if you do not want a
-- @CompletionReport@ generated when the task completes.
completionReport_enabled :: Lens.Lens' CompletionReport Prelude.Bool
completionReport_enabled :: Lens' CompletionReport Bool
completionReport_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CompletionReport' {Bool
enabled :: Bool
$sel:enabled:CompletionReport' :: CompletionReport -> Bool
enabled} -> Bool
enabled) (\s :: CompletionReport
s@CompletionReport' {} Bool
a -> CompletionReport
s {$sel:enabled:CompletionReport' :: Bool
enabled = Bool
a} :: CompletionReport)

instance Data.FromJSON CompletionReport where
  parseJSON :: Value -> Parser CompletionReport
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CompletionReport"
      ( \Object
x ->
          Maybe ReportFormat
-> Maybe Text -> Maybe ReportScope -> Bool -> CompletionReport
CompletionReport'
            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
"Format")
            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
"Path")
            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
"Scope")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Enabled")
      )

instance Prelude.Hashable CompletionReport where
  hashWithSalt :: Int -> CompletionReport -> Int
hashWithSalt Int
_salt CompletionReport' {Bool
Maybe Text
Maybe ReportFormat
Maybe ReportScope
enabled :: Bool
scope :: Maybe ReportScope
path :: Maybe Text
format :: Maybe ReportFormat
$sel:enabled:CompletionReport' :: CompletionReport -> Bool
$sel:scope:CompletionReport' :: CompletionReport -> Maybe ReportScope
$sel:path:CompletionReport' :: CompletionReport -> Maybe Text
$sel:format:CompletionReport' :: CompletionReport -> Maybe ReportFormat
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ReportFormat
format
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
path
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ReportScope
scope
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
enabled

instance Prelude.NFData CompletionReport where
  rnf :: CompletionReport -> ()
rnf CompletionReport' {Bool
Maybe Text
Maybe ReportFormat
Maybe ReportScope
enabled :: Bool
scope :: Maybe ReportScope
path :: Maybe Text
format :: Maybe ReportFormat
$sel:enabled:CompletionReport' :: CompletionReport -> Bool
$sel:scope:CompletionReport' :: CompletionReport -> Maybe ReportScope
$sel:path:CompletionReport' :: CompletionReport -> Maybe Text
$sel:format:CompletionReport' :: CompletionReport -> Maybe ReportFormat
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ReportFormat
format
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
path
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ReportScope
scope
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
enabled

instance Data.ToJSON CompletionReport where
  toJSON :: CompletionReport -> Value
toJSON CompletionReport' {Bool
Maybe Text
Maybe ReportFormat
Maybe ReportScope
enabled :: Bool
scope :: Maybe ReportScope
path :: Maybe Text
format :: Maybe ReportFormat
$sel:enabled:CompletionReport' :: CompletionReport -> Bool
$sel:scope:CompletionReport' :: CompletionReport -> Maybe ReportScope
$sel:path:CompletionReport' :: CompletionReport -> Maybe Text
$sel:format:CompletionReport' :: CompletionReport -> Maybe ReportFormat
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Format" 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 ReportFormat
format,
            (Key
"Path" 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
path,
            (Key
"Scope" 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 ReportScope
scope,
            forall a. a -> Maybe a
Prelude.Just (Key
"Enabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
enabled)
          ]
      )