{-# 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.IoT.TestInvokeAuthorizer
-- 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)
--
-- Tests a custom authorization behavior by invoking a specified custom
-- authorizer. Use this to test and debug the custom authorization behavior
-- of devices that connect to the IoT device gateway.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions TestInvokeAuthorizer>
-- action.
module Amazonka.IoT.TestInvokeAuthorizer
  ( -- * Creating a Request
    TestInvokeAuthorizer (..),
    newTestInvokeAuthorizer,

    -- * Request Lenses
    testInvokeAuthorizer_token,
    testInvokeAuthorizer_tlsContext,
    testInvokeAuthorizer_tokenSignature,
    testInvokeAuthorizer_httpContext,
    testInvokeAuthorizer_mqttContext,
    testInvokeAuthorizer_authorizerName,

    -- * Destructuring the Response
    TestInvokeAuthorizerResponse (..),
    newTestInvokeAuthorizerResponse,

    -- * Response Lenses
    testInvokeAuthorizerResponse_policyDocuments,
    testInvokeAuthorizerResponse_principalId,
    testInvokeAuthorizerResponse_disconnectAfterInSeconds,
    testInvokeAuthorizerResponse_isAuthenticated,
    testInvokeAuthorizerResponse_refreshAfterInSeconds,
    testInvokeAuthorizerResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.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

-- | /See:/ 'newTestInvokeAuthorizer' smart constructor.
data TestInvokeAuthorizer = TestInvokeAuthorizer'
  { -- | The token returned by your custom authentication service.
    TestInvokeAuthorizer -> Maybe Text
token :: Prelude.Maybe Prelude.Text,
    -- | Specifies a test TLS authorization request.
    TestInvokeAuthorizer -> Maybe TlsContext
tlsContext :: Prelude.Maybe TlsContext,
    -- | The signature made with the token and your custom authentication
    -- service\'s private key. This value must be Base-64-encoded.
    TestInvokeAuthorizer -> Maybe Text
tokenSignature :: Prelude.Maybe Prelude.Text,
    -- | Specifies a test HTTP authorization request.
    TestInvokeAuthorizer -> Maybe HttpContext
httpContext :: Prelude.Maybe HttpContext,
    -- | Specifies a test MQTT authorization request.
    TestInvokeAuthorizer -> Maybe MqttContext
mqttContext :: Prelude.Maybe MqttContext,
    -- | The custom authorizer name.
    TestInvokeAuthorizer -> Text
authorizerName :: Prelude.Text
  }
  deriving (TestInvokeAuthorizer -> TestInvokeAuthorizer -> Bool
(TestInvokeAuthorizer -> TestInvokeAuthorizer -> Bool)
-> (TestInvokeAuthorizer -> TestInvokeAuthorizer -> Bool)
-> Eq TestInvokeAuthorizer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestInvokeAuthorizer -> TestInvokeAuthorizer -> Bool
$c/= :: TestInvokeAuthorizer -> TestInvokeAuthorizer -> Bool
== :: TestInvokeAuthorizer -> TestInvokeAuthorizer -> Bool
$c== :: TestInvokeAuthorizer -> TestInvokeAuthorizer -> Bool
Prelude.Eq, ReadPrec [TestInvokeAuthorizer]
ReadPrec TestInvokeAuthorizer
Int -> ReadS TestInvokeAuthorizer
ReadS [TestInvokeAuthorizer]
(Int -> ReadS TestInvokeAuthorizer)
-> ReadS [TestInvokeAuthorizer]
-> ReadPrec TestInvokeAuthorizer
-> ReadPrec [TestInvokeAuthorizer]
-> Read TestInvokeAuthorizer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TestInvokeAuthorizer]
$creadListPrec :: ReadPrec [TestInvokeAuthorizer]
readPrec :: ReadPrec TestInvokeAuthorizer
$creadPrec :: ReadPrec TestInvokeAuthorizer
readList :: ReadS [TestInvokeAuthorizer]
$creadList :: ReadS [TestInvokeAuthorizer]
readsPrec :: Int -> ReadS TestInvokeAuthorizer
$creadsPrec :: Int -> ReadS TestInvokeAuthorizer
Prelude.Read, Int -> TestInvokeAuthorizer -> ShowS
[TestInvokeAuthorizer] -> ShowS
TestInvokeAuthorizer -> String
(Int -> TestInvokeAuthorizer -> ShowS)
-> (TestInvokeAuthorizer -> String)
-> ([TestInvokeAuthorizer] -> ShowS)
-> Show TestInvokeAuthorizer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestInvokeAuthorizer] -> ShowS
$cshowList :: [TestInvokeAuthorizer] -> ShowS
show :: TestInvokeAuthorizer -> String
$cshow :: TestInvokeAuthorizer -> String
showsPrec :: Int -> TestInvokeAuthorizer -> ShowS
$cshowsPrec :: Int -> TestInvokeAuthorizer -> ShowS
Prelude.Show, (forall x. TestInvokeAuthorizer -> Rep TestInvokeAuthorizer x)
-> (forall x. Rep TestInvokeAuthorizer x -> TestInvokeAuthorizer)
-> Generic TestInvokeAuthorizer
forall x. Rep TestInvokeAuthorizer x -> TestInvokeAuthorizer
forall x. TestInvokeAuthorizer -> Rep TestInvokeAuthorizer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TestInvokeAuthorizer x -> TestInvokeAuthorizer
$cfrom :: forall x. TestInvokeAuthorizer -> Rep TestInvokeAuthorizer x
Prelude.Generic)

-- |
-- Create a value of 'TestInvokeAuthorizer' 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:
--
-- 'token', 'testInvokeAuthorizer_token' - The token returned by your custom authentication service.
--
-- 'tlsContext', 'testInvokeAuthorizer_tlsContext' - Specifies a test TLS authorization request.
--
-- 'tokenSignature', 'testInvokeAuthorizer_tokenSignature' - The signature made with the token and your custom authentication
-- service\'s private key. This value must be Base-64-encoded.
--
-- 'httpContext', 'testInvokeAuthorizer_httpContext' - Specifies a test HTTP authorization request.
--
-- 'mqttContext', 'testInvokeAuthorizer_mqttContext' - Specifies a test MQTT authorization request.
--
-- 'authorizerName', 'testInvokeAuthorizer_authorizerName' - The custom authorizer name.
newTestInvokeAuthorizer ::
  -- | 'authorizerName'
  Prelude.Text ->
  TestInvokeAuthorizer
newTestInvokeAuthorizer :: Text -> TestInvokeAuthorizer
newTestInvokeAuthorizer Text
pAuthorizerName_ =
  TestInvokeAuthorizer' :: Maybe Text
-> Maybe TlsContext
-> Maybe Text
-> Maybe HttpContext
-> Maybe MqttContext
-> Text
-> TestInvokeAuthorizer
TestInvokeAuthorizer'
    { $sel:token:TestInvokeAuthorizer' :: Maybe Text
token = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tlsContext:TestInvokeAuthorizer' :: Maybe TlsContext
tlsContext = Maybe TlsContext
forall a. Maybe a
Prelude.Nothing,
      $sel:tokenSignature:TestInvokeAuthorizer' :: Maybe Text
tokenSignature = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpContext:TestInvokeAuthorizer' :: Maybe HttpContext
httpContext = Maybe HttpContext
forall a. Maybe a
Prelude.Nothing,
      $sel:mqttContext:TestInvokeAuthorizer' :: Maybe MqttContext
mqttContext = Maybe MqttContext
forall a. Maybe a
Prelude.Nothing,
      $sel:authorizerName:TestInvokeAuthorizer' :: Text
authorizerName = Text
pAuthorizerName_
    }

-- | The token returned by your custom authentication service.
testInvokeAuthorizer_token :: Lens.Lens' TestInvokeAuthorizer (Prelude.Maybe Prelude.Text)
testInvokeAuthorizer_token :: (Maybe Text -> f (Maybe Text))
-> TestInvokeAuthorizer -> f TestInvokeAuthorizer
testInvokeAuthorizer_token = (TestInvokeAuthorizer -> Maybe Text)
-> (TestInvokeAuthorizer -> Maybe Text -> TestInvokeAuthorizer)
-> Lens
     TestInvokeAuthorizer TestInvokeAuthorizer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestInvokeAuthorizer' {Maybe Text
token :: Maybe Text
$sel:token:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Maybe Text
token} -> Maybe Text
token) (\s :: TestInvokeAuthorizer
s@TestInvokeAuthorizer' {} Maybe Text
a -> TestInvokeAuthorizer
s {$sel:token:TestInvokeAuthorizer' :: Maybe Text
token = Maybe Text
a} :: TestInvokeAuthorizer)

-- | Specifies a test TLS authorization request.
testInvokeAuthorizer_tlsContext :: Lens.Lens' TestInvokeAuthorizer (Prelude.Maybe TlsContext)
testInvokeAuthorizer_tlsContext :: (Maybe TlsContext -> f (Maybe TlsContext))
-> TestInvokeAuthorizer -> f TestInvokeAuthorizer
testInvokeAuthorizer_tlsContext = (TestInvokeAuthorizer -> Maybe TlsContext)
-> (TestInvokeAuthorizer
    -> Maybe TlsContext -> TestInvokeAuthorizer)
-> Lens
     TestInvokeAuthorizer
     TestInvokeAuthorizer
     (Maybe TlsContext)
     (Maybe TlsContext)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestInvokeAuthorizer' {Maybe TlsContext
tlsContext :: Maybe TlsContext
$sel:tlsContext:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Maybe TlsContext
tlsContext} -> Maybe TlsContext
tlsContext) (\s :: TestInvokeAuthorizer
s@TestInvokeAuthorizer' {} Maybe TlsContext
a -> TestInvokeAuthorizer
s {$sel:tlsContext:TestInvokeAuthorizer' :: Maybe TlsContext
tlsContext = Maybe TlsContext
a} :: TestInvokeAuthorizer)

-- | The signature made with the token and your custom authentication
-- service\'s private key. This value must be Base-64-encoded.
testInvokeAuthorizer_tokenSignature :: Lens.Lens' TestInvokeAuthorizer (Prelude.Maybe Prelude.Text)
testInvokeAuthorizer_tokenSignature :: (Maybe Text -> f (Maybe Text))
-> TestInvokeAuthorizer -> f TestInvokeAuthorizer
testInvokeAuthorizer_tokenSignature = (TestInvokeAuthorizer -> Maybe Text)
-> (TestInvokeAuthorizer -> Maybe Text -> TestInvokeAuthorizer)
-> Lens
     TestInvokeAuthorizer TestInvokeAuthorizer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestInvokeAuthorizer' {Maybe Text
tokenSignature :: Maybe Text
$sel:tokenSignature:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Maybe Text
tokenSignature} -> Maybe Text
tokenSignature) (\s :: TestInvokeAuthorizer
s@TestInvokeAuthorizer' {} Maybe Text
a -> TestInvokeAuthorizer
s {$sel:tokenSignature:TestInvokeAuthorizer' :: Maybe Text
tokenSignature = Maybe Text
a} :: TestInvokeAuthorizer)

-- | Specifies a test HTTP authorization request.
testInvokeAuthorizer_httpContext :: Lens.Lens' TestInvokeAuthorizer (Prelude.Maybe HttpContext)
testInvokeAuthorizer_httpContext :: (Maybe HttpContext -> f (Maybe HttpContext))
-> TestInvokeAuthorizer -> f TestInvokeAuthorizer
testInvokeAuthorizer_httpContext = (TestInvokeAuthorizer -> Maybe HttpContext)
-> (TestInvokeAuthorizer
    -> Maybe HttpContext -> TestInvokeAuthorizer)
-> Lens
     TestInvokeAuthorizer
     TestInvokeAuthorizer
     (Maybe HttpContext)
     (Maybe HttpContext)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestInvokeAuthorizer' {Maybe HttpContext
httpContext :: Maybe HttpContext
$sel:httpContext:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Maybe HttpContext
httpContext} -> Maybe HttpContext
httpContext) (\s :: TestInvokeAuthorizer
s@TestInvokeAuthorizer' {} Maybe HttpContext
a -> TestInvokeAuthorizer
s {$sel:httpContext:TestInvokeAuthorizer' :: Maybe HttpContext
httpContext = Maybe HttpContext
a} :: TestInvokeAuthorizer)

-- | Specifies a test MQTT authorization request.
testInvokeAuthorizer_mqttContext :: Lens.Lens' TestInvokeAuthorizer (Prelude.Maybe MqttContext)
testInvokeAuthorizer_mqttContext :: (Maybe MqttContext -> f (Maybe MqttContext))
-> TestInvokeAuthorizer -> f TestInvokeAuthorizer
testInvokeAuthorizer_mqttContext = (TestInvokeAuthorizer -> Maybe MqttContext)
-> (TestInvokeAuthorizer
    -> Maybe MqttContext -> TestInvokeAuthorizer)
-> Lens
     TestInvokeAuthorizer
     TestInvokeAuthorizer
     (Maybe MqttContext)
     (Maybe MqttContext)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestInvokeAuthorizer' {Maybe MqttContext
mqttContext :: Maybe MqttContext
$sel:mqttContext:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Maybe MqttContext
mqttContext} -> Maybe MqttContext
mqttContext) (\s :: TestInvokeAuthorizer
s@TestInvokeAuthorizer' {} Maybe MqttContext
a -> TestInvokeAuthorizer
s {$sel:mqttContext:TestInvokeAuthorizer' :: Maybe MqttContext
mqttContext = Maybe MqttContext
a} :: TestInvokeAuthorizer)

-- | The custom authorizer name.
testInvokeAuthorizer_authorizerName :: Lens.Lens' TestInvokeAuthorizer Prelude.Text
testInvokeAuthorizer_authorizerName :: (Text -> f Text) -> TestInvokeAuthorizer -> f TestInvokeAuthorizer
testInvokeAuthorizer_authorizerName = (TestInvokeAuthorizer -> Text)
-> (TestInvokeAuthorizer -> Text -> TestInvokeAuthorizer)
-> Lens TestInvokeAuthorizer TestInvokeAuthorizer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestInvokeAuthorizer' {Text
authorizerName :: Text
$sel:authorizerName:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Text
authorizerName} -> Text
authorizerName) (\s :: TestInvokeAuthorizer
s@TestInvokeAuthorizer' {} Text
a -> TestInvokeAuthorizer
s {$sel:authorizerName:TestInvokeAuthorizer' :: Text
authorizerName = Text
a} :: TestInvokeAuthorizer)

instance Core.AWSRequest TestInvokeAuthorizer where
  type
    AWSResponse TestInvokeAuthorizer =
      TestInvokeAuthorizerResponse
  request :: TestInvokeAuthorizer -> Request TestInvokeAuthorizer
request = Service -> TestInvokeAuthorizer -> Request TestInvokeAuthorizer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy TestInvokeAuthorizer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse TestInvokeAuthorizer)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse TestInvokeAuthorizer))
-> Logger
-> Service
-> Proxy TestInvokeAuthorizer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse TestInvokeAuthorizer)))
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]
-> Maybe Text
-> Maybe Int
-> Maybe Bool
-> Maybe Int
-> Int
-> TestInvokeAuthorizerResponse
TestInvokeAuthorizerResponse'
            (Maybe [Text]
 -> Maybe Text
 -> Maybe Int
 -> Maybe Bool
 -> Maybe Int
 -> Int
 -> TestInvokeAuthorizerResponse)
-> Either String (Maybe [Text])
-> Either
     String
     (Maybe Text
      -> Maybe Int
      -> Maybe Bool
      -> Maybe Int
      -> Int
      -> TestInvokeAuthorizerResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Either String (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"policyDocuments"
                            Either String (Maybe (Maybe [Text]))
-> Maybe [Text] -> Either String (Maybe [Text])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either
  String
  (Maybe Text
   -> Maybe Int
   -> Maybe Bool
   -> Maybe Int
   -> Int
   -> TestInvokeAuthorizerResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Int
      -> Maybe Bool -> Maybe Int -> Int -> TestInvokeAuthorizerResponse)
forall (f :: * -> *) a b. Applicative f => 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
"principalId")
            Either
  String
  (Maybe Int
   -> Maybe Bool -> Maybe Int -> Int -> TestInvokeAuthorizerResponse)
-> Either String (Maybe Int)
-> Either
     String
     (Maybe Bool -> Maybe Int -> Int -> TestInvokeAuthorizerResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Int)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"disconnectAfterInSeconds")
            Either
  String
  (Maybe Bool -> Maybe Int -> Int -> TestInvokeAuthorizerResponse)
-> Either String (Maybe Bool)
-> Either String (Maybe Int -> Int -> TestInvokeAuthorizerResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"isAuthenticated")
            Either String (Maybe Int -> Int -> TestInvokeAuthorizerResponse)
-> Either String (Maybe Int)
-> Either String (Int -> TestInvokeAuthorizerResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Int)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"refreshAfterInSeconds")
            Either String (Int -> TestInvokeAuthorizerResponse)
-> Either String Int -> Either String TestInvokeAuthorizerResponse
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 TestInvokeAuthorizer

instance Prelude.NFData TestInvokeAuthorizer

instance Core.ToHeaders TestInvokeAuthorizer where
  toHeaders :: TestInvokeAuthorizer -> ResponseHeaders
toHeaders = ResponseHeaders -> TestInvokeAuthorizer -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON TestInvokeAuthorizer where
  toJSON :: TestInvokeAuthorizer -> Value
toJSON TestInvokeAuthorizer' {Maybe Text
Maybe HttpContext
Maybe MqttContext
Maybe TlsContext
Text
authorizerName :: Text
mqttContext :: Maybe MqttContext
httpContext :: Maybe HttpContext
tokenSignature :: Maybe Text
tlsContext :: Maybe TlsContext
token :: Maybe Text
$sel:authorizerName:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Text
$sel:mqttContext:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Maybe MqttContext
$sel:httpContext:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Maybe HttpContext
$sel:tokenSignature:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Maybe Text
$sel:tlsContext:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Maybe TlsContext
$sel:token:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"token" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
token,
            (Text
"tlsContext" Text -> TlsContext -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TlsContext -> Pair) -> Maybe TlsContext -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TlsContext
tlsContext,
            (Text
"tokenSignature" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
tokenSignature,
            (Text
"httpContext" Text -> HttpContext -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HttpContext -> Pair) -> Maybe HttpContext -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HttpContext
httpContext,
            (Text
"mqttContext" Text -> MqttContext -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (MqttContext -> Pair) -> Maybe MqttContext -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MqttContext
mqttContext
          ]
      )

instance Core.ToPath TestInvokeAuthorizer where
  toPath :: TestInvokeAuthorizer -> ByteString
toPath TestInvokeAuthorizer' {Maybe Text
Maybe HttpContext
Maybe MqttContext
Maybe TlsContext
Text
authorizerName :: Text
mqttContext :: Maybe MqttContext
httpContext :: Maybe HttpContext
tokenSignature :: Maybe Text
tlsContext :: Maybe TlsContext
token :: Maybe Text
$sel:authorizerName:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Text
$sel:mqttContext:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Maybe MqttContext
$sel:httpContext:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Maybe HttpContext
$sel:tokenSignature:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Maybe Text
$sel:tlsContext:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Maybe TlsContext
$sel:token:TestInvokeAuthorizer' :: TestInvokeAuthorizer -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/authorizer/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
authorizerName, ByteString
"/test"]

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

-- | /See:/ 'newTestInvokeAuthorizerResponse' smart constructor.
data TestInvokeAuthorizerResponse = TestInvokeAuthorizerResponse'
  { -- | IAM policy documents.
    TestInvokeAuthorizerResponse -> Maybe [Text]
policyDocuments :: Prelude.Maybe [Prelude.Text],
    -- | The principal ID.
    TestInvokeAuthorizerResponse -> Maybe Text
principalId :: Prelude.Maybe Prelude.Text,
    -- | The number of seconds after which the connection is terminated.
    TestInvokeAuthorizerResponse -> Maybe Int
disconnectAfterInSeconds :: Prelude.Maybe Prelude.Int,
    -- | True if the token is authenticated, otherwise false.
    TestInvokeAuthorizerResponse -> Maybe Bool
isAuthenticated :: Prelude.Maybe Prelude.Bool,
    -- | The number of seconds after which the temporary credentials are
    -- refreshed.
    TestInvokeAuthorizerResponse -> Maybe Int
refreshAfterInSeconds :: Prelude.Maybe Prelude.Int,
    -- | The response's http status code.
    TestInvokeAuthorizerResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (TestInvokeAuthorizerResponse
-> TestInvokeAuthorizerResponse -> Bool
(TestInvokeAuthorizerResponse
 -> TestInvokeAuthorizerResponse -> Bool)
-> (TestInvokeAuthorizerResponse
    -> TestInvokeAuthorizerResponse -> Bool)
-> Eq TestInvokeAuthorizerResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestInvokeAuthorizerResponse
-> TestInvokeAuthorizerResponse -> Bool
$c/= :: TestInvokeAuthorizerResponse
-> TestInvokeAuthorizerResponse -> Bool
== :: TestInvokeAuthorizerResponse
-> TestInvokeAuthorizerResponse -> Bool
$c== :: TestInvokeAuthorizerResponse
-> TestInvokeAuthorizerResponse -> Bool
Prelude.Eq, ReadPrec [TestInvokeAuthorizerResponse]
ReadPrec TestInvokeAuthorizerResponse
Int -> ReadS TestInvokeAuthorizerResponse
ReadS [TestInvokeAuthorizerResponse]
(Int -> ReadS TestInvokeAuthorizerResponse)
-> ReadS [TestInvokeAuthorizerResponse]
-> ReadPrec TestInvokeAuthorizerResponse
-> ReadPrec [TestInvokeAuthorizerResponse]
-> Read TestInvokeAuthorizerResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TestInvokeAuthorizerResponse]
$creadListPrec :: ReadPrec [TestInvokeAuthorizerResponse]
readPrec :: ReadPrec TestInvokeAuthorizerResponse
$creadPrec :: ReadPrec TestInvokeAuthorizerResponse
readList :: ReadS [TestInvokeAuthorizerResponse]
$creadList :: ReadS [TestInvokeAuthorizerResponse]
readsPrec :: Int -> ReadS TestInvokeAuthorizerResponse
$creadsPrec :: Int -> ReadS TestInvokeAuthorizerResponse
Prelude.Read, Int -> TestInvokeAuthorizerResponse -> ShowS
[TestInvokeAuthorizerResponse] -> ShowS
TestInvokeAuthorizerResponse -> String
(Int -> TestInvokeAuthorizerResponse -> ShowS)
-> (TestInvokeAuthorizerResponse -> String)
-> ([TestInvokeAuthorizerResponse] -> ShowS)
-> Show TestInvokeAuthorizerResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestInvokeAuthorizerResponse] -> ShowS
$cshowList :: [TestInvokeAuthorizerResponse] -> ShowS
show :: TestInvokeAuthorizerResponse -> String
$cshow :: TestInvokeAuthorizerResponse -> String
showsPrec :: Int -> TestInvokeAuthorizerResponse -> ShowS
$cshowsPrec :: Int -> TestInvokeAuthorizerResponse -> ShowS
Prelude.Show, (forall x.
 TestInvokeAuthorizerResponse -> Rep TestInvokeAuthorizerResponse x)
-> (forall x.
    Rep TestInvokeAuthorizerResponse x -> TestInvokeAuthorizerResponse)
-> Generic TestInvokeAuthorizerResponse
forall x.
Rep TestInvokeAuthorizerResponse x -> TestInvokeAuthorizerResponse
forall x.
TestInvokeAuthorizerResponse -> Rep TestInvokeAuthorizerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TestInvokeAuthorizerResponse x -> TestInvokeAuthorizerResponse
$cfrom :: forall x.
TestInvokeAuthorizerResponse -> Rep TestInvokeAuthorizerResponse x
Prelude.Generic)

-- |
-- Create a value of 'TestInvokeAuthorizerResponse' 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:
--
-- 'policyDocuments', 'testInvokeAuthorizerResponse_policyDocuments' - IAM policy documents.
--
-- 'principalId', 'testInvokeAuthorizerResponse_principalId' - The principal ID.
--
-- 'disconnectAfterInSeconds', 'testInvokeAuthorizerResponse_disconnectAfterInSeconds' - The number of seconds after which the connection is terminated.
--
-- 'isAuthenticated', 'testInvokeAuthorizerResponse_isAuthenticated' - True if the token is authenticated, otherwise false.
--
-- 'refreshAfterInSeconds', 'testInvokeAuthorizerResponse_refreshAfterInSeconds' - The number of seconds after which the temporary credentials are
-- refreshed.
--
-- 'httpStatus', 'testInvokeAuthorizerResponse_httpStatus' - The response's http status code.
newTestInvokeAuthorizerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  TestInvokeAuthorizerResponse
newTestInvokeAuthorizerResponse :: Int -> TestInvokeAuthorizerResponse
newTestInvokeAuthorizerResponse Int
pHttpStatus_ =
  TestInvokeAuthorizerResponse' :: Maybe [Text]
-> Maybe Text
-> Maybe Int
-> Maybe Bool
-> Maybe Int
-> Int
-> TestInvokeAuthorizerResponse
TestInvokeAuthorizerResponse'
    { $sel:policyDocuments:TestInvokeAuthorizerResponse' :: Maybe [Text]
policyDocuments =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:principalId:TestInvokeAuthorizerResponse' :: Maybe Text
principalId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:disconnectAfterInSeconds:TestInvokeAuthorizerResponse' :: Maybe Int
disconnectAfterInSeconds = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:isAuthenticated:TestInvokeAuthorizerResponse' :: Maybe Bool
isAuthenticated = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:refreshAfterInSeconds:TestInvokeAuthorizerResponse' :: Maybe Int
refreshAfterInSeconds = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:TestInvokeAuthorizerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | IAM policy documents.
testInvokeAuthorizerResponse_policyDocuments :: Lens.Lens' TestInvokeAuthorizerResponse (Prelude.Maybe [Prelude.Text])
testInvokeAuthorizerResponse_policyDocuments :: (Maybe [Text] -> f (Maybe [Text]))
-> TestInvokeAuthorizerResponse -> f TestInvokeAuthorizerResponse
testInvokeAuthorizerResponse_policyDocuments = (TestInvokeAuthorizerResponse -> Maybe [Text])
-> (TestInvokeAuthorizerResponse
    -> Maybe [Text] -> TestInvokeAuthorizerResponse)
-> Lens
     TestInvokeAuthorizerResponse
     TestInvokeAuthorizerResponse
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestInvokeAuthorizerResponse' {Maybe [Text]
policyDocuments :: Maybe [Text]
$sel:policyDocuments:TestInvokeAuthorizerResponse' :: TestInvokeAuthorizerResponse -> Maybe [Text]
policyDocuments} -> Maybe [Text]
policyDocuments) (\s :: TestInvokeAuthorizerResponse
s@TestInvokeAuthorizerResponse' {} Maybe [Text]
a -> TestInvokeAuthorizerResponse
s {$sel:policyDocuments:TestInvokeAuthorizerResponse' :: Maybe [Text]
policyDocuments = Maybe [Text]
a} :: TestInvokeAuthorizerResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> TestInvokeAuthorizerResponse -> f TestInvokeAuthorizerResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> TestInvokeAuthorizerResponse
-> f TestInvokeAuthorizerResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The principal ID.
testInvokeAuthorizerResponse_principalId :: Lens.Lens' TestInvokeAuthorizerResponse (Prelude.Maybe Prelude.Text)
testInvokeAuthorizerResponse_principalId :: (Maybe Text -> f (Maybe Text))
-> TestInvokeAuthorizerResponse -> f TestInvokeAuthorizerResponse
testInvokeAuthorizerResponse_principalId = (TestInvokeAuthorizerResponse -> Maybe Text)
-> (TestInvokeAuthorizerResponse
    -> Maybe Text -> TestInvokeAuthorizerResponse)
-> Lens
     TestInvokeAuthorizerResponse
     TestInvokeAuthorizerResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestInvokeAuthorizerResponse' {Maybe Text
principalId :: Maybe Text
$sel:principalId:TestInvokeAuthorizerResponse' :: TestInvokeAuthorizerResponse -> Maybe Text
principalId} -> Maybe Text
principalId) (\s :: TestInvokeAuthorizerResponse
s@TestInvokeAuthorizerResponse' {} Maybe Text
a -> TestInvokeAuthorizerResponse
s {$sel:principalId:TestInvokeAuthorizerResponse' :: Maybe Text
principalId = Maybe Text
a} :: TestInvokeAuthorizerResponse)

-- | The number of seconds after which the connection is terminated.
testInvokeAuthorizerResponse_disconnectAfterInSeconds :: Lens.Lens' TestInvokeAuthorizerResponse (Prelude.Maybe Prelude.Int)
testInvokeAuthorizerResponse_disconnectAfterInSeconds :: (Maybe Int -> f (Maybe Int))
-> TestInvokeAuthorizerResponse -> f TestInvokeAuthorizerResponse
testInvokeAuthorizerResponse_disconnectAfterInSeconds = (TestInvokeAuthorizerResponse -> Maybe Int)
-> (TestInvokeAuthorizerResponse
    -> Maybe Int -> TestInvokeAuthorizerResponse)
-> Lens
     TestInvokeAuthorizerResponse
     TestInvokeAuthorizerResponse
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestInvokeAuthorizerResponse' {Maybe Int
disconnectAfterInSeconds :: Maybe Int
$sel:disconnectAfterInSeconds:TestInvokeAuthorizerResponse' :: TestInvokeAuthorizerResponse -> Maybe Int
disconnectAfterInSeconds} -> Maybe Int
disconnectAfterInSeconds) (\s :: TestInvokeAuthorizerResponse
s@TestInvokeAuthorizerResponse' {} Maybe Int
a -> TestInvokeAuthorizerResponse
s {$sel:disconnectAfterInSeconds:TestInvokeAuthorizerResponse' :: Maybe Int
disconnectAfterInSeconds = Maybe Int
a} :: TestInvokeAuthorizerResponse)

-- | True if the token is authenticated, otherwise false.
testInvokeAuthorizerResponse_isAuthenticated :: Lens.Lens' TestInvokeAuthorizerResponse (Prelude.Maybe Prelude.Bool)
testInvokeAuthorizerResponse_isAuthenticated :: (Maybe Bool -> f (Maybe Bool))
-> TestInvokeAuthorizerResponse -> f TestInvokeAuthorizerResponse
testInvokeAuthorizerResponse_isAuthenticated = (TestInvokeAuthorizerResponse -> Maybe Bool)
-> (TestInvokeAuthorizerResponse
    -> Maybe Bool -> TestInvokeAuthorizerResponse)
-> Lens
     TestInvokeAuthorizerResponse
     TestInvokeAuthorizerResponse
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestInvokeAuthorizerResponse' {Maybe Bool
isAuthenticated :: Maybe Bool
$sel:isAuthenticated:TestInvokeAuthorizerResponse' :: TestInvokeAuthorizerResponse -> Maybe Bool
isAuthenticated} -> Maybe Bool
isAuthenticated) (\s :: TestInvokeAuthorizerResponse
s@TestInvokeAuthorizerResponse' {} Maybe Bool
a -> TestInvokeAuthorizerResponse
s {$sel:isAuthenticated:TestInvokeAuthorizerResponse' :: Maybe Bool
isAuthenticated = Maybe Bool
a} :: TestInvokeAuthorizerResponse)

-- | The number of seconds after which the temporary credentials are
-- refreshed.
testInvokeAuthorizerResponse_refreshAfterInSeconds :: Lens.Lens' TestInvokeAuthorizerResponse (Prelude.Maybe Prelude.Int)
testInvokeAuthorizerResponse_refreshAfterInSeconds :: (Maybe Int -> f (Maybe Int))
-> TestInvokeAuthorizerResponse -> f TestInvokeAuthorizerResponse
testInvokeAuthorizerResponse_refreshAfterInSeconds = (TestInvokeAuthorizerResponse -> Maybe Int)
-> (TestInvokeAuthorizerResponse
    -> Maybe Int -> TestInvokeAuthorizerResponse)
-> Lens
     TestInvokeAuthorizerResponse
     TestInvokeAuthorizerResponse
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestInvokeAuthorizerResponse' {Maybe Int
refreshAfterInSeconds :: Maybe Int
$sel:refreshAfterInSeconds:TestInvokeAuthorizerResponse' :: TestInvokeAuthorizerResponse -> Maybe Int
refreshAfterInSeconds} -> Maybe Int
refreshAfterInSeconds) (\s :: TestInvokeAuthorizerResponse
s@TestInvokeAuthorizerResponse' {} Maybe Int
a -> TestInvokeAuthorizerResponse
s {$sel:refreshAfterInSeconds:TestInvokeAuthorizerResponse' :: Maybe Int
refreshAfterInSeconds = Maybe Int
a} :: TestInvokeAuthorizerResponse)

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

instance Prelude.NFData TestInvokeAuthorizerResponse