{-# 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.CognitoSync.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 the specific dataset. The dataset will be deleted permanently,
-- and the action can\'t be undone. Datasets that this dataset was merged
-- with will no longer report the merge. Any subsequent operation on this
-- dataset will result in a ResourceNotFoundException.
--
-- This API can be called with temporary user credentials provided by
-- Cognito Identity or with developer credentials.
module Amazonka.CognitoSync.DeleteDataset
  ( -- * Creating a Request
    DeleteDataset (..),
    newDeleteDataset,

    -- * Request Lenses
    deleteDataset_identityPoolId,
    deleteDataset_identityId,
    deleteDataset_datasetName,

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

    -- * Response Lenses
    deleteDatasetResponse_dataset,
    deleteDatasetResponse_httpStatus,
  )
where

import Amazonka.CognitoSync.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

-- | A request to delete the specific dataset.
--
-- /See:/ 'newDeleteDataset' smart constructor.
data DeleteDataset = DeleteDataset'
  { -- | A name-spaced GUID (for example,
    -- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon
    -- Cognito. GUID generation is unique within a region.
    DeleteDataset -> Text
identityPoolId :: Prelude.Text,
    -- | A name-spaced GUID (for example,
    -- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon
    -- Cognito. GUID generation is unique within a region.
    DeleteDataset -> Text
identityId :: Prelude.Text,
    -- | A string of up to 128 characters. Allowed characters are a-z, A-Z, 0-9,
    -- \'_\' (underscore), \'-\' (dash), and \'.\' (dot).
    DeleteDataset -> Text
datasetName :: 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:
--
-- 'identityPoolId', 'deleteDataset_identityPoolId' - A name-spaced GUID (for example,
-- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon
-- Cognito. GUID generation is unique within a region.
--
-- 'identityId', 'deleteDataset_identityId' - A name-spaced GUID (for example,
-- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon
-- Cognito. GUID generation is unique within a region.
--
-- 'datasetName', 'deleteDataset_datasetName' - A string of up to 128 characters. Allowed characters are a-z, A-Z, 0-9,
-- \'_\' (underscore), \'-\' (dash), and \'.\' (dot).
newDeleteDataset ::
  -- | 'identityPoolId'
  Prelude.Text ->
  -- | 'identityId'
  Prelude.Text ->
  -- | 'datasetName'
  Prelude.Text ->
  DeleteDataset
newDeleteDataset :: Text -> Text -> Text -> DeleteDataset
newDeleteDataset
  Text
pIdentityPoolId_
  Text
pIdentityId_
  Text
pDatasetName_ =
    DeleteDataset' :: Text -> Text -> Text -> DeleteDataset
DeleteDataset'
      { $sel:identityPoolId:DeleteDataset' :: Text
identityPoolId = Text
pIdentityPoolId_,
        $sel:identityId:DeleteDataset' :: Text
identityId = Text
pIdentityId_,
        $sel:datasetName:DeleteDataset' :: Text
datasetName = Text
pDatasetName_
      }

-- | A name-spaced GUID (for example,
-- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon
-- Cognito. GUID generation is unique within a region.
deleteDataset_identityPoolId :: Lens.Lens' DeleteDataset Prelude.Text
deleteDataset_identityPoolId :: (Text -> f Text) -> DeleteDataset -> f DeleteDataset
deleteDataset_identityPoolId = (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
identityPoolId :: Text
$sel:identityPoolId:DeleteDataset' :: DeleteDataset -> Text
identityPoolId} -> Text
identityPoolId) (\s :: DeleteDataset
s@DeleteDataset' {} Text
a -> DeleteDataset
s {$sel:identityPoolId:DeleteDataset' :: Text
identityPoolId = Text
a} :: DeleteDataset)

-- | A name-spaced GUID (for example,
-- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon
-- Cognito. GUID generation is unique within a region.
deleteDataset_identityId :: Lens.Lens' DeleteDataset Prelude.Text
deleteDataset_identityId :: (Text -> f Text) -> DeleteDataset -> f DeleteDataset
deleteDataset_identityId = (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
identityId :: Text
$sel:identityId:DeleteDataset' :: DeleteDataset -> Text
identityId} -> Text
identityId) (\s :: DeleteDataset
s@DeleteDataset' {} Text
a -> DeleteDataset
s {$sel:identityId:DeleteDataset' :: Text
identityId = Text
a} :: DeleteDataset)

-- | A string of up to 128 characters. Allowed characters are a-z, A-Z, 0-9,
-- \'_\' (underscore), \'-\' (dash), and \'.\' (dot).
deleteDataset_datasetName :: Lens.Lens' DeleteDataset Prelude.Text
deleteDataset_datasetName :: (Text -> f Text) -> DeleteDataset -> f DeleteDataset
deleteDataset_datasetName = (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
datasetName :: Text
$sel:datasetName:DeleteDataset' :: DeleteDataset -> Text
datasetName} -> Text
datasetName) (\s :: DeleteDataset
s@DeleteDataset' {} Text
a -> DeleteDataset
s {$sel:datasetName:DeleteDataset' :: Text
datasetName = 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
 -> Object
 -> Either String (AWSResponse DeleteDataset))
-> Logger
-> Service
-> Proxy DeleteDataset
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteDataset)))
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 Dataset -> Int -> DeleteDatasetResponse
DeleteDatasetResponse'
            (Maybe Dataset -> Int -> DeleteDatasetResponse)
-> Either String (Maybe Dataset)
-> Either String (Int -> DeleteDatasetResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Dataset)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Dataset")
            Either String (Int -> DeleteDatasetResponse)
-> Either String Int -> Either String DeleteDatasetResponse
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 DeleteDataset

instance Prelude.NFData DeleteDataset

instance Core.ToHeaders DeleteDataset where
  toHeaders :: DeleteDataset -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteDataset -> 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 DeleteDataset where
  toPath :: DeleteDataset -> ByteString
toPath DeleteDataset' {Text
datasetName :: Text
identityId :: Text
identityPoolId :: Text
$sel:datasetName:DeleteDataset' :: DeleteDataset -> Text
$sel:identityId:DeleteDataset' :: DeleteDataset -> Text
$sel:identityPoolId:DeleteDataset' :: DeleteDataset -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/identitypools/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
identityPoolId,
        ByteString
"/identities/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
identityId,
        ByteString
"/datasets/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
datasetName
      ]

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

-- | Response to a successful DeleteDataset request.
--
-- /See:/ 'newDeleteDatasetResponse' smart constructor.
data DeleteDatasetResponse = DeleteDatasetResponse'
  { -- | A collection of data for an identity pool. An identity pool can have
    -- multiple datasets. A dataset is per identity and can be general or
    -- associated with a particular entity in an application (like a saved
    -- game). Datasets are automatically created if they don\'t exist. Data is
    -- synced by dataset, and a dataset can hold up to 1MB of key-value pairs.
    DeleteDatasetResponse -> Maybe Dataset
dataset :: Prelude.Maybe Dataset,
    -- | 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:
--
-- 'dataset', 'deleteDatasetResponse_dataset' - A collection of data for an identity pool. An identity pool can have
-- multiple datasets. A dataset is per identity and can be general or
-- associated with a particular entity in an application (like a saved
-- game). Datasets are automatically created if they don\'t exist. Data is
-- synced by dataset, and a dataset can hold up to 1MB of key-value pairs.
--
-- 'httpStatus', 'deleteDatasetResponse_httpStatus' - The response's http status code.
newDeleteDatasetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteDatasetResponse
newDeleteDatasetResponse :: Int -> DeleteDatasetResponse
newDeleteDatasetResponse Int
pHttpStatus_ =
  DeleteDatasetResponse' :: Maybe Dataset -> Int -> DeleteDatasetResponse
DeleteDatasetResponse'
    { $sel:dataset:DeleteDatasetResponse' :: Maybe Dataset
dataset = Maybe Dataset
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteDatasetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A collection of data for an identity pool. An identity pool can have
-- multiple datasets. A dataset is per identity and can be general or
-- associated with a particular entity in an application (like a saved
-- game). Datasets are automatically created if they don\'t exist. Data is
-- synced by dataset, and a dataset can hold up to 1MB of key-value pairs.
deleteDatasetResponse_dataset :: Lens.Lens' DeleteDatasetResponse (Prelude.Maybe Dataset)
deleteDatasetResponse_dataset :: (Maybe Dataset -> f (Maybe Dataset))
-> DeleteDatasetResponse -> f DeleteDatasetResponse
deleteDatasetResponse_dataset = (DeleteDatasetResponse -> Maybe Dataset)
-> (DeleteDatasetResponse
    -> Maybe Dataset -> DeleteDatasetResponse)
-> Lens
     DeleteDatasetResponse
     DeleteDatasetResponse
     (Maybe Dataset)
     (Maybe Dataset)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDatasetResponse' {Maybe Dataset
dataset :: Maybe Dataset
$sel:dataset:DeleteDatasetResponse' :: DeleteDatasetResponse -> Maybe Dataset
dataset} -> Maybe Dataset
dataset) (\s :: DeleteDatasetResponse
s@DeleteDatasetResponse' {} Maybe Dataset
a -> DeleteDatasetResponse
s {$sel:dataset:DeleteDatasetResponse' :: Maybe Dataset
dataset = Maybe Dataset
a} :: DeleteDatasetResponse)

-- | 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