{-# 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.AppSync.DeleteApiKey
-- 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 API key.
module Amazonka.AppSync.DeleteApiKey
  ( -- * Creating a Request
    DeleteApiKey (..),
    newDeleteApiKey,

    -- * Request Lenses
    deleteApiKey_apiId,
    deleteApiKey_id,

    -- * Destructuring the Response
    DeleteApiKeyResponse (..),
    newDeleteApiKeyResponse,

    -- * Response Lenses
    deleteApiKeyResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'DeleteApiKey' 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:
--
-- 'apiId', 'deleteApiKey_apiId' - The API ID.
--
-- 'id', 'deleteApiKey_id' - The ID for the API key.
newDeleteApiKey ::
  -- | 'apiId'
  Prelude.Text ->
  -- | 'id'
  Prelude.Text ->
  DeleteApiKey
newDeleteApiKey :: Text -> Text -> DeleteApiKey
newDeleteApiKey Text
pApiId_ Text
pId_ =
  DeleteApiKey' :: Text -> Text -> DeleteApiKey
DeleteApiKey' {$sel:apiId:DeleteApiKey' :: Text
apiId = Text
pApiId_, $sel:id:DeleteApiKey' :: Text
id = Text
pId_}

-- | The API ID.
deleteApiKey_apiId :: Lens.Lens' DeleteApiKey Prelude.Text
deleteApiKey_apiId :: (Text -> f Text) -> DeleteApiKey -> f DeleteApiKey
deleteApiKey_apiId = (DeleteApiKey -> Text)
-> (DeleteApiKey -> Text -> DeleteApiKey)
-> Lens DeleteApiKey DeleteApiKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteApiKey' {Text
apiId :: Text
$sel:apiId:DeleteApiKey' :: DeleteApiKey -> Text
apiId} -> Text
apiId) (\s :: DeleteApiKey
s@DeleteApiKey' {} Text
a -> DeleteApiKey
s {$sel:apiId:DeleteApiKey' :: Text
apiId = Text
a} :: DeleteApiKey)

-- | The ID for the API key.
deleteApiKey_id :: Lens.Lens' DeleteApiKey Prelude.Text
deleteApiKey_id :: (Text -> f Text) -> DeleteApiKey -> f DeleteApiKey
deleteApiKey_id = (DeleteApiKey -> Text)
-> (DeleteApiKey -> Text -> DeleteApiKey)
-> Lens DeleteApiKey DeleteApiKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteApiKey' {Text
id :: Text
$sel:id:DeleteApiKey' :: DeleteApiKey -> Text
id} -> Text
id) (\s :: DeleteApiKey
s@DeleteApiKey' {} Text
a -> DeleteApiKey
s {$sel:id:DeleteApiKey' :: Text
id = Text
a} :: DeleteApiKey)

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

instance Prelude.NFData DeleteApiKey

instance Core.ToHeaders DeleteApiKey where
  toHeaders :: DeleteApiKey -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteApiKey -> 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 DeleteApiKey where
  toPath :: DeleteApiKey -> ByteString
toPath DeleteApiKey' {Text
id :: Text
apiId :: Text
$sel:id:DeleteApiKey' :: DeleteApiKey -> Text
$sel:apiId:DeleteApiKey' :: DeleteApiKey -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v1/apis/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
apiId,
        ByteString
"/apikeys/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
id
      ]

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

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

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

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

instance Prelude.NFData DeleteApiKeyResponse