{-# 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.CertificateManagerPCA.Types.EdiPartyName
-- 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.CertificateManagerPCA.Types.EdiPartyName 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

-- | Describes an Electronic Data Interchange (EDI) entity as described in as
-- defined in
-- <https://datatracker.ietf.org/doc/html/rfc5280 Subject Alternative Name>
-- in RFC 5280.
--
-- /See:/ 'newEdiPartyName' smart constructor.
data EdiPartyName = EdiPartyName'
  { -- | Specifies the name assigner.
    EdiPartyName -> Maybe Text
nameAssigner :: Prelude.Maybe Prelude.Text,
    -- | Specifies the party name.
    EdiPartyName -> Text
partyName :: Prelude.Text
  }
  deriving (EdiPartyName -> EdiPartyName -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EdiPartyName -> EdiPartyName -> Bool
$c/= :: EdiPartyName -> EdiPartyName -> Bool
== :: EdiPartyName -> EdiPartyName -> Bool
$c== :: EdiPartyName -> EdiPartyName -> Bool
Prelude.Eq, ReadPrec [EdiPartyName]
ReadPrec EdiPartyName
Int -> ReadS EdiPartyName
ReadS [EdiPartyName]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EdiPartyName]
$creadListPrec :: ReadPrec [EdiPartyName]
readPrec :: ReadPrec EdiPartyName
$creadPrec :: ReadPrec EdiPartyName
readList :: ReadS [EdiPartyName]
$creadList :: ReadS [EdiPartyName]
readsPrec :: Int -> ReadS EdiPartyName
$creadsPrec :: Int -> ReadS EdiPartyName
Prelude.Read, Int -> EdiPartyName -> ShowS
[EdiPartyName] -> ShowS
EdiPartyName -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EdiPartyName] -> ShowS
$cshowList :: [EdiPartyName] -> ShowS
show :: EdiPartyName -> String
$cshow :: EdiPartyName -> String
showsPrec :: Int -> EdiPartyName -> ShowS
$cshowsPrec :: Int -> EdiPartyName -> ShowS
Prelude.Show, forall x. Rep EdiPartyName x -> EdiPartyName
forall x. EdiPartyName -> Rep EdiPartyName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EdiPartyName x -> EdiPartyName
$cfrom :: forall x. EdiPartyName -> Rep EdiPartyName x
Prelude.Generic)

-- |
-- Create a value of 'EdiPartyName' 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:
--
-- 'nameAssigner', 'ediPartyName_nameAssigner' - Specifies the name assigner.
--
-- 'partyName', 'ediPartyName_partyName' - Specifies the party name.
newEdiPartyName ::
  -- | 'partyName'
  Prelude.Text ->
  EdiPartyName
newEdiPartyName :: Text -> EdiPartyName
newEdiPartyName Text
pPartyName_ =
  EdiPartyName'
    { $sel:nameAssigner:EdiPartyName' :: Maybe Text
nameAssigner = forall a. Maybe a
Prelude.Nothing,
      $sel:partyName:EdiPartyName' :: Text
partyName = Text
pPartyName_
    }

-- | Specifies the name assigner.
ediPartyName_nameAssigner :: Lens.Lens' EdiPartyName (Prelude.Maybe Prelude.Text)
ediPartyName_nameAssigner :: Lens' EdiPartyName (Maybe Text)
ediPartyName_nameAssigner = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EdiPartyName' {Maybe Text
nameAssigner :: Maybe Text
$sel:nameAssigner:EdiPartyName' :: EdiPartyName -> Maybe Text
nameAssigner} -> Maybe Text
nameAssigner) (\s :: EdiPartyName
s@EdiPartyName' {} Maybe Text
a -> EdiPartyName
s {$sel:nameAssigner:EdiPartyName' :: Maybe Text
nameAssigner = Maybe Text
a} :: EdiPartyName)

-- | Specifies the party name.
ediPartyName_partyName :: Lens.Lens' EdiPartyName Prelude.Text
ediPartyName_partyName :: Lens' EdiPartyName Text
ediPartyName_partyName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EdiPartyName' {Text
partyName :: Text
$sel:partyName:EdiPartyName' :: EdiPartyName -> Text
partyName} -> Text
partyName) (\s :: EdiPartyName
s@EdiPartyName' {} Text
a -> EdiPartyName
s {$sel:partyName:EdiPartyName' :: Text
partyName = Text
a} :: EdiPartyName)

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

instance Prelude.Hashable EdiPartyName where
  hashWithSalt :: Int -> EdiPartyName -> Int
hashWithSalt Int
_salt EdiPartyName' {Maybe Text
Text
partyName :: Text
nameAssigner :: Maybe Text
$sel:partyName:EdiPartyName' :: EdiPartyName -> Text
$sel:nameAssigner:EdiPartyName' :: EdiPartyName -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nameAssigner
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
partyName

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

instance Data.ToJSON EdiPartyName where
  toJSON :: EdiPartyName -> Value
toJSON EdiPartyName' {Maybe Text
Text
partyName :: Text
nameAssigner :: Maybe Text
$sel:partyName:EdiPartyName' :: EdiPartyName -> Text
$sel:nameAssigner:EdiPartyName' :: EdiPartyName -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"NameAssigner" 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
nameAssigner,
            forall a. a -> Maybe a
Prelude.Just (Key
"PartyName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
partyName)
          ]
      )