{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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 Amazonka.DirectoryService.Types
import qualified Amazonka.Lens as Lens
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
(VerifyTrust -> VerifyTrust -> Bool)
-> (VerifyTrust -> VerifyTrust -> Bool) -> Eq VerifyTrust
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]
(Int -> ReadS VerifyTrust)
-> ReadS [VerifyTrust]
-> ReadPrec VerifyTrust
-> ReadPrec [VerifyTrust]
-> Read 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
(Int -> VerifyTrust -> ShowS)
-> (VerifyTrust -> String)
-> ([VerifyTrust] -> ShowS)
-> Show VerifyTrust
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. VerifyTrust -> Rep VerifyTrust x)
-> (forall x. Rep VerifyTrust x -> VerifyTrust)
-> Generic VerifyTrust
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' :: Text -> VerifyTrust
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 :: (Text -> f Text) -> VerifyTrust -> f VerifyTrust
verifyTrust_trustId = (VerifyTrust -> Text)
-> (VerifyTrust -> Text -> VerifyTrust)
-> Lens VerifyTrust VerifyTrust Text Text
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 :: VerifyTrust -> Request VerifyTrust
request = Service -> VerifyTrust -> Request VerifyTrust
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy VerifyTrust
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse VerifyTrust)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse VerifyTrust))
-> Logger
-> Service
-> Proxy VerifyTrust
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse VerifyTrust)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> VerifyTrustResponse
VerifyTrustResponse'
            (Maybe Text -> Int -> VerifyTrustResponse)
-> Either String (Maybe Text)
-> Either String (Int -> VerifyTrustResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"TrustId")
            Either String (Int -> VerifyTrustResponse)
-> Either String Int -> Either String VerifyTrustResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable VerifyTrust

instance Prelude.NFData VerifyTrust

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

instance Core.ToJSON VerifyTrust where
  toJSON :: VerifyTrust -> Value
toJSON VerifyTrust' {Text
trustId :: Text
$sel:trustId:VerifyTrust' :: VerifyTrust -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TrustId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
trustId)]
      )

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

instance Core.ToQuery VerifyTrust where
  toQuery :: VerifyTrust -> QueryString
toQuery = QueryString -> VerifyTrust -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(VerifyTrustResponse -> VerifyTrustResponse -> Bool)
-> (VerifyTrustResponse -> VerifyTrustResponse -> Bool)
-> Eq VerifyTrustResponse
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]
(Int -> ReadS VerifyTrustResponse)
-> ReadS [VerifyTrustResponse]
-> ReadPrec VerifyTrustResponse
-> ReadPrec [VerifyTrustResponse]
-> Read 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
(Int -> VerifyTrustResponse -> ShowS)
-> (VerifyTrustResponse -> String)
-> ([VerifyTrustResponse] -> ShowS)
-> Show VerifyTrustResponse
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. VerifyTrustResponse -> Rep VerifyTrustResponse x)
-> (forall x. Rep VerifyTrustResponse x -> VerifyTrustResponse)
-> Generic VerifyTrustResponse
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' :: Maybe Text -> Int -> VerifyTrustResponse
VerifyTrustResponse'
    { $sel:trustId:VerifyTrustResponse' :: Maybe Text
trustId = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> VerifyTrustResponse -> f VerifyTrustResponse
verifyTrustResponse_trustId = (VerifyTrustResponse -> Maybe Text)
-> (VerifyTrustResponse -> Maybe Text -> VerifyTrustResponse)
-> Lens
     VerifyTrustResponse VerifyTrustResponse (Maybe Text) (Maybe Text)
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 :: (Int -> f Int) -> VerifyTrustResponse -> f VerifyTrustResponse
verifyTrustResponse_httpStatus = (VerifyTrustResponse -> Int)
-> (VerifyTrustResponse -> Int -> VerifyTrustResponse)
-> Lens VerifyTrustResponse VerifyTrustResponse Int Int
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