{-# 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.DirectoryService.VerifyTrust
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Directory Service for Microsoft Active Directory allows you to configure
-- and verify trust relationships.
--
-- This action verifies a trust relationship between your Managed Microsoft
-- AD directory and an external domain.
module Amazonka.DirectoryService.VerifyTrust
  ( -- * Creating a Request
    VerifyTrust (..),
    newVerifyTrust,

    -- * Request Lenses
    verifyTrust_trustId,

    -- * Destructuring the Response
    VerifyTrustResponse (..),
    newVerifyTrustResponse,

    -- * Response Lenses
    verifyTrustResponse_trustId,
    verifyTrustResponse_httpStatus,
  )
where

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

-- | Initiates the verification of an existing trust relationship between an
-- Managed Microsoft AD directory and an external domain.
--
-- /See:/ 'newVerifyTrust' smart constructor.
data VerifyTrust = VerifyTrust'
  { -- | The unique Trust ID of the trust relationship to verify.
    VerifyTrust -> Text
trustId :: Prelude.Text
  }
  deriving (VerifyTrust -> VerifyTrust -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerifyTrust -> VerifyTrust -> Bool
$c/= :: VerifyTrust -> VerifyTrust -> Bool
== :: VerifyTrust -> VerifyTrust -> Bool
$c== :: VerifyTrust -> VerifyTrust -> Bool
Prelude.Eq, ReadPrec [VerifyTrust]
ReadPrec VerifyTrust
Int -> ReadS VerifyTrust
ReadS [VerifyTrust]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VerifyTrust]
$creadListPrec :: ReadPrec [VerifyTrust]
readPrec :: ReadPrec VerifyTrust
$creadPrec :: ReadPrec VerifyTrust
readList :: ReadS [VerifyTrust]
$creadList :: ReadS [VerifyTrust]
readsPrec :: Int -> ReadS VerifyTrust
$creadsPrec :: Int -> ReadS VerifyTrust
Prelude.Read, Int -> VerifyTrust -> ShowS
[VerifyTrust] -> ShowS
VerifyTrust -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerifyTrust] -> ShowS
$cshowList :: [VerifyTrust] -> ShowS
show :: VerifyTrust -> String
$cshow :: VerifyTrust -> String
showsPrec :: Int -> VerifyTrust -> ShowS
$cshowsPrec :: Int -> VerifyTrust -> ShowS
Prelude.Show, forall x. Rep VerifyTrust x -> VerifyTrust
forall x. VerifyTrust -> Rep VerifyTrust x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VerifyTrust x -> VerifyTrust
$cfrom :: forall x. VerifyTrust -> Rep VerifyTrust x
Prelude.Generic)

-- |
-- Create a value of 'VerifyTrust' 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:
--
-- 'trustId', 'verifyTrust_trustId' - The unique Trust ID of the trust relationship to verify.
newVerifyTrust ::
  -- | 'trustId'
  Prelude.Text ->
  VerifyTrust
newVerifyTrust :: Text -> VerifyTrust
newVerifyTrust Text
pTrustId_ =
  VerifyTrust' {$sel:trustId:VerifyTrust' :: Text
trustId = Text
pTrustId_}

-- | The unique Trust ID of the trust relationship to verify.
verifyTrust_trustId :: Lens.Lens' VerifyTrust Prelude.Text
verifyTrust_trustId :: Lens' VerifyTrust Text
verifyTrust_trustId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VerifyTrust' {Text
trustId :: Text
$sel:trustId:VerifyTrust' :: VerifyTrust -> Text
trustId} -> Text
trustId) (\s :: VerifyTrust
s@VerifyTrust' {} Text
a -> VerifyTrust
s {$sel:trustId:VerifyTrust' :: Text
trustId = Text
a} :: VerifyTrust)

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

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

instance Data.ToHeaders VerifyTrust where
  toHeaders :: VerifyTrust -> 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
"DirectoryService_20150416.VerifyTrust" ::
                          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 VerifyTrust where
  toJSON :: VerifyTrust -> Value
toJSON VerifyTrust' {Text
trustId :: Text
$sel:trustId:VerifyTrust' :: VerifyTrust -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"TrustId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
trustId)]
      )

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

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

