{-# 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.DeleteDataset
-- 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 an existing Amazon Lookout for Vision @dataset@.
--
-- If your the project has a single dataset, you must create a new dataset
-- before you can create a model.
--
-- If you project has a training dataset and a test dataset consider the
-- following.
--
-- -   If you delete the test dataset, your project reverts to a single
--     dataset project. If you then train the model, Amazon Lookout for
--     Vision internally splits the remaining dataset into a training and
--     test dataset.
--
-- -   If you delete the training dataset, you must create a training
--     dataset before you can create a model.
--
-- This operation requires permissions to perform the
-- @lookoutvision:DeleteDataset@ operation.
module Amazonka.LookoutVision.DeleteDataset
  ( -- * Creating a Request
    DeleteDataset (..),
    newDeleteDataset,

    -- * Request Lenses
    deleteDataset_clientToken,
    deleteDataset_projectName,
    deleteDataset_datasetType,

    -- * Destructuring the Response
    DeleteDatasetResponse (..),
    newDeleteDatasetResponse,

    -- * Response Lenses
    deleteDatasetResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteDataset' smart constructor.
data DeleteDataset = DeleteDataset'
  { -- | ClientToken is an idempotency token that ensures a call to
    -- @DeleteDataset@ completes only once. You choose the value to pass. For
    -- example, An issue, such as an network outage, might prevent you from
    -- getting a response from @DeleteDataset@. In this case, safely retry your
    -- call to @DeleteDataset@ by using the same @ClientToken@ parameter value.
    -- 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 @DeleteDataset@. An idempotency token is active for 8 hours.
    DeleteDataset -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the project that contains the dataset that you want to
    -- delete.
    DeleteDataset -> Text
projectName :: Prelude.Text,
    -- | The type of the dataset to delete. Specify @train@ to delete the
    -- training dataset. Specify @test@ to delete the test dataset. To delete
    -- the dataset in a single dataset project, specify @train@.
    DeleteDataset -> Text
datasetType :: Prelude.Text
  }
  deriving (DeleteDataset -> DeleteDataset -> Bool
(DeleteDataset -> DeleteDataset -> Bool)
-> (DeleteDataset -> DeleteDataset -> Bool) -> Eq DeleteDataset
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDataset -> DeleteDataset -> Bool
$c/= :: DeleteDataset -> DeleteDataset -> Bool
== :: DeleteDataset -> DeleteDataset -> Bool
$c== :: DeleteDataset -> DeleteDataset -> Bool
Prelude.Eq, ReadPrec [DeleteDataset]
ReadPrec DeleteDataset
Int -> ReadS DeleteDataset
ReadS [DeleteDataset]
(Int -> ReadS DeleteDataset)
-> ReadS [DeleteDataset]
-> ReadPrec DeleteDataset
-> ReadPrec [DeleteDataset]
-> Read DeleteDataset
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDataset]
$creadListPrec :: ReadPrec [DeleteDataset]
readPrec :: ReadPrec DeleteDataset
$creadPrec :: ReadPrec DeleteDataset
readList :: ReadS [DeleteDataset]
$creadList :: ReadS [DeleteDataset]
readsPrec :: Int -> ReadS DeleteDataset
$creadsPrec :: Int -> ReadS DeleteDataset
Prelude.Read, Int -> DeleteDataset -> ShowS
[DeleteDataset] -> ShowS
DeleteDataset -> String
(Int -> DeleteDataset -> ShowS)
-> (DeleteDataset -> String)
-> ([DeleteDataset] -> ShowS)
-> Show DeleteDataset
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDataset] -> ShowS
$cshowList :: [DeleteDataset] -> ShowS
show :: DeleteDataset -> String
$cshow :: DeleteDataset -> String
showsPrec :: Int -> DeleteDataset -> ShowS
$cshowsPrec :: Int -> DeleteDataset -> ShowS
Prelude.Show, (forall x. DeleteDataset -> Rep DeleteDataset x)
-> (forall x. Rep DeleteDataset x -> DeleteDataset)
-> Generic DeleteDataset
forall x. Rep DeleteDataset x -> DeleteDataset
forall x. DeleteDataset -> Rep DeleteDataset x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteDataset x -> DeleteDataset
$cfrom :: forall x. DeleteDataset -> Rep DeleteDataset x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDataset' 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', 'deleteDataset_clientToken' - ClientToken is an idempotency token that ensures a call to
-- @DeleteDataset@ completes only once. You choose the value to pass. For
-- example, An issue, such as an network outage, might prevent you from
-- getting a response from @DeleteDataset@. In this case, safely retry your
-- call to @DeleteDataset@ by using the same @ClientToken@ parameter value.
-- 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 @DeleteDataset@. An idempotency token is active for 8 hours.
--
-- 'projectName', 'deleteDataset_projectName' - The name of the project that contains the dataset that you want to
-- delete.
--
-- 'datasetType', 'deleteDataset_datasetType' - The type of the dataset to delete. Specify @train@ to delete the
-- training dataset. Specify @test@ to delete the test dataset. To delete
-- the dataset in a single dataset project, specify @train@.
newDeleteDataset ::
  -- | 'projectName'
  Prelude.Text ->
  -- | 'datasetType'
  Prelude.Text ->
  DeleteDataset
newDeleteDataset :: Text -> Text -> DeleteDataset
newDeleteDataset Text
pProjectName_ Text
pDatasetType_ =
  DeleteDataset' :: Maybe Text -> Text -> Text -> DeleteDataset
DeleteDataset'
    { $sel:clientToken:DeleteDataset' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:projectName:DeleteDataset' :: Text
projectName = Text
pProjectName_,
      $sel:datasetType:DeleteDataset' :: Text
datasetType = Text
pDatasetType_
    }

-- | ClientToken is an idempotency token that ensures a call to
-- @DeleteDataset@ completes only once. You choose the value to pass. For
-- example, An issue, such as an network outage, might prevent you from
-- getting a response from @DeleteDataset@. In this case, safely retry your
-- call to @DeleteDataset@ by using the same @ClientToken@ parameter value.
-- 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 @DeleteDataset@. An idempotency token is active for 8 hours.
deleteDataset_clientToken :: Lens.Lens' DeleteDataset (Prelude.Maybe Prelude.Text)
deleteDataset_clientToken :: (Maybe Text -> f (Maybe Text)) -> DeleteDataset -> f DeleteDataset
deleteDataset_clientToken = (DeleteDataset -> Maybe Text)
-> (DeleteDataset -> Maybe Text -> DeleteDataset)
-> Lens DeleteDataset DeleteDataset (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDataset' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:DeleteDataset' :: DeleteDataset -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: DeleteDataset
s@DeleteDataset' {} Maybe Text
a -> DeleteDataset
s {$sel:clientToken:DeleteDataset' :: Maybe Text
clientToken = Maybe Text
a} :: DeleteDataset)

-- | The name of the project that contains the dataset that you want to
-- delete.
deleteDataset_projectName :: Lens.Lens' DeleteDataset Prelude.Text
deleteDataset_projectName :: (Text -> f Text) -> DeleteDataset -> f DeleteDataset
deleteDataset_projectName = (DeleteDataset -> Text)
-> (DeleteDataset -> Text -> DeleteDataset)
-> Lens DeleteDataset DeleteDataset Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDataset' {Text
projectName :: Text
$sel:projectName:DeleteDataset' :: DeleteDataset -> Text
projectName} -> Text
projectName) (\s :: DeleteDataset
s@DeleteDataset' {} Text
a -> DeleteDataset
s {$sel:projectName:DeleteDataset' :: Text
projectName = Text
a} :: DeleteDataset)

-- | The type of the dataset to delete. Specify @train@ to delete the
-- training dataset. Specify @test@ to delete the test dataset. To delete
-- the dataset in a single dataset project, specify @train@.
deleteDataset_datasetType :: Lens.Lens' DeleteDataset Prelude.Text
deleteDataset_datasetType :: (Text -> f Text) -> DeleteDataset -> f DeleteDataset
deleteDataset_datasetType = (DeleteDataset -> Text)
-> (DeleteDataset -> Text -> DeleteDataset)
-> Lens DeleteDataset DeleteDataset Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDataset' {Text
datasetType :: Text
$sel:datasetType:DeleteDataset' :: DeleteDataset -> Text
datasetType} -> Text
datasetType) (\s :: DeleteDataset
s@DeleteDataset' {} Text
a -> DeleteDataset
s {$sel:datasetType:DeleteDataset' :: Text
datasetType = Text
a} :: DeleteDataset)

instance Core.AWSRequest DeleteDataset where
  type
    AWSResponse DeleteDataset =
      DeleteDatasetResponse
  request :: DeleteDataset -> Request DeleteDataset
request = Service -> DeleteDataset -> Request DeleteDataset
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteDataset
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteDataset)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteDataset))
-> Logger
-> Service
-> Proxy DeleteDataset
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteDataset)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteDatasetResponse
DeleteDatasetResponse'
            (Int -> DeleteDatasetResponse)
-> Either String Int -> Either String DeleteDatasetResponse
forall (f :: * -> *) a b. Functor 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 DeleteDataset

instance Prelude.NFData DeleteDataset

instance Core.ToHeaders DeleteDataset where
  toHeaders :: DeleteDataset -> ResponseHeaders
toHeaders DeleteDataset' {Maybe Text
Text
datasetType :: Text
projectName :: Text
clientToken :: Maybe Text
$sel:datasetType:DeleteDataset' :: DeleteDataset -> Text
$sel:projectName:DeleteDataset' :: DeleteDataset -> Text
$sel:clientToken:DeleteDataset' :: DeleteDataset -> Maybe Text
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"X-Amzn-Client-Token" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
clientToken,
        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 DeleteDataset where
  toPath :: DeleteDataset -> ByteString
toPath DeleteDataset' {Maybe Text
Text
datasetType :: Text
projectName :: Text
clientToken :: Maybe Text
$sel:datasetType:DeleteDataset' :: DeleteDataset -> Text
$sel:projectName:DeleteDataset' :: DeleteDataset -> Text
$sel:clientToken:DeleteDataset' :: DeleteDataset -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2020-11-20/projects/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
projectName,
        ByteString
"/datasets/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
datasetType
      ]

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

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

-- |
-- Create a value of 'DeleteDatasetResponse' 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', 'deleteDatasetResponse_httpStatus' - The response's http status code.
newDeleteDatasetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteDatasetResponse
newDeleteDatasetResponse :: Int -> DeleteDatasetResponse
newDeleteDatasetResponse Int
pHttpStatus_ =
  DeleteDatasetResponse' :: Int -> DeleteDatasetResponse
DeleteDatasetResponse' {$sel:httpStatus:DeleteDatasetResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData DeleteDatasetResponse