{-# 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.MQ.Types.ConfigurationId
-- 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.MQ.Types.ConfigurationId 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 list of information about the configuration.
--
-- Does not apply to RabbitMQ brokers.
--
-- /See:/ 'newConfigurationId' smart constructor.
data ConfigurationId = ConfigurationId'
  { -- | The revision number of the configuration.
    ConfigurationId -> Maybe Int
revision :: Prelude.Maybe Prelude.Int,
    -- | Required. The unique ID that Amazon MQ generates for the configuration.
    ConfigurationId -> Text
id :: Prelude.Text
  }
  deriving (ConfigurationId -> ConfigurationId -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfigurationId -> ConfigurationId -> Bool
$c/= :: ConfigurationId -> ConfigurationId -> Bool
== :: ConfigurationId -> ConfigurationId -> Bool
$c== :: ConfigurationId -> ConfigurationId -> Bool
Prelude.Eq, ReadPrec [ConfigurationId]
ReadPrec ConfigurationId
Int -> ReadS ConfigurationId
ReadS [ConfigurationId]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfigurationId]
$creadListPrec :: ReadPrec [ConfigurationId]
readPrec :: ReadPrec ConfigurationId
$creadPrec :: ReadPrec ConfigurationId
readList :: ReadS [ConfigurationId]
$creadList :: ReadS [ConfigurationId]
readsPrec :: Int -> ReadS ConfigurationId
$creadsPrec :: Int -> ReadS ConfigurationId
Prelude.Read, Int -> ConfigurationId -> ShowS
[ConfigurationId] -> ShowS
ConfigurationId -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfigurationId] -> ShowS
$cshowList :: [ConfigurationId] -> ShowS
show :: ConfigurationId -> String
$cshow :: ConfigurationId -> String
showsPrec :: Int -> ConfigurationId -> ShowS
$cshowsPrec :: Int -> ConfigurationId -> ShowS
Prelude.Show, forall x. Rep ConfigurationId x -> ConfigurationId
forall x. ConfigurationId -> Rep ConfigurationId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConfigurationId x -> ConfigurationId
$cfrom :: forall x. ConfigurationId -> Rep ConfigurationId x
Prelude.Generic)

-- |
-- Create a value of 'ConfigurationId' 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:
--
-- 'revision', 'configurationId_revision' - The revision number of the configuration.
--
-- 'id', 'configurationId_id' - Required. The unique ID that Amazon MQ generates for the configuration.
newConfigurationId ::
  -- | 'id'
  Prelude.Text ->
  ConfigurationId
newConfigurationId :: Text -> ConfigurationId
newConfigurationId Text
pId_ =
  ConfigurationId'
    { $sel:revision:ConfigurationId' :: Maybe Int
revision = forall a. Maybe a
Prelude.Nothing,
      $sel:id:ConfigurationId' :: Text
id = Text
pId_
    }

-- | The revision number of the configuration.
configurationId_revision :: Lens.Lens' ConfigurationId (Prelude.Maybe Prelude.Int)
configurationId_revision :: Lens' ConfigurationId (Maybe Int)
configurationId_revision = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationId' {Maybe Int
revision :: Maybe Int
$sel:revision:ConfigurationId' :: ConfigurationId -> Maybe Int
revision} -> Maybe Int
revision) (\s :: ConfigurationId
s@ConfigurationId' {} Maybe Int
a -> ConfigurationId
s {$sel:revision:ConfigurationId' :: Maybe Int
revision = Maybe Int
a} :: ConfigurationId)

-- | Required. The unique ID that Amazon MQ generates for the configuration.
configurationId_id :: Lens.Lens' ConfigurationId Prelude.Text
configurationId_id :: Lens' ConfigurationId Text
configurationId_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationId' {Text
id :: Text
$sel:id:ConfigurationId' :: ConfigurationId -> Text
id} -> Text
id) (\s :: ConfigurationId
s@ConfigurationId' {} Text
a -> ConfigurationId
s {$sel:id:ConfigurationId' :: Text
id = Text
a} :: ConfigurationId)

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

instance Prelude.Hashable ConfigurationId where
  hashWithSalt :: Int -> ConfigurationId -> Int
hashWithSalt Int
_salt ConfigurationId' {Maybe Int
Text
id :: Text
revision :: Maybe Int
$sel:id:ConfigurationId' :: ConfigurationId -> Text
$sel:revision:ConfigurationId' :: ConfigurationId -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
revision
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData ConfigurationId where
  rnf :: ConfigurationId -> ()
rnf ConfigurationId' {Maybe Int
Text
id :: Text
revision :: Maybe Int
$sel:id:ConfigurationId' :: ConfigurationId -> Text
$sel:revision:ConfigurationId' :: ConfigurationId -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
revision seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id

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