{-# 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.LexModels.Types.Intent
-- 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.LexModels.Types.Intent where

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

-- | Identifies the specific version of an intent.
--
-- /See:/ 'newIntent' smart constructor.
data Intent = Intent'
  { -- | The name of the intent.
    Intent -> Text
intentName :: Prelude.Text,
    -- | The version of the intent.
    Intent -> Text
intentVersion :: Prelude.Text
  }
  deriving (Intent -> Intent -> Bool
(Intent -> Intent -> Bool)
-> (Intent -> Intent -> Bool) -> Eq Intent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Intent -> Intent -> Bool
$c/= :: Intent -> Intent -> Bool
== :: Intent -> Intent -> Bool
$c== :: Intent -> Intent -> Bool
Prelude.Eq, ReadPrec [Intent]
ReadPrec Intent
Int -> ReadS Intent
ReadS [Intent]
(Int -> ReadS Intent)
-> ReadS [Intent]
-> ReadPrec Intent
-> ReadPrec [Intent]
-> Read Intent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Intent]
$creadListPrec :: ReadPrec [Intent]
readPrec :: ReadPrec Intent
$creadPrec :: ReadPrec Intent
readList :: ReadS [Intent]
$creadList :: ReadS [Intent]
readsPrec :: Int -> ReadS Intent
$creadsPrec :: Int -> ReadS Intent
Prelude.Read, Int -> Intent -> ShowS
[Intent] -> ShowS
Intent -> String
(Int -> Intent -> ShowS)
-> (Intent -> String) -> ([Intent] -> ShowS) -> Show Intent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Intent] -> ShowS
$cshowList :: [Intent] -> ShowS
show :: Intent -> String
$cshow :: Intent -> String
showsPrec :: Int -> Intent -> ShowS
$cshowsPrec :: Int -> Intent -> ShowS
Prelude.Show, (forall x. Intent -> Rep Intent x)
-> (forall x. Rep Intent x -> Intent) -> Generic Intent
forall x. Rep Intent x -> Intent
forall x. Intent -> Rep Intent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Intent x -> Intent
$cfrom :: forall x. Intent -> Rep Intent x
Prelude.Generic)

-- |
-- Create a value of 'Intent' 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:
--
-- 'intentName', 'intent_intentName' - The name of the intent.
--
-- 'intentVersion', 'intent_intentVersion' - The version of the intent.
newIntent ::
  -- | 'intentName'
  Prelude.Text ->
  -- | 'intentVersion'
  Prelude.Text ->
  Intent
newIntent :: Text -> Text -> Intent
newIntent Text
pIntentName_ Text
pIntentVersion_ =
  Intent' :: Text -> Text -> Intent
Intent'
    { $sel:intentName:Intent' :: Text
intentName = Text
pIntentName_,
      $sel:intentVersion:Intent' :: Text
intentVersion = Text
pIntentVersion_
    }

-- | The name of the intent.
intent_intentName :: Lens.Lens' Intent Prelude.Text
intent_intentName :: (Text -> f Text) -> Intent -> f Intent
intent_intentName = (Intent -> Text)
-> (Intent -> Text -> Intent) -> Lens Intent Intent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Intent' {Text
intentName :: Text
$sel:intentName:Intent' :: Intent -> Text
intentName} -> Text
intentName) (\s :: Intent
s@Intent' {} Text
a -> Intent
s {$sel:intentName:Intent' :: Text
intentName = Text
a} :: Intent)

-- | The version of the intent.
intent_intentVersion :: Lens.Lens' Intent Prelude.Text
intent_intentVersion :: (Text -> f Text) -> Intent -> f Intent
intent_intentVersion = (Intent -> Text)
-> (Intent -> Text -> Intent) -> Lens Intent Intent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Intent' {Text
intentVersion :: Text
$sel:intentVersion:Intent' :: Intent -> Text
intentVersion} -> Text
intentVersion) (\s :: Intent
s@Intent' {} Text
a -> Intent
s {$sel:intentVersion:Intent' :: Text
intentVersion = Text
a} :: Intent)

instance Core.FromJSON Intent where
  parseJSON :: Value -> Parser Intent
parseJSON =
    String -> (Object -> Parser Intent) -> Value -> Parser Intent
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Intent"
      ( \Object
x ->
          Text -> Text -> Intent
Intent'
            (Text -> Text -> Intent) -> Parser Text -> Parser (Text -> Intent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"intentName")
            Parser (Text -> Intent) -> Parser Text -> Parser Intent
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"intentVersion")
      )

instance Prelude.Hashable Intent

instance Prelude.NFData Intent

instance Core.ToJSON Intent where
  toJSON :: Intent -> Value
toJSON Intent' {Text
intentVersion :: Text
intentName :: Text
$sel:intentVersion:Intent' :: Intent -> Text
$sel:intentName:Intent' :: Intent -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"intentName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
intentName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"intentVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
intentVersion)
          ]
      )