{-# 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.Lightsail.DeleteBucketAccessKey
-- 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 an access key for the specified Amazon Lightsail bucket.
--
-- We recommend that you delete an access key if the secret access key is
-- compromised.
--
-- For more information about access keys, see
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-creating-bucket-access-keys Creating access keys for a bucket in Amazon Lightsail>
-- in the /Amazon Lightsail Developer Guide/.
module Amazonka.Lightsail.DeleteBucketAccessKey
  ( -- * Creating a Request
    DeleteBucketAccessKey (..),
    newDeleteBucketAccessKey,

    -- * Request Lenses
    deleteBucketAccessKey_bucketName,
    deleteBucketAccessKey_accessKeyId,

    -- * Destructuring the Response
    DeleteBucketAccessKeyResponse (..),
    newDeleteBucketAccessKeyResponse,

    -- * Response Lenses
    deleteBucketAccessKeyResponse_operations,
    deleteBucketAccessKeyResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Lightsail.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteBucketAccessKey' smart constructor.
data DeleteBucketAccessKey = DeleteBucketAccessKey'
  { -- | The name of the bucket that the access key belongs to.
    DeleteBucketAccessKey -> Text
bucketName :: Prelude.Text,
    -- | The ID of the access key to delete.
    --
    -- Use the
    -- <https://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetBucketAccessKeys.html GetBucketAccessKeys>
    -- action to get a list of access key IDs that you can specify.
    DeleteBucketAccessKey -> Text
accessKeyId :: Prelude.Text
  }
  deriving (DeleteBucketAccessKey -> DeleteBucketAccessKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteBucketAccessKey -> DeleteBucketAccessKey -> Bool
$c/= :: DeleteBucketAccessKey -> DeleteBucketAccessKey -> Bool
== :: DeleteBucketAccessKey -> DeleteBucketAccessKey -> Bool
$c== :: DeleteBucketAccessKey -> DeleteBucketAccessKey -> Bool
Prelude.Eq, ReadPrec [DeleteBucketAccessKey]
ReadPrec DeleteBucketAccessKey
Int -> ReadS DeleteBucketAccessKey
ReadS [DeleteBucketAccessKey]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteBucketAccessKey]
$creadListPrec :: ReadPrec [DeleteBucketAccessKey]
readPrec :: ReadPrec DeleteBucketAccessKey
$creadPrec :: ReadPrec DeleteBucketAccessKey
readList :: ReadS [DeleteBucketAccessKey]
$creadList :: ReadS [DeleteBucketAccessKey]
readsPrec :: Int -> ReadS DeleteBucketAccessKey
$creadsPrec :: Int -> ReadS DeleteBucketAccessKey
Prelude.Read, Int -> DeleteBucketAccessKey -> ShowS
[DeleteBucketAccessKey] -> ShowS
DeleteBucketAccessKey -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteBucketAccessKey] -> ShowS
$cshowList :: [DeleteBucketAccessKey] -> ShowS
show :: DeleteBucketAccessKey -> String
$cshow :: DeleteBucketAccessKey -> String
showsPrec :: Int -> DeleteBucketAccessKey -> ShowS
$cshowsPrec :: Int -> DeleteBucketAccessKey -> ShowS
Prelude.Show, forall x. Rep DeleteBucketAccessKey x -> DeleteBucketAccessKey
forall x. DeleteBucketAccessKey -> Rep DeleteBucketAccessKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteBucketAccessKey x -> DeleteBucketAccessKey
$cfrom :: forall x. DeleteBucketAccessKey -> Rep DeleteBucketAccessKey x
Prelude.Generic)

-- |
-- Create a value of 'DeleteBucketAccessKey' 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:
--
-- 'bucketName', 'deleteBucketAccessKey_bucketName' - The name of the bucket that the access key belongs to.
--
-- 'accessKeyId', 'deleteBucketAccessKey_accessKeyId' - The ID of the access key to delete.
--
-- Use the
-- <https://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetBucketAccessKeys.html GetBucketAccessKeys>
-- action to get a list of access key IDs that you can specify.
newDeleteBucketAccessKey ::
  -- | 'bucketName'
  Prelude.Text ->
  -- | 'accessKeyId'
  Prelude.Text ->
  DeleteBucketAccessKey
newDeleteBucketAccessKey :: Text -> Text -> DeleteBucketAccessKey
newDeleteBucketAccessKey Text
pBucketName_ Text
pAccessKeyId_ =
  DeleteBucketAccessKey'
    { $sel:bucketName:DeleteBucketAccessKey' :: Text
bucketName = Text
pBucketName_,
      $sel:accessKeyId:DeleteBucketAccessKey' :: Text
accessKeyId = Text
pAccessKeyId_
    }

-- | The name of the bucket that the access key belongs to.
deleteBucketAccessKey_bucketName :: Lens.Lens' DeleteBucketAccessKey Prelude.Text
deleteBucketAccessKey_bucketName :: Lens' DeleteBucketAccessKey Text
deleteBucketAccessKey_bucketName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBucketAccessKey' {Text
bucketName :: Text
$sel:bucketName:DeleteBucketAccessKey' :: DeleteBucketAccessKey -> Text
bucketName} -> Text
bucketName) (\s :: DeleteBucketAccessKey
s@DeleteBucketAccessKey' {} Text
a -> DeleteBucketAccessKey
s {$sel:bucketName:DeleteBucketAccessKey' :: Text
bucketName = Text
a} :: DeleteBucketAccessKey)

-- | The ID of the access key to delete.
--
-- Use the
-- <https://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetBucketAccessKeys.html GetBucketAccessKeys>
-- action to get a list of access key IDs that you can specify.
deleteBucketAccessKey_accessKeyId :: Lens.Lens' DeleteBucketAccessKey Prelude.Text
deleteBucketAccessKey_accessKeyId :: Lens' DeleteBucketAccessKey Text
deleteBucketAccessKey_accessKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBucketAccessKey' {Text
accessKeyId :: Text
$sel:accessKeyId:DeleteBucketAccessKey' :: DeleteBucketAccessKey -> Text
accessKeyId} -> Text
accessKeyId) (\s :: DeleteBucketAccessKey
s@DeleteBucketAccessKey' {} Text
a -> DeleteBucketAccessKey
s {$sel:accessKeyId:DeleteBucketAccessKey' :: Text
accessKeyId = Text
a} :: DeleteBucketAccessKey)

instance Core.AWSRequest DeleteBucketAccessKey where
  type
    AWSResponse DeleteBucketAccessKey =
      DeleteBucketAccessKeyResponse
  request :: (Service -> Service)
-> DeleteBucketAccessKey -> Request DeleteBucketAccessKey
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteBucketAccessKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteBucketAccessKey)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Operation] -> Int -> DeleteBucketAccessKeyResponse
DeleteBucketAccessKeyResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"operations" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteBucketAccessKey where
  hashWithSalt :: Int -> DeleteBucketAccessKey -> Int
hashWithSalt Int
_salt DeleteBucketAccessKey' {Text
accessKeyId :: Text
bucketName :: Text
$sel:accessKeyId:DeleteBucketAccessKey' :: DeleteBucketAccessKey -> Text
$sel:bucketName:DeleteBucketAccessKey' :: DeleteBucketAccessKey -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
bucketName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
accessKeyId

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

instance Data.ToHeaders DeleteBucketAccessKey where
  toHeaders :: DeleteBucketAccessKey -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"Lightsail_20161128.DeleteBucketAccessKey" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteBucketAccessKey where
  toJSON :: DeleteBucketAccessKey -> Value
toJSON DeleteBucketAccessKey' {Text
accessKeyId :: Text
bucketName :: Text
$sel:accessKeyId:DeleteBucketAccessKey' :: DeleteBucketAccessKey -> Text
$sel:bucketName:DeleteBucketAccessKey' :: DeleteBucketAccessKey -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"bucketName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
bucketName),
            forall a. a -> Maybe a
Prelude.Just (Key
"accessKeyId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
accessKeyId)
          ]
      )

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

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

-- | /See:/ 'newDeleteBucketAccessKeyResponse' smart constructor.
data DeleteBucketAccessKeyResponse = DeleteBucketAccessKeyResponse'
  { -- | An array of objects that describe the result of the action, such as the
    -- status of the request, the timestamp of the request, and the resources
    -- affected by the request.
    DeleteBucketAccessKeyResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
    -- | The response's http status code.
    DeleteBucketAccessKeyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteBucketAccessKeyResponse
-> DeleteBucketAccessKeyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteBucketAccessKeyResponse
-> DeleteBucketAccessKeyResponse -> Bool
$c/= :: DeleteBucketAccessKeyResponse
-> DeleteBucketAccessKeyResponse -> Bool
== :: DeleteBucketAccessKeyResponse
-> DeleteBucketAccessKeyResponse -> Bool
$c== :: DeleteBucketAccessKeyResponse
-> DeleteBucketAccessKeyResponse -> Bool
Prelude.Eq, ReadPrec [DeleteBucketAccessKeyResponse]
ReadPrec DeleteBucketAccessKeyResponse
Int -> ReadS DeleteBucketAccessKeyResponse
ReadS [DeleteBucketAccessKeyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteBucketAccessKeyResponse]
$creadListPrec :: ReadPrec [DeleteBucketAccessKeyResponse]
readPrec :: ReadPrec DeleteBucketAccessKeyResponse
$creadPrec :: ReadPrec DeleteBucketAccessKeyResponse
readList :: ReadS [DeleteBucketAccessKeyResponse]
$creadList :: ReadS [DeleteBucketAccessKeyResponse]
readsPrec :: Int -> ReadS DeleteBucketAccessKeyResponse
$creadsPrec :: Int -> ReadS DeleteBucketAccessKeyResponse
Prelude.Read, Int -> DeleteBucketAccessKeyResponse -> ShowS
[DeleteBucketAccessKeyResponse] -> ShowS
DeleteBucketAccessKeyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteBucketAccessKeyResponse] -> ShowS
$cshowList :: [DeleteBucketAccessKeyResponse] -> ShowS
show :: DeleteBucketAccessKeyResponse -> String
$cshow :: DeleteBucketAccessKeyResponse -> String
showsPrec :: Int -> DeleteBucketAccessKeyResponse -> ShowS
$cshowsPrec :: Int -> DeleteBucketAccessKeyResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteBucketAccessKeyResponse x
-> DeleteBucketAccessKeyResponse
forall x.
DeleteBucketAccessKeyResponse
-> Rep DeleteBucketAccessKeyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteBucketAccessKeyResponse x
-> DeleteBucketAccessKeyResponse
$cfrom :: forall x.
DeleteBucketAccessKeyResponse
-> Rep DeleteBucketAccessKeyResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteBucketAccessKeyResponse' 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:
--
-- 'operations', 'deleteBucketAccessKeyResponse_operations' - An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
--
-- 'httpStatus', 'deleteBucketAccessKeyResponse_httpStatus' - The response's http status code.
newDeleteBucketAccessKeyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteBucketAccessKeyResponse
newDeleteBucketAccessKeyResponse :: Int -> DeleteBucketAccessKeyResponse
newDeleteBucketAccessKeyResponse Int
pHttpStatus_ =
  DeleteBucketAccessKeyResponse'
    { $sel:operations:DeleteBucketAccessKeyResponse' :: Maybe [Operation]
operations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteBucketAccessKeyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
deleteBucketAccessKeyResponse_operations :: Lens.Lens' DeleteBucketAccessKeyResponse (Prelude.Maybe [Operation])
deleteBucketAccessKeyResponse_operations :: Lens' DeleteBucketAccessKeyResponse (Maybe [Operation])
deleteBucketAccessKeyResponse_operations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBucketAccessKeyResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:DeleteBucketAccessKeyResponse' :: DeleteBucketAccessKeyResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: DeleteBucketAccessKeyResponse
s@DeleteBucketAccessKeyResponse' {} Maybe [Operation]
a -> DeleteBucketAccessKeyResponse
s {$sel:operations:DeleteBucketAccessKeyResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: DeleteBucketAccessKeyResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DeleteBucketAccessKeyResponse where
  rnf :: DeleteBucketAccessKeyResponse -> ()
rnf DeleteBucketAccessKeyResponse' {Int
Maybe [Operation]
httpStatus :: Int
operations :: Maybe [Operation]
$sel:httpStatus:DeleteBucketAccessKeyResponse' :: DeleteBucketAccessKeyResponse -> Int
$sel:operations:DeleteBucketAccessKeyResponse' :: DeleteBucketAccessKeyResponse -> Maybe [Operation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Operation]
operations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus