{-# 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.Mobile.CreateProject
-- 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 an AWS Mobile Hub project.
module Amazonka.Mobile.CreateProject
  ( -- * Creating a Request
    CreateProject (..),
    newCreateProject,

    -- * Request Lenses
    createProject_contents,
    createProject_name,
    createProject_region,
    createProject_snapshotId,

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

    -- * Response Lenses
    createProjectResponse_details,
    createProjectResponse_httpStatus,
  )
where

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

-- | Request structure used to request a project be created.
--
-- /See:/ 'newCreateProject' smart constructor.
data CreateProject = CreateProject'
  { -- | ZIP or YAML file which contains configuration settings to be used when
    -- creating the project. This may be the contents of the file downloaded
    -- from the URL provided in an export project operation.
    CreateProject -> Maybe ByteString
contents :: Prelude.Maybe Prelude.ByteString,
    -- | Name of the project.
    CreateProject -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Default region where project resources should be created.
    CreateProject -> Maybe Text
region :: Prelude.Maybe Prelude.Text,
    -- | Unique identifier for an exported snapshot of project configuration.
    -- This snapshot identifier is included in the share URL when a project is
    -- exported.
    CreateProject -> Maybe Text
snapshotId :: Prelude.Maybe Prelude.Text
  }
  deriving (CreateProject -> CreateProject -> Bool
(CreateProject -> CreateProject -> Bool)
-> (CreateProject -> CreateProject -> Bool) -> Eq CreateProject
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]
(Int -> ReadS CreateProject)
-> ReadS [CreateProject]
-> ReadPrec CreateProject
-> ReadPrec [CreateProject]
-> Read 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
(Int -> CreateProject -> ShowS)
-> (CreateProject -> String)
-> ([CreateProject] -> ShowS)
-> Show CreateProject
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. CreateProject -> Rep CreateProject x)
-> (forall x. Rep CreateProject x -> CreateProject)
-> Generic CreateProject
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:
--
-- 'contents', 'createProject_contents' - ZIP or YAML file which contains configuration settings to be used when
-- creating the project. This may be the contents of the file downloaded
-- from the URL provided in an export project operation.
--
-- 'name', 'createProject_name' - Name of the project.
--
-- 'region', 'createProject_region' - Default region where project resources should be created.
--
-- 'snapshotId', 'createProject_snapshotId' - Unique identifier for an exported snapshot of project configuration.
-- This snapshot identifier is included in the share URL when a project is
-- exported.
newCreateProject ::
  CreateProject
newCreateProject :: CreateProject
newCreateProject =
  CreateProject' :: Maybe ByteString
-> Maybe Text -> Maybe Text -> Maybe Text -> CreateProject
CreateProject'
    { $sel:contents:CreateProject' :: Maybe ByteString
contents = Maybe ByteString
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateProject' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:region:CreateProject' :: Maybe Text
region = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:snapshotId:CreateProject' :: Maybe Text
snapshotId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | ZIP or YAML file which contains configuration settings to be used when
-- creating the project. This may be the contents of the file downloaded
-- from the URL provided in an export project operation.
createProject_contents :: Lens.Lens' CreateProject (Prelude.Maybe Prelude.ByteString)
createProject_contents :: (Maybe ByteString -> f (Maybe ByteString))
-> CreateProject -> f CreateProject
createProject_contents = (CreateProject -> Maybe ByteString)
-> (CreateProject -> Maybe ByteString -> CreateProject)
-> Lens
     CreateProject CreateProject (Maybe ByteString) (Maybe ByteString)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProject' {Maybe ByteString
contents :: Maybe ByteString
$sel:contents:CreateProject' :: CreateProject -> Maybe ByteString
contents} -> Maybe ByteString
contents) (\s :: CreateProject
s@CreateProject' {} Maybe ByteString
a -> CreateProject
s {$sel:contents:CreateProject' :: Maybe ByteString
contents = Maybe ByteString
a} :: CreateProject)

-- | Name of the project.
createProject_name :: Lens.Lens' CreateProject (Prelude.Maybe Prelude.Text)
createProject_name :: (Maybe Text -> f (Maybe Text)) -> CreateProject -> f CreateProject
createProject_name = (CreateProject -> Maybe Text)
-> (CreateProject -> Maybe Text -> CreateProject)
-> Lens CreateProject CreateProject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProject' {Maybe Text
name :: Maybe Text
$sel:name:CreateProject' :: CreateProject -> Maybe Text
name} -> Maybe Text
name) (\s :: CreateProject
s@CreateProject' {} Maybe Text
a -> CreateProject
s {$sel:name:CreateProject' :: Maybe Text
name = Maybe Text
a} :: CreateProject)

-- | Default region where project resources should be created.
createProject_region :: Lens.Lens' CreateProject (Prelude.Maybe Prelude.Text)
createProject_region :: (Maybe Text -> f (Maybe Text)) -> CreateProject -> f CreateProject
createProject_region = (CreateProject -> Maybe Text)
-> (CreateProject -> Maybe Text -> CreateProject)
-> Lens CreateProject CreateProject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProject' {Maybe Text
region :: Maybe Text
$sel:region:CreateProject' :: CreateProject -> Maybe Text
region} -> Maybe Text
region) (\s :: CreateProject
s@CreateProject' {} Maybe Text
a -> CreateProject
s {$sel:region:CreateProject' :: Maybe Text
region = Maybe Text
a} :: CreateProject)

-- | Unique identifier for an exported snapshot of project configuration.
-- This snapshot identifier is included in the share URL when a project is
-- exported.
createProject_snapshotId :: Lens.Lens' CreateProject (Prelude.Maybe Prelude.Text)
createProject_snapshotId :: (Maybe Text -> f (Maybe Text)) -> CreateProject -> f CreateProject
createProject_snapshotId = (CreateProject -> Maybe Text)
-> (CreateProject -> Maybe Text -> CreateProject)
-> Lens CreateProject CreateProject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProject' {Maybe Text
snapshotId :: Maybe Text
$sel:snapshotId:CreateProject' :: CreateProject -> Maybe Text
snapshotId} -> Maybe Text
snapshotId) (\s :: CreateProject
s@CreateProject' {} Maybe Text
a -> CreateProject
s {$sel:snapshotId:CreateProject' :: Maybe Text
snapshotId = Maybe Text
a} :: CreateProject)

instance Core.AWSRequest CreateProject where
  type
    AWSResponse CreateProject =
      CreateProjectResponse
  request :: CreateProject -> Request CreateProject
request = Service -> CreateProject -> Request CreateProject
forall a. (ToRequest a, ToBody a) => Service -> a -> Request a
Request.postBody Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateProject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateProject)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateProject))
-> Logger
-> Service
-> Proxy CreateProject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateProject)))
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 ProjectDetails -> Int -> CreateProjectResponse
CreateProjectResponse'
            (Maybe ProjectDetails -> Int -> CreateProjectResponse)
-> Either String (Maybe ProjectDetails)
-> Either String (Int -> CreateProjectResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ProjectDetails)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"details")
            Either String (Int -> CreateProjectResponse)
-> Either String Int -> Either String CreateProjectResponse
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 CreateProject

instance Prelude.NFData CreateProject

instance Core.ToBody CreateProject where
  toBody :: CreateProject -> RequestBody
toBody CreateProject' {Maybe ByteString
Maybe Text
snapshotId :: Maybe Text
region :: Maybe Text
name :: Maybe Text
contents :: Maybe ByteString
$sel:snapshotId:CreateProject' :: CreateProject -> Maybe Text
$sel:region:CreateProject' :: CreateProject -> Maybe Text
$sel:name:CreateProject' :: CreateProject -> Maybe Text
$sel:contents:CreateProject' :: CreateProject -> Maybe ByteString
..} = Maybe ByteString -> RequestBody
forall a. ToBody a => a -> RequestBody
Core.toBody Maybe ByteString
contents

instance Core.ToHeaders CreateProject where
  toHeaders :: CreateProject -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateProject -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath CreateProject where
  toPath :: CreateProject -> ByteString
toPath = ByteString -> CreateProject -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/projects"

instance Core.ToQuery CreateProject where
  toQuery :: CreateProject -> QueryString
toQuery CreateProject' {Maybe ByteString
Maybe Text
snapshotId :: Maybe Text
region :: Maybe Text
name :: Maybe Text
contents :: Maybe ByteString
$sel:snapshotId:CreateProject' :: CreateProject -> Maybe Text
$sel:region:CreateProject' :: CreateProject -> Maybe Text
$sel:name:CreateProject' :: CreateProject -> Maybe Text
$sel:contents:CreateProject' :: CreateProject -> Maybe ByteString
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"name" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
name,
        ByteString
"region" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
region,
        ByteString
"snapshotId" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
snapshotId
      ]

-- | Result structure used in response to a request to create a project.
--
-- /See:/ 'newCreateProjectResponse' smart constructor.
data CreateProjectResponse = CreateProjectResponse'
  { -- | Detailed information about the created AWS Mobile Hub project.
    CreateProjectResponse -> Maybe ProjectDetails
details :: Prelude.Maybe ProjectDetails,
    -- | The response's http status code.
    CreateProjectResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateProjectResponse -> CreateProjectResponse -> Bool
(CreateProjectResponse -> CreateProjectResponse -> Bool)
-> (CreateProjectResponse -> CreateProjectResponse -> Bool)
-> Eq CreateProjectResponse
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]
(Int -> ReadS CreateProjectResponse)
-> ReadS [CreateProjectResponse]
-> ReadPrec CreateProjectResponse
-> ReadPrec [CreateProjectResponse]
-> Read 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
(Int -> CreateProjectResponse -> ShowS)
-> (CreateProjectResponse -> String)
-> ([CreateProjectResponse] -> ShowS)
-> Show CreateProjectResponse
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. CreateProjectResponse -> Rep CreateProjectResponse x)
-> (forall x. Rep CreateProjectResponse x -> CreateProjectResponse)
-> Generic CreateProjectResponse
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:
--
-- 'details', 'createProjectResponse_details' - Detailed information about the created AWS Mobile Hub project.
--
-- 'httpStatus', 'createProjectResponse_httpStatus' - The response's http status code.
newCreateProjectResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateProjectResponse
newCreateProjectResponse :: Int -> CreateProjectResponse
newCreateProjectResponse Int
pHttpStatus_ =
  CreateProjectResponse' :: Maybe ProjectDetails -> Int -> CreateProjectResponse
CreateProjectResponse'
    { $sel:details:CreateProjectResponse' :: Maybe ProjectDetails
details = Maybe ProjectDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateProjectResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Detailed information about the created AWS Mobile Hub project.
createProjectResponse_details :: Lens.Lens' CreateProjectResponse (Prelude.Maybe ProjectDetails)
createProjectResponse_details :: (Maybe ProjectDetails -> f (Maybe ProjectDetails))
-> CreateProjectResponse -> f CreateProjectResponse
createProjectResponse_details = (CreateProjectResponse -> Maybe ProjectDetails)
-> (CreateProjectResponse
    -> Maybe ProjectDetails -> CreateProjectResponse)
-> Lens
     CreateProjectResponse
     CreateProjectResponse
     (Maybe ProjectDetails)
     (Maybe ProjectDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProjectResponse' {Maybe ProjectDetails
details :: Maybe ProjectDetails
$sel:details:CreateProjectResponse' :: CreateProjectResponse -> Maybe ProjectDetails
details} -> Maybe ProjectDetails
details) (\s :: CreateProjectResponse
s@CreateProjectResponse' {} Maybe ProjectDetails
a -> CreateProjectResponse
s {$sel:details:CreateProjectResponse' :: Maybe ProjectDetails
details = Maybe ProjectDetails
a} :: CreateProjectResponse)

-- | The response's http status code.
createProjectResponse_httpStatus :: Lens.Lens' CreateProjectResponse Prelude.Int
createProjectResponse_httpStatus :: (Int -> f Int) -> CreateProjectResponse -> f CreateProjectResponse
createProjectResponse_httpStatus = (CreateProjectResponse -> Int)
-> (CreateProjectResponse -> Int -> CreateProjectResponse)
-> Lens CreateProjectResponse CreateProjectResponse Int Int
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)

instance Prelude.NFData CreateProjectResponse