{-# 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.DataBrew.CreateProject
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a new DataBrew project.
module Amazonka.DataBrew.CreateProject
  ( -- * Creating a Request
    CreateProject (..),
    newCreateProject,

    -- * Request Lenses
    createProject_sample,
    createProject_tags,
    createProject_datasetName,
    createProject_name,
    createProject_recipeName,
    createProject_roleArn,

    -- * Destructuring the Response
    CreateProjectResponse (..),
    newCreateProjectResponse,

    -- * Response Lenses
    createProjectResponse_httpStatus,
    createProjectResponse_name,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataBrew.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreateProject' smart constructor.
data CreateProject = CreateProject'
  { CreateProject -> Maybe Sample
sample :: Prelude.Maybe Sample,
    -- | Metadata tags to apply to this project.
    CreateProject -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of an existing dataset to associate this project with.
    CreateProject -> Text
datasetName :: Prelude.Text,
    -- | A unique name for the new project. Valid characters are alphanumeric
    -- (A-Z, a-z, 0-9), hyphen (-), period (.), and space.
    CreateProject -> Text
name :: Prelude.Text,
    -- | The name of an existing recipe to associate with the project.
    CreateProject -> Text
recipeName :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the Identity and Access Management
    -- (IAM) role to be assumed for this request.
    CreateProject -> Text
roleArn :: Prelude.Text
  }
  deriving (CreateProject -> CreateProject -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateProject -> CreateProject -> Bool
$c/= :: CreateProject -> CreateProject -> Bool
== :: CreateProject -> CreateProject -> Bool
$c== :: CreateProject -> CreateProject -> Bool
Prelude.Eq, ReadPrec [CreateProject]
ReadPrec CreateProject
Int -> ReadS CreateProject
ReadS [CreateProject]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateProject]
$creadListPrec :: ReadPrec [CreateProject]
readPrec :: ReadPrec CreateProject
$creadPrec :: ReadPrec CreateProject
readList :: ReadS [CreateProject]
$creadList :: ReadS [CreateProject]
readsPrec :: Int -> ReadS CreateProject
$creadsPrec :: Int -> ReadS CreateProject
Prelude.Read, Int -> CreateProject -> ShowS
[CreateProject] -> ShowS
CreateProject -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateProject] -> ShowS
$cshowList :: [CreateProject] -> ShowS
show :: CreateProject -> String
$cshow :: CreateProject -> String
showsPrec :: Int -> CreateProject -> ShowS
$cshowsPrec :: Int -> CreateProject -> ShowS
Prelude.Show, forall x. Rep CreateProject x -> CreateProject
forall x. CreateProject -> Rep CreateProject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateProject x -> CreateProject
$cfrom :: forall x. CreateProject -> Rep CreateProject x
Prelude.Generic)

-- |
-- Create a value of 'CreateProject' 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:
--
-- 'sample', 'createProject_sample' - Undocumented member.
--
-- 'tags', 'createProject_tags' - Metadata tags to apply to this project.
--
-- 'datasetName', 'createProject_datasetName' - The name of an existing dataset to associate this project with.
--
-- 'name', 'createProject_name' - A unique name for the new project. Valid characters are alphanumeric
-- (A-Z, a-z, 0-9), hyphen (-), period (.), and space.
--
-- 'recipeName', 'createProject_recipeName' - The name of an existing recipe to associate with the project.
--
-- 'roleArn', 'createProject_roleArn' - The Amazon Resource Name (ARN) of the Identity and Access Management
-- (IAM) role to be assumed for this request.
newCreateProject ::
  -- | 'datasetName'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'recipeName'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  CreateProject
newCreateProject :: Text -> Text -> Text -> Text -> CreateProject
newCreateProject
  Text
pDatasetName_
  Text
pName_
  Text
pRecipeName_
  Text
pRoleArn_ =
    CreateProject'
      { $sel:sample:CreateProject' :: Maybe Sample
sample = forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateProject' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
        $sel:datasetName:CreateProject' :: Text
datasetName = Text
pDatasetName_,
        $sel:name:CreateProject' :: Text
name = Text
pName_,
        $sel:recipeName:CreateProject' :: Text
recipeName = Text
pRecipeName_,
        $sel:roleArn:CreateProject' :: Text
roleArn = Text
pRoleArn_
      }

