{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IAM.Types
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
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]
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
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. 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'
    { $sel:userName:DeleteAccessKey' :: Maybe Text
userName = 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 :: Lens' DeleteAccessKey (Maybe Text)
deleteAccessKey_userName = 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 :: Lens' DeleteAccessKey AccessKey
deleteAccessKey_accessKeyId = 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 :: (Service -> Service) -> DeleteAccessKey -> Request DeleteAccessKey
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteAccessKey
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteAccessKey)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull DeleteAccessKeyResponse
DeleteAccessKeyResponse'

instance Prelude.Hashable DeleteAccessKey where
  hashWithSalt :: Int -> DeleteAccessKey -> Int
hashWithSalt Int
_salt DeleteAccessKey' {Maybe Text
AccessKey
accessKeyId :: AccessKey
userName :: Maybe Text
$sel:accessKeyId:DeleteAccessKey' :: DeleteAccessKey -> AccessKey
$sel:userName:DeleteAccessKey' :: DeleteAccessKey -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AccessKey
accessKeyId

instance Prelude.NFData DeleteAccessKey where
  rnf :: DeleteAccessKey -> ()
rnf DeleteAccessKey' {Maybe Text
AccessKey
accessKeyId :: AccessKey
userName :: Maybe Text
$sel:accessKeyId:DeleteAccessKey' :: DeleteAccessKey -> AccessKey
$sel:userName:DeleteAccessKey' :: DeleteAccessKey -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AccessKey
accessKeyId

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

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

instance Data.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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DeleteAccessKey" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"UserName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
userName,
        ByteString
"AccessKeyId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: AccessKey
accessKeyId
      ]

-- | /See:/ 'newDeleteAccessKeyResponse' smart constructor.
data DeleteAccessKeyResponse = DeleteAccessKeyResponse'
  {
  }
  deriving (DeleteAccessKeyResponse -> DeleteAccessKeyResponse -> Bool
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]
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
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. 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 where
  rnf :: DeleteAccessKeyResponse -> ()
rnf DeleteAccessKeyResponse
_ = ()