{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.CreateTestGridProject
-- 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)
--
-- Creates a Selenium testing project. Projects are used to track
-- TestGridSession instances.
module Amazonka.DeviceFarm.CreateTestGridProject
  ( -- * Creating a Request
    CreateTestGridProject (..),
    newCreateTestGridProject,

    -- * Request Lenses
    createTestGridProject_vpcConfig,
    createTestGridProject_description,
    createTestGridProject_name,

    -- * Destructuring the Response
    CreateTestGridProjectResponse (..),
    newCreateTestGridProjectResponse,

    -- * Response Lenses
    createTestGridProjectResponse_testGridProject,
    createTestGridProjectResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DeviceFarm.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreateTestGridProject' smart constructor.
data CreateTestGridProject = CreateTestGridProject'
  { -- | The VPC security groups and subnets that are attached to a project.
    CreateTestGridProject -> Maybe TestGridVpcConfig
vpcConfig :: Prelude.Maybe TestGridVpcConfig,
    -- | Human-readable description of the project.
    CreateTestGridProject -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | Human-readable name of the Selenium testing project.
    CreateTestGridProject -> Text
name :: Prelude.Text
  }
  deriving (CreateTestGridProject -> CreateTestGridProject -> Bool
(CreateTestGridProject -> CreateTestGridProject -> Bool)
-> (CreateTestGridProject -> CreateTestGridProject -> Bool)
-> Eq CreateTestGridProject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTestGridProject -> CreateTestGridProject -> Bool
$c/= :: CreateTestGridProject -> CreateTestGridProject -> Bool
== :: CreateTestGridProject -> CreateTestGridProject -> Bool
$c== :: CreateTestGridProject -> CreateTestGridProject -> Bool
Prelude.Eq, ReadPrec [CreateTestGridProject]
ReadPrec CreateTestGridProject
Int -> ReadS CreateTestGridProject
ReadS [CreateTestGridProject]
(Int -> ReadS CreateTestGridProject)
-> ReadS [CreateTestGridProject]
-> ReadPrec CreateTestGridProject
-> ReadPrec [CreateTestGridProject]
-> Read CreateTestGridProject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTestGridProject]
$creadListPrec :: ReadPrec [CreateTestGridProject]
readPrec :: ReadPrec CreateTestGridProject
$creadPrec :: ReadPrec CreateTestGridProject
readList :: ReadS [CreateTestGridProject]
$creadList :: ReadS [CreateTestGridProject]
readsPrec :: Int -> ReadS CreateTestGridProject
$creadsPrec :: Int -> ReadS CreateTestGridProject
Prelude.Read, Int -> CreateTestGridProject -> ShowS
[CreateTestGridProject] -> ShowS
CreateTestGridProject -> String
(Int -> CreateTestGridProject -> ShowS)
-> (CreateTestGridProject -> String)
-> ([CreateTestGridProject] -> ShowS)
-> Show CreateTestGridProject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTestGridProject] -> ShowS
$cshowList :: [CreateTestGridProject] -> ShowS
show :: CreateTestGridProject -> String
$cshow :: CreateTestGridProject -> String
showsPrec :: Int -> CreateTestGridProject -> ShowS
$cshowsPrec :: Int -> CreateTestGridProject -> ShowS
Prelude.Show, (forall x. CreateTestGridProject -> Rep CreateTestGridProject x)
-> (forall x. Rep CreateTestGridProject x -> CreateTestGridProject)
-> Generic CreateTestGridProject
forall x. Rep CreateTestGridProject x -> CreateTestGridProject
forall x. CreateTestGridProject -> Rep CreateTestGridProject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTestGridProject x -> CreateTestGridProject
$cfrom :: forall x. CreateTestGridProject -> Rep CreateTestGridProject x
Prelude.Generic)

-- |
-- Create a value of 'CreateTestGridProject' 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:
--
-- 'vpcConfig', 'createTestGridProject_vpcConfig' - The VPC security groups and subnets that are attached to a project.
--
-- 'description', 'createTestGridProject_description' - Human-readable description of the project.
--
-- 'name', 'createTestGridProject_name' - Human-readable name of the Selenium testing project.
newCreateTestGridProject ::
  -- | 'name'
  Prelude.Text ->
  CreateTestGridProject
