{-# 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.LexV2Models.Types.PathFormat
-- 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.LexV2Models.Types.PathFormat 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 object that contains a path format that will be applied when Amazon
-- Lex reads the transcript file in the bucket you provide. Specify this
-- object if you only want Lex to read a subset of files in your Amazon S3
-- bucket.
--
-- /See:/ 'newPathFormat' smart constructor.
data PathFormat = PathFormat'
  { -- | A list of Amazon S3 prefixes that points to sub-folders in the Amazon S3
    -- bucket. Specify this list if you only want Lex to read the files under
    -- this set of sub-folders.
    PathFormat -> Maybe (NonEmpty Text)
objectPrefixes :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text)
  }
  deriving (PathFormat -> PathFormat -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PathFormat -> PathFormat -> Bool
$c/= :: PathFormat -> PathFormat -> Bool
== :: PathFormat -> PathFormat -> Bool
$c== :: PathFormat -> PathFormat -> Bool
Prelude.Eq, ReadPrec [PathFormat]
ReadPrec PathFormat
Int -> ReadS PathFormat
ReadS [PathFormat]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PathFormat]
$creadListPrec :: ReadPrec [PathFormat]
readPrec :: ReadPrec PathFormat
$creadPrec :: ReadPrec PathFormat
readList :: ReadS [PathFormat]
$creadList :: ReadS [PathFormat]
readsPrec :: Int -> ReadS PathFormat
$creadsPrec :: Int -> ReadS PathFormat
Prelude.Read, Int -> PathFormat -> ShowS
[PathFormat] -> ShowS
PathFormat -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PathFormat] -> ShowS
$cshowList :: [PathFormat] -> ShowS
show :: PathFormat -> String
$cshow :: PathFormat -> String
showsPrec :: Int -> PathFormat -> ShowS
$cshowsPrec :: Int -> PathFormat -> ShowS
Prelude.Show, forall x. Rep PathFormat x -> PathFormat
forall x. PathFormat -> Rep PathFormat x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PathFormat x -> PathFormat
$cfrom :: forall x. PathFormat -> Rep PathFormat x
Prelude.Generic)

-- |
-- Create a value of 'PathFormat' 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:
--
-- 'objectPrefixes', 'pathFormat_objectPrefixes' - A list of Amazon S3 prefixes that points to sub-folders in the Amazon S3
-- bucket. Specify this list if you only want Lex to read the files under
-- this set of sub-folders.
newPathFormat ::
  PathFormat
newPathFormat :: PathFormat
newPathFormat =
  PathFormat' {$sel:objectPrefixes:PathFormat' :: Maybe (NonEmpty Text)
objectPrefixes = forall a. Maybe a
Prelude.Nothing}

-- | A list of Amazon S3 prefixes that points to sub-folders in the Amazon S3
-- bucket. Specify this list if you only want Lex to read the files under
-- this set of sub-folders.
pathFormat_objectPrefixes :: Lens.Lens' PathFormat (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
pathFormat_objectPrefixes :: Lens' PathFormat (Maybe (NonEmpty Text))
pathFormat_objectPrefixes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PathFormat' {Maybe (NonEmpty Text)
objectPrefixes :: Maybe (NonEmpty Text)
$sel:objectPrefixes:PathFormat' :: PathFormat -> Maybe (NonEmpty Text)
objectPrefixes} -> Maybe (NonEmpty Text)
objectPrefixes) (\s :: PathFormat
s@PathFormat' {} Maybe (NonEmpty Text)
a -> PathFormat
s {$sel:objectPrefixes:PathFormat' :: Maybe (NonEmpty Text)
objectPrefixes = Maybe (NonEmpty Text)
a} :: PathFormat) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable PathFormat where
  hashWithSalt :: Int -> PathFormat -> Int
hashWithSalt Int
_salt PathFormat' {Maybe (NonEmpty Text)
objectPrefixes :: Maybe (NonEmpty Text)
$sel:objectPrefixes:PathFormat' :: PathFormat -> Maybe (NonEmpty Text)
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
objectPrefixes

instance Prelude.NFData PathFormat where
  rnf :: PathFormat -> ()
rnf PathFormat' {Maybe (NonEmpty Text)
objectPrefixes :: Maybe (NonEmpty Text)
$sel:objectPrefixes:PathFormat' :: PathFormat -> Maybe (NonEmpty Text)
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
objectPrefixes

instance Data.ToJSON PathFormat where
  toJSON :: PathFormat -> Value
toJSON PathFormat' {Maybe (NonEmpty Text)
objectPrefixes :: Maybe (NonEmpty Text)
$sel:objectPrefixes:PathFormat' :: PathFormat -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"objectPrefixes" 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 (NonEmpty Text)
objectPrefixes
          ]
      )