{-# 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.CodeStar.DeleteProject
-- 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)
--
-- Deletes a project, including project resources. Does not delete users
-- associated with the project, but does delete the IAM roles that allowed
-- access to the project.
module Amazonka.CodeStar.DeleteProject
  ( -- * Creating a Request
    DeleteProject (..),
    newDeleteProject,

    -- * Request Lenses
    deleteProject_deleteStack,
    deleteProject_clientRequestToken,
    deleteProject_id,

    -- * Destructuring the Response
    DeleteProjectResponse (..),
    newDeleteProjectResponse,

    -- * Response Lenses
    deleteProjectResponse_projectArn,
    deleteProjectResponse_stackId,
    deleteProjectResponse_httpStatus,
  )
where

import Amazonka.CodeStar.Types
import qualified Amazonka.Core as Core
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:/ 'newDeleteProject' smart constructor.
data DeleteProject = DeleteProject'
  { -- | Whether to send a delete request for the primary stack in AWS
    -- CloudFormation originally used to generate the project and its
    -- resources. This option will delete all AWS resources for the project
    -- (except for any buckets in Amazon S3) as well as deleting the project
    -- itself. Recommended for most use cases.
    DeleteProject -> Maybe Bool
deleteStack :: Prelude.Maybe Prelude.Bool,
    -- | A user- or system-generated token that identifies the entity that
    -- requested project deletion. This token can be used to repeat the
    -- request.
    DeleteProject -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | The ID of the project to be deleted in AWS CodeStar.
    DeleteProject -> Text
id :: Prelude.Text
  }
  deriving (DeleteProject -> DeleteProject -> Bool
(DeleteProject -> DeleteProject -> Bool)
-> (DeleteProject -> DeleteProject -> Bool) -> Eq DeleteProject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteProject -> DeleteProject -> Bool
$c/= :: DeleteProject -> DeleteProject -> Bool
== :: DeleteProject -> DeleteProject -> Bool
$c== :: DeleteProject -> DeleteProject -> Bool
Prelude.Eq, ReadPrec [DeleteProject]
ReadPrec DeleteProject
Int -> ReadS DeleteProject
ReadS [DeleteProject]
(Int -> ReadS DeleteProject)
-> ReadS [DeleteProject]
-> ReadPrec DeleteProject
-> ReadPrec [DeleteProject]
-> Read DeleteProject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteProject]
$creadListPrec :: ReadPrec [DeleteProject]
readPrec :: ReadPrec DeleteProject
$creadPrec :: ReadPrec DeleteProject
readList :: ReadS [DeleteProject]
$creadList :: ReadS [DeleteProject]
readsPrec :: Int -> ReadS DeleteProject
$creadsPrec :: Int -> ReadS DeleteProject
Prelude.Read, Int -> DeleteProject -> ShowS
[DeleteProject] -> ShowS
DeleteProject -> String
(Int -> DeleteProject -> ShowS)
-> (DeleteProject -> String)
-> ([DeleteProject] -> ShowS)
-> Show DeleteProject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteProject] -> ShowS
$cshowList :: [DeleteProject] -> ShowS
show :: DeleteProject -> String
$cshow :: DeleteProject -> String
showsPrec :: Int -> DeleteProject -> ShowS
$cshowsPrec :: Int -> DeleteProject -> ShowS
Prelude.Show, (forall x. DeleteProject -> Rep DeleteProject x)
-> (forall x. Rep DeleteProject x -> DeleteProject)
-> Generic DeleteProject
forall x. Rep DeleteProject x -> DeleteProject
forall x. DeleteProject -> Rep DeleteProject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteProject x -> DeleteProject
$cfrom :: forall x. DeleteProject -> Rep DeleteProject x
Prelude.Generic)

-- |
-- Create a value of 'DeleteProject' 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:
--
-- 'deleteStack', 'deleteProject_deleteStack' - Whether to send a delete request for the primary stack in AWS
-- CloudFormation originally used to generate the project and its
-- resources. This option will delete all AWS resources for the project
-- (except for any buckets in Amazon S3) as well as deleting the project
-- itself. Recommended for most use cases.
--
-- 'clientRequestToken', 'deleteProject_clientRequestToken' - A user- or system-generated token that identifies the entity that
-- requested project deletion. This token can be used to repeat the
-- request.
--
-- 'id', 'deleteProject_id' - The ID of the project to be deleted in AWS CodeStar.
newDeleteProject ::
  -- | 'id'
  Prelude.Text ->
  DeleteProject
newDeleteProject :: Text -> DeleteProject
newDeleteProject Text
pId_ =
  DeleteProject' :: Maybe Bool -> Maybe Text -> Text -> DeleteProject
DeleteProject'
    { $sel:deleteStack:DeleteProject' :: Maybe Bool
deleteStack = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:clientRequestToken:DeleteProject' :: Maybe Text
clientRequestToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:DeleteProject' :: Text
id = Text
pId_
    }

