{-# 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.Kendra.Types.S3Path
-- 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.Kendra.Types.S3Path 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

-- | Information required to find a specific file in an Amazon S3 bucket.
--
-- /See:/ 'newS3Path' smart constructor.
data S3Path = S3Path'
  { -- | The name of the S3 bucket that contains the file.
    S3Path -> Text
bucket :: Prelude.Text,
    -- | The name of the file.
    S3Path -> Text
key :: Prelude.Text
  }
  deriving (S3Path -> S3Path -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Path -> S3Path -> Bool
$c/= :: S3Path -> S3Path -> Bool
== :: S3Path -> S3Path -> Bool
$c== :: S3Path -> S3Path -> Bool
Prelude.Eq, ReadPrec [S3Path]
ReadPrec S3Path
Int -> ReadS S3Path
ReadS [S3Path]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Path]
$creadListPrec :: ReadPrec [S3Path]
readPrec :: ReadPrec S3Path
$creadPrec :: ReadPrec S3Path
readList :: ReadS [S3Path]
$creadList :: ReadS [S3Path]
readsPrec :: Int -> ReadS S3Path
$creadsPrec :: Int -> ReadS S3Path
Prelude.Read, Int -> S3Path -> ShowS
[S3Path] -> ShowS
S3Path -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Path] -> ShowS
$cshowList :: [S3Path] -> ShowS
show :: S3Path -> String
$cshow :: S3Path -> String
showsPrec :: Int -> S3Path -> ShowS
$cshowsPrec :: Int -> S3Path -> ShowS
Prelude.Show, forall x. Rep S3Path x -> S3Path
forall x. S3Path -> Rep S3Path x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Path x -> S3Path
$cfrom :: forall x. S3Path -> Rep S3Path x
Prelude.Generic)

-- |
-- Create a value of 'S3Path' 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', 's3Path_bucket' - The name of the S3 bucket that contains the file.
--
-- 'key', 's3Path_key' - The name of the file.
newS3Path ::
  -- | 'bucket'
  Prelude.Text ->
  -- | 'key'
  Prelude.Text ->
  S3Path
newS3Path :: Text -> Text -> S3Path
newS3Path Text
pBucket_ Text
pKey_ =
  S3Path' {$sel:bucket:S3Path' :: Text
bucket = Text
pBucket_, $sel:key:S3Path' :: Text
key = Text
pKey_}

-- | The name of the S3 bucket that contains the file.
s3Path_bucket :: Lens.Lens' S3Path Prelude.Text
s3Path_bucket :: Lens' S3Path Text
s3Path_bucket = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Path' {Text
bucket :: Text
$sel:bucket:S3Path' :: S3Path -> Text
bucket} -> Text
bucket) (\s :: S3Path
s@S3Path' {} Text
a -> S3Path
s {$sel:bucket:S3Path' :: Text
bucket = Text
a} :: S3Path)

-- | The name of the file.
s3Path_key :: Lens.Lens' S3Path Prelude.Text
s3Path_key :: Lens' S3Path Text
s3Path_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Path' {Text
key :: Text
$sel:key:S3Path' :: S3Path -> Text
key} -> Text
key) (\s :: S3Path
s@S3Path' {} Text
a -> S3Path
s {$sel:key:S3Path' :: Text
key = Text
a} :: S3Path)

instance Data.FromJSON S3Path where
  parseJSON :: Value -> Parser S3Path
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3Path"
      ( \Object
x ->
          Text -> Text -> S3Path
S3Path'
            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
"Key")
      )

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

instance Prelude.NFData S3Path where
  rnf :: S3Path -> ()
rnf S3Path' {Text
key :: Text
bucket :: Text
$sel:key:S3Path' :: S3Path -> Text
$sel:bucket:S3Path' :: S3Path -> 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
key

instance Data.ToJSON S3Path where
  toJSON :: S3Path -> Value
toJSON S3Path' {Text
key :: Text
bucket :: Text
$sel:key:S3Path' :: S3Path -> Text
$sel:bucket:S3Path' :: S3Path -> 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
"Key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
key)
          ]
      )