{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Kafka.Types.Configuration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kafka.Types.ConfigurationRevision
import Amazonka.Kafka.Types.ConfigurationState
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 -> ISO8601
creationTime :: Data.ISO8601,
    -- | 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
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]
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
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. 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'
      { $sel:description:Configuration' :: Text
description = Text
pDescription_,
        $sel:latestRevision:Configuration' :: ConfigurationRevision
latestRevision = ConfigurationRevision
pLatestRevision_,
        $sel:creationTime:Configuration' :: ISO8601
creationTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreationTime_,
        $sel:kafkaVersions:Configuration' :: [Text]
kafkaVersions = 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 :: Lens' Configuration Text
configuration_description = 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 :: Lens' Configuration ConfigurationRevision
configuration_latestRevision = 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 :: Lens' Configuration UTCTime
configuration_creationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Configuration' {ISO8601
creationTime :: ISO8601
$sel:creationTime:Configuration' :: Configuration -> ISO8601
creationTime} -> ISO8601
creationTime) (\s :: Configuration
s@Configuration' {} ISO8601
a -> Configuration
s {$sel:creationTime:Configuration' :: ISO8601
creationTime = ISO8601
a} :: Configuration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._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 :: Lens' Configuration [Text]
configuration_kafkaVersions = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 :: Lens' Configuration Text
configuration_arn = 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 :: Lens' Configuration Text
configuration_name = 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 :: Lens' Configuration ConfigurationState
configuration_state = 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 Data.FromJSON Configuration where
  parseJSON :: Value -> Parser Configuration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Configuration"
      ( \Object
x ->
          Text
-> ConfigurationRevision
-> ISO8601
-> [Text]
-> Text
-> Text
-> ConfigurationState
-> Configuration
Configuration'
            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
"description")
            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
"latestRevision")
            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
"creationTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"kafkaVersions" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"arn")
            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
"name")
            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
"state")
      )

instance Prelude.Hashable Configuration where
  hashWithSalt :: Int -> Configuration -> Int
hashWithSalt Int
_salt Configuration' {[Text]
Text
ISO8601
ConfigurationRevision
ConfigurationState
state :: ConfigurationState
name :: Text
arn :: Text
kafkaVersions :: [Text]
creationTime :: ISO8601
latestRevision :: ConfigurationRevision
description :: Text
$sel:state:Configuration' :: Configuration -> ConfigurationState
$sel:name:Configuration' :: Configuration -> Text
$sel:arn:Configuration' :: Configuration -> Text
$sel:kafkaVersions:Configuration' :: Configuration -> [Text]
$sel:creationTime:Configuration' :: Configuration -> ISO8601
$sel:latestRevision:Configuration' :: Configuration -> ConfigurationRevision
$sel:description:Configuration' :: Configuration -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ConfigurationRevision
latestRevision
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ISO8601
creationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
kafkaVersions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ConfigurationState
state

instance Prelude.NFData Configuration where
  rnf :: Configuration -> ()
rnf Configuration' {[Text]
Text
ISO8601
ConfigurationRevision
ConfigurationState
state :: ConfigurationState
name :: Text
arn :: Text
kafkaVersions :: [Text]
creationTime :: ISO8601
latestRevision :: ConfigurationRevision
description :: Text
$sel:state:Configuration' :: Configuration -> ConfigurationState
$sel:name:Configuration' :: Configuration -> Text
$sel:arn:Configuration' :: Configuration -> Text
$sel:kafkaVersions:Configuration' :: Configuration -> [Text]
$sel:creationTime:Configuration' :: Configuration -> ISO8601
$sel:latestRevision:Configuration' :: Configuration -> ConfigurationRevision
$sel:description:Configuration' :: Configuration -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ConfigurationRevision
latestRevision
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ISO8601
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
kafkaVersions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ConfigurationState
state