-- | Whether to send a delete request for the primary stack in AWS
-- CloudFormation originally used to generate the project and its
-- resources. This option will delete all AWS resources for the project
-- (except for any buckets in Amazon S3) as well as deleting the project
-- itself. Recommended for most use cases.
deleteProject_deleteStack :: Lens.Lens' DeleteProject (Prelude.Maybe Prelude.Bool)
deleteProject_deleteStack :: (Maybe Bool -> f (Maybe Bool)) -> DeleteProject -> f DeleteProject
deleteProject_deleteStack = (DeleteProject -> Maybe Bool)
-> (DeleteProject -> Maybe Bool -> DeleteProject)
-> Lens DeleteProject DeleteProject (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProject' {Maybe Bool
deleteStack :: Maybe Bool
$sel:deleteStack:DeleteProject' :: DeleteProject -> Maybe Bool
deleteStack} -> Maybe Bool
deleteStack) (\s :: DeleteProject
s@DeleteProject' {} Maybe Bool
a -> DeleteProject
s {$sel:deleteStack:DeleteProject' :: Maybe Bool
deleteStack = Maybe Bool
a} :: DeleteProject)

-- | A user- or system-generated token that identifies the entity that
-- requested project deletion. This token can be used to repeat the
-- request.
deleteProject_clientRequestToken :: Lens.Lens' DeleteProject (Prelude.Maybe Prelude.Text)
deleteProject_clientRequestToken :: (Maybe Text -> f (Maybe Text)) -> DeleteProject -> f DeleteProject
deleteProject_clientRequestToken = (DeleteProject -> Maybe Text)
-> (DeleteProject -> Maybe Text -> DeleteProject)
-> Lens DeleteProject DeleteProject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProject' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:DeleteProject' :: DeleteProject -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: DeleteProject
s@DeleteProject' {} Maybe Text
a -> DeleteProject
s {$sel:clientRequestToken:DeleteProject' :: Maybe Text
clientRequestToken = Maybe Text
a} :: DeleteProject)

-- | The ID of the project to be deleted in AWS CodeStar.
deleteProject_id :: Lens.Lens' DeleteProject Prelude.Text
deleteProject_id :: (Text -> f Text) -> DeleteProject -> f DeleteProject
deleteProject_id = (DeleteProject -> Text)
-> (DeleteProject -> Text -> DeleteProject)
-> Lens DeleteProject DeleteProject Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProject' {Text
id :: Text
$sel:id:DeleteProject' :: DeleteProject -> Text
id} -> Text
id) (\s :: DeleteProject
s@DeleteProject' {} Text
a -> DeleteProject
s {$sel:id:DeleteProject' :: Text
id = Text
a} :: DeleteProject)

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

instance Prelude.NFData DeleteProject

instance Core.ToHeaders DeleteProject where
  toHeaders :: DeleteProject -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteProject -> 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
"CodeStar_20170419.DeleteProject" ::
                          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 DeleteProject where
  toJSON :: DeleteProject -> Value
toJSON DeleteProject' {Maybe Bool
Maybe Text
Text
id :: Text
clientRequestToken :: Maybe Text
deleteStack :: Maybe Bool
$sel:id:DeleteProject' :: DeleteProject -> Text
$sel:clientRequestToken:DeleteProject' :: DeleteProject -> Maybe Text
$sel:deleteStack:DeleteProject' :: DeleteProject -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"deleteStack" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
deleteStack,
            (Text
"clientRequestToken" 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
clientRequestToken,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)
          ]
      )

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

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

-- | /See:/ 'newDeleteProjectResponse' smart constructor.
data DeleteProjectResponse = DeleteProjectResponse'
  { -- | The Amazon Resource Name (ARN) of the deleted project.
    DeleteProjectResponse -> Maybe Text
projectArn :: Prelude.Maybe Prelude.Text,
    -- | The ID of the primary stack in AWS CloudFormation that will be deleted
    -- as part of deleting the project and its resources.
    DeleteProjectResponse -> Maybe Text
stackId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteProjectResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteProjectResponse -> DeleteProjectResponse -> Bool
(DeleteProjectResponse -> DeleteProjectResponse -> Bool)
-> (DeleteProjectResponse -> DeleteProjectResponse -> Bool)
-> Eq DeleteProjectResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteProjectResponse -> DeleteProjectResponse -> Bool
$c/= :: DeleteProjectResponse -> DeleteProjectResponse -> Bool
== :: DeleteProjectResponse -> DeleteProjectResponse -> Bool
$c== :: DeleteProjectResponse -> DeleteProjectResponse -> Bool
Prelude.Eq, ReadPrec [DeleteProjectResponse]
ReadPrec DeleteProjectResponse
Int -> ReadS DeleteProjectResponse
ReadS [DeleteProjectResponse]
(Int -> ReadS DeleteProjectResponse)
-> ReadS [DeleteProjectResponse]
-> ReadPrec DeleteProjectResponse
-> ReadPrec [DeleteProjectResponse]
-> Read DeleteProjectResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteProjectResponse]
$creadListPrec :: ReadPrec [DeleteProjectResponse]
readPrec :: ReadPrec DeleteProjectResponse
$creadPrec :: ReadPrec DeleteProjectResponse
readList :: ReadS [DeleteProjectResponse]
$creadList :: ReadS [DeleteProjectResponse]
readsPrec :: Int -> ReadS DeleteProjectResponse
$creadsPrec :: Int -> ReadS DeleteProjectResponse
Prelude.Read, Int -> DeleteProjectResponse -> ShowS
[DeleteProjectResponse] -> ShowS
DeleteProjectResponse -> String
(Int -> DeleteProjectResponse -> ShowS)
-> (DeleteProjectResponse -> String)
-> ([DeleteProjectResponse] -> ShowS)
-> Show DeleteProjectResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteProjectResponse] -> ShowS
$cshowList :: [DeleteProjectResponse] -> ShowS
show :: DeleteProjectResponse -> String
$cshow :: DeleteProjectResponse -> String
showsPrec :: Int -> DeleteProjectResponse -> ShowS
$cshowsPrec :: Int -> DeleteProjectResponse -> ShowS
Prelude.Show, (forall x. DeleteProjectResponse -> Rep DeleteProjectResponse x)
-> (forall x. Rep DeleteProjectResponse x -> DeleteProjectResponse)
-> Generic DeleteProjectResponse
forall x. Rep DeleteProjectResponse x -> DeleteProjectResponse
forall x. DeleteProjectResponse -> Rep DeleteProjectResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteProjectResponse x -> DeleteProjectResponse
$cfrom :: forall x. DeleteProjectResponse -> Rep DeleteProjectResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteProjectResponse' 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:
--
-- 'projectArn', 'deleteProjectResponse_projectArn' - The Amazon Resource Name (ARN) of the deleted project.
--
-- 'stackId', 'deleteProjectResponse_stackId' - The ID of the primary stack in AWS CloudFormation that will be deleted
-- as part of deleting the project and its resources.
--
-- 'httpStatus', 'deleteProjectResponse_httpStatus' - The response's http status code.
newDeleteProjectResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteProjectResponse
newDeleteProjectResponse :: Int -> DeleteProjectResponse
newDeleteProjectResponse Int
pHttpStatus_ =
  DeleteProjectResponse' :: Maybe Text -> Maybe Text -> Int -> DeleteProjectResponse
DeleteProjectResponse'
    { $sel:projectArn:DeleteProjectResponse' :: Maybe Text
projectArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:stackId:DeleteProjectResponse' :: Maybe Text
stackId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteProjectResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the deleted project.
deleteProjectResponse_projectArn :: Lens.Lens' DeleteProjectResponse (Prelude.Maybe Prelude.Text)
deleteProjectResponse_projectArn :: (Maybe Text -> f (Maybe Text))
-> DeleteProjectResponse -> f DeleteProjectResponse
deleteProjectResponse_projectArn = (DeleteProjectResponse -> Maybe Text)
-> (DeleteProjectResponse -> Maybe Text -> DeleteProjectResponse)
-> Lens
     DeleteProjectResponse
     DeleteProjectResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProjectResponse' {Maybe Text
projectArn :: Maybe Text
$sel:projectArn:DeleteProjectResponse' :: DeleteProjectResponse -> Maybe Text
projectArn} -> Maybe Text
projectArn) (\s :: DeleteProjectResponse
s@DeleteProjectResponse' {} Maybe Text
a -> DeleteProjectResponse
s {$sel:projectArn:DeleteProjectResponse' :: Maybe Text
projectArn = Maybe Text
a} :: DeleteProjectResponse)

-- | The ID of the primary stack in AWS CloudFormation that will be deleted
-- as part of deleting the project and its resources.
deleteProjectResponse_stackId :: Lens.Lens' DeleteProjectResponse (Prelude.Maybe Prelude.Text)
deleteProjectResponse_stackId :: (Maybe Text -> f (Maybe Text))
-> DeleteProjectResponse -> f DeleteProjectResponse
deleteProjectResponse_stackId = (DeleteProjectResponse -> Maybe Text)
-> (DeleteProjectResponse -> Maybe Text -> DeleteProjectResponse)
-> Lens
     DeleteProjectResponse
     DeleteProjectResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProjectResponse' {Maybe Text
stackId :: Maybe Text
$sel:stackId:DeleteProjectResponse' :: DeleteProjectResponse -> Maybe Text
stackId} -> Maybe Text
stackId) (\s :: DeleteProjectResponse
s@DeleteProjectResponse' {} Maybe Text
a -> DeleteProjectResponse
s {$sel:stackId:DeleteProjectResponse' :: Maybe Text
stackId = Maybe Text
a} :: DeleteProjectResponse)

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

instance Prelude.NFData DeleteProjectResponse