{-# 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.DeviceFarm.Types.TestGridVpcConfig
-- 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.DeviceFarm.Types.TestGridVpcConfig 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 VPC security groups and subnets that are attached to a project.
--
-- /See:/ 'newTestGridVpcConfig' smart constructor.
data TestGridVpcConfig = TestGridVpcConfig'
  { -- | A list of VPC security group IDs in your Amazon VPC.
    TestGridVpcConfig -> NonEmpty Text
securityGroupIds :: Prelude.NonEmpty Prelude.Text,
    -- | A list of VPC subnet IDs in your Amazon VPC.
    TestGridVpcConfig -> NonEmpty Text
subnetIds :: Prelude.NonEmpty Prelude.Text,
    -- | The ID of the Amazon VPC.
    TestGridVpcConfig -> Text
vpcId :: Prelude.Text
  }
  deriving (TestGridVpcConfig -> TestGridVpcConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestGridVpcConfig -> TestGridVpcConfig -> Bool
$c/= :: TestGridVpcConfig -> TestGridVpcConfig -> Bool
== :: TestGridVpcConfig -> TestGridVpcConfig -> Bool
$c== :: TestGridVpcConfig -> TestGridVpcConfig -> Bool
Prelude.Eq, ReadPrec [TestGridVpcConfig]
ReadPrec TestGridVpcConfig
Int -> ReadS TestGridVpcConfig
ReadS [TestGridVpcConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TestGridVpcConfig]
$creadListPrec :: ReadPrec [TestGridVpcConfig]
readPrec :: ReadPrec TestGridVpcConfig
$creadPrec :: ReadPrec TestGridVpcConfig
readList :: ReadS [TestGridVpcConfig]
$creadList :: ReadS [TestGridVpcConfig]
readsPrec :: Int -> ReadS TestGridVpcConfig
$creadsPrec :: Int -> ReadS TestGridVpcConfig
Prelude.Read, Int -> TestGridVpcConfig -> ShowS
[TestGridVpcConfig] -> ShowS
TestGridVpcConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestGridVpcConfig] -> ShowS
$cshowList :: [TestGridVpcConfig] -> ShowS
show :: TestGridVpcConfig -> String
$cshow :: TestGridVpcConfig -> String
showsPrec :: Int -> TestGridVpcConfig -> ShowS
$cshowsPrec :: Int -> TestGridVpcConfig -> ShowS
Prelude.Show, forall x. Rep TestGridVpcConfig x -> TestGridVpcConfig
forall x. TestGridVpcConfig -> Rep TestGridVpcConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TestGridVpcConfig x -> TestGridVpcConfig
$cfrom :: forall x. TestGridVpcConfig -> Rep TestGridVpcConfig x
Prelude.Generic)

-- |
-- Create a value of 'TestGridVpcConfig' 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:
--
-- 'securityGroupIds', 'testGridVpcConfig_securityGroupIds' - A list of VPC security group IDs in your Amazon VPC.
--
-- 'subnetIds', 'testGridVpcConfig_subnetIds' - A list of VPC subnet IDs in your Amazon VPC.
--
-- 'vpcId', 'testGridVpcConfig_vpcId' - The ID of the Amazon VPC.
newTestGridVpcConfig ::
  -- | 'securityGroupIds'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'subnetIds'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'vpcId'
  Prelude.Text ->
  TestGridVpcConfig
newTestGridVpcConfig :: NonEmpty Text -> NonEmpty Text -> Text -> TestGridVpcConfig
newTestGridVpcConfig
  NonEmpty Text
pSecurityGroupIds_
  NonEmpty Text
pSubnetIds_
  Text
pVpcId_ =
    TestGridVpcConfig'
      { $sel:securityGroupIds:TestGridVpcConfig' :: NonEmpty Text
securityGroupIds =
          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
pSecurityGroupIds_,
        $sel:subnetIds:TestGridVpcConfig' :: NonEmpty Text
subnetIds = 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
pSubnetIds_,
        $sel:vpcId:TestGridVpcConfig' :: Text
vpcId = Text
pVpcId_
      }

-- | A list of VPC security group IDs in your Amazon VPC.
testGridVpcConfig_securityGroupIds :: Lens.Lens' TestGridVpcConfig (Prelude.NonEmpty Prelude.Text)
testGridVpcConfig_securityGroupIds :: Lens' TestGridVpcConfig (NonEmpty Text)
testGridVpcConfig_securityGroupIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestGridVpcConfig' {NonEmpty Text
securityGroupIds :: NonEmpty Text
$sel:securityGroupIds:TestGridVpcConfig' :: TestGridVpcConfig -> NonEmpty Text
securityGroupIds} -> NonEmpty Text
securityGroupIds) (\s :: TestGridVpcConfig
s@TestGridVpcConfig' {} NonEmpty Text
a -> TestGridVpcConfig
s {$sel:securityGroupIds:TestGridVpcConfig' :: NonEmpty Text
securityGroupIds = NonEmpty Text
a} :: TestGridVpcConfig) 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

-- | A list of VPC subnet IDs in your Amazon VPC.
testGridVpcConfig_subnetIds :: Lens.Lens' TestGridVpcConfig (Prelude.NonEmpty Prelude.Text)
testGridVpcConfig_subnetIds :: Lens' TestGridVpcConfig (NonEmpty Text)
testGridVpcConfig_subnetIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestGridVpcConfig' {NonEmpty Text
subnetIds :: NonEmpty Text
$sel:subnetIds:TestGridVpcConfig' :: TestGridVpcConfig -> NonEmpty Text
subnetIds} -> NonEmpty Text
subnetIds) (\s :: TestGridVpcConfig
s@TestGridVpcConfig' {} NonEmpty Text
a -> TestGridVpcConfig
s {$sel:subnetIds:TestGridVpcConfig' :: NonEmpty Text
subnetIds = NonEmpty Text
a} :: TestGridVpcConfig) 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 ID of the Amazon VPC.
testGridVpcConfig_vpcId :: Lens.Lens' TestGridVpcConfig Prelude.Text
testGridVpcConfig_vpcId :: Lens' TestGridVpcConfig Text
testGridVpcConfig_vpcId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestGridVpcConfig' {Text
vpcId :: Text
$sel:vpcId:TestGridVpcConfig' :: TestGridVpcConfig -> Text
vpcId} -> Text
vpcId) (\s :: TestGridVpcConfig
s@TestGridVpcConfig' {} Text
a -> TestGridVpcConfig
s {$sel:vpcId:TestGridVpcConfig' :: Text
vpcId = Text
a} :: TestGridVpcConfig)

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

instance Prelude.Hashable TestGridVpcConfig where
  hashWithSalt :: Int -> TestGridVpcConfig -> Int
hashWithSalt Int
_salt TestGridVpcConfig' {NonEmpty Text
Text
vpcId :: Text
subnetIds :: NonEmpty Text
securityGroupIds :: NonEmpty Text
$sel:vpcId:TestGridVpcConfig' :: TestGridVpcConfig -> Text
$sel:subnetIds:TestGridVpcConfig' :: TestGridVpcConfig -> NonEmpty Text
$sel:securityGroupIds:TestGridVpcConfig' :: TestGridVpcConfig -> NonEmpty Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
securityGroupIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
subnetIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
vpcId

instance Prelude.NFData TestGridVpcConfig where
  rnf :: TestGridVpcConfig -> ()
rnf TestGridVpcConfig' {NonEmpty Text
Text
vpcId :: Text
subnetIds :: NonEmpty Text
securityGroupIds :: NonEmpty Text
$sel:vpcId:TestGridVpcConfig' :: TestGridVpcConfig -> Text
$sel:subnetIds:TestGridVpcConfig' :: TestGridVpcConfig -> NonEmpty Text
$sel:securityGroupIds:TestGridVpcConfig' :: TestGridVpcConfig -> NonEmpty Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
securityGroupIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
subnetIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
vpcId

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