{-# 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.LicenseManagerUserSubscriptions.Types.Settings
-- 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.LicenseManagerUserSubscriptions.Types.Settings 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 registered identity provider’s product related configuration
-- settings such as the subnets to provision VPC endpoints, and the
-- security group ID that is associated with the VPC endpoints. The
-- security group should permit inbound TCP port 1688 communication from
-- resources in the VPC.
--
-- /See:/ 'newSettings' smart constructor.
data Settings = Settings'
  { -- | A security group ID that allows inbound TCP port 1688 communication
    -- between resources in your VPC and the VPC endpoint for activation
    -- servers.
    Settings -> Text
securityGroupId :: Prelude.Text,
    -- | The subnets defined for the registered identity provider.
    Settings -> NonEmpty Text
subnets :: Prelude.NonEmpty Prelude.Text
  }
  deriving (Settings -> Settings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Settings -> Settings -> Bool
$c/= :: Settings -> Settings -> Bool
== :: Settings -> Settings -> Bool
$c== :: Settings -> Settings -> Bool
Prelude.Eq, ReadPrec [Settings]
ReadPrec Settings
Int -> ReadS Settings
ReadS [Settings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Settings]
$creadListPrec :: ReadPrec [Settings]
readPrec :: ReadPrec Settings
$creadPrec :: ReadPrec Settings
readList :: ReadS [Settings]
$creadList :: ReadS [Settings]
readsPrec :: Int -> ReadS Settings
$creadsPrec :: Int -> ReadS Settings
Prelude.Read, Int -> Settings -> ShowS
[Settings] -> ShowS
Settings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Settings] -> ShowS
$cshowList :: [Settings] -> ShowS
show :: Settings -> String
$cshow :: Settings -> String
showsPrec :: Int -> Settings -> ShowS
$cshowsPrec :: Int -> Settings -> ShowS
Prelude.Show, forall x. Rep Settings x -> Settings
forall x. Settings -> Rep Settings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Settings x -> Settings
$cfrom :: forall x. Settings -> Rep Settings x
Prelude.Generic)

-- |
-- Create a value of 'Settings' 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:
--
-- 'securityGroupId', 'settings_securityGroupId' - A security group ID that allows inbound TCP port 1688 communication
-- between resources in your VPC and the VPC endpoint for activation
-- servers.
--
-- 'subnets', 'settings_subnets' - The subnets defined for the registered identity provider.
newSettings ::
  -- | 'securityGroupId'
  Prelude.Text ->
  -- | 'subnets'
  Prelude.NonEmpty Prelude.Text ->
  Settings
newSettings :: Text -> NonEmpty Text -> Settings
newSettings Text
pSecurityGroupId_ NonEmpty Text
pSubnets_ =
  Settings'
    { $sel:securityGroupId:Settings' :: Text
securityGroupId = Text
pSecurityGroupId_,
      $sel:subnets:Settings' :: NonEmpty Text
subnets = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pSubnets_
    }

-- | A security group ID that allows inbound TCP port 1688 communication
-- between resources in your VPC and the VPC endpoint for activation
-- servers.
settings_securityGroupId :: Lens.Lens' Settings Prelude.Text
settings_securityGroupId :: Lens' Settings Text
settings_securityGroupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Settings' {Text
securityGroupId :: Text
$sel:securityGroupId:Settings' :: Settings -> Text
securityGroupId} -> Text
securityGroupId) (\s :: Settings
s@Settings' {} Text
a -> Settings
s {$sel:securityGroupId:Settings' :: Text
securityGroupId = Text
a} :: Settings)

-- | The subnets defined for the registered identity provider.
settings_subnets :: Lens.Lens' Settings (Prelude.NonEmpty Prelude.Text)
settings_subnets :: Lens' Settings (NonEmpty Text)
settings_subnets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Settings' {NonEmpty Text
subnets :: NonEmpty Text
$sel:subnets:Settings' :: Settings -> NonEmpty Text
subnets} -> NonEmpty Text
subnets) (\s :: Settings
s@Settings' {} NonEmpty Text
a -> Settings
s {$sel:subnets:Settings' :: NonEmpty Text
subnets = NonEmpty Text
a} :: Settings) 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

instance Data.FromJSON Settings where
  parseJSON :: Value -> Parser Settings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Settings"
      ( \Object
x ->
          Text -> NonEmpty Text -> Settings
Settings'
            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
"SecurityGroupId")
            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
"Subnets")
      )

instance Prelude.Hashable Settings where
  hashWithSalt :: Int -> Settings -> Int
hashWithSalt Int
_salt Settings' {NonEmpty Text
Text
subnets :: NonEmpty Text
securityGroupId :: Text
$sel:subnets:Settings' :: Settings -> NonEmpty Text
$sel:securityGroupId:Settings' :: Settings -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
securityGroupId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
subnets

instance Prelude.NFData Settings where
  rnf :: Settings -> ()
rnf Settings' {NonEmpty Text
Text
subnets :: NonEmpty Text
securityGroupId :: Text
$sel:subnets:Settings' :: Settings -> NonEmpty Text
$sel:securityGroupId:Settings' :: Settings -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
securityGroupId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
subnets

instance Data.ToJSON Settings where
  toJSON :: Settings -> Value
toJSON Settings' {NonEmpty Text
Text
subnets :: NonEmpty Text
securityGroupId :: Text
$sel:subnets:Settings' :: Settings -> NonEmpty Text
$sel:securityGroupId:Settings' :: Settings -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"SecurityGroupId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
securityGroupId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Subnets" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
subnets)
          ]
      )