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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(SchemaFacet -> SchemaFacet -> Bool)
-> (SchemaFacet -> SchemaFacet -> Bool) -> Eq SchemaFacet
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]
(Int -> ReadS SchemaFacet)
-> ReadS [SchemaFacet]
-> ReadPrec SchemaFacet
-> ReadPrec [SchemaFacet]
-> Read 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
(Int -> SchemaFacet -> ShowS)
-> (SchemaFacet -> String)
-> ([SchemaFacet] -> ShowS)
-> Show SchemaFacet
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. SchemaFacet -> Rep SchemaFacet x)
-> (forall x. Rep SchemaFacet x -> SchemaFacet)
-> Generic SchemaFacet
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' :: Maybe Text -> Maybe Text -> SchemaFacet
SchemaFacet'
    { $sel:facetName:SchemaFacet' :: Maybe Text
facetName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:schemaArn:SchemaFacet' :: Maybe Text
schemaArn = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> SchemaFacet -> f SchemaFacet
schemaFacet_facetName = (SchemaFacet -> Maybe Text)
-> (SchemaFacet -> Maybe Text -> SchemaFacet)
-> Lens SchemaFacet SchemaFacet (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> SchemaFacet -> f SchemaFacet
schemaFacet_schemaArn = (SchemaFacet -> Maybe Text)
-> (SchemaFacet -> Maybe Text -> SchemaFacet)
-> Lens SchemaFacet SchemaFacet (Maybe Text) (Maybe Text)
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 Core.FromJSON SchemaFacet where
  parseJSON :: Value -> Parser SchemaFacet
parseJSON =
    String
-> (Object -> Parser SchemaFacet) -> Value -> Parser SchemaFacet
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SchemaFacet"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> SchemaFacet
SchemaFacet'
            (Maybe Text -> Maybe Text -> SchemaFacet)
-> Parser (Maybe Text) -> Parser (Maybe Text -> SchemaFacet)
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
"FacetName")
            Parser (Maybe Text -> SchemaFacet)
-> Parser (Maybe Text) -> Parser SchemaFacet
forall (f :: * -> *) a b. Applicative f => 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
"SchemaArn")
      )

instance Prelude.Hashable SchemaFacet

instance Prelude.NFData SchemaFacet

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FacetName" 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
facetName,
            (Text
"SchemaArn" 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
schemaArn
          ]
      )