{-# 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.ChimeSDKMessaging.Types.ElasticChannelConfiguration
-- 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.ChimeSDKMessaging.Types.ElasticChannelConfiguration 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

-- | The attributes required to configure and create an elastic channel. An
-- elastic channel can support a maximum of 1-million members.
--
-- /See:/ 'newElasticChannelConfiguration' smart constructor.
data ElasticChannelConfiguration = ElasticChannelConfiguration'
  { -- | The maximum number of SubChannels that you want to allow in the elastic
    -- channel.
    ElasticChannelConfiguration -> Natural
maximumSubChannels :: Prelude.Natural,
    -- | The maximum number of members allowed in a SubChannel.
    ElasticChannelConfiguration -> Natural
targetMembershipsPerSubChannel :: Prelude.Natural,
    -- | The minimum allowed percentage of TargetMembershipsPerSubChannel users.
    -- Ceil of the calculated value is used in balancing members among
    -- SubChannels of the elastic channel.
    ElasticChannelConfiguration -> Natural
minimumMembershipPercentage :: Prelude.Natural
  }
  deriving (ElasticChannelConfiguration -> ElasticChannelConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ElasticChannelConfiguration -> ElasticChannelConfiguration -> Bool
$c/= :: ElasticChannelConfiguration -> ElasticChannelConfiguration -> Bool
== :: ElasticChannelConfiguration -> ElasticChannelConfiguration -> Bool
$c== :: ElasticChannelConfiguration -> ElasticChannelConfiguration -> Bool
Prelude.Eq, ReadPrec [ElasticChannelConfiguration]
ReadPrec ElasticChannelConfiguration
Int -> ReadS ElasticChannelConfiguration
ReadS [ElasticChannelConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ElasticChannelConfiguration]
$creadListPrec :: ReadPrec [ElasticChannelConfiguration]
readPrec :: ReadPrec ElasticChannelConfiguration
$creadPrec :: ReadPrec ElasticChannelConfiguration
readList :: ReadS [ElasticChannelConfiguration]
$creadList :: ReadS [ElasticChannelConfiguration]
readsPrec :: Int -> ReadS ElasticChannelConfiguration
$creadsPrec :: Int -> ReadS ElasticChannelConfiguration
Prelude.Read, Int -> ElasticChannelConfiguration -> ShowS
[ElasticChannelConfiguration] -> ShowS
ElasticChannelConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ElasticChannelConfiguration] -> ShowS
$cshowList :: [ElasticChannelConfiguration] -> ShowS
show :: ElasticChannelConfiguration -> String
$cshow :: ElasticChannelConfiguration -> String
showsPrec :: Int -> ElasticChannelConfiguration -> ShowS
$cshowsPrec :: Int -> ElasticChannelConfiguration -> ShowS
Prelude.Show, forall x.
Rep ElasticChannelConfiguration x -> ElasticChannelConfiguration
forall x.
ElasticChannelConfiguration -> Rep ElasticChannelConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ElasticChannelConfiguration x -> ElasticChannelConfiguration
$cfrom :: forall x.
ElasticChannelConfiguration -> Rep ElasticChannelConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ElasticChannelConfiguration' 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:
--
-- 'maximumSubChannels', 'elasticChannelConfiguration_maximumSubChannels' - The maximum number of SubChannels that you want to allow in the elastic
-- channel.
--
-- 'targetMembershipsPerSubChannel', 'elasticChannelConfiguration_targetMembershipsPerSubChannel' - The maximum number of members allowed in a SubChannel.
--
-- 'minimumMembershipPercentage', 'elasticChannelConfiguration_minimumMembershipPercentage' - The minimum allowed percentage of TargetMembershipsPerSubChannel users.
-- Ceil of the calculated value is used in balancing members among
-- SubChannels of the elastic channel.
newElasticChannelConfiguration ::
  -- | 'maximumSubChannels'
  Prelude.Natural ->
  -- | 'targetMembershipsPerSubChannel'
  Prelude.Natural ->
  -- | 'minimumMembershipPercentage'
  Prelude.Natural ->
  ElasticChannelConfiguration
newElasticChannelConfiguration :: Natural -> Natural -> Natural -> ElasticChannelConfiguration
newElasticChannelConfiguration
  Natural
pMaximumSubChannels_
  Natural
pTargetMembershipsPerSubChannel_
  Natural
pMinimumMembershipPercentage_ =
    ElasticChannelConfiguration'
      { $sel:maximumSubChannels:ElasticChannelConfiguration' :: Natural
maximumSubChannels =
          Natural
pMaximumSubChannels_,
        $sel:targetMembershipsPerSubChannel:ElasticChannelConfiguration' :: Natural
targetMembershipsPerSubChannel =
          Natural
pTargetMembershipsPerSubChannel_,
        $sel:minimumMembershipPercentage:ElasticChannelConfiguration' :: Natural
minimumMembershipPercentage =
          Natural
pMinimumMembershipPercentage_
      }

-- | The maximum number of SubChannels that you want to allow in the elastic
-- channel.
elasticChannelConfiguration_maximumSubChannels :: Lens.Lens' ElasticChannelConfiguration Prelude.Natural
elasticChannelConfiguration_maximumSubChannels :: Lens' ElasticChannelConfiguration Natural
elasticChannelConfiguration_maximumSubChannels = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticChannelConfiguration' {Natural
maximumSubChannels :: Natural
$sel:maximumSubChannels:ElasticChannelConfiguration' :: ElasticChannelConfiguration -> Natural
maximumSubChannels} -> Natural
maximumSubChannels) (\s :: ElasticChannelConfiguration
s@ElasticChannelConfiguration' {} Natural
a -> ElasticChannelConfiguration
s {$sel:maximumSubChannels:ElasticChannelConfiguration' :: Natural
maximumSubChannels = Natural
a} :: ElasticChannelConfiguration)

-- | The maximum number of members allowed in a SubChannel.
elasticChannelConfiguration_targetMembershipsPerSubChannel :: Lens.Lens' ElasticChannelConfiguration Prelude.Natural
elasticChannelConfiguration_targetMembershipsPerSubChannel :: Lens' ElasticChannelConfiguration Natural
elasticChannelConfiguration_targetMembershipsPerSubChannel = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticChannelConfiguration' {Natural
targetMembershipsPerSubChannel :: Natural
$sel:targetMembershipsPerSubChannel:ElasticChannelConfiguration' :: ElasticChannelConfiguration -> Natural
targetMembershipsPerSubChannel} -> Natural
targetMembershipsPerSubChannel) (\s :: ElasticChannelConfiguration
s@ElasticChannelConfiguration' {} Natural
a -> ElasticChannelConfiguration
s {$sel:targetMembershipsPerSubChannel:ElasticChannelConfiguration' :: Natural
targetMembershipsPerSubChannel = Natural
a} :: ElasticChannelConfiguration)

-- | The minimum allowed percentage of TargetMembershipsPerSubChannel users.
-- Ceil of the calculated value is used in balancing members among
-- SubChannels of the elastic channel.
elasticChannelConfiguration_minimumMembershipPercentage :: Lens.Lens' ElasticChannelConfiguration Prelude.Natural
elasticChannelConfiguration_minimumMembershipPercentage :: Lens' ElasticChannelConfiguration Natural
elasticChannelConfiguration_minimumMembershipPercentage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticChannelConfiguration' {Natural
minimumMembershipPercentage :: Natural
$sel:minimumMembershipPercentage:ElasticChannelConfiguration' :: ElasticChannelConfiguration -> Natural
minimumMembershipPercentage} -> Natural
minimumMembershipPercentage) (\s :: ElasticChannelConfiguration
s@ElasticChannelConfiguration' {} Natural
a -> ElasticChannelConfiguration
s {$sel:minimumMembershipPercentage:ElasticChannelConfiguration' :: Natural
minimumMembershipPercentage = Natural
a} :: ElasticChannelConfiguration)

instance Data.FromJSON ElasticChannelConfiguration where
  parseJSON :: Value -> Parser ElasticChannelConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ElasticChannelConfiguration"
      ( \Object
x ->
          Natural -> Natural -> Natural -> ElasticChannelConfiguration
ElasticChannelConfiguration'
            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
"MaximumSubChannels")
            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
"TargetMembershipsPerSubChannel")
            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
"MinimumMembershipPercentage")
      )

instance Prelude.Hashable ElasticChannelConfiguration where
  hashWithSalt :: Int -> ElasticChannelConfiguration -> Int
hashWithSalt Int
_salt ElasticChannelConfiguration' {Natural
minimumMembershipPercentage :: Natural
targetMembershipsPerSubChannel :: Natural
maximumSubChannels :: Natural
$sel:minimumMembershipPercentage:ElasticChannelConfiguration' :: ElasticChannelConfiguration -> Natural
$sel:targetMembershipsPerSubChannel:ElasticChannelConfiguration' :: ElasticChannelConfiguration -> Natural
$sel:maximumSubChannels:ElasticChannelConfiguration' :: ElasticChannelConfiguration -> Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
maximumSubChannels
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
targetMembershipsPerSubChannel
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
minimumMembershipPercentage

instance Prelude.NFData ElasticChannelConfiguration where
  rnf :: ElasticChannelConfiguration -> ()
rnf ElasticChannelConfiguration' {Natural
minimumMembershipPercentage :: Natural
targetMembershipsPerSubChannel :: Natural
maximumSubChannels :: Natural
$sel:minimumMembershipPercentage:ElasticChannelConfiguration' :: ElasticChannelConfiguration -> Natural
$sel:targetMembershipsPerSubChannel:ElasticChannelConfiguration' :: ElasticChannelConfiguration -> Natural
$sel:maximumSubChannels:ElasticChannelConfiguration' :: ElasticChannelConfiguration -> Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Natural
maximumSubChannels
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
targetMembershipsPerSubChannel
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
minimumMembershipPercentage

instance Data.ToJSON ElasticChannelConfiguration where
  toJSON :: ElasticChannelConfiguration -> Value
toJSON ElasticChannelConfiguration' {Natural
minimumMembershipPercentage :: Natural
targetMembershipsPerSubChannel :: Natural
maximumSubChannels :: Natural
$sel:minimumMembershipPercentage:ElasticChannelConfiguration' :: ElasticChannelConfiguration -> Natural
$sel:targetMembershipsPerSubChannel:ElasticChannelConfiguration' :: ElasticChannelConfiguration -> Natural
$sel:maximumSubChannels:ElasticChannelConfiguration' :: ElasticChannelConfiguration -> Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"MaximumSubChannels" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
maximumSubChannels),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"TargetMembershipsPerSubChannel"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
targetMembershipsPerSubChannel
              ),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"MinimumMembershipPercentage"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
minimumMembershipPercentage
              )
          ]
      )