{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DeviceFarm.Types.TestGridVpcConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(TestGridVpcConfig -> TestGridVpcConfig -> Bool)
-> (TestGridVpcConfig -> TestGridVpcConfig -> Bool)
-> Eq TestGridVpcConfig
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]
(Int -> ReadS TestGridVpcConfig)
-> ReadS [TestGridVpcConfig]
-> ReadPrec TestGridVpcConfig
-> ReadPrec [TestGridVpcConfig]
-> Read 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
(Int -> TestGridVpcConfig -> ShowS)
-> (TestGridVpcConfig -> String)
-> ([TestGridVpcConfig] -> ShowS)
-> Show TestGridVpcConfig
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. TestGridVpcConfig -> Rep TestGridVpcConfig x)
-> (forall x. Rep TestGridVpcConfig x -> TestGridVpcConfig)
-> Generic TestGridVpcConfig
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' :: NonEmpty Text -> NonEmpty Text -> Text -> TestGridVpcConfig
TestGridVpcConfig'
      { $sel:securityGroupIds:TestGridVpcConfig' :: NonEmpty Text
securityGroupIds =
          Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pSecurityGroupIds_,
        $sel:subnetIds:TestGridVpcConfig' :: NonEmpty Text
subnetIds = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
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 :: (NonEmpty Text -> f (NonEmpty Text))
-> TestGridVpcConfig -> f TestGridVpcConfig
testGridVpcConfig_securityGroupIds = (TestGridVpcConfig -> NonEmpty Text)
-> (TestGridVpcConfig -> NonEmpty Text -> TestGridVpcConfig)
-> Lens
     TestGridVpcConfig TestGridVpcConfig (NonEmpty Text) (NonEmpty Text)
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) ((NonEmpty Text -> f (NonEmpty Text))
 -> TestGridVpcConfig -> f TestGridVpcConfig)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> TestGridVpcConfig
-> f TestGridVpcConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
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 :: (NonEmpty Text -> f (NonEmpty Text))
-> TestGridVpcConfig -> f TestGridVpcConfig
testGridVpcConfig_subnetIds = (TestGridVpcConfig -> NonEmpty Text)
-> (TestGridVpcConfig -> NonEmpty Text -> TestGridVpcConfig)
-> Lens
     TestGridVpcConfig TestGridVpcConfig (NonEmpty Text) (NonEmpty Text)
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) ((NonEmpty Text -> f (NonEmpty Text))
 -> TestGridVpcConfig -> f TestGridVpcConfig)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> TestGridVpcConfig
-> f TestGridVpcConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
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 :: (Text -> f Text) -> TestGridVpcConfig -> f TestGridVpcConfig
testGridVpcConfig_vpcId = (TestGridVpcConfig -> Text)
-> (TestGridVpcConfig -> Text -> TestGridVpcConfig)
-> Lens TestGridVpcConfig TestGridVpcConfig Text Text
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 Core.FromJSON TestGridVpcConfig where
  parseJSON :: Value -> Parser TestGridVpcConfig
parseJSON =
    String
-> (Object -> Parser TestGridVpcConfig)
-> Value
-> Parser TestGridVpcConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TestGridVpcConfig"
      ( \Object
x ->
          NonEmpty Text -> NonEmpty Text -> Text -> TestGridVpcConfig
TestGridVpcConfig'
            (NonEmpty Text -> NonEmpty Text -> Text -> TestGridVpcConfig)
-> Parser (NonEmpty Text)
-> Parser (NonEmpty Text -> Text -> TestGridVpcConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (NonEmpty Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"securityGroupIds")
            Parser (NonEmpty Text -> Text -> TestGridVpcConfig)
-> Parser (NonEmpty Text) -> Parser (Text -> TestGridVpcConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"subnetIds")
            Parser (Text -> TestGridVpcConfig)
-> Parser Text -> Parser TestGridVpcConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"vpcId")
      )

instance Prelude.Hashable TestGridVpcConfig

instance Prelude.NFData TestGridVpcConfig

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"securityGroupIds" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
securityGroupIds),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"subnetIds" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
subnetIds),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"vpcId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
vpcId)
          ]
      )