{-# 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.LicenseManager.DeleteToken
-- 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 specified token. Must be called in the license home Region.
module Amazonka.LicenseManager.DeleteToken
  ( -- * Creating a Request
    DeleteToken (..),
    newDeleteToken,

    -- * Request Lenses
    deleteToken_tokenId,

    -- * Destructuring the Response
    DeleteTokenResponse (..),
    newDeleteTokenResponse,

    -- * Response Lenses
    deleteTokenResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteToken' smart constructor.
data DeleteToken = DeleteToken'
  { -- | Token ID.
    DeleteToken -> Text
tokenId :: Prelude.Text
  }
  deriving (DeleteToken -> DeleteToken -> Bool
(DeleteToken -> DeleteToken -> Bool)
-> (DeleteToken -> DeleteToken -> Bool) -> Eq DeleteToken
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteToken -> DeleteToken -> Bool
$c/= :: DeleteToken -> DeleteToken -> Bool
== :: DeleteToken -> DeleteToken -> Bool
$c== :: DeleteToken -> DeleteToken -> Bool
Prelude.Eq, ReadPrec [DeleteToken]
ReadPrec DeleteToken
Int -> ReadS DeleteToken
ReadS [DeleteToken]
(Int -> ReadS DeleteToken)
-> ReadS [DeleteToken]
-> ReadPrec DeleteToken
-> ReadPrec [DeleteToken]
-> Read DeleteToken
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteToken]
$creadListPrec :: ReadPrec [DeleteToken]
readPrec :: ReadPrec DeleteToken
$creadPrec :: ReadPrec DeleteToken
readList :: ReadS [DeleteToken]
$creadList :: ReadS [DeleteToken]
readsPrec :: Int -> ReadS DeleteToken
$creadsPrec :: Int -> ReadS DeleteToken
Prelude.Read, Int -> DeleteToken -> ShowS
[DeleteToken] -> ShowS
DeleteToken -> String
(Int -> DeleteToken -> ShowS)
-> (DeleteToken -> String)
-> ([DeleteToken] -> ShowS)
-> Show DeleteToken
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteToken] -> ShowS
$cshowList :: [DeleteToken] -> ShowS
show :: DeleteToken -> String
$cshow :: DeleteToken -> String
showsPrec :: Int -> DeleteToken -> ShowS
$cshowsPrec :: Int -> DeleteToken -> ShowS
Prelude.Show, (forall x. DeleteToken -> Rep DeleteToken x)
-> (forall x. Rep DeleteToken x -> DeleteToken)
-> Generic DeleteToken
forall x. Rep DeleteToken x -> DeleteToken
forall x. DeleteToken -> Rep DeleteToken x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteToken x -> DeleteToken
$cfrom :: forall x. DeleteToken -> Rep DeleteToken x
Prelude.Generic)

-- |
-- Create a value of 'DeleteToken' 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:
--
-- 'tokenId', 'deleteToken_tokenId' - Token ID.
newDeleteToken ::
  -- | 'tokenId'
  Prelude.Text ->
  DeleteToken
newDeleteToken :: Text -> DeleteToken
newDeleteToken Text
pTokenId_ =
  DeleteToken' :: Text -> DeleteToken
DeleteToken' {$sel:tokenId:DeleteToken' :: Text
tokenId = Text
pTokenId_}

-- | Token ID.
deleteToken_tokenId :: Lens.Lens' DeleteToken Prelude.Text
deleteToken_tokenId :: (Text -> f Text) -> DeleteToken -> f DeleteToken
deleteToken_tokenId = (DeleteToken -> Text)
-> (DeleteToken -> Text -> DeleteToken)
-> Lens DeleteToken DeleteToken Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteToken' {Text
tokenId :: Text
$sel:tokenId:DeleteToken' :: DeleteToken -> Text
tokenId} -> Text
tokenId) (\s :: DeleteToken
s@DeleteToken' {} Text
a -> DeleteToken
s {$sel:tokenId:DeleteToken' :: Text
tokenId = Text
a} :: DeleteToken)

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

instance Prelude.NFData DeleteToken

instance Core.ToHeaders DeleteToken where
  toHeaders :: DeleteToken -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteToken -> 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
"AWSLicenseManager.DeleteToken" ::
                          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 DeleteToken where
  toJSON :: DeleteToken -> Value
toJSON DeleteToken' {Text
tokenId :: Text
$sel:tokenId:DeleteToken' :: DeleteToken -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TokenId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
tokenId)]
      )

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

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

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

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

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

instance Prelude.NFData DeleteTokenResponse