-- | Result of a VerifyTrust request.
--
-- /See:/ 'newVerifyTrustResponse' smart constructor.
data VerifyTrustResponse = VerifyTrustResponse'
  { -- | The unique Trust ID of the trust relationship that was verified.
    VerifyTrustResponse -> Maybe Text
trustId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    VerifyTrustResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (VerifyTrustResponse -> VerifyTrustResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerifyTrustResponse -> VerifyTrustResponse -> Bool
$c/= :: VerifyTrustResponse -> VerifyTrustResponse -> Bool
== :: VerifyTrustResponse -> VerifyTrustResponse -> Bool
$c== :: VerifyTrustResponse -> VerifyTrustResponse -> Bool
Prelude.Eq, ReadPrec [VerifyTrustResponse]
ReadPrec VerifyTrustResponse
Int -> ReadS VerifyTrustResponse
ReadS [VerifyTrustResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VerifyTrustResponse]
$creadListPrec :: ReadPrec [VerifyTrustResponse]
readPrec :: ReadPrec VerifyTrustResponse
$creadPrec :: ReadPrec VerifyTrustResponse
readList :: ReadS [VerifyTrustResponse]
$creadList :: ReadS [VerifyTrustResponse]
readsPrec :: Int -> ReadS VerifyTrustResponse
$creadsPrec :: Int -> ReadS VerifyTrustResponse
Prelude.Read, Int -> VerifyTrustResponse -> ShowS
[VerifyTrustResponse] -> ShowS
VerifyTrustResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerifyTrustResponse] -> ShowS
$cshowList :: [VerifyTrustResponse] -> ShowS
show :: VerifyTrustResponse -> String
$cshow :: VerifyTrustResponse -> String
showsPrec :: Int -> VerifyTrustResponse -> ShowS
$cshowsPrec :: Int -> VerifyTrustResponse -> ShowS
Prelude.Show, forall x. Rep VerifyTrustResponse x -> VerifyTrustResponse
forall x. VerifyTrustResponse -> Rep VerifyTrustResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VerifyTrustResponse x -> VerifyTrustResponse
$cfrom :: forall x. VerifyTrustResponse -> Rep VerifyTrustResponse x
Prelude.Generic)

-- |
-- Create a value of 'VerifyTrustResponse' 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:
--
-- 'trustId', 'verifyTrustResponse_trustId' - The unique Trust ID of the trust relationship that was verified.
--
-- 'httpStatus', 'verifyTrustResponse_httpStatus' - The response's http status code.
newVerifyTrustResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  VerifyTrustResponse
newVerifyTrustResponse :: Int -> VerifyTrustResponse
newVerifyTrustResponse Int
pHttpStatus_ =
  VerifyTrustResponse'
    { $sel:trustId:VerifyTrustResponse' :: Maybe Text
trustId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:VerifyTrustResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The unique Trust ID of the trust relationship that was verified.
verifyTrustResponse_trustId :: Lens.Lens' VerifyTrustResponse (Prelude.Maybe Prelude.Text)
verifyTrustResponse_trustId :: Lens' VerifyTrustResponse (Maybe Text)
verifyTrustResponse_trustId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VerifyTrustResponse' {Maybe Text
trustId :: Maybe Text
$sel:trustId:VerifyTrustResponse' :: VerifyTrustResponse -> Maybe Text
trustId} -> Maybe Text
trustId) (\s :: VerifyTrustResponse
s@VerifyTrustResponse' {} Maybe Text
a -> VerifyTrustResponse
s {$sel:trustId:VerifyTrustResponse' :: Maybe Text
trustId = Maybe Text
a} :: VerifyTrustResponse)

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

instance Prelude.NFData VerifyTrustResponse where
  rnf :: VerifyTrustResponse -> ()
rnf VerifyTrustResponse' {Int
Maybe Text
httpStatus :: Int
trustId :: Maybe Text
$sel:httpStatus:VerifyTrustResponse' :: VerifyTrustResponse -> Int
$sel:trustId:VerifyTrustResponse' :: VerifyTrustResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
trustId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus