{-# 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.CustomAttribute
-- 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.CustomAttribute 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

-- | Defines the X.500 relative distinguished name (RDN).
--
-- /See:/ 'newCustomAttribute' smart constructor.
data CustomAttribute = CustomAttribute'
  { -- | Specifies the object identifier (OID) of the attribute type of the
    -- relative distinguished name (RDN).
    CustomAttribute -> Text
objectIdentifier :: Prelude.Text,
    -- | Specifies the attribute value of relative distinguished name (RDN).
    CustomAttribute -> Text
value :: Prelude.Text
  }
  deriving (CustomAttribute -> CustomAttribute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomAttribute -> CustomAttribute -> Bool
$c/= :: CustomAttribute -> CustomAttribute -> Bool
== :: CustomAttribute -> CustomAttribute -> Bool
$c== :: CustomAttribute -> CustomAttribute -> Bool
Prelude.Eq, ReadPrec [CustomAttribute]
ReadPrec CustomAttribute
Int -> ReadS CustomAttribute
ReadS [CustomAttribute]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomAttribute]
$creadListPrec :: ReadPrec [CustomAttribute]
readPrec :: ReadPrec CustomAttribute
$creadPrec :: ReadPrec CustomAttribute
readList :: ReadS [CustomAttribute]
$creadList :: ReadS [CustomAttribute]
readsPrec :: Int -> ReadS CustomAttribute
$creadsPrec :: Int -> ReadS CustomAttribute
Prelude.Read, Int -> CustomAttribute -> ShowS
[CustomAttribute] -> ShowS
CustomAttribute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomAttribute] -> ShowS
$cshowList :: [CustomAttribute] -> ShowS
show :: CustomAttribute -> String
$cshow :: CustomAttribute -> String
showsPrec :: Int -> CustomAttribute -> ShowS
$cshowsPrec :: Int -> CustomAttribute -> ShowS
Prelude.Show, forall x. Rep CustomAttribute x -> CustomAttribute
forall x. CustomAttribute -> Rep CustomAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomAttribute x -> CustomAttribute
$cfrom :: forall x. CustomAttribute -> Rep CustomAttribute x
Prelude.Generic)

-- |
-- Create a value of 'CustomAttribute' 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:
--
-- 'objectIdentifier', 'customAttribute_objectIdentifier' - Specifies the object identifier (OID) of the attribute type of the
-- relative distinguished name (RDN).
--
-- 'value', 'customAttribute_value' - Specifies the attribute value of relative distinguished name (RDN).
newCustomAttribute ::
  -- | 'objectIdentifier'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  CustomAttribute
newCustomAttribute :: Text -> Text -> CustomAttribute
newCustomAttribute Text
pObjectIdentifier_ Text
pValue_ =
  CustomAttribute'
    { $sel:objectIdentifier:CustomAttribute' :: Text
objectIdentifier =
        Text
pObjectIdentifier_,
      $sel:value:CustomAttribute' :: Text
value = Text
pValue_
    }

-- | Specifies the object identifier (OID) of the attribute type of the
-- relative distinguished name (RDN).
customAttribute_objectIdentifier :: Lens.Lens' CustomAttribute Prelude.Text
customAttribute_objectIdentifier :: Lens' CustomAttribute Text
customAttribute_objectIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomAttribute' {Text
objectIdentifier :: Text
$sel:objectIdentifier:CustomAttribute' :: CustomAttribute -> Text
objectIdentifier} -> Text
objectIdentifier) (\s :: CustomAttribute
s@CustomAttribute' {} Text
a -> CustomAttribute
s {$sel:objectIdentifier:CustomAttribute' :: Text
objectIdentifier = Text
a} :: CustomAttribute)

-- | Specifies the attribute value of relative distinguished name (RDN).
customAttribute_value :: Lens.Lens' CustomAttribute Prelude.Text
customAttribute_value :: Lens' CustomAttribute Text
customAttribute_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomAttribute' {Text
value :: Text
$sel:value:CustomAttribute' :: CustomAttribute -> Text
value} -> Text
value) (\s :: CustomAttribute
s@CustomAttribute' {} Text
a -> CustomAttribute
s {$sel:value:CustomAttribute' :: Text
value = Text
a} :: CustomAttribute)

instance Data.FromJSON CustomAttribute where
  parseJSON :: Value -> Parser CustomAttribute
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomAttribute"
      ( \Object
x ->
          Text -> Text -> CustomAttribute
CustomAttribute'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ObjectIdentifier")
            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
"Value")
      )

instance Prelude.Hashable CustomAttribute where
  hashWithSalt :: Int -> CustomAttribute -> Int
hashWithSalt Int
_salt CustomAttribute' {Text
value :: Text
objectIdentifier :: Text
$sel:value:CustomAttribute' :: CustomAttribute -> Text
$sel:objectIdentifier:CustomAttribute' :: CustomAttribute -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
objectIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

instance Prelude.NFData CustomAttribute where
  rnf :: CustomAttribute -> ()
rnf CustomAttribute' {Text
value :: Text
objectIdentifier :: Text
$sel:value:CustomAttribute' :: CustomAttribute -> Text
$sel:objectIdentifier:CustomAttribute' :: CustomAttribute -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
objectIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value

instance Data.ToJSON CustomAttribute where
  toJSON :: CustomAttribute -> Value
toJSON CustomAttribute' {Text
value :: Text
objectIdentifier :: Text
$sel:value:CustomAttribute' :: CustomAttribute -> Text
$sel:objectIdentifier:CustomAttribute' :: CustomAttribute -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ObjectIdentifier" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
objectIdentifier),
            forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)
          ]
      )