{-# 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.DataBrew.Types.RecipeReference
-- 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.DataBrew.Types.RecipeReference where

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

-- | Represents the name and version of a DataBrew recipe.
--
-- /See:/ 'newRecipeReference' smart constructor.
data RecipeReference = RecipeReference'
  { -- | The identifier for the version for the recipe.
    RecipeReference -> Maybe Text
recipeVersion :: Prelude.Maybe Prelude.Text,
    -- | The name of the recipe.
    RecipeReference -> Text
name :: Prelude.Text
  }
  deriving (RecipeReference -> RecipeReference -> Bool
(RecipeReference -> RecipeReference -> Bool)
-> (RecipeReference -> RecipeReference -> Bool)
-> Eq RecipeReference
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecipeReference -> RecipeReference -> Bool
$c/= :: RecipeReference -> RecipeReference -> Bool
== :: RecipeReference -> RecipeReference -> Bool
$c== :: RecipeReference -> RecipeReference -> Bool
Prelude.Eq, ReadPrec [RecipeReference]
ReadPrec RecipeReference
Int -> ReadS RecipeReference
ReadS [RecipeReference]
(Int -> ReadS RecipeReference)
-> ReadS [RecipeReference]
-> ReadPrec RecipeReference
-> ReadPrec [RecipeReference]
-> Read RecipeReference
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RecipeReference]
$creadListPrec :: ReadPrec [RecipeReference]
readPrec :: ReadPrec RecipeReference
$creadPrec :: ReadPrec RecipeReference
readList :: ReadS [RecipeReference]
$creadList :: ReadS [RecipeReference]
readsPrec :: Int -> ReadS RecipeReference
$creadsPrec :: Int -> ReadS RecipeReference
Prelude.Read, Int -> RecipeReference -> ShowS
[RecipeReference] -> ShowS
RecipeReference -> String
(Int -> RecipeReference -> ShowS)
-> (RecipeReference -> String)
-> ([RecipeReference] -> ShowS)
-> Show RecipeReference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecipeReference] -> ShowS
$cshowList :: [RecipeReference] -> ShowS
show :: RecipeReference -> String
$cshow :: RecipeReference -> String
showsPrec :: Int -> RecipeReference -> ShowS
$cshowsPrec :: Int -> RecipeReference -> ShowS
Prelude.Show, (forall x. RecipeReference -> Rep RecipeReference x)
-> (forall x. Rep RecipeReference x -> RecipeReference)
-> Generic RecipeReference
forall x. Rep RecipeReference x -> RecipeReference
forall x. RecipeReference -> Rep RecipeReference x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RecipeReference x -> RecipeReference
$cfrom :: forall x. RecipeReference -> Rep RecipeReference x
Prelude.Generic)

-- |
-- Create a value of 'RecipeReference' 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:
--
-- 'recipeVersion', 'recipeReference_recipeVersion' - The identifier for the version for the recipe.
--
-- 'name', 'recipeReference_name' - The name of the recipe.
newRecipeReference ::
  -- | 'name'
  Prelude.Text ->
  RecipeReference
newRecipeReference :: Text -> RecipeReference
newRecipeReference Text
pName_ =
  RecipeReference' :: Maybe Text -> Text -> RecipeReference
RecipeReference'
    { $sel:recipeVersion:RecipeReference' :: Maybe Text
recipeVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:RecipeReference' :: Text
name = Text
pName_
    }

-- | The identifier for the version for the recipe.
recipeReference_recipeVersion :: Lens.Lens' RecipeReference (Prelude.Maybe Prelude.Text)
recipeReference_recipeVersion :: (Maybe Text -> f (Maybe Text))
-> RecipeReference -> f RecipeReference
recipeReference_recipeVersion = (RecipeReference -> Maybe Text)
-> (RecipeReference -> Maybe Text -> RecipeReference)
-> Lens RecipeReference RecipeReference (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecipeReference' {Maybe Text
recipeVersion :: Maybe Text
$sel:recipeVersion:RecipeReference' :: RecipeReference -> Maybe Text
recipeVersion} -> Maybe Text
recipeVersion) (\s :: RecipeReference
s@RecipeReference' {} Maybe Text
a -> RecipeReference
s {$sel:recipeVersion:RecipeReference' :: Maybe Text
recipeVersion = Maybe Text
a} :: RecipeReference)

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

instance Core.FromJSON RecipeReference where
  parseJSON :: Value -> Parser RecipeReference
parseJSON =
    String
-> (Object -> Parser RecipeReference)
-> Value
-> Parser RecipeReference
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RecipeReference"
      ( \Object
x ->
          Maybe Text -> Text -> RecipeReference
RecipeReference'
            (Maybe Text -> Text -> RecipeReference)
-> Parser (Maybe Text) -> Parser (Text -> RecipeReference)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RecipeVersion")
            Parser (Text -> RecipeReference)
-> Parser Text -> Parser RecipeReference
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
"Name")
      )

instance Prelude.Hashable RecipeReference

instance Prelude.NFData RecipeReference

instance Core.ToJSON RecipeReference where
  toJSON :: RecipeReference -> Value
toJSON RecipeReference' {Maybe Text
Text
name :: Text
recipeVersion :: Maybe Text
$sel:name:RecipeReference' :: RecipeReference -> Text
$sel:recipeVersion:RecipeReference' :: RecipeReference -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RecipeVersion" 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
recipeVersion,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )