{-# 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.Kafka.Types.Configuration
-- 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.Kafka.Types.Configuration where

import qualified Amazonka.Core as Core
import Amazonka.Kafka.Types.ConfigurationRevision
import Amazonka.Kafka.Types.ConfigurationState
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents an MSK Configuration.
--
-- /See:/ 'newConfiguration' smart constructor.
data Configuration = Configuration'
  { -- | The description of the configuration.
    Configuration -> Text
description :: Prelude.Text,
    -- | Latest revision of the configuration.
    Configuration -> ConfigurationRevision
latestRevision :: ConfigurationRevision,
    -- | The time when the configuration was created.
    Configuration -> POSIX
creationTime :: Core.POSIX,
    -- | An array of the versions of Apache Kafka with which you can use this MSK
    -- configuration. You can use this configuration for an MSK cluster only if
    -- the Apache Kafka version specified for the cluster appears in this
    -- array.
    Configuration -> [Text]
kafkaVersions :: [Prelude.Text],
    -- | The Amazon Resource Name (ARN) of the configuration.
    Configuration -> Text
arn :: Prelude.Text,
    -- | The name of the configuration.
    Configuration -> Text
name :: Prelude.Text,
    -- | The state of the configuration. The possible states are ACTIVE,
    -- DELETING, and DELETE_FAILED.
    Configuration -> ConfigurationState
state :: ConfigurationState
  }
  deriving (Configuration -> Configuration -> Bool
(Configuration -> Configuration -> Bool)
-> (Configuration -> Configuration -> Bool) -> Eq Configuration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Configuration -> Configuration -> Bool
$c/= :: Configuration -> Configuration -> Bool
== :: Configuration -> Configuration -> Bool
$c== :: Configuration -> Configuration -> Bool
Prelude.Eq, ReadPrec [Configuration]
ReadPrec Configuration
Int -> ReadS Configuration
ReadS [Configuration]
(Int -> ReadS Configuration)
-> ReadS [Configuration]
-> ReadPrec Configuration
-> ReadPrec [Configuration]
-> Read Configuration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Configuration]
$creadListPrec :: ReadPrec [Configuration]
readPrec :: ReadPrec Configuration
$creadPrec :: ReadPrec Configuration
readList :: ReadS [Configuration]
$creadList :: ReadS [Configuration]
readsPrec :: Int -> ReadS Configuration
$creadsPrec :: Int -> ReadS Configuration
Prelude.Read, Int -> Configuration -> ShowS
[Configuration] -> ShowS
Configuration -> String
(Int -> Configuration -> ShowS)
-> (Configuration -> String)
-> ([Configuration] -> ShowS)
-> Show Configuration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Configuration] -> ShowS
$cshowList :: [Configuration] -> ShowS
show :: Configuration -> String
$cshow :: Configuration -> String
showsPrec :: Int -> Configuration -> ShowS
$cshowsPrec :: Int -> Configuration -> ShowS
Prelude.Show, (forall x. Configuration -> Rep Configuration x)
-> (forall x. Rep Configuration x -> Configuration)
-> Generic Configuration
forall x. Rep Configuration x -> Configuration
forall x. Configuration -> Rep Configuration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Configuration x -> Configuration
$cfrom :: forall x. Configuration -> Rep Configuration x
Prelude.Generic)

-- |
-- Create a value of 'Configuration' 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:
--
-- 'description', 'configuration_description' - The description of the configuration.
--
-- 'latestRevision', 'configuration_latestRevision' - Latest revision of the configuration.
--
-- 'creationTime', 'configuration_creationTime' - The time when the configuration was created.
--
-- 'kafkaVersions', 'configuration_kafkaVersions' - An array of the versions of Apache Kafka with which you can use this MSK
-- configuration. You can use this configuration for an MSK cluster only if
-- the Apache Kafka version specified for the cluster appears in this
-- array.
--
-- 'arn', 'configuration_arn' - The Amazon Resource Name (ARN) of the configuration.
--
-- 'name', 'configuration_name' - The name of the configuration.
--
-- 'state', 'configuration_state' - The state of the configuration. The possible states are ACTIVE,
-- DELETING, and DELETE_FAILED.
newConfiguration ::
  -- | 'description'
  Prelude.Text ->
  -- | 'latestRevision'
  ConfigurationRevision ->
  -- | 'creationTime'
  Prelude.UTCTime ->
  -- | 'arn'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'state'
  ConfigurationState ->
  Configuration
newConfiguration :: Text
-> ConfigurationRevision
-> UTCTime
-> Text
-> Text
-> ConfigurationState
-> Configuration
newConfiguration
  Text
pDescription_
  ConfigurationRevision
pLatestRevision_
  UTCTime
pCreationTime_
  Text
pArn_
  Text
pName_
  ConfigurationState
pState_ =
    Configuration' :: Text
-> ConfigurationRevision
-> POSIX
-> [Text]
-> Text
-> Text
-> ConfigurationState
-> Configuration
Configuration'
      { $sel:description:Configuration' :: Text
description = Text
pDescription_,
        $sel:latestRevision:Configuration' :: ConfigurationRevision
latestRevision = ConfigurationRevision
pLatestRevision_,
        $sel:creationTime:Configuration' :: POSIX
creationTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreationTime_,
        $sel:kafkaVersions:Configuration' :: [Text]
kafkaVersions = [Text]
forall a. Monoid a => a
Prelude.mempty,
        $sel:arn:Configuration' :: Text
arn = Text
pArn_,
        $sel:name:Configuration' :: Text
name = Text
pName_,
        $sel:state:Configuration' :: ConfigurationState
state = ConfigurationState
pState_
      }

-- | The description of the configuration.
configuration_description :: Lens.Lens' Configuration Prelude.Text
configuration_description :: (Text -> f Text) -> Configuration -> f Configuration
configuration_description = (Configuration -> Text)
-> (Configuration -> Text -> Configuration)
-> Lens Configuration Configuration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Configuration' {Text
description :: Text
$sel:description:Configuration' :: Configuration -> Text
description} -> Text
description) (\s :: Configuration
s@Configuration' {} Text
a -> Configuration
s {$sel:description:Configuration' :: Text
description = Text
a} :: Configuration)

-- | Latest revision of the configuration.
configuration_latestRevision :: Lens.Lens' Configuration ConfigurationRevision
configuration_latestRevision :: (ConfigurationRevision -> f ConfigurationRevision)
-> Configuration -> f Configuration
configuration_latestRevision = (Configuration -> ConfigurationRevision)
-> (Configuration -> ConfigurationRevision -> Configuration)
-> Lens
     Configuration
     Configuration
     ConfigurationRevision
     ConfigurationRevision
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Configuration' {ConfigurationRevision
latestRevision :: ConfigurationRevision
$sel:latestRevision:Configuration' :: Configuration -> ConfigurationRevision
latestRevision} -> ConfigurationRevision
latestRevision) (\s :: Configuration
s@Configuration' {} ConfigurationRevision
a -> Configuration
s {$sel:latestRevision:Configuration' :: ConfigurationRevision
latestRevision = ConfigurationRevision
a} :: Configuration)

-- | The time when the configuration was created.
configuration_creationTime :: Lens.Lens' Configuration Prelude.UTCTime
configuration_creationTime :: (UTCTime -> f UTCTime) -> Configuration -> f Configuration
configuration_creationTime = (Configuration -> POSIX)
-> (Configuration -> POSIX -> Configuration)
-> Lens Configuration Configuration POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Configuration' {POSIX
creationTime :: POSIX
$sel:creationTime:Configuration' :: Configuration -> POSIX
creationTime} -> POSIX
creationTime) (\s :: Configuration
s@Configuration' {} POSIX
a -> Configuration
s {$sel:creationTime:Configuration' :: POSIX
creationTime = POSIX
a} :: Configuration) ((POSIX -> f POSIX) -> Configuration -> f Configuration)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> Configuration
-> f Configuration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | An array of the versions of Apache Kafka with which you can use this MSK
-- configuration. You can use this configuration for an MSK cluster only if
-- the Apache Kafka version specified for the cluster appears in this
-- array.
configuration_kafkaVersions :: Lens.Lens' Configuration [Prelude.Text]
configuration_kafkaVersions :: ([Text] -> f [Text]) -> Configuration -> f Configuration
configuration_kafkaVersions = (Configuration -> [Text])
-> (Configuration -> [Text] -> Configuration)
-> Lens Configuration Configuration [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Configuration' {[Text]
kafkaVersions :: [Text]
$sel:kafkaVersions:Configuration' :: Configuration -> [Text]
kafkaVersions} -> [Text]
kafkaVersions) (\s :: Configuration
s@Configuration' {} [Text]
a -> Configuration
s {$sel:kafkaVersions:Configuration' :: [Text]
kafkaVersions = [Text]
a} :: Configuration) (([Text] -> f [Text]) -> Configuration -> f Configuration)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> Configuration
-> f Configuration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) of the configuration.
configuration_arn :: Lens.Lens' Configuration Prelude.Text
configuration_arn :: (Text -> f Text) -> Configuration -> f Configuration
configuration_arn = (Configuration -> Text)
-> (Configuration -> Text -> Configuration)
-> Lens Configuration Configuration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Configuration' {Text
arn :: Text
$sel:arn:Configuration' :: Configuration -> Text
arn} -> Text
arn) (\s :: Configuration
s@Configuration' {} Text
a -> Configuration
s {$sel:arn:Configuration' :: Text
arn = Text
a} :: Configuration)