-- | Undocumented member.
createProject_sample :: Lens.Lens' CreateProject (Prelude.Maybe Sample)
createProject_sample :: Lens' CreateProject (Maybe Sample)
createProject_sample = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProject' {Maybe Sample
sample :: Maybe Sample
$sel:sample:CreateProject' :: CreateProject -> Maybe Sample
sample} -> Maybe Sample
sample) (\s :: CreateProject
s@CreateProject' {} Maybe Sample
a -> CreateProject
s {$sel:sample:CreateProject' :: Maybe Sample
sample = Maybe Sample
a} :: CreateProject)

-- | Metadata tags to apply to this project.
createProject_tags :: Lens.Lens' CreateProject (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createProject_tags :: Lens' CreateProject (Maybe (HashMap Text Text))
createProject_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProject' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateProject' :: CreateProject -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateProject
s@CreateProject' {} Maybe (HashMap Text Text)
a -> CreateProject
s {$sel:tags:CreateProject' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateProject) 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 name of an existing dataset to associate this project with.
createProject_datasetName :: Lens.Lens' CreateProject Prelude.Text
createProject_datasetName :: Lens' CreateProject Text
createProject_datasetName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProject' {Text
datasetName :: Text
$sel:datasetName:CreateProject' :: CreateProject -> Text
datasetName} -> Text
datasetName) (\s :: CreateProject
s@CreateProject' {} Text
a -> CreateProject
s {$sel:datasetName:CreateProject' :: Text
datasetName = Text
a} :: CreateProject)

-- | A unique name for the new project. Valid characters are alphanumeric
-- (A-Z, a-z, 0-9), hyphen (-), period (.), and space.
createProject_name :: Lens.Lens' CreateProject Prelude.Text
createProject_name :: Lens' CreateProject Text
createProject_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProject' {Text
name :: Text
$sel:name:CreateProject' :: CreateProject -> Text
name} -> Text
name) (\s :: CreateProject
s@CreateProject' {} Text
a -> CreateProject
s {$sel:name:CreateProject' :: Text
name = Text
a} :: CreateProject)

-- | The name of an existing recipe to associate with the project.
createProject_recipeName :: Lens.Lens' CreateProject Prelude.Text
createProject_recipeName :: Lens' CreateProject Text
createProject_recipeName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProject' {Text
recipeName :: Text
$sel:recipeName:CreateProject' :: CreateProject -> Text
recipeName} -> Text
recipeName) (\s :: CreateProject
s@CreateProject' {} Text
a -> CreateProject
s {$sel:recipeName:CreateProject' :: Text
recipeName = Text
a} :: CreateProject)

-- | The Amazon Resource Name (ARN) of the Identity and Access Management
-- (IAM) role to be assumed for this request.
createProject_roleArn :: Lens.Lens' CreateProject Prelude.Text
createProject_roleArn :: Lens' CreateProject Text
createProject_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProject' {Text
roleArn :: Text
$sel:roleArn:CreateProject' :: CreateProject -> Text
roleArn} -> Text
roleArn) (\s :: CreateProject
s@CreateProject' {} Text
a -> CreateProject
s {$sel:roleArn:CreateProject' :: Text
roleArn = Text
a} :: CreateProject)

instance Core.AWSRequest CreateProject where
  type
    AWSResponse CreateProject =
      CreateProjectResponse
  request :: (Service -> Service) -> CreateProject -> Request CreateProject
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateProject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateProject)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> Text -> CreateProjectResponse
CreateProjectResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"Name")
      )

instance Prelude.Hashable CreateProject where
  hashWithSalt :: Int -> CreateProject -> Int
hashWithSalt Int
_salt CreateProject' {Maybe (HashMap Text Text)
Maybe Sample
Text
roleArn :: Text
recipeName :: Text
name :: Text
datasetName :: Text
tags :: Maybe (HashMap Text Text)
sample :: Maybe Sample
$sel:roleArn:CreateProject' :: CreateProject -> Text
$sel:recipeName:CreateProject' :: CreateProject -> Text
$sel:name:CreateProject' :: CreateProject -> Text
$sel:datasetName:CreateProject' :: CreateProject -> Text
$sel:tags:CreateProject' :: CreateProject -> Maybe (HashMap Text Text)
$sel:sample:CreateProject' :: CreateProject -> Maybe Sample
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Sample
sample
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
datasetName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
recipeName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleArn

instance Prelude.NFData CreateProject where
  rnf :: CreateProject -> ()
rnf CreateProject' {Maybe (HashMap Text Text)
Maybe Sample
Text
roleArn :: Text
recipeName :: Text
name :: Text
datasetName :: Text
tags :: Maybe (HashMap Text Text)
sample :: Maybe Sample
$sel:roleArn:CreateProject' :: CreateProject -> Text
$sel:recipeName:CreateProject' :: CreateProject -> Text
$sel:name:CreateProject' :: CreateProject -> Text
$sel:datasetName:CreateProject' :: CreateProject -> Text
$sel:tags:CreateProject' :: CreateProject -> Maybe (HashMap Text Text)
$sel:sample:CreateProject' :: CreateProject -> Maybe Sample
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Sample
sample
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
datasetName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
recipeName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
roleArn

instance Data.ToHeaders CreateProject where
  toHeaders :: CreateProject -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON CreateProject where
  toJSON :: CreateProject -> Value
toJSON CreateProject' {Maybe (HashMap Text Text)
Maybe Sample
Text
roleArn :: Text
recipeName :: Text
name :: Text
datasetName :: Text
tags :: Maybe (HashMap Text Text)
sample :: Maybe Sample
$sel:roleArn:CreateProject' :: CreateProject -> Text
$sel:recipeName:CreateProject' :: CreateProject -> Text
$sel:name:CreateProject' :: CreateProject -> Text
$sel:datasetName:CreateProject' :: CreateProject -> Text
$sel:tags:CreateProject' :: CreateProject -> Maybe (HashMap Text Text)
$sel:sample:CreateProject' :: CreateProject -> Maybe Sample
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Sample" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Sample
sample,
            (Key
"Tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
            forall a. a -> Maybe a
Prelude.Just (Key
"DatasetName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
datasetName),
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"RecipeName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
recipeName),
            forall a. a -> Maybe a
Prelude.Just (Key
"RoleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
roleArn)
          ]
      )

instance Data.ToPath CreateProject where
  toPath :: CreateProject -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/projects"

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

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

-- |
-- Create a value of 'CreateProjectResponse' 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:
--
-- 'httpStatus', 'createProjectResponse_httpStatus' - The response's http status code.
--
-- 'name', 'createProjectResponse_name' - The name of the project that you created.
newCreateProjectResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'name'
  Prelude.Text ->
  CreateProjectResponse
newCreateProjectResponse :: Int -> Text -> CreateProjectResponse
newCreateProjectResponse Int
pHttpStatus_ Text
pName_ =
  CreateProjectResponse'
    { $sel:httpStatus:CreateProjectResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:name:CreateProjectResponse' :: Text
name = Text
pName_
    }

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

-- | The name of the project that you created.
createProjectResponse_name :: Lens.Lens' CreateProjectResponse Prelude.Text
createProjectResponse_name :: Lens' CreateProjectResponse Text
createProjectResponse_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProjectResponse' {Text
name :: Text
$sel:name:CreateProjectResponse' :: CreateProjectResponse -> Text
name} -> Text
name) (\s :: CreateProjectResponse
s@CreateProjectResponse' {} Text
a -> CreateProjectResponse
s {$sel:name:CreateProjectResponse' :: Text
name = Text
a} :: CreateProjectResponse)

instance Prelude.NFData CreateProjectResponse where
  rnf :: CreateProjectResponse -> ()
rnf CreateProjectResponse' {Int
Text
name :: Text
httpStatus :: Int
$sel:name:CreateProjectResponse' :: CreateProjectResponse -> Text
$sel:httpStatus:CreateProjectResponse' :: CreateProjectResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name