{-# 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.GrammarSlotTypeSource
-- 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.GrammarSlotTypeSource 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

-- | Describes the Amazon S3 bucket name and location for the grammar that is
-- the source for the slot type.
--
-- /See:/ 'newGrammarSlotTypeSource' smart constructor.
data GrammarSlotTypeSource = GrammarSlotTypeSource'
  { -- | The Amazon KMS key required to decrypt the contents of the grammar, if
    -- any.
    GrammarSlotTypeSource -> Maybe Text
kmsKeyArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the S3 bucket that contains the grammar source.
    GrammarSlotTypeSource -> Text
s3BucketName :: Prelude.Text,
    -- | The path to the grammar in the S3 bucket.
    GrammarSlotTypeSource -> Text
s3ObjectKey :: Prelude.Text
  }
  deriving (GrammarSlotTypeSource -> GrammarSlotTypeSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GrammarSlotTypeSource -> GrammarSlotTypeSource -> Bool
$c/= :: GrammarSlotTypeSource -> GrammarSlotTypeSource -> Bool
== :: GrammarSlotTypeSource -> GrammarSlotTypeSource -> Bool
$c== :: GrammarSlotTypeSource -> GrammarSlotTypeSource -> Bool
Prelude.Eq, ReadPrec [GrammarSlotTypeSource]
ReadPrec GrammarSlotTypeSource
Int -> ReadS GrammarSlotTypeSource
ReadS [GrammarSlotTypeSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GrammarSlotTypeSource]
$creadListPrec :: ReadPrec [GrammarSlotTypeSource]
readPrec :: ReadPrec GrammarSlotTypeSource
$creadPrec :: ReadPrec GrammarSlotTypeSource
readList :: ReadS [GrammarSlotTypeSource]
$creadList :: ReadS [GrammarSlotTypeSource]
readsPrec :: Int -> ReadS GrammarSlotTypeSource
$creadsPrec :: Int -> ReadS GrammarSlotTypeSource
Prelude.Read, Int -> GrammarSlotTypeSource -> ShowS
[GrammarSlotTypeSource] -> ShowS
GrammarSlotTypeSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GrammarSlotTypeSource] -> ShowS
$cshowList :: [GrammarSlotTypeSource] -> ShowS
show :: GrammarSlotTypeSource -> String
$cshow :: GrammarSlotTypeSource -> String
showsPrec :: Int -> GrammarSlotTypeSource -> ShowS
$cshowsPrec :: Int -> GrammarSlotTypeSource -> ShowS
Prelude.Show, forall x. Rep GrammarSlotTypeSource x -> GrammarSlotTypeSource
forall x. GrammarSlotTypeSource -> Rep GrammarSlotTypeSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GrammarSlotTypeSource x -> GrammarSlotTypeSource
$cfrom :: forall x. GrammarSlotTypeSource -> Rep GrammarSlotTypeSource x
Prelude.Generic)

-- |
-- Create a value of 'GrammarSlotTypeSource' 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:
--
-- 'kmsKeyArn', 'grammarSlotTypeSource_kmsKeyArn' - The Amazon KMS key required to decrypt the contents of the grammar, if
-- any.
--
-- 's3BucketName', 'grammarSlotTypeSource_s3BucketName' - The name of the S3 bucket that contains the grammar source.
--
-- 's3ObjectKey', 'grammarSlotTypeSource_s3ObjectKey' - The path to the grammar in the S3 bucket.
newGrammarSlotTypeSource ::
  -- | 's3BucketName'
  Prelude.Text ->
  -- | 's3ObjectKey'
  Prelude.Text ->
  GrammarSlotTypeSource
newGrammarSlotTypeSource :: Text -> Text -> GrammarSlotTypeSource
newGrammarSlotTypeSource Text
pS3BucketName_ Text
pS3ObjectKey_ =
  GrammarSlotTypeSource'
    { $sel:kmsKeyArn:GrammarSlotTypeSource' :: Maybe Text
kmsKeyArn = forall a. Maybe a
Prelude.Nothing,
      $sel:s3BucketName:GrammarSlotTypeSource' :: Text
s3BucketName = Text
pS3BucketName_,
      $sel:s3ObjectKey:GrammarSlotTypeSource' :: Text
s3ObjectKey = Text
pS3ObjectKey_
    }

-- | The Amazon KMS key required to decrypt the contents of the grammar, if
-- any.
grammarSlotTypeSource_kmsKeyArn :: Lens.Lens' GrammarSlotTypeSource (Prelude.Maybe Prelude.Text)
grammarSlotTypeSource_kmsKeyArn :: Lens' GrammarSlotTypeSource (Maybe Text)
grammarSlotTypeSource_kmsKeyArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrammarSlotTypeSource' {Maybe Text
kmsKeyArn :: Maybe Text
$sel:kmsKeyArn:GrammarSlotTypeSource' :: GrammarSlotTypeSource -> Maybe Text
kmsKeyArn} -> Maybe Text
kmsKeyArn) (\s :: GrammarSlotTypeSource
s@GrammarSlotTypeSource' {} Maybe Text
a -> GrammarSlotTypeSource
s {$sel:kmsKeyArn:GrammarSlotTypeSource' :: Maybe Text
kmsKeyArn = Maybe Text
a} :: GrammarSlotTypeSource)

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

-- | The path to the grammar in the S3 bucket.
grammarSlotTypeSource_s3ObjectKey :: Lens.Lens' GrammarSlotTypeSource Prelude.Text
grammarSlotTypeSource_s3ObjectKey :: Lens' GrammarSlotTypeSource Text
grammarSlotTypeSource_s3ObjectKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrammarSlotTypeSource' {Text
s3ObjectKey :: Text
$sel:s3ObjectKey:GrammarSlotTypeSource' :: GrammarSlotTypeSource -> Text
s3ObjectKey} -> Text
s3ObjectKey) (\s :: GrammarSlotTypeSource
s@GrammarSlotTypeSource' {} Text
a -> GrammarSlotTypeSource
s {$sel:s3ObjectKey:GrammarSlotTypeSource' :: Text
s3ObjectKey = Text
a} :: GrammarSlotTypeSource)

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

instance Prelude.Hashable GrammarSlotTypeSource where
  hashWithSalt :: Int -> GrammarSlotTypeSource -> Int
hashWithSalt Int
_salt GrammarSlotTypeSource' {Maybe Text
Text
s3ObjectKey :: Text
s3BucketName :: Text
kmsKeyArn :: Maybe Text
$sel:s3ObjectKey:GrammarSlotTypeSource' :: GrammarSlotTypeSource -> Text
$sel:s3BucketName:GrammarSlotTypeSource' :: GrammarSlotTypeSource -> Text
$sel:kmsKeyArn:GrammarSlotTypeSource' :: GrammarSlotTypeSource -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
s3BucketName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
s3ObjectKey

instance Prelude.NFData GrammarSlotTypeSource where
  rnf :: GrammarSlotTypeSource -> ()
rnf GrammarSlotTypeSource' {Maybe Text
Text
s3ObjectKey :: Text
s3BucketName :: Text
kmsKeyArn :: Maybe Text
$sel:s3ObjectKey:GrammarSlotTypeSource' :: GrammarSlotTypeSource -> Text
$sel:s3BucketName:GrammarSlotTypeSource' :: GrammarSlotTypeSource -> Text
$sel:kmsKeyArn:GrammarSlotTypeSource' :: GrammarSlotTypeSource -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
s3BucketName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
s3ObjectKey

instance Data.ToJSON GrammarSlotTypeSource where
  toJSON :: GrammarSlotTypeSource -> Value
toJSON GrammarSlotTypeSource' {Maybe Text
Text
s3ObjectKey :: Text
s3BucketName :: Text
kmsKeyArn :: Maybe Text
$sel:s3ObjectKey:GrammarSlotTypeSource' :: GrammarSlotTypeSource -> Text
$sel:s3BucketName:GrammarSlotTypeSource' :: GrammarSlotTypeSource -> Text
$sel:kmsKeyArn:GrammarSlotTypeSource' :: GrammarSlotTypeSource -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"kmsKeyArn" 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
kmsKeyArn,
            forall a. a -> Maybe a
Prelude.Just (Key
"s3BucketName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
s3BucketName),
            forall a. a -> Maybe a
Prelude.Just (Key
"s3ObjectKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
s3ObjectKey)
          ]
      )