{-# 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.RolesAnywhere.DeleteTrustAnchor
-- 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 a trust anchor.
--
-- __Required permissions:__ @rolesanywhere:DeleteTrustAnchor@.
module Amazonka.RolesAnywhere.DeleteTrustAnchor
  ( -- * Creating a Request
    DeleteTrustAnchor (..),
    newDeleteTrustAnchor,

    -- * Request Lenses
    deleteTrustAnchor_trustAnchorId,

    -- * Destructuring the Response
    TrustAnchorDetailResponse (..),
    newTrustAnchorDetailResponse,

    -- * Response Lenses
    trustAnchorDetailResponse_trustAnchor,
  )
where

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

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

-- |
-- Create a value of 'DeleteTrustAnchor' 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:
--
-- 'trustAnchorId', 'deleteTrustAnchor_trustAnchorId' - The unique identifier of the trust anchor.
newDeleteTrustAnchor ::
  -- | 'trustAnchorId'
  Prelude.Text ->
  DeleteTrustAnchor
newDeleteTrustAnchor :: Text -> DeleteTrustAnchor
newDeleteTrustAnchor Text
pTrustAnchorId_ =
  DeleteTrustAnchor' {$sel:trustAnchorId:DeleteTrustAnchor' :: Text
trustAnchorId = Text
pTrustAnchorId_}

-- | The unique identifier of the trust anchor.
deleteTrustAnchor_trustAnchorId :: Lens.Lens' DeleteTrustAnchor Prelude.Text
deleteTrustAnchor_trustAnchorId :: Lens' DeleteTrustAnchor Text
deleteTrustAnchor_trustAnchorId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTrustAnchor' {Text
trustAnchorId :: Text
$sel:trustAnchorId:DeleteTrustAnchor' :: DeleteTrustAnchor -> Text
trustAnchorId} -> Text
trustAnchorId) (\s :: DeleteTrustAnchor
s@DeleteTrustAnchor' {} Text
a -> DeleteTrustAnchor
s {$sel:trustAnchorId:DeleteTrustAnchor' :: Text
trustAnchorId = Text
a} :: DeleteTrustAnchor)

instance Core.AWSRequest DeleteTrustAnchor where
  type
    AWSResponse DeleteTrustAnchor =
      TrustAnchorDetailResponse
  request :: (Service -> Service)
-> DeleteTrustAnchor -> Request DeleteTrustAnchor
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteTrustAnchor
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteTrustAnchor)))
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 -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

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

instance Prelude.NFData DeleteTrustAnchor where
  rnf :: DeleteTrustAnchor -> ()
rnf DeleteTrustAnchor' {Text
trustAnchorId :: Text
$sel:trustAnchorId:DeleteTrustAnchor' :: DeleteTrustAnchor -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
trustAnchorId

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

instance Data.ToPath DeleteTrustAnchor where
  toPath :: DeleteTrustAnchor -> ByteString
toPath DeleteTrustAnchor' {Text
trustAnchorId :: Text
$sel:trustAnchorId:DeleteTrustAnchor' :: DeleteTrustAnchor -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/trustanchor/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
trustAnchorId]

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