newCreateTestGridProject :: Text -> CreateTestGridProject
newCreateTestGridProject Text
pName_ =
  CreateTestGridProject' :: Maybe TestGridVpcConfig
-> Maybe Text -> Text -> CreateTestGridProject
CreateTestGridProject'
    { $sel:vpcConfig:CreateTestGridProject' :: Maybe TestGridVpcConfig
vpcConfig = Maybe TestGridVpcConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:description:CreateTestGridProject' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateTestGridProject' :: Text
name = Text
pName_
    }

-- | The VPC security groups and subnets that are attached to a project.
createTestGridProject_vpcConfig :: Lens.Lens' CreateTestGridProject (Prelude.Maybe TestGridVpcConfig)
createTestGridProject_vpcConfig :: (Maybe TestGridVpcConfig -> f (Maybe TestGridVpcConfig))
-> CreateTestGridProject -> f CreateTestGridProject
createTestGridProject_vpcConfig = (CreateTestGridProject -> Maybe TestGridVpcConfig)
-> (CreateTestGridProject
    -> Maybe TestGridVpcConfig -> CreateTestGridProject)
-> Lens
     CreateTestGridProject
     CreateTestGridProject
     (Maybe TestGridVpcConfig)
     (Maybe TestGridVpcConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTestGridProject' {Maybe TestGridVpcConfig
vpcConfig :: Maybe TestGridVpcConfig
$sel:vpcConfig:CreateTestGridProject' :: CreateTestGridProject -> Maybe TestGridVpcConfig
vpcConfig} -> Maybe TestGridVpcConfig
vpcConfig) (\s :: CreateTestGridProject
s@CreateTestGridProject' {} Maybe TestGridVpcConfig
a -> CreateTestGridProject
s {$sel:vpcConfig:CreateTestGridProject' :: Maybe TestGridVpcConfig
vpcConfig = Maybe TestGridVpcConfig
a} :: CreateTestGridProject)

-- | Human-readable description of the project.
createTestGridProject_description :: Lens.Lens' CreateTestGridProject (Prelude.Maybe Prelude.Text)
createTestGridProject_description :: (Maybe Text -> f (Maybe Text))
-> CreateTestGridProject -> f CreateTestGridProject
createTestGridProject_description = (CreateTestGridProject -> Maybe Text)
-> (CreateTestGridProject -> Maybe Text -> CreateTestGridProject)
-> Lens
     CreateTestGridProject
     CreateTestGridProject
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTestGridProject' {Maybe Text
description :: Maybe Text
$sel:description:CreateTestGridProject' :: CreateTestGridProject -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateTestGridProject
s@CreateTestGridProject' {} Maybe Text
a -> CreateTestGridProject
s {$sel:description:CreateTestGridProject' :: Maybe Text
description = Maybe Text
a} :: CreateTestGridProject)

-- | Human-readable name of the Selenium testing project.
createTestGridProject_name :: Lens.Lens' CreateTestGridProject Prelude.Text
createTestGridProject_name :: (Text -> f Text)
-> CreateTestGridProject -> f CreateTestGridProject
createTestGridProject_name = (CreateTestGridProject -> Text)
-> (CreateTestGridProject -> Text -> CreateTestGridProject)
-> Lens CreateTestGridProject CreateTestGridProject Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTestGridProject' {Text
name :: Text
$sel:name:CreateTestGridProject' :: CreateTestGridProject -> Text
name} -> Text
name) (\s :: CreateTestGridProject
s@CreateTestGridProject' {} Text
a -> CreateTestGridProject
s {$sel:name:CreateTestGridProject' :: Text
name = Text
a} :: CreateTestGridProject)

instance Core.AWSRequest CreateTestGridProject where
  type
    AWSResponse CreateTestGridProject =
      CreateTestGridProjectResponse
  request :: CreateTestGridProject -> Request CreateTestGridProject
request = Service -> CreateTestGridProject -> Request CreateTestGridProject
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateTestGridProject
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateTestGridProject)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateTestGridProject))
-> Logger
-> Service
-> Proxy CreateTestGridProject
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateTestGridProject)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe TestGridProject -> Int -> CreateTestGridProjectResponse
CreateTestGridProjectResponse'
            (Maybe TestGridProject -> Int -> CreateTestGridProjectResponse)
-> Either String (Maybe TestGridProject)
-> Either String (Int -> CreateTestGridProjectResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe TestGridProject)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"testGridProject")
            Either String (Int -> CreateTestGridProjectResponse)
-> Either String Int -> Either String CreateTestGridProjectResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateTestGridProject

instance Prelude.NFData CreateTestGridProject

instance Core.ToHeaders CreateTestGridProject where
  toHeaders :: CreateTestGridProject -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateTestGridProject -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"DeviceFarm_20150623.CreateTestGridProject" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CreateTestGridProject where
  toJSON :: CreateTestGridProject -> Value
toJSON CreateTestGridProject' {Maybe Text
Maybe TestGridVpcConfig
Text
name :: Text
description :: Maybe Text
vpcConfig :: Maybe TestGridVpcConfig
$sel:name:CreateTestGridProject' :: CreateTestGridProject -> Text
$sel:description:CreateTestGridProject' :: CreateTestGridProject -> Maybe Text
$sel:vpcConfig:CreateTestGridProject' :: CreateTestGridProject -> Maybe TestGridVpcConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"vpcConfig" Text -> TestGridVpcConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TestGridVpcConfig -> Pair)
-> Maybe TestGridVpcConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TestGridVpcConfig
vpcConfig,
            (Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )

instance Core.ToPath CreateTestGridProject where
  toPath :: CreateTestGridProject -> ByteString
toPath = ByteString -> CreateTestGridProject -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery CreateTestGridProject where
  toQuery :: CreateTestGridProject -> QueryString
toQuery = QueryString -> CreateTestGridProject -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreateTestGridProjectResponse' smart constructor.
data CreateTestGridProjectResponse = CreateTestGridProjectResponse'
  { -- | ARN of the Selenium testing project that was created.
    CreateTestGridProjectResponse -> Maybe TestGridProject
testGridProject :: Prelude.Maybe TestGridProject,
    -- | The response's http status code.
    CreateTestGridProjectResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateTestGridProjectResponse
-> CreateTestGridProjectResponse -> Bool
(CreateTestGridProjectResponse
 -> CreateTestGridProjectResponse -> Bool)
-> (CreateTestGridProjectResponse
    -> CreateTestGridProjectResponse -> Bool)
-> Eq CreateTestGridProjectResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTestGridProjectResponse
-> CreateTestGridProjectResponse -> Bool
$c/= :: CreateTestGridProjectResponse
-> CreateTestGridProjectResponse -> Bool
== :: CreateTestGridProjectResponse
-> CreateTestGridProjectResponse -> Bool
$c== :: CreateTestGridProjectResponse
-> CreateTestGridProjectResponse -> Bool
Prelude.Eq, ReadPrec [CreateTestGridProjectResponse]
ReadPrec CreateTestGridProjectResponse
Int -> ReadS CreateTestGridProjectResponse
ReadS [CreateTestGridProjectResponse]
(Int -> ReadS CreateTestGridProjectResponse)
-> ReadS [CreateTestGridProjectResponse]
-> ReadPrec CreateTestGridProjectResponse
-> ReadPrec [CreateTestGridProjectResponse]
-> Read CreateTestGridProjectResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTestGridProjectResponse]
$creadListPrec :: ReadPrec [CreateTestGridProjectResponse]
readPrec :: ReadPrec CreateTestGridProjectResponse
$creadPrec :: ReadPrec CreateTestGridProjectResponse
readList :: ReadS [CreateTestGridProjectResponse]
$creadList :: ReadS [CreateTestGridProjectResponse]
readsPrec :: Int -> ReadS CreateTestGridProjectResponse
$creadsPrec :: Int -> ReadS CreateTestGridProjectResponse
Prelude.Read, Int -> CreateTestGridProjectResponse -> ShowS
[CreateTestGridProjectResponse] -> ShowS
CreateTestGridProjectResponse -> String
(Int -> CreateTestGridProjectResponse -> ShowS)
-> (CreateTestGridProjectResponse -> String)
-> ([CreateTestGridProjectResponse] -> ShowS)
-> Show CreateTestGridProjectResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTestGridProjectResponse] -> ShowS
$cshowList :: [CreateTestGridProjectResponse] -> ShowS
show :: CreateTestGridProjectResponse -> String
$cshow :: CreateTestGridProjectResponse -> String
showsPrec :: Int -> CreateTestGridProjectResponse -> ShowS
$cshowsPrec :: Int -> CreateTestGridProjectResponse -> ShowS
Prelude.Show, (forall x.
 CreateTestGridProjectResponse
 -> Rep CreateTestGridProjectResponse x)
-> (forall x.
    Rep CreateTestGridProjectResponse x
    -> CreateTestGridProjectResponse)
-> Generic CreateTestGridProjectResponse
forall x.
Rep CreateTestGridProjectResponse x
-> CreateTestGridProjectResponse
forall x.
CreateTestGridProjectResponse
-> Rep CreateTestGridProjectResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateTestGridProjectResponse x
-> CreateTestGridProjectResponse
$cfrom :: forall x.
CreateTestGridProjectResponse
-> Rep CreateTestGridProjectResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateTestGridProjectResponse' 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:
--
-- 'testGridProject', 'createTestGridProjectResponse_testGridProject' - ARN of the Selenium testing project that was created.
--
-- 'httpStatus', 'createTestGridProjectResponse_httpStatus' - The response's http status code.
newCreateTestGridProjectResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateTestGridProjectResponse
newCreateTestGridProjectResponse :: Int -> CreateTestGridProjectResponse
newCreateTestGridProjectResponse Int
pHttpStatus_ =
  CreateTestGridProjectResponse' :: Maybe TestGridProject -> Int -> CreateTestGridProjectResponse
CreateTestGridProjectResponse'
    { $sel:testGridProject:CreateTestGridProjectResponse' :: Maybe TestGridProject
testGridProject =
        Maybe TestGridProject
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateTestGridProjectResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | ARN of the Selenium testing project that was created.
createTestGridProjectResponse_testGridProject :: Lens.Lens' CreateTestGridProjectResponse (Prelude.Maybe TestGridProject)
createTestGridProjectResponse_testGridProject :: (Maybe TestGridProject -> f (Maybe TestGridProject))
-> CreateTestGridProjectResponse -> f CreateTestGridProjectResponse
createTestGridProjectResponse_testGridProject = (CreateTestGridProjectResponse -> Maybe TestGridProject)
-> (CreateTestGridProjectResponse
    -> Maybe TestGridProject -> CreateTestGridProjectResponse)
-> Lens
     CreateTestGridProjectResponse
     CreateTestGridProjectResponse
     (Maybe TestGridProject)
     (Maybe TestGridProject)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTestGridProjectResponse' {Maybe TestGridProject
testGridProject :: Maybe TestGridProject
$sel:testGridProject:CreateTestGridProjectResponse' :: CreateTestGridProjectResponse -> Maybe TestGridProject
testGridProject} -> Maybe TestGridProject
testGridProject) (\s :: CreateTestGridProjectResponse
s@CreateTestGridProjectResponse' {} Maybe TestGridProject
a -> CreateTestGridProjectResponse
s {$sel:testGridProject:CreateTestGridProjectResponse' :: Maybe TestGridProject
testGridProject = Maybe TestGridProject
a} :: CreateTestGridProjectResponse)

-- | The response's http status code.
createTestGridProjectResponse_httpStatus :: Lens.Lens' CreateTestGridProjectResponse Prelude.Int
createTestGridProjectResponse_httpStatus :: (Int -> f Int)
-> CreateTestGridProjectResponse -> f CreateTestGridProjectResponse
createTestGridProjectResponse_httpStatus = (CreateTestGridProjectResponse -> Int)
-> (CreateTestGridProjectResponse
    -> Int -> CreateTestGridProjectResponse)
-> Lens
     CreateTestGridProjectResponse CreateTestGridProjectResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTestGridProjectResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateTestGridProjectResponse' :: CreateTestGridProjectResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateTestGridProjectResponse
s@CreateTestGridProjectResponse' {} Int
a -> CreateTestGridProjectResponse
s {$sel:httpStatus:CreateTestGridProjectResponse' :: Int
httpStatus = Int
a} :: CreateTestGridProjectResponse)

instance Prelude.NFData CreateTestGridProjectResponse