{-# 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.LookoutVision.DeleteProject
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes an Amazon Lookout for Vision project.
--
-- To delete a project, you must first delete each version of the model
-- associated with the project. To delete a model use the DeleteModel
-- operation.
--
-- You also have to delete the dataset(s) associated with the model. For
-- more information, see DeleteDataset. The images referenced by the
-- training and test datasets aren\'t deleted.
--
-- This operation requires permissions to perform the
-- @lookoutvision:DeleteProject@ operation.
module Amazonka.LookoutVision.DeleteProject
  ( -- * Creating a Request
    DeleteProject (..),
    newDeleteProject,

    -- * Request Lenses
    deleteProject_clientToken,
    deleteProject_projectName,

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

    -- * Response Lenses
    deleteProjectResponse_projectArn,
    deleteProjectResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LookoutVision.Types
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'
  { -- | ClientToken is an idempotency token that ensures a call to
    -- @DeleteProject@ completes only once. You choose the value to pass. For
    -- example, An issue might prevent you from getting a response from
    -- @DeleteProject@. In this case, safely retry your call to @DeleteProject@
    -- by using the same @ClientToken@ parameter value.
    --
    -- If you don\'t supply a value for @ClientToken@, the AWS SDK you are
    -- using inserts a value for you. This prevents retries after a network
    -- error from making multiple project deletion requests. You\'ll need to
    -- provide your own value for other use cases.
    --
    -- An error occurs if the other input parameters are not the same as in the
    -- first request. Using a different value for @ClientToken@ is considered a
    -- new call to @DeleteProject@. An idempotency token is active for 8 hours.
    DeleteProject -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the project to delete.
    DeleteProject -> Text
projectName :: Prelude.Text
  }
  deriving (DeleteProject -> DeleteProject -> Bool
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]
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
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. 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:
--
-- 'clientToken', 'deleteProject_clientToken' - ClientToken is an idempotency token that ensures a call to
-- @DeleteProject@ completes only once. You choose the value to pass. For
-- example, An issue might prevent you from getting a response from
-- @DeleteProject@. In this case, safely retry your call to @DeleteProject@
-- by using the same @ClientToken@ parameter value.
--
-- If you don\'t supply a value for @ClientToken@, the AWS SDK you are
-- using inserts a value for you. This prevents retries after a network
-- error from making multiple project deletion requests. You\'ll need to
-- provide your own value for other use cases.
--
-- An error occurs if the other input parameters are not the same as in the
-- first request. Using a different value for @ClientToken@ is considered a
-- new call to @DeleteProject@. An idempotency token is active for 8 hours.
--
-- 'projectName', 'deleteProject_projectName' - The name of the project to delete.
newDeleteProject ::
  -- | 'projectName'
  Prelude.Text ->
  DeleteProject
newDeleteProject :: Text -> DeleteProject
newDeleteProject Text
pProjectName_ =
  DeleteProject'
    { $sel:clientToken:DeleteProject' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
      $sel:projectName:DeleteProject' :: Text
projectName = Text
pProjectName_
    }

-- | ClientToken is an idempotency token that ensures a call to
-- @DeleteProject@ completes only once. You choose the value to pass. For
-- example, An issue might prevent you from getting a response from
-- @DeleteProject@. In this case, safely retry your call to @DeleteProject@
-- by using the same @ClientToken@ parameter value.
--
-- If you don\'t supply a value for @ClientToken@, the AWS SDK you are
-- using inserts a value for you. This prevents retries after a network
-- error from making multiple project deletion requests. You\'ll need to
-- provide your own value for other use cases.
--
-- An error occurs if the other input parameters are not the same as in the
-- first request. Using a different value for @ClientToken@ is considered a
-- new call to @DeleteProject@. An idempotency token is active for 8 hours.
deleteProject_clientToken :: Lens.Lens' DeleteProject (Prelude.Maybe Prelude.Text)
deleteProject_clientToken :: Lens' DeleteProject (Maybe Text)
deleteProject_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProject' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:DeleteProject' :: DeleteProject -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: DeleteProject
s@DeleteProject' {} Maybe Text
a -> DeleteProject
s {$sel:clientToken:DeleteProject' :: Maybe Text
clientToken = Maybe Text
a} :: DeleteProject)

-- | The name of the project to delete.
deleteProject_projectName :: Lens.Lens' DeleteProject Prelude.Text
deleteProject_projectName :: Lens' DeleteProject Text
deleteProject_projectName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProject' {Text
projectName :: Text
$sel:projectName:DeleteProject' :: DeleteProject -> Text
projectName} -> Text
projectName) (\s :: DeleteProject
s@DeleteProject' {} Text
a -> DeleteProject
s {$sel:projectName:DeleteProject' :: Text
projectName = Text
a} :: DeleteProject)

instance Core.AWSRequest DeleteProject where
  type
    AWSResponse DeleteProject =
      DeleteProjectResponse
  request :: (Service -> Service) -> DeleteProject -> Request DeleteProject
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteProject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteProject)))
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 ->
          Maybe Text -> Int -> DeleteProjectResponse
DeleteProjectResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ProjectArn")
            forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable DeleteProject where
  hashWithSalt :: Int -> DeleteProject -> Int
hashWithSalt Int
_salt DeleteProject' {Maybe Text
Text
projectName :: Text
clientToken :: Maybe Text
$sel:projectName:DeleteProject' :: DeleteProject -> Text
$sel:clientToken:DeleteProject' :: DeleteProject -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
projectName

instance Prelude.NFData DeleteProject where
  rnf :: DeleteProject -> ()
rnf DeleteProject' {Maybe Text
Text
projectName :: Text
clientToken :: Maybe Text
$sel:projectName:DeleteProject' :: DeleteProject -> Text
$sel:clientToken:DeleteProject' :: DeleteProject -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
projectName

instance Data.ToHeaders DeleteProject where
  toHeaders :: DeleteProject -> ResponseHeaders
toHeaders DeleteProject' {Maybe Text
Text
projectName :: Text
clientToken :: Maybe Text
$sel:projectName:DeleteProject' :: DeleteProject -> Text
$sel:clientToken:DeleteProject' :: DeleteProject -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"X-Amzn-Client-Token" forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# Maybe Text
clientToken,
        HeaderName
"Content-Type"
          forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
      ]

instance Data.ToPath DeleteProject where
  toPath :: DeleteProject -> ByteString
toPath DeleteProject' {Maybe Text
Text
projectName :: Text
clientToken :: Maybe Text
$sel:projectName:DeleteProject' :: DeleteProject -> Text
$sel:clientToken:DeleteProject' :: DeleteProject -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2020-11-20/projects/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
projectName]

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

-- | /See:/ 'newDeleteProjectResponse' smart constructor.
data DeleteProjectResponse = DeleteProjectResponse'
  { -- | The Amazon Resource Name (ARN) of the project that was deleted.
    DeleteProjectResponse -> Maybe Text
projectArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteProjectResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteProjectResponse -> DeleteProjectResponse -> Bool
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]
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
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. 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 project that was deleted.
--
-- 'httpStatus', 'deleteProjectResponse_httpStatus' - The response's http status code.
newDeleteProjectResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteProjectResponse
newDeleteProjectResponse :: Int -> DeleteProjectResponse
newDeleteProjectResponse Int
pHttpStatus_ =
  DeleteProjectResponse'
    { $sel:projectArn:DeleteProjectResponse' :: Maybe Text
projectArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteProjectResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the project that was deleted.
deleteProjectResponse_projectArn :: Lens.Lens' DeleteProjectResponse (Prelude.Maybe Prelude.Text)
deleteProjectResponse_projectArn :: Lens' DeleteProjectResponse (Maybe Text)
deleteProjectResponse_projectArn = 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 response's http status code.
deleteProjectResponse_httpStatus :: Lens.Lens' DeleteProjectResponse Prelude.Int
deleteProjectResponse_httpStatus :: Lens' DeleteProjectResponse Int
deleteProjectResponse_httpStatus = 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 where
  rnf :: DeleteProjectResponse -> ()
rnf DeleteProjectResponse' {Int
Maybe Text
httpStatus :: Int
projectArn :: Maybe Text
$sel:httpStatus:DeleteProjectResponse' :: DeleteProjectResponse -> Int
$sel:projectArn:DeleteProjectResponse' :: DeleteProjectResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
projectArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus