{-# 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.IoTSiteWise.Types.ErrorReportLocation
-- 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.IoTSiteWise.Types.ErrorReportLocation where

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

-- | The Amazon S3 destination where errors associated with the job creation
-- request are saved.
--
-- /See:/ 'newErrorReportLocation' smart constructor.
data ErrorReportLocation = ErrorReportLocation'
  { -- | The name of the Amazon S3 bucket to which errors associated with the
    -- bulk import job are sent.
    ErrorReportLocation -> Text
bucket :: Prelude.Text,
    -- | Amazon S3 uses the prefix as a folder name to organize data in the
    -- bucket. Each Amazon S3 object has a key that is its unique identifier in
    -- the bucket. Each object in a bucket has exactly one key. The prefix must
    -- end with a forward slash (\/). For more information, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-prefixes.html Organizing objects using prefixes>
    -- in the /Amazon Simple Storage Service User Guide/.
    ErrorReportLocation -> Text
prefix :: Prelude.Text
  }
  deriving (ErrorReportLocation -> ErrorReportLocation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ErrorReportLocation -> ErrorReportLocation -> Bool
$c/= :: ErrorReportLocation -> ErrorReportLocation -> Bool
== :: ErrorReportLocation -> ErrorReportLocation -> Bool
$c== :: ErrorReportLocation -> ErrorReportLocation -> Bool
Prelude.Eq, ReadPrec [ErrorReportLocation]
ReadPrec ErrorReportLocation
Int -> ReadS ErrorReportLocation
ReadS [ErrorReportLocation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ErrorReportLocation]
$creadListPrec :: ReadPrec [ErrorReportLocation]
readPrec :: ReadPrec ErrorReportLocation
$creadPrec :: ReadPrec ErrorReportLocation
readList :: ReadS [ErrorReportLocation]
$creadList :: ReadS [ErrorReportLocation]
readsPrec :: Int -> ReadS ErrorReportLocation
$creadsPrec :: Int -> ReadS ErrorReportLocation
Prelude.Read, Int -> ErrorReportLocation -> ShowS
[ErrorReportLocation] -> ShowS
ErrorReportLocation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ErrorReportLocation] -> ShowS
$cshowList :: [ErrorReportLocation] -> ShowS
show :: ErrorReportLocation -> String
$cshow :: ErrorReportLocation -> String
showsPrec :: Int -> ErrorReportLocation -> ShowS
$cshowsPrec :: Int -> ErrorReportLocation -> ShowS
Prelude.Show, forall x. Rep ErrorReportLocation x -> ErrorReportLocation
forall x. ErrorReportLocation -> Rep ErrorReportLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ErrorReportLocation x -> ErrorReportLocation
$cfrom :: forall x. ErrorReportLocation -> Rep ErrorReportLocation x
Prelude.Generic)

-- |
-- Create a value of 'ErrorReportLocation' 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:
--
-- 'bucket', 'errorReportLocation_bucket' - The name of the Amazon S3 bucket to which errors associated with the
-- bulk import job are sent.
--
-- 'prefix', 'errorReportLocation_prefix' - Amazon S3 uses the prefix as a folder name to organize data in the
-- bucket. Each Amazon S3 object has a key that is its unique identifier in
-- the bucket. Each object in a bucket has exactly one key. The prefix must
-- end with a forward slash (\/). For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-prefixes.html Organizing objects using prefixes>
-- in the /Amazon Simple Storage Service User Guide/.
newErrorReportLocation ::
  -- | 'bucket'
  Prelude.Text ->
  -- | 'prefix'
  Prelude.Text ->
  ErrorReportLocation
newErrorReportLocation :: Text -> Text -> ErrorReportLocation
newErrorReportLocation Text
pBucket_ Text
pPrefix_ =
  ErrorReportLocation'
    { $sel:bucket:ErrorReportLocation' :: Text
bucket = Text
pBucket_,
      $sel:prefix:ErrorReportLocation' :: Text
prefix = Text
pPrefix_
    }

-- | The name of the Amazon S3 bucket to which errors associated with the
-- bulk import job are sent.
errorReportLocation_bucket :: Lens.Lens' ErrorReportLocation Prelude.Text
errorReportLocation_bucket :: Lens' ErrorReportLocation Text
errorReportLocation_bucket = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorReportLocation' {Text
bucket :: Text
$sel:bucket:ErrorReportLocation' :: ErrorReportLocation -> Text
bucket} -> Text
bucket) (\s :: ErrorReportLocation
s@ErrorReportLocation' {} Text
a -> ErrorReportLocation
s {$sel:bucket:ErrorReportLocation' :: Text
bucket = Text
a} :: ErrorReportLocation)

-- | Amazon S3 uses the prefix as a folder name to organize data in the
-- bucket. Each Amazon S3 object has a key that is its unique identifier in
-- the bucket. Each object in a bucket has exactly one key. The prefix must
-- end with a forward slash (\/). For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-prefixes.html Organizing objects using prefixes>
-- in the /Amazon Simple Storage Service User Guide/.
errorReportLocation_prefix :: Lens.Lens' ErrorReportLocation Prelude.Text
errorReportLocation_prefix :: Lens' ErrorReportLocation Text
errorReportLocation_prefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorReportLocation' {Text
prefix :: Text
$sel:prefix:ErrorReportLocation' :: ErrorReportLocation -> Text
prefix} -> Text
prefix) (\s :: ErrorReportLocation
s@ErrorReportLocation' {} Text
a -> ErrorReportLocation
s {$sel:prefix:ErrorReportLocation' :: Text
prefix = Text
a} :: ErrorReportLocation)

instance Data.FromJSON ErrorReportLocation where
  parseJSON :: Value -> Parser ErrorReportLocation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ErrorReportLocation"
      ( \Object
x ->
          Text -> Text -> ErrorReportLocation
ErrorReportLocation'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"bucket")
            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
"prefix")
      )

instance Prelude.Hashable ErrorReportLocation where
  hashWithSalt :: Int -> ErrorReportLocation -> Int
hashWithSalt Int
_salt ErrorReportLocation' {Text
prefix :: Text
bucket :: Text
$sel:prefix:ErrorReportLocation' :: ErrorReportLocation -> Text
$sel:bucket:ErrorReportLocation' :: ErrorReportLocation -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
bucket
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
prefix

instance Prelude.NFData ErrorReportLocation where
  rnf :: ErrorReportLocation -> ()
rnf ErrorReportLocation' {Text
prefix :: Text
bucket :: Text
$sel:prefix:ErrorReportLocation' :: ErrorReportLocation -> Text
$sel:bucket:ErrorReportLocation' :: ErrorReportLocation -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
bucket seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
prefix

instance Data.ToJSON ErrorReportLocation where
  toJSON :: ErrorReportLocation -> Value
toJSON ErrorReportLocation' {Text
prefix :: Text
bucket :: Text
$sel:prefix:ErrorReportLocation' :: ErrorReportLocation -> Text
$sel:bucket:ErrorReportLocation' :: ErrorReportLocation -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"bucket" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
bucket),
            forall a. a -> Maybe a
Prelude.Just (Key
"prefix" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
prefix)
          ]
      )