{-# 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.UnsubscribeFromDataset
-- 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)
--
-- Unsubscribes from receiving notifications when a dataset is modified by
-- another device.
--
-- This API can only be called with temporary credentials provided by
-- Cognito Identity. You cannot call this API with developer credentials.
module Amazonka.CognitoSync.UnsubscribeFromDataset
  ( -- * Creating a Request
    UnsubscribeFromDataset (..),
    newUnsubscribeFromDataset,

    -- * Request Lenses
    unsubscribeFromDataset_identityPoolId,
    unsubscribeFromDataset_identityId,
    unsubscribeFromDataset_datasetName,
    unsubscribeFromDataset_deviceId,

    -- * Destructuring the Response
    UnsubscribeFromDatasetResponse (..),
    newUnsubscribeFromDatasetResponse,

    -- * Response Lenses
    unsubscribeFromDatasetResponse_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 UnsubscribeFromDataset.
--
-- /See:/ 'newUnsubscribeFromDataset' smart constructor.
data UnsubscribeFromDataset = UnsubscribeFromDataset'
  { -- | A name-spaced GUID (for example,
    -- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon
    -- Cognito. The ID of the pool to which this identity belongs.
    UnsubscribeFromDataset -> Text
identityPoolId :: Prelude.Text,
    -- | Unique ID for this identity.
    UnsubscribeFromDataset -> Text
identityId :: Prelude.Text,
    -- | The name of the dataset from which to unsubcribe.
    UnsubscribeFromDataset -> Text
datasetName :: Prelude.Text,
    -- | The unique ID generated for this device by Cognito.
    UnsubscribeFromDataset -> Text
deviceId :: Prelude.Text
  }
  deriving (UnsubscribeFromDataset -> UnsubscribeFromDataset -> Bool
(UnsubscribeFromDataset -> UnsubscribeFromDataset -> Bool)
-> (UnsubscribeFromDataset -> UnsubscribeFromDataset -> Bool)
-> Eq UnsubscribeFromDataset
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnsubscribeFromDataset -> UnsubscribeFromDataset -> Bool
$c/= :: UnsubscribeFromDataset -> UnsubscribeFromDataset -> Bool
== :: UnsubscribeFromDataset -> UnsubscribeFromDataset -> Bool
$c== :: UnsubscribeFromDataset -> UnsubscribeFromDataset -> Bool
Prelude.Eq, ReadPrec [UnsubscribeFromDataset]
ReadPrec UnsubscribeFromDataset
Int -> ReadS UnsubscribeFromDataset
ReadS [UnsubscribeFromDataset]
(Int -> ReadS UnsubscribeFromDataset)
-> ReadS [UnsubscribeFromDataset]
-> ReadPrec UnsubscribeFromDataset
-> ReadPrec [UnsubscribeFromDataset]
-> Read UnsubscribeFromDataset
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UnsubscribeFromDataset]
$creadListPrec :: ReadPrec [UnsubscribeFromDataset]
readPrec :: ReadPrec UnsubscribeFromDataset
$creadPrec :: ReadPrec UnsubscribeFromDataset
readList :: ReadS [UnsubscribeFromDataset]
$creadList :: ReadS [UnsubscribeFromDataset]
readsPrec :: Int -> ReadS UnsubscribeFromDataset
$creadsPrec :: Int -> ReadS UnsubscribeFromDataset
Prelude.Read, Int -> UnsubscribeFromDataset -> ShowS
[UnsubscribeFromDataset] -> ShowS
UnsubscribeFromDataset -> String
(Int -> UnsubscribeFromDataset -> ShowS)
-> (UnsubscribeFromDataset -> String)
-> ([UnsubscribeFromDataset] -> ShowS)
-> Show UnsubscribeFromDataset
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnsubscribeFromDataset] -> ShowS
$cshowList :: [UnsubscribeFromDataset] -> ShowS
show :: UnsubscribeFromDataset -> String
$cshow :: UnsubscribeFromDataset -> String
showsPrec :: Int -> UnsubscribeFromDataset -> ShowS
$cshowsPrec :: Int -> UnsubscribeFromDataset -> ShowS
Prelude.Show, (forall x. UnsubscribeFromDataset -> Rep UnsubscribeFromDataset x)
-> (forall x.
    Rep UnsubscribeFromDataset x -> UnsubscribeFromDataset)
-> Generic UnsubscribeFromDataset
forall x. Rep UnsubscribeFromDataset x -> UnsubscribeFromDataset
forall x. UnsubscribeFromDataset -> Rep UnsubscribeFromDataset x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UnsubscribeFromDataset x -> UnsubscribeFromDataset
$cfrom :: forall x. UnsubscribeFromDataset -> Rep UnsubscribeFromDataset x
Prelude.Generic)

-- |
-- Create a value of 'UnsubscribeFromDataset' 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', 'unsubscribeFromDataset_identityPoolId' - A name-spaced GUID (for example,
-- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon
-- Cognito. The ID of the pool to which this identity belongs.
--
-- 'identityId', 'unsubscribeFromDataset_identityId' - Unique ID for this identity.
--
-- 'datasetName', 'unsubscribeFromDataset_datasetName' - The name of the dataset from which to unsubcribe.
--
-- 'deviceId', 'unsubscribeFromDataset_deviceId' - The unique ID generated for this device by Cognito.
newUnsubscribeFromDataset ::
  -- | 'identityPoolId'
  Prelude.Text ->
  -- | 'identityId'
  Prelude.Text ->
  -- | 'datasetName'
  Prelude.Text ->
  -- | 'deviceId'
  Prelude.Text ->
  UnsubscribeFromDataset
newUnsubscribeFromDataset :: Text -> Text -> Text -> Text -> UnsubscribeFromDataset
newUnsubscribeFromDataset
  Text
pIdentityPoolId_
  Text
pIdentityId_
  Text
pDatasetName_
  Text
pDeviceId_ =
    UnsubscribeFromDataset' :: Text -> Text -> Text -> Text -> UnsubscribeFromDataset
UnsubscribeFromDataset'
      { $sel:identityPoolId:UnsubscribeFromDataset' :: Text
identityPoolId =
          Text
pIdentityPoolId_,
        $sel:identityId:UnsubscribeFromDataset' :: Text
identityId = Text
pIdentityId_,
        $sel:datasetName:UnsubscribeFromDataset' :: Text
datasetName = Text
pDatasetName_,
        $sel:deviceId:UnsubscribeFromDataset' :: Text
deviceId = Text
pDeviceId_
      }

-- | A name-spaced GUID (for example,
-- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon
-- Cognito. The ID of the pool to which this identity belongs.
unsubscribeFromDataset_identityPoolId :: Lens.Lens' UnsubscribeFromDataset Prelude.Text
unsubscribeFromDataset_identityPoolId :: (Text -> f Text)
-> UnsubscribeFromDataset -> f UnsubscribeFromDataset
unsubscribeFromDataset_identityPoolId = (UnsubscribeFromDataset -> Text)
-> (UnsubscribeFromDataset -> Text -> UnsubscribeFromDataset)
-> Lens UnsubscribeFromDataset UnsubscribeFromDataset Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnsubscribeFromDataset' {Text
identityPoolId :: Text
$sel:identityPoolId:UnsubscribeFromDataset' :: UnsubscribeFromDataset -> Text
identityPoolId} -> Text
identityPoolId) (\s :: UnsubscribeFromDataset
s@UnsubscribeFromDataset' {} Text
a -> UnsubscribeFromDataset
s {$sel:identityPoolId:UnsubscribeFromDataset' :: Text
identityPoolId = Text
a} :: UnsubscribeFromDataset)

-- | Unique ID for this identity.
unsubscribeFromDataset_identityId :: Lens.Lens' UnsubscribeFromDataset Prelude.Text
unsubscribeFromDataset_identityId :: (Text -> f Text)
-> UnsubscribeFromDataset -> f UnsubscribeFromDataset
unsubscribeFromDataset_identityId = (UnsubscribeFromDataset -> Text)
-> (UnsubscribeFromDataset -> Text -> UnsubscribeFromDataset)
-> Lens UnsubscribeFromDataset UnsubscribeFromDataset Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnsubscribeFromDataset' {Text
identityId :: Text
$sel:identityId:UnsubscribeFromDataset' :: UnsubscribeFromDataset -> Text
identityId} -> Text
identityId) (\s :: UnsubscribeFromDataset
s@UnsubscribeFromDataset' {} Text
a -> UnsubscribeFromDataset
s {$sel:identityId:UnsubscribeFromDataset' :: Text
identityId = Text
a} :: UnsubscribeFromDataset)

-- | The name of the dataset from which to unsubcribe.
unsubscribeFromDataset_datasetName :: Lens.Lens' UnsubscribeFromDataset Prelude.Text
unsubscribeFromDataset_datasetName :: (Text -> f Text)
-> UnsubscribeFromDataset -> f UnsubscribeFromDataset
unsubscribeFromDataset_datasetName = (UnsubscribeFromDataset -> Text)
-> (UnsubscribeFromDataset -> Text -> UnsubscribeFromDataset)
-> Lens UnsubscribeFromDataset UnsubscribeFromDataset Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnsubscribeFromDataset' {Text
datasetName :: Text
$sel:datasetName:UnsubscribeFromDataset' :: UnsubscribeFromDataset -> Text
datasetName} -> Text
datasetName) (\s :: UnsubscribeFromDataset
s@UnsubscribeFromDataset' {} Text
a -> UnsubscribeFromDataset
s {$sel:datasetName:UnsubscribeFromDataset' :: Text
datasetName = Text
a} :: UnsubscribeFromDataset)

-- | The unique ID generated for this device by Cognito.
unsubscribeFromDataset_deviceId :: Lens.Lens' UnsubscribeFromDataset Prelude.Text
unsubscribeFromDataset_deviceId :: (Text -> f Text)
-> UnsubscribeFromDataset -> f UnsubscribeFromDataset
unsubscribeFromDataset_deviceId = (UnsubscribeFromDataset -> Text)
-> (UnsubscribeFromDataset -> Text -> UnsubscribeFromDataset)
-> Lens UnsubscribeFromDataset UnsubscribeFromDataset Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnsubscribeFromDataset' {Text
deviceId :: Text
$sel:deviceId:UnsubscribeFromDataset' :: UnsubscribeFromDataset -> Text
deviceId} -> Text
deviceId) (\s :: UnsubscribeFromDataset
s@UnsubscribeFromDataset' {} Text
a -> UnsubscribeFromDataset
s {$sel:deviceId:UnsubscribeFromDataset' :: Text
deviceId = Text
a} :: UnsubscribeFromDataset)

instance Core.AWSRequest UnsubscribeFromDataset where
  type
    AWSResponse UnsubscribeFromDataset =
      UnsubscribeFromDatasetResponse
  request :: UnsubscribeFromDataset -> Request UnsubscribeFromDataset
request = Service -> UnsubscribeFromDataset -> Request UnsubscribeFromDataset
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy UnsubscribeFromDataset
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UnsubscribeFromDataset)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UnsubscribeFromDataset))
-> Logger
-> Service
-> Proxy UnsubscribeFromDataset
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UnsubscribeFromDataset)))
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 -> UnsubscribeFromDatasetResponse
UnsubscribeFromDatasetResponse'
            (Int -> UnsubscribeFromDatasetResponse)
-> Either String Int
-> Either String UnsubscribeFromDatasetResponse
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 UnsubscribeFromDataset

instance Prelude.NFData UnsubscribeFromDataset

instance Core.ToHeaders UnsubscribeFromDataset where
  toHeaders :: UnsubscribeFromDataset -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UnsubscribeFromDataset -> 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 UnsubscribeFromDataset where
  toPath :: UnsubscribeFromDataset -> ByteString
toPath UnsubscribeFromDataset' {Text
deviceId :: Text
datasetName :: Text
identityId :: Text
identityPoolId :: Text
$sel:deviceId:UnsubscribeFromDataset' :: UnsubscribeFromDataset -> Text
$sel:datasetName:UnsubscribeFromDataset' :: UnsubscribeFromDataset -> Text
$sel:identityId:UnsubscribeFromDataset' :: UnsubscribeFromDataset -> Text
$sel:identityPoolId:UnsubscribeFromDataset' :: UnsubscribeFromDataset -> 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,
        ByteString
"/subscriptions/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
deviceId
      ]

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

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

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

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

instance
  Prelude.NFData
    UnsubscribeFromDatasetResponse