{-# 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-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.MQ.Types.ConfigurationId where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ConfigurationId -> ConfigurationId -> Bool)
-> (ConfigurationId -> ConfigurationId -> Bool)
-> Eq ConfigurationId
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]
(Int -> ReadS ConfigurationId)
-> ReadS [ConfigurationId]
-> ReadPrec ConfigurationId
-> ReadPrec [ConfigurationId]
-> Read 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
(Int -> ConfigurationId -> ShowS)
-> (ConfigurationId -> String)
-> ([ConfigurationId] -> ShowS)
-> Show ConfigurationId
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. ConfigurationId -> Rep ConfigurationId x)
-> (forall x. Rep ConfigurationId x -> ConfigurationId)
-> Generic ConfigurationId
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' :: Maybe Int -> Text -> ConfigurationId
ConfigurationId'
    { $sel:revision:ConfigurationId' :: Maybe Int
revision = Maybe Int
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 :: (Maybe Int -> f (Maybe Int))
-> ConfigurationId -> f ConfigurationId
configurationId_revision = (ConfigurationId -> Maybe Int)
-> (ConfigurationId -> Maybe Int -> ConfigurationId)
-> Lens ConfigurationId ConfigurationId (Maybe Int) (Maybe Int)
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 :: (Text -> f Text) -> ConfigurationId -> f ConfigurationId
configurationId_id = (ConfigurationId -> Text)
-> (ConfigurationId -> Text -> ConfigurationId)
-> Lens ConfigurationId ConfigurationId Text Text
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 Core.FromJSON ConfigurationId where
  parseJSON :: Value -> Parser ConfigurationId
parseJSON =
    String
-> (Object -> Parser ConfigurationId)
-> Value
-> Parser ConfigurationId
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConfigurationId"
      ( \Object
x ->
          Maybe Int -> Text -> ConfigurationId
ConfigurationId'
            (Maybe Int -> Text -> ConfigurationId)
-> Parser (Maybe Int) -> Parser (Text -> ConfigurationId)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"revision") Parser (Text -> ConfigurationId)
-> Parser Text -> Parser ConfigurationId
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"id")
      )

instance Prelude.Hashable ConfigurationId

instance Prelude.NFData ConfigurationId

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"revision" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
revision,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)
          ]
      )