{-# 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.DisableTrustAnchor
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disables a trust anchor. When disabled,
-- <https://docs.aws.amazon.com/rolesanywhere/latest/APIReference/API_CreateSession.html CreateSession>
-- requests specifying this trust anchor are unauthorized.
--
-- __Required permissions:__ @rolesanywhere:DisableTrustAnchor@.
module Amazonka.RolesAnywhere.DisableTrustAnchor
  ( -- * Creating a Request
    DisableTrustAnchor (..),
    newDisableTrustAnchor,

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

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

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

instance Core.AWSRequest DisableTrustAnchor where
  type
    AWSResponse DisableTrustAnchor =
      TrustAnchorDetailResponse
  request :: (Service -> Service)
-> DisableTrustAnchor -> Request DisableTrustAnchor
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 DisableTrustAnchor
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisableTrustAnchor)))
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 DisableTrustAnchor where
  hashWithSalt :: Int -> DisableTrustAnchor -> Int
hashWithSalt Int
_salt DisableTrustAnchor' {Text
trustAnchorId :: Text
$sel:trustAnchorId:DisableTrustAnchor' :: DisableTrustAnchor -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
trustAnchorId

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

instance Data.ToHeaders DisableTrustAnchor where
  toHeaders :: DisableTrustAnchor -> 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.ToJSON DisableTrustAnchor where
  toJSON :: DisableTrustAnchor -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

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

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