{-# 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.Configurations
-- 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.Configurations where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MQ.Types.ConfigurationId
import qualified Amazonka.Prelude as Prelude

-- | Broker configuration information
--
-- /See:/ 'newConfigurations' smart constructor.
data Configurations = Configurations'
  { -- | The broker\'s pending configuration.
    Configurations -> Maybe ConfigurationId
pending :: Prelude.Maybe ConfigurationId,
    -- | The history of configurations applied to the broker.
    Configurations -> Maybe [ConfigurationId]
history :: Prelude.Maybe [ConfigurationId],
    -- | The broker\'s current configuration.
    Configurations -> Maybe ConfigurationId
current :: Prelude.Maybe ConfigurationId
  }
  deriving (Configurations -> Configurations -> Bool
(Configurations -> Configurations -> Bool)
-> (Configurations -> Configurations -> Bool) -> Eq Configurations
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Configurations -> Configurations -> Bool
$c/= :: Configurations -> Configurations -> Bool
== :: Configurations -> Configurations -> Bool
$c== :: Configurations -> Configurations -> Bool
Prelude.Eq, ReadPrec [Configurations]
ReadPrec Configurations
Int -> ReadS Configurations
ReadS [Configurations]
(Int -> ReadS Configurations)
-> ReadS [Configurations]
-> ReadPrec Configurations
-> ReadPrec [Configurations]
-> Read Configurations
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Configurations]
$creadListPrec :: ReadPrec [Configurations]
readPrec :: ReadPrec Configurations
$creadPrec :: ReadPrec Configurations
readList :: ReadS [Configurations]
$creadList :: ReadS [Configurations]
readsPrec :: Int -> ReadS Configurations
$creadsPrec :: Int -> ReadS Configurations
Prelude.Read, Int -> Configurations -> ShowS
[Configurations] -> ShowS
Configurations -> String
(Int -> Configurations -> ShowS)
-> (Configurations -> String)
-> ([Configurations] -> ShowS)
-> Show Configurations
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Configurations] -> ShowS
$cshowList :: [Configurations] -> ShowS
show :: Configurations -> String
$cshow :: Configurations -> String
showsPrec :: Int -> Configurations -> ShowS
$cshowsPrec :: Int -> Configurations -> ShowS
Prelude.Show, (forall x. Configurations -> Rep Configurations x)
-> (forall x. Rep Configurations x -> Configurations)
-> Generic Configurations
forall x. Rep Configurations x -> Configurations
forall x. Configurations -> Rep Configurations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Configurations x -> Configurations
$cfrom :: forall x. Configurations -> Rep Configurations x
Prelude.Generic)

-- |
-- Create a value of 'Configurations' 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:
--
-- 'pending', 'configurations_pending' - The broker\'s pending configuration.
--
-- 'history', 'configurations_history' - The history of configurations applied to the broker.
--
-- 'current', 'configurations_current' - The broker\'s current configuration.
newConfigurations ::
  Configurations
newConfigurations :: Configurations
newConfigurations =
  Configurations' :: Maybe ConfigurationId
-> Maybe [ConfigurationId]
-> Maybe ConfigurationId
-> Configurations
Configurations'
    { $sel:pending:Configurations' :: Maybe ConfigurationId
pending = Maybe ConfigurationId
forall a. Maybe a
Prelude.Nothing,
      $sel:history:Configurations' :: Maybe [ConfigurationId]
history = Maybe [ConfigurationId]
forall a. Maybe a
Prelude.Nothing,
      $sel:current:Configurations' :: Maybe ConfigurationId
current = Maybe ConfigurationId
forall a. Maybe a
Prelude.Nothing
    }

-- | The broker\'s pending configuration.
configurations_pending :: Lens.Lens' Configurations (Prelude.Maybe ConfigurationId)
configurations_pending :: (Maybe ConfigurationId -> f (Maybe ConfigurationId))
-> Configurations -> f Configurations
configurations_pending = (Configurations -> Maybe ConfigurationId)
-> (Configurations -> Maybe ConfigurationId -> Configurations)
-> Lens
     Configurations
     Configurations
     (Maybe ConfigurationId)
     (Maybe ConfigurationId)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Configurations' {Maybe ConfigurationId
pending :: Maybe ConfigurationId
$sel:pending:Configurations' :: Configurations -> Maybe ConfigurationId
pending} -> Maybe ConfigurationId
pending) (\s :: Configurations
s@Configurations' {} Maybe ConfigurationId
a -> Configurations
s {$sel:pending:Configurations' :: Maybe ConfigurationId
pending = Maybe ConfigurationId
a} :: Configurations)

-- | The history of configurations applied to the broker.
configurations_history :: Lens.Lens' Configurations (Prelude.Maybe [ConfigurationId])
configurations_history :: (Maybe [ConfigurationId] -> f (Maybe [ConfigurationId]))
-> Configurations -> f Configurations
configurations_history = (Configurations -> Maybe [ConfigurationId])
-> (Configurations -> Maybe [ConfigurationId] -> Configurations)
-> Lens
     Configurations
     Configurations
     (Maybe [ConfigurationId])
     (Maybe [ConfigurationId])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Configurations' {Maybe [ConfigurationId]
history :: Maybe [ConfigurationId]
$sel:history:Configurations' :: Configurations -> Maybe [ConfigurationId]
history} -> Maybe [ConfigurationId]
history) (\s :: Configurations
s@Configurations' {} Maybe [ConfigurationId]
a -> Configurations
s {$sel:history:Configurations' :: Maybe [ConfigurationId]
history = Maybe [ConfigurationId]
a} :: Configurations) ((Maybe [ConfigurationId] -> f (Maybe [ConfigurationId]))
 -> Configurations -> f Configurations)
-> ((Maybe [ConfigurationId] -> f (Maybe [ConfigurationId]))
    -> Maybe [ConfigurationId] -> f (Maybe [ConfigurationId]))
-> (Maybe [ConfigurationId] -> f (Maybe [ConfigurationId]))
-> Configurations
-> f Configurations
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ConfigurationId]
  [ConfigurationId]
  [ConfigurationId]
  [ConfigurationId]
-> Iso
     (Maybe [ConfigurationId])
     (Maybe [ConfigurationId])
     (Maybe [ConfigurationId])
     (Maybe [ConfigurationId])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ConfigurationId]
  [ConfigurationId]
  [ConfigurationId]
  [ConfigurationId]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The broker\'s current configuration.
configurations_current :: Lens.Lens' Configurations (Prelude.Maybe ConfigurationId)
configurations_current :: (Maybe ConfigurationId -> f (Maybe ConfigurationId))
-> Configurations -> f Configurations
configurations_current = (Configurations -> Maybe ConfigurationId)
-> (Configurations -> Maybe ConfigurationId -> Configurations)
-> Lens
     Configurations
     Configurations
     (Maybe ConfigurationId)
     (Maybe ConfigurationId)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Configurations' {Maybe ConfigurationId
current :: Maybe ConfigurationId
$sel:current:Configurations' :: Configurations -> Maybe ConfigurationId
current} -> Maybe ConfigurationId
current) (\s :: Configurations
s@Configurations' {} Maybe ConfigurationId
a -> Configurations
s {$sel:current:Configurations' :: Maybe ConfigurationId
current = Maybe ConfigurationId
a} :: Configurations)

instance Core.FromJSON Configurations where
  parseJSON :: Value -> Parser Configurations
parseJSON =
    String
-> (Object -> Parser Configurations)
-> Value
-> Parser Configurations
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Configurations"
      ( \Object
x ->
          Maybe ConfigurationId
-> Maybe [ConfigurationId]
-> Maybe ConfigurationId
-> Configurations
Configurations'
            (Maybe ConfigurationId
 -> Maybe [ConfigurationId]
 -> Maybe ConfigurationId
 -> Configurations)
-> Parser (Maybe ConfigurationId)
-> Parser
     (Maybe [ConfigurationId]
      -> Maybe ConfigurationId -> Configurations)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ConfigurationId)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"pending")
            Parser
  (Maybe [ConfigurationId]
   -> Maybe ConfigurationId -> Configurations)
-> Parser (Maybe [ConfigurationId])
-> Parser (Maybe ConfigurationId -> Configurations)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [ConfigurationId]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"history" Parser (Maybe (Maybe [ConfigurationId]))
-> Maybe [ConfigurationId] -> Parser (Maybe [ConfigurationId])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ConfigurationId]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe ConfigurationId -> Configurations)
-> Parser (Maybe ConfigurationId) -> Parser Configurations
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ConfigurationId)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"current")
      )

instance Prelude.Hashable Configurations

instance Prelude.NFData Configurations