-- | The name of the configuration.
configuration_name :: Lens.Lens' Configuration Prelude.Text
configuration_name :: (Text -> f Text) -> Configuration -> f Configuration
configuration_name = (Configuration -> Text)
-> (Configuration -> Text -> Configuration)
-> Lens Configuration Configuration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Configuration' {Text
name :: Text
$sel:name:Configuration' :: Configuration -> Text
name} -> Text
name) (\s :: Configuration
s@Configuration' {} Text
a -> Configuration
s {$sel:name:Configuration' :: Text
name = Text
a} :: Configuration)

-- | The state of the configuration. The possible states are ACTIVE,
-- DELETING, and DELETE_FAILED.
configuration_state :: Lens.Lens' Configuration ConfigurationState
configuration_state :: (ConfigurationState -> f ConfigurationState)
-> Configuration -> f Configuration
configuration_state = (Configuration -> ConfigurationState)
-> (Configuration -> ConfigurationState -> Configuration)
-> Lens
     Configuration Configuration ConfigurationState ConfigurationState
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Configuration' {ConfigurationState
state :: ConfigurationState
$sel:state:Configuration' :: Configuration -> ConfigurationState
state} -> ConfigurationState
state) (\s :: Configuration
s@Configuration' {} ConfigurationState
a -> Configuration
s {$sel:state:Configuration' :: ConfigurationState
state = ConfigurationState
a} :: Configuration)

instance Core.FromJSON Configuration where
  parseJSON :: Value -> Parser Configuration
parseJSON =
    String
-> (Object -> Parser Configuration)
-> Value
-> Parser Configuration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Configuration"
      ( \Object
x ->
          Text
-> ConfigurationRevision
-> POSIX
-> [Text]
-> Text
-> Text
-> ConfigurationState
-> Configuration
Configuration'
            (Text
 -> ConfigurationRevision
 -> POSIX
 -> [Text]
 -> Text
 -> Text
 -> ConfigurationState
 -> Configuration)
-> Parser Text
-> Parser
     (ConfigurationRevision
      -> POSIX
      -> [Text]
      -> Text
      -> Text
      -> ConfigurationState
      -> Configuration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"description")
            Parser
  (ConfigurationRevision
   -> POSIX
   -> [Text]
   -> Text
   -> Text
   -> ConfigurationState
   -> Configuration)
-> Parser ConfigurationRevision
-> Parser
     (POSIX
      -> [Text] -> Text -> Text -> ConfigurationState -> Configuration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ConfigurationRevision
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"latestRevision")
            Parser
  (POSIX
   -> [Text] -> Text -> Text -> ConfigurationState -> Configuration)
-> Parser POSIX
-> Parser
     ([Text] -> Text -> Text -> ConfigurationState -> Configuration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"creationTime")
            Parser
  ([Text] -> Text -> Text -> ConfigurationState -> Configuration)
-> Parser [Text]
-> Parser (Text -> Text -> ConfigurationState -> Configuration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"kafkaVersions" Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> Text -> ConfigurationState -> Configuration)
-> Parser Text
-> Parser (Text -> ConfigurationState -> Configuration)
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
"arn")
            Parser (Text -> ConfigurationState -> Configuration)
-> Parser Text -> Parser (ConfigurationState -> Configuration)
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
"name")
            Parser (ConfigurationState -> Configuration)
-> Parser ConfigurationState -> Parser Configuration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ConfigurationState
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"state")
      )

instance Prelude.Hashable Configuration

instance Prelude.NFData Configuration