{-# 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.Glue.Types.SchemaId
-- 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.Glue.Types.SchemaId 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 unique ID of the schema in the Glue schema registry.
--
-- /See:/ 'newSchemaId' smart constructor.
data SchemaId = SchemaId'
  { -- | The name of the schema registry that contains the schema.
    SchemaId -> Maybe Text
registryName :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the schema. One of @SchemaArn@ or
    -- @SchemaName@ has to be provided.
    SchemaId -> Maybe Text
schemaArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the schema. One of @SchemaArn@ or @SchemaName@ has to be
    -- provided.
    SchemaId -> Maybe Text
schemaName :: Prelude.Maybe Prelude.Text
  }
  deriving (SchemaId -> SchemaId -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SchemaId -> SchemaId -> Bool
$c/= :: SchemaId -> SchemaId -> Bool
== :: SchemaId -> SchemaId -> Bool
$c== :: SchemaId -> SchemaId -> Bool
Prelude.Eq, ReadPrec [SchemaId]
ReadPrec SchemaId
Int -> ReadS SchemaId
ReadS [SchemaId]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SchemaId]
$creadListPrec :: ReadPrec [SchemaId]
readPrec :: ReadPrec SchemaId
$creadPrec :: ReadPrec SchemaId
readList :: ReadS [SchemaId]
$creadList :: ReadS [SchemaId]
readsPrec :: Int -> ReadS SchemaId
$creadsPrec :: Int -> ReadS SchemaId
Prelude.Read, Int -> SchemaId -> ShowS
[SchemaId] -> ShowS
SchemaId -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SchemaId] -> ShowS
$cshowList :: [SchemaId] -> ShowS
show :: SchemaId -> String
$cshow :: SchemaId -> String
showsPrec :: Int -> SchemaId -> ShowS
$cshowsPrec :: Int -> SchemaId -> ShowS
Prelude.Show, forall x. Rep SchemaId x -> SchemaId
forall x. SchemaId -> Rep SchemaId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SchemaId x -> SchemaId
$cfrom :: forall x. SchemaId -> Rep SchemaId x
Prelude.Generic)

-- |
-- Create a value of 'SchemaId' 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:
--
-- 'registryName', 'schemaId_registryName' - The name of the schema registry that contains the schema.
--
-- 'schemaArn', 'schemaId_schemaArn' - The Amazon Resource Name (ARN) of the schema. One of @SchemaArn@ or
-- @SchemaName@ has to be provided.
--
-- 'schemaName', 'schemaId_schemaName' - The name of the schema. One of @SchemaArn@ or @SchemaName@ has to be
-- provided.
newSchemaId ::
  SchemaId
newSchemaId :: SchemaId
newSchemaId =
  SchemaId'
    { $sel:registryName:SchemaId' :: Maybe Text
registryName = forall a. Maybe a
Prelude.Nothing,
      $sel:schemaArn:SchemaId' :: Maybe Text
schemaArn = forall a. Maybe a
Prelude.Nothing,
      $sel:schemaName:SchemaId' :: Maybe Text
schemaName = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the schema registry that contains the schema.
schemaId_registryName :: Lens.Lens' SchemaId (Prelude.Maybe Prelude.Text)
schemaId_registryName :: Lens' SchemaId (Maybe Text)
schemaId_registryName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaId' {Maybe Text
registryName :: Maybe Text
$sel:registryName:SchemaId' :: SchemaId -> Maybe Text
registryName} -> Maybe Text
registryName) (\s :: SchemaId
s@SchemaId' {} Maybe Text
a -> SchemaId
s {$sel:registryName:SchemaId' :: Maybe Text
registryName = Maybe Text
a} :: SchemaId)

-- | The Amazon Resource Name (ARN) of the schema. One of @SchemaArn@ or
-- @SchemaName@ has to be provided.
schemaId_schemaArn :: Lens.Lens' SchemaId (Prelude.Maybe Prelude.Text)
schemaId_schemaArn :: Lens' SchemaId (Maybe Text)
schemaId_schemaArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaId' {Maybe Text
schemaArn :: Maybe Text
$sel:schemaArn:SchemaId' :: SchemaId -> Maybe Text
schemaArn} -> Maybe Text
schemaArn) (\s :: SchemaId
s@SchemaId' {} Maybe Text
a -> SchemaId
s {$sel:schemaArn:SchemaId' :: Maybe Text
schemaArn = Maybe Text
a} :: SchemaId)

-- | The name of the schema. One of @SchemaArn@ or @SchemaName@ has to be
-- provided.
schemaId_schemaName :: Lens.Lens' SchemaId (Prelude.Maybe Prelude.Text)
schemaId_schemaName :: Lens' SchemaId (Maybe Text)
schemaId_schemaName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaId' {Maybe Text
schemaName :: Maybe Text
$sel:schemaName:SchemaId' :: SchemaId -> Maybe Text
schemaName} -> Maybe Text
schemaName) (\s :: SchemaId
s@SchemaId' {} Maybe Text
a -> SchemaId
s {$sel:schemaName:SchemaId' :: Maybe Text
schemaName = Maybe Text
a} :: SchemaId)

instance Data.FromJSON SchemaId where
  parseJSON :: Value -> Parser SchemaId
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SchemaId"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> SchemaId
SchemaId'
            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
"RegistryName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SchemaArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SchemaName")
      )

instance Prelude.Hashable SchemaId where
  hashWithSalt :: Int -> SchemaId -> Int
hashWithSalt Int
_salt SchemaId' {Maybe Text
schemaName :: Maybe Text
schemaArn :: Maybe Text
registryName :: Maybe Text
$sel:schemaName:SchemaId' :: SchemaId -> Maybe Text
$sel:schemaArn:SchemaId' :: SchemaId -> Maybe Text
$sel:registryName:SchemaId' :: SchemaId -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
registryName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
schemaArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
schemaName

instance Prelude.NFData SchemaId where
  rnf :: SchemaId -> ()
rnf SchemaId' {Maybe Text
schemaName :: Maybe Text
schemaArn :: Maybe Text
registryName :: Maybe Text
$sel:schemaName:SchemaId' :: SchemaId -> Maybe Text
$sel:schemaArn:SchemaId' :: SchemaId -> Maybe Text
$sel:registryName:SchemaId' :: SchemaId -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
registryName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
schemaArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
schemaName

instance Data.ToJSON SchemaId where
  toJSON :: SchemaId -> Value
toJSON SchemaId' {Maybe Text
schemaName :: Maybe Text
schemaArn :: Maybe Text
registryName :: Maybe Text
$sel:schemaName:SchemaId' :: SchemaId -> Maybe Text
$sel:schemaArn:SchemaId' :: SchemaId -> Maybe Text
$sel:registryName:SchemaId' :: SchemaId -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"RegistryName" 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
registryName,
            (Key
"SchemaArn" 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
schemaArn,
            (Key
"SchemaName" 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
schemaName
          ]
      )