{-# 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.IAM.DeleteAccessKey
-- 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 access key pair associated with the specified IAM user.
--
-- If you do not specify a user name, IAM determines the user name
-- implicitly based on the Amazon Web Services access key ID signing the
-- request. This operation works for access keys under the Amazon Web
-- Services account. Consequently, you can use this operation to manage
-- Amazon Web Services account root user credentials even if the Amazon Web
-- Services account has no associated users.
module Amazonka.IAM.DeleteAccessKey
  ( -- * Creating a Request
    DeleteAccessKey (..),
    newDeleteAccessKey,

    -- * Request Lenses
    deleteAccessKey_userName,
    deleteAccessKey_accessKeyId,

    -- * Destructuring the Response
    DeleteAccessKeyResponse (..),
    newDeleteAccessKeyResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types
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:/ 'newDeleteAccessKey' smart constructor.
data DeleteAccessKey = DeleteAccessKey'
  { -- | The name of the user whose access key pair you want to delete.
    --
    -- This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- consisting of upper and lowercase alphanumeric characters with no
    -- spaces. You can also include any of the following characters: _+=,.\@-
    DeleteAccessKey -> Maybe Text
userName :: Prelude.Maybe Prelude.Text,
    -- | The access key ID for the access key ID and secret access key you want
    -- to delete.
    --
    -- This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- that can consist of any upper or lowercased letter or digit.
    DeleteAccessKey -> AccessKey
accessKeyId :: Core.AccessKey
  }
  deriving (DeleteAccessKey -> DeleteAccessKey -> Bool
(DeleteAccessKey -> DeleteAccessKey -> Bool)
-> (DeleteAccessKey -> DeleteAccessKey -> Bool)
-> Eq DeleteAccessKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteAccessKey -> DeleteAccessKey -> Bool
$c/= :: DeleteAccessKey -> DeleteAccessKey -> Bool
== :: DeleteAccessKey -> DeleteAccessKey -> Bool
$c== :: DeleteAccessKey -> DeleteAccessKey -> Bool
Prelude.Eq, ReadPrec [DeleteAccessKey]
ReadPrec DeleteAccessKey
Int -> ReadS DeleteAccessKey
ReadS [DeleteAccessKey]
(Int -> ReadS DeleteAccessKey)
-> ReadS [DeleteAccessKey]
-> ReadPrec DeleteAccessKey
-> ReadPrec [DeleteAccessKey]
-> Read DeleteAccessKey
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteAccessKey]
$creadListPrec :: ReadPrec [DeleteAccessKey]
readPrec :: ReadPrec DeleteAccessKey
$creadPrec :: ReadPrec DeleteAccessKey
readList :: ReadS [DeleteAccessKey]
$creadList :: ReadS [DeleteAccessKey]
readsPrec :: Int -> ReadS DeleteAccessKey
$creadsPrec :: Int -> ReadS DeleteAccessKey
Prelude.Read, Int -> DeleteAccessKey -> ShowS
[DeleteAccessKey] -> ShowS
DeleteAccessKey -> String
(Int -> DeleteAccessKey -> ShowS)
-> (DeleteAccessKey -> String)
-> ([DeleteAccessKey] -> ShowS)
-> Show DeleteAccessKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteAccessKey] -> ShowS
$cshowList :: [DeleteAccessKey] -> ShowS
show :: DeleteAccessKey -> String
$cshow :: DeleteAccessKey -> String
showsPrec :: Int -> DeleteAccessKey -> ShowS
$cshowsPrec :: Int -> DeleteAccessKey -> ShowS
Prelude.Show, (forall x. DeleteAccessKey -> Rep DeleteAccessKey x)
-> (forall x. Rep DeleteAccessKey x -> DeleteAccessKey)
-> Generic DeleteAccessKey
forall x. Rep DeleteAccessKey x -> DeleteAccessKey
forall x. DeleteAccessKey -> Rep DeleteAccessKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteAccessKey x -> DeleteAccessKey
$cfrom :: forall x. DeleteAccessKey -> Rep DeleteAccessKey x
Prelude.Generic)

-- |
-- Create a value of 'DeleteAccessKey' 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:
--
-- 'userName', 'deleteAccessKey_userName' - The name of the user whose access key pair you want to delete.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
--
-- 'accessKeyId', 'deleteAccessKey_accessKeyId' - The access key ID for the access key ID and secret access key you want
-- to delete.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- that can consist of any upper or lowercased letter or digit.
newDeleteAccessKey ::
  -- | 'accessKeyId'
  Core.AccessKey ->
  DeleteAccessKey
newDeleteAccessKey :: AccessKey -> DeleteAccessKey
newDeleteAccessKey AccessKey
pAccessKeyId_ =
  DeleteAccessKey' :: Maybe Text -> AccessKey -> DeleteAccessKey
DeleteAccessKey'
    { $sel:userName:DeleteAccessKey' :: Maybe Text
userName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accessKeyId:DeleteAccessKey' :: AccessKey
accessKeyId = AccessKey
pAccessKeyId_
    }

-- | The name of the user whose access key pair you want to delete.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
deleteAccessKey_userName :: Lens.Lens' DeleteAccessKey (Prelude.Maybe Prelude.Text)
deleteAccessKey_userName :: (Maybe Text -> f (Maybe Text))
-> DeleteAccessKey -> f DeleteAccessKey
deleteAccessKey_userName = (DeleteAccessKey -> Maybe Text)
-> (DeleteAccessKey -> Maybe Text -> DeleteAccessKey)
-> Lens DeleteAccessKey DeleteAccessKey (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAccessKey' {Maybe Text
userName :: Maybe Text
$sel:userName:DeleteAccessKey' :: DeleteAccessKey -> Maybe Text
userName} -> Maybe Text
userName) (\s :: DeleteAccessKey
s@DeleteAccessKey' {} Maybe Text
a -> DeleteAccessKey
s {$sel:userName:DeleteAccessKey' :: Maybe Text
userName = Maybe Text
a} :: DeleteAccessKey)

-- | The access key ID for the access key ID and secret access key you want
-- to delete.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- that can consist of any upper or lowercased letter or digit.
deleteAccessKey_accessKeyId :: Lens.Lens' DeleteAccessKey Core.AccessKey
deleteAccessKey_accessKeyId :: (AccessKey -> f AccessKey) -> DeleteAccessKey -> f DeleteAccessKey
deleteAccessKey_accessKeyId = (DeleteAccessKey -> AccessKey)
-> (DeleteAccessKey -> AccessKey -> DeleteAccessKey)
-> Lens DeleteAccessKey DeleteAccessKey AccessKey AccessKey
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAccessKey' {AccessKey
accessKeyId :: AccessKey
$sel:accessKeyId:DeleteAccessKey' :: DeleteAccessKey -> AccessKey
accessKeyId} -> AccessKey
accessKeyId) (\s :: DeleteAccessKey
s@DeleteAccessKey' {} AccessKey
a -> DeleteAccessKey
s {$sel:accessKeyId:DeleteAccessKey' :: AccessKey
accessKeyId = AccessKey
a} :: DeleteAccessKey)

instance Core.AWSRequest DeleteAccessKey where
  type
    AWSResponse DeleteAccessKey =
      DeleteAccessKeyResponse
  request :: DeleteAccessKey -> Request DeleteAccessKey
request = Service -> DeleteAccessKey -> Request DeleteAccessKey
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteAccessKey
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteAccessKey)))
response =
    AWSResponse DeleteAccessKey
-> Logger
-> Service
-> Proxy DeleteAccessKey
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteAccessKey)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DeleteAccessKey
DeleteAccessKeyResponse
DeleteAccessKeyResponse'

instance Prelude.Hashable DeleteAccessKey

instance Prelude.NFData DeleteAccessKey

instance Core.ToHeaders DeleteAccessKey where
  toHeaders :: DeleteAccessKey -> [Header]
toHeaders = [Header] -> DeleteAccessKey -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery DeleteAccessKey where
  toQuery :: DeleteAccessKey -> QueryString
toQuery DeleteAccessKey' {Maybe Text
AccessKey
accessKeyId :: AccessKey
userName :: Maybe Text
$sel:accessKeyId:DeleteAccessKey' :: DeleteAccessKey -> AccessKey
$sel:userName:DeleteAccessKey' :: DeleteAccessKey -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DeleteAccessKey" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"UserName" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
userName,
        ByteString
"AccessKeyId" ByteString -> AccessKey -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: AccessKey
accessKeyId
      ]

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

-- |
-- Create a value of 'DeleteAccessKeyResponse' 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.
newDeleteAccessKeyResponse ::
  DeleteAccessKeyResponse
newDeleteAccessKeyResponse :: DeleteAccessKeyResponse
newDeleteAccessKeyResponse = DeleteAccessKeyResponse
DeleteAccessKeyResponse'

instance Prelude.NFData DeleteAccessKeyResponse