{-# 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.Textract.Types.S3Object
-- 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.Textract.Types.S3Object where

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

-- | The S3 bucket name and file name that identifies the document.
--
-- The AWS Region for the S3 bucket that contains the document must match
-- the Region that you use for Amazon Textract operations.
--
-- For Amazon Textract to process a file in an S3 bucket, the user must
-- have permission to access the S3 bucket and file.
--
-- /See:/ 'newS3Object' smart constructor.
data S3Object = S3Object'
  { -- | The name of the S3 bucket. Note that the # character is not valid in the
    -- file name.
    S3Object -> Maybe Text
bucket :: Prelude.Maybe Prelude.Text,
    -- | The file name of the input document. Synchronous operations can use
    -- image files that are in JPEG or PNG format. Asynchronous operations also
    -- support PDF format files.
    S3Object -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | If the bucket has versioning enabled, you can specify the object
    -- version.
    S3Object -> Maybe Text
version :: Prelude.Maybe Prelude.Text
  }
  deriving (S3Object -> S3Object -> Bool
(S3Object -> S3Object -> Bool)
-> (S3Object -> S3Object -> Bool) -> Eq S3Object
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Object -> S3Object -> Bool
$c/= :: S3Object -> S3Object -> Bool
== :: S3Object -> S3Object -> Bool
$c== :: S3Object -> S3Object -> Bool
Prelude.Eq, ReadPrec [S3Object]
ReadPrec S3Object
Int -> ReadS S3Object
ReadS [S3Object]
(Int -> ReadS S3Object)
-> ReadS [S3Object]
-> ReadPrec S3Object
-> ReadPrec [S3Object]
-> Read S3Object
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Object]
$creadListPrec :: ReadPrec [S3Object]
readPrec :: ReadPrec S3Object
$creadPrec :: ReadPrec S3Object
readList :: ReadS [S3Object]
$creadList :: ReadS [S3Object]
readsPrec :: Int -> ReadS S3Object
$creadsPrec :: Int -> ReadS S3Object
Prelude.Read, Int -> S3Object -> ShowS
[S3Object] -> ShowS
S3Object -> String
(Int -> S3Object -> ShowS)
-> (S3Object -> String) -> ([S3Object] -> ShowS) -> Show S3Object
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Object] -> ShowS
$cshowList :: [S3Object] -> ShowS
show :: S3Object -> String
$cshow :: S3Object -> String
showsPrec :: Int -> S3Object -> ShowS
$cshowsPrec :: Int -> S3Object -> ShowS
Prelude.Show, (forall x. S3Object -> Rep S3Object x)
-> (forall x. Rep S3Object x -> S3Object) -> Generic S3Object
forall x. Rep S3Object x -> S3Object
forall x. S3Object -> Rep S3Object x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Object x -> S3Object
$cfrom :: forall x. S3Object -> Rep S3Object x
Prelude.Generic)

-- |
-- Create a value of 'S3Object' 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', 's3Object_bucket' - The name of the S3 bucket. Note that the # character is not valid in the
-- file name.
--
-- 'name', 's3Object_name' - The file name of the input document. Synchronous operations can use
-- image files that are in JPEG or PNG format. Asynchronous operations also
-- support PDF format files.
--
-- 'version', 's3Object_version' - If the bucket has versioning enabled, you can specify the object
-- version.
newS3Object ::
  S3Object
newS3Object :: S3Object
newS3Object =
  S3Object' :: Maybe Text -> Maybe Text -> Maybe Text -> S3Object
S3Object'
    { $sel:bucket:S3Object' :: Maybe Text
bucket = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:S3Object' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:version:S3Object' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the S3 bucket. Note that the # character is not valid in the
-- file name.
s3Object_bucket :: Lens.Lens' S3Object (Prelude.Maybe Prelude.Text)
s3Object_bucket :: (Maybe Text -> f (Maybe Text)) -> S3Object -> f S3Object
s3Object_bucket = (S3Object -> Maybe Text)
-> (S3Object -> Maybe Text -> S3Object)
-> Lens S3Object S3Object (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Object' {Maybe Text
bucket :: Maybe Text
$sel:bucket:S3Object' :: S3Object -> Maybe Text
bucket} -> Maybe Text
bucket) (\s :: S3Object
s@S3Object' {} Maybe Text
a -> S3Object
s {$sel:bucket:S3Object' :: Maybe Text
bucket = Maybe Text
a} :: S3Object)

-- | The file name of the input document. Synchronous operations can use
-- image files that are in JPEG or PNG format. Asynchronous operations also
-- support PDF format files.
s3Object_name :: Lens.Lens' S3Object (Prelude.Maybe Prelude.Text)
s3Object_name :: (Maybe Text -> f (Maybe Text)) -> S3Object -> f S3Object
s3Object_name = (S3Object -> Maybe Text)
-> (S3Object -> Maybe Text -> S3Object)
-> Lens S3Object S3Object (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Object' {Maybe Text
name :: Maybe Text
$sel:name:S3Object' :: S3Object -> Maybe Text
name} -> Maybe Text
name) (\s :: S3Object
s@S3Object' {} Maybe Text
a -> S3Object
s {$sel:name:S3Object' :: Maybe Text
name = Maybe Text
a} :: S3Object)

-- | If the bucket has versioning enabled, you can specify the object
-- version.
s3Object_version :: Lens.Lens' S3Object (Prelude.Maybe Prelude.Text)
s3Object_version :: (Maybe Text -> f (Maybe Text)) -> S3Object -> f S3Object
s3Object_version = (S3Object -> Maybe Text)
-> (S3Object -> Maybe Text -> S3Object)
-> Lens S3Object S3Object (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Object' {Maybe Text
version :: Maybe Text
$sel:version:S3Object' :: S3Object -> Maybe Text
version} -> Maybe Text
version) (\s :: S3Object
s@S3Object' {} Maybe Text
a -> S3Object
s {$sel:version:S3Object' :: Maybe Text
version = Maybe Text
a} :: S3Object)

instance Prelude.Hashable S3Object

instance Prelude.NFData S3Object

instance Core.ToJSON S3Object where
  toJSON :: S3Object -> Value
toJSON S3Object' {Maybe Text
version :: Maybe Text
name :: Maybe Text
bucket :: Maybe Text
$sel:version:S3Object' :: S3Object -> Maybe Text
$sel:name:S3Object' :: S3Object -> Maybe Text
$sel:bucket:S3Object' :: S3Object -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Bucket" 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
bucket,
            (Text
"Name" 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
name,
            (Text
"Version" 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
version
          ]
      )