{-# 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.ServiceCatalog.Types.OrganizationNode
-- 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.ServiceCatalog.Types.OrganizationNode where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.ServiceCatalog.Types.OrganizationNodeType

-- | Information about the organization node.
--
-- /See:/ 'newOrganizationNode' smart constructor.
data OrganizationNode = OrganizationNode'
  { -- | The identifier of the organization node.
    OrganizationNode -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The organization node type.
    OrganizationNode -> Maybe OrganizationNodeType
type' :: Prelude.Maybe OrganizationNodeType
  }
  deriving (OrganizationNode -> OrganizationNode -> Bool
(OrganizationNode -> OrganizationNode -> Bool)
-> (OrganizationNode -> OrganizationNode -> Bool)
-> Eq OrganizationNode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OrganizationNode -> OrganizationNode -> Bool
$c/= :: OrganizationNode -> OrganizationNode -> Bool
== :: OrganizationNode -> OrganizationNode -> Bool
$c== :: OrganizationNode -> OrganizationNode -> Bool
Prelude.Eq, ReadPrec [OrganizationNode]
ReadPrec OrganizationNode
Int -> ReadS OrganizationNode
ReadS [OrganizationNode]
(Int -> ReadS OrganizationNode)
-> ReadS [OrganizationNode]
-> ReadPrec OrganizationNode
-> ReadPrec [OrganizationNode]
-> Read OrganizationNode
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OrganizationNode]
$creadListPrec :: ReadPrec [OrganizationNode]
readPrec :: ReadPrec OrganizationNode
$creadPrec :: ReadPrec OrganizationNode
readList :: ReadS [OrganizationNode]
$creadList :: ReadS [OrganizationNode]
readsPrec :: Int -> ReadS OrganizationNode
$creadsPrec :: Int -> ReadS OrganizationNode
Prelude.Read, Int -> OrganizationNode -> ShowS
[OrganizationNode] -> ShowS
OrganizationNode -> String
(Int -> OrganizationNode -> ShowS)
-> (OrganizationNode -> String)
-> ([OrganizationNode] -> ShowS)
-> Show OrganizationNode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OrganizationNode] -> ShowS
$cshowList :: [OrganizationNode] -> ShowS
show :: OrganizationNode -> String
$cshow :: OrganizationNode -> String
showsPrec :: Int -> OrganizationNode -> ShowS
$cshowsPrec :: Int -> OrganizationNode -> ShowS
Prelude.Show, (forall x. OrganizationNode -> Rep OrganizationNode x)
-> (forall x. Rep OrganizationNode x -> OrganizationNode)
-> Generic OrganizationNode
forall x. Rep OrganizationNode x -> OrganizationNode
forall x. OrganizationNode -> Rep OrganizationNode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OrganizationNode x -> OrganizationNode
$cfrom :: forall x. OrganizationNode -> Rep OrganizationNode x
Prelude.Generic)

-- |
-- Create a value of 'OrganizationNode' 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:
--
-- 'value', 'organizationNode_value' - The identifier of the organization node.
--
-- 'type'', 'organizationNode_type' - The organization node type.
newOrganizationNode ::
  OrganizationNode
newOrganizationNode :: OrganizationNode
newOrganizationNode =
  OrganizationNode' :: Maybe Text -> Maybe OrganizationNodeType -> OrganizationNode
OrganizationNode'
    { $sel:value:OrganizationNode' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':OrganizationNode' :: Maybe OrganizationNodeType
type' = Maybe OrganizationNodeType
forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier of the organization node.
organizationNode_value :: Lens.Lens' OrganizationNode (Prelude.Maybe Prelude.Text)
organizationNode_value :: (Maybe Text -> f (Maybe Text))
-> OrganizationNode -> f OrganizationNode
organizationNode_value = (OrganizationNode -> Maybe Text)
-> (OrganizationNode -> Maybe Text -> OrganizationNode)
-> Lens OrganizationNode OrganizationNode (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OrganizationNode' {Maybe Text
value :: Maybe Text
$sel:value:OrganizationNode' :: OrganizationNode -> Maybe Text
value} -> Maybe Text
value) (\s :: OrganizationNode
s@OrganizationNode' {} Maybe Text
a -> OrganizationNode
s {$sel:value:OrganizationNode' :: Maybe Text
value = Maybe Text
a} :: OrganizationNode)

-- | The organization node type.
organizationNode_type :: Lens.Lens' OrganizationNode (Prelude.Maybe OrganizationNodeType)
organizationNode_type :: (Maybe OrganizationNodeType -> f (Maybe OrganizationNodeType))
-> OrganizationNode -> f OrganizationNode
organizationNode_type = (OrganizationNode -> Maybe OrganizationNodeType)
-> (OrganizationNode
    -> Maybe OrganizationNodeType -> OrganizationNode)
-> Lens
     OrganizationNode
     OrganizationNode
     (Maybe OrganizationNodeType)
     (Maybe OrganizationNodeType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OrganizationNode' {Maybe OrganizationNodeType
type' :: Maybe OrganizationNodeType
$sel:type':OrganizationNode' :: OrganizationNode -> Maybe OrganizationNodeType
type'} -> Maybe OrganizationNodeType
type') (\s :: OrganizationNode
s@OrganizationNode' {} Maybe OrganizationNodeType
a -> OrganizationNode
s {$sel:type':OrganizationNode' :: Maybe OrganizationNodeType
type' = Maybe OrganizationNodeType
a} :: OrganizationNode)

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

instance Prelude.Hashable OrganizationNode

instance Prelude.NFData OrganizationNode

instance Core.ToJSON OrganizationNode where
  toJSON :: OrganizationNode -> Value
toJSON OrganizationNode' {Maybe Text
Maybe OrganizationNodeType
type' :: Maybe OrganizationNodeType
value :: Maybe Text
$sel:type':OrganizationNode' :: OrganizationNode -> Maybe OrganizationNodeType
$sel:value:OrganizationNode' :: OrganizationNode -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Value" 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
value,
            (Text
"Type" Text -> OrganizationNodeType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (OrganizationNodeType -> Pair)
-> Maybe OrganizationNodeType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OrganizationNodeType
type'
          ]
      )