{-# 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.CloudDirectory.Types.SchemaFacet
-- 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.CloudDirectory.Types.SchemaFacet 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

-- | A facet.
--
-- /See:/ 'newSchemaFacet' smart constructor.
data SchemaFacet = SchemaFacet'
  { -- | The name of the facet. If this value is set, SchemaArn must also be set.
    SchemaFacet -> Maybe Text
facetName :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the schema that contains the facet with no minor component.
    -- See arns and
    -- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/schemas_inplaceschemaupgrade.html In-Place Schema Upgrade>
    -- for a description of when to provide minor versions. If this value is
    -- set, FacetName must also be set.
    SchemaFacet -> Maybe Text
schemaArn :: Prelude.Maybe Prelude.Text
  }
  deriving (SchemaFacet -> SchemaFacet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SchemaFacet -> SchemaFacet -> Bool
$c/= :: SchemaFacet -> SchemaFacet -> Bool
== :: SchemaFacet -> SchemaFacet -> Bool
$c== :: SchemaFacet -> SchemaFacet -> Bool
Prelude.Eq, ReadPrec [SchemaFacet]
ReadPrec SchemaFacet
Int -> ReadS SchemaFacet
ReadS [SchemaFacet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SchemaFacet]
$creadListPrec :: ReadPrec [SchemaFacet]
readPrec :: ReadPrec SchemaFacet
$creadPrec :: ReadPrec SchemaFacet
readList :: ReadS [SchemaFacet]
$creadList :: ReadS [SchemaFacet]
readsPrec :: Int -> ReadS SchemaFacet
$creadsPrec :: Int -> ReadS SchemaFacet
Prelude.Read, Int -> SchemaFacet -> ShowS
[SchemaFacet] -> ShowS
SchemaFacet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SchemaFacet] -> ShowS
$cshowList :: [SchemaFacet] -> ShowS
show :: SchemaFacet -> String
$cshow :: SchemaFacet -> String
showsPrec :: Int -> SchemaFacet -> ShowS
$cshowsPrec :: Int -> SchemaFacet -> ShowS
Prelude.Show, forall x. Rep SchemaFacet x -> SchemaFacet
forall x. SchemaFacet -> Rep SchemaFacet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SchemaFacet x -> SchemaFacet
$cfrom :: forall x. SchemaFacet -> Rep SchemaFacet x
Prelude.Generic)

-- |
-- Create a value of 'SchemaFacet' 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:
--
-- 'facetName', 'schemaFacet_facetName' - The name of the facet. If this value is set, SchemaArn must also be set.
--
-- 'schemaArn', 'schemaFacet_schemaArn' - The ARN of the schema that contains the facet with no minor component.
-- See arns and
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/schemas_inplaceschemaupgrade.html In-Place Schema Upgrade>
-- for a description of when to provide minor versions. If this value is
-- set, FacetName must also be set.
newSchemaFacet ::
  SchemaFacet
newSchemaFacet :: SchemaFacet
newSchemaFacet =
  SchemaFacet'
    { $sel:facetName:SchemaFacet' :: Maybe Text
facetName = forall a. Maybe a
Prelude.Nothing,
      $sel:schemaArn:SchemaFacet' :: Maybe Text
schemaArn = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the facet. If this value is set, SchemaArn must also be set.
schemaFacet_facetName :: Lens.Lens' SchemaFacet (Prelude.Maybe Prelude.Text)
schemaFacet_facetName :: Lens' SchemaFacet (Maybe Text)
schemaFacet_facetName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaFacet' {Maybe Text
facetName :: Maybe Text
$sel:facetName:SchemaFacet' :: SchemaFacet -> Maybe Text
facetName} -> Maybe Text
facetName) (\s :: SchemaFacet
s@SchemaFacet' {} Maybe Text
a -> SchemaFacet
s {$sel:facetName:SchemaFacet' :: Maybe Text
facetName = Maybe Text
a} :: SchemaFacet)

-- | The ARN of the schema that contains the facet with no minor component.
-- See arns and
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/schemas_inplaceschemaupgrade.html In-Place Schema Upgrade>
-- for a description of when to provide minor versions. If this value is
-- set, FacetName must also be set.
schemaFacet_schemaArn :: Lens.Lens' SchemaFacet (Prelude.Maybe Prelude.Text)
schemaFacet_schemaArn :: Lens' SchemaFacet (Maybe Text)
schemaFacet_schemaArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaFacet' {Maybe Text
schemaArn :: Maybe Text
$sel:schemaArn:SchemaFacet' :: SchemaFacet -> Maybe Text
schemaArn} -> Maybe Text
schemaArn) (\s :: SchemaFacet
s@SchemaFacet' {} Maybe Text
a -> SchemaFacet
s {$sel:schemaArn:SchemaFacet' :: Maybe Text
schemaArn = Maybe Text
a} :: SchemaFacet)

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

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

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

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