{-# 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.WorkSpacesWeb.Types.NetworkSettings
-- 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.WorkSpacesWeb.Types.NetworkSettings 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

-- | A network settings resource that can be associated with a web portal.
-- Once associated with a web portal, network settings define how streaming
-- instances will connect with your specified VPC.
--
-- /See:/ 'newNetworkSettings' smart constructor.
data NetworkSettings = NetworkSettings'
  { -- | A list of web portal ARNs that this network settings is associated with.
    NetworkSettings -> Maybe [Text]
associatedPortalArns :: Prelude.Maybe [Prelude.Text],
    -- | One or more security groups used to control access from streaming
    -- instances to your VPC.
    NetworkSettings -> Maybe (NonEmpty Text)
securityGroupIds :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The subnets in which network interfaces are created to connect streaming
    -- instances to your VPC. At least two of these subnets must be in
    -- different availability zones.
    NetworkSettings -> Maybe (NonEmpty Text)
subnetIds :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The VPC that streaming instances will connect to.
    NetworkSettings -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the network settings.
    NetworkSettings -> Text
networkSettingsArn :: Prelude.Text
  }
  deriving (NetworkSettings -> NetworkSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NetworkSettings -> NetworkSettings -> Bool
$c/= :: NetworkSettings -> NetworkSettings -> Bool
== :: NetworkSettings -> NetworkSettings -> Bool
$c== :: NetworkSettings -> NetworkSettings -> Bool
Prelude.Eq, ReadPrec [NetworkSettings]
ReadPrec NetworkSettings
Int -> ReadS NetworkSettings
ReadS [NetworkSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NetworkSettings]
$creadListPrec :: ReadPrec [NetworkSettings]
readPrec :: ReadPrec NetworkSettings
$creadPrec :: ReadPrec NetworkSettings
readList :: ReadS [NetworkSettings]
$creadList :: ReadS [NetworkSettings]
readsPrec :: Int -> ReadS NetworkSettings
$creadsPrec :: Int -> ReadS NetworkSettings
Prelude.Read, Int -> NetworkSettings -> ShowS
[NetworkSettings] -> ShowS
NetworkSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NetworkSettings] -> ShowS
$cshowList :: [NetworkSettings] -> ShowS
show :: NetworkSettings -> String
$cshow :: NetworkSettings -> String
showsPrec :: Int -> NetworkSettings -> ShowS
$cshowsPrec :: Int -> NetworkSettings -> ShowS
Prelude.Show, forall x. Rep NetworkSettings x -> NetworkSettings
forall x. NetworkSettings -> Rep NetworkSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NetworkSettings x -> NetworkSettings
$cfrom :: forall x. NetworkSettings -> Rep NetworkSettings x
Prelude.Generic)

-- |
-- Create a value of 'NetworkSettings' 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:
--
-- 'associatedPortalArns', 'networkSettings_associatedPortalArns' - A list of web portal ARNs that this network settings is associated with.
--
-- 'securityGroupIds', 'networkSettings_securityGroupIds' - One or more security groups used to control access from streaming
-- instances to your VPC.
--
-- 'subnetIds', 'networkSettings_subnetIds' - The subnets in which network interfaces are created to connect streaming
-- instances to your VPC. At least two of these subnets must be in
-- different availability zones.
--
-- 'vpcId', 'networkSettings_vpcId' - The VPC that streaming instances will connect to.
--
-- 'networkSettingsArn', 'networkSettings_networkSettingsArn' - The ARN of the network settings.
newNetworkSettings ::
  -- | 'networkSettingsArn'
  Prelude.Text ->
  NetworkSettings
newNetworkSettings :: Text -> NetworkSettings
newNetworkSettings Text
pNetworkSettingsArn_ =
  NetworkSettings'
    { $sel:associatedPortalArns:NetworkSettings' :: Maybe [Text]
associatedPortalArns =
        forall a. Maybe a
Prelude.Nothing,
      $sel:securityGroupIds:NetworkSettings' :: Maybe (NonEmpty Text)
securityGroupIds = forall a. Maybe a
Prelude.Nothing,
      $sel:subnetIds:NetworkSettings' :: Maybe (NonEmpty Text)
subnetIds = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:NetworkSettings' :: Maybe Text
vpcId = forall a. Maybe a
Prelude.Nothing,
      $sel:networkSettingsArn:NetworkSettings' :: Text
networkSettingsArn = Text
pNetworkSettingsArn_
    }

-- | A list of web portal ARNs that this network settings is associated with.
networkSettings_associatedPortalArns :: Lens.Lens' NetworkSettings (Prelude.Maybe [Prelude.Text])
networkSettings_associatedPortalArns :: Lens' NetworkSettings (Maybe [Text])
networkSettings_associatedPortalArns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkSettings' {Maybe [Text]
associatedPortalArns :: Maybe [Text]
$sel:associatedPortalArns:NetworkSettings' :: NetworkSettings -> Maybe [Text]
associatedPortalArns} -> Maybe [Text]
associatedPortalArns) (\s :: NetworkSettings
s@NetworkSettings' {} Maybe [Text]
a -> NetworkSettings
s {$sel:associatedPortalArns:NetworkSettings' :: Maybe [Text]
associatedPortalArns = Maybe [Text]
a} :: NetworkSettings) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | One or more security groups used to control access from streaming
-- instances to your VPC.
networkSettings_securityGroupIds :: Lens.Lens' NetworkSettings (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
networkSettings_securityGroupIds :: Lens' NetworkSettings (Maybe (NonEmpty Text))
networkSettings_securityGroupIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkSettings' {Maybe (NonEmpty Text)
securityGroupIds :: Maybe (NonEmpty Text)
$sel:securityGroupIds:NetworkSettings' :: NetworkSettings -> Maybe (NonEmpty Text)
securityGroupIds} -> Maybe (NonEmpty Text)
securityGroupIds) (\s :: NetworkSettings
s@NetworkSettings' {} Maybe (NonEmpty Text)
a -> NetworkSettings
s {$sel:securityGroupIds:NetworkSettings' :: Maybe (NonEmpty Text)
securityGroupIds = Maybe (NonEmpty Text)
a} :: NetworkSettings) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The subnets in which network interfaces are created to connect streaming
-- instances to your VPC. At least two of these subnets must be in
-- different availability zones.
networkSettings_subnetIds :: Lens.Lens' NetworkSettings (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
networkSettings_subnetIds :: Lens' NetworkSettings (Maybe (NonEmpty Text))
networkSettings_subnetIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkSettings' {Maybe (NonEmpty Text)
subnetIds :: Maybe (NonEmpty Text)
$sel:subnetIds:NetworkSettings' :: NetworkSettings -> Maybe (NonEmpty Text)
subnetIds} -> Maybe (NonEmpty Text)
subnetIds) (\s :: NetworkSettings
s@NetworkSettings' {} Maybe (NonEmpty Text)
a -> NetworkSettings
s {$sel:subnetIds:NetworkSettings' :: Maybe (NonEmpty Text)
subnetIds = Maybe (NonEmpty Text)
a} :: NetworkSettings) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The VPC that streaming instances will connect to.
networkSettings_vpcId :: Lens.Lens' NetworkSettings (Prelude.Maybe Prelude.Text)
networkSettings_vpcId :: Lens' NetworkSettings (Maybe Text)
networkSettings_vpcId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkSettings' {Maybe Text
vpcId :: Maybe Text
$sel:vpcId:NetworkSettings' :: NetworkSettings -> Maybe Text
vpcId} -> Maybe Text
vpcId) (\s :: NetworkSettings
s@NetworkSettings' {} Maybe Text
a -> NetworkSettings
s {$sel:vpcId:NetworkSettings' :: Maybe Text
vpcId = Maybe Text
a} :: NetworkSettings)

-- | The ARN of the network settings.
networkSettings_networkSettingsArn :: Lens.Lens' NetworkSettings Prelude.Text
networkSettings_networkSettingsArn :: Lens' NetworkSettings Text
networkSettings_networkSettingsArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkSettings' {Text
networkSettingsArn :: Text
$sel:networkSettingsArn:NetworkSettings' :: NetworkSettings -> Text
networkSettingsArn} -> Text
networkSettingsArn) (\s :: NetworkSettings
s@NetworkSettings' {} Text
a -> NetworkSettings
s {$sel:networkSettingsArn:NetworkSettings' :: Text
networkSettingsArn = Text
a} :: NetworkSettings)

instance Data.FromJSON NetworkSettings where
  parseJSON :: Value -> Parser NetworkSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NetworkSettings"
      ( \Object
x ->
          Maybe [Text]
-> Maybe (NonEmpty Text)
-> Maybe (NonEmpty Text)
-> Maybe Text
-> Text
-> NetworkSettings
NetworkSettings'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"associatedPortalArns"
                            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 (Maybe a)
Data..:? Key
"securityGroupIds")
            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
"subnetIds")
            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
"vpcId")
            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
"networkSettingsArn")
      )

instance Prelude.Hashable NetworkSettings where
  hashWithSalt :: Int -> NetworkSettings -> Int
hashWithSalt Int
_salt NetworkSettings' {Maybe [Text]
Maybe (NonEmpty Text)
Maybe Text
Text
networkSettingsArn :: Text
vpcId :: Maybe Text
subnetIds :: Maybe (NonEmpty Text)
securityGroupIds :: Maybe (NonEmpty Text)
associatedPortalArns :: Maybe [Text]
$sel:networkSettingsArn:NetworkSettings' :: NetworkSettings -> Text
$sel:vpcId:NetworkSettings' :: NetworkSettings -> Maybe Text
$sel:subnetIds:NetworkSettings' :: NetworkSettings -> Maybe (NonEmpty Text)
$sel:securityGroupIds:NetworkSettings' :: NetworkSettings -> Maybe (NonEmpty Text)
$sel:associatedPortalArns:NetworkSettings' :: NetworkSettings -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
associatedPortalArns
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
securityGroupIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
subnetIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vpcId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
networkSettingsArn

instance Prelude.NFData NetworkSettings where
  rnf :: NetworkSettings -> ()
rnf NetworkSettings' {Maybe [Text]
Maybe (NonEmpty Text)
Maybe Text
Text
networkSettingsArn :: Text
vpcId :: Maybe Text
subnetIds :: Maybe (NonEmpty Text)
securityGroupIds :: Maybe (NonEmpty Text)
associatedPortalArns :: Maybe [Text]
$sel:networkSettingsArn:NetworkSettings' :: NetworkSettings -> Text
$sel:vpcId:NetworkSettings' :: NetworkSettings -> Maybe Text
$sel:subnetIds:NetworkSettings' :: NetworkSettings -> Maybe (NonEmpty Text)
$sel:securityGroupIds:NetworkSettings' :: NetworkSettings -> Maybe (NonEmpty Text)
$sel:associatedPortalArns:NetworkSettings' :: NetworkSettings -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
associatedPortalArns
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
securityGroupIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
subnetIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vpcId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
networkSettingsArn