{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CloudWatchEvents.Types.CreateConnectionOAuthRequestParameters
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudWatchEvents.Types.CreateConnectionOAuthRequestParameters where

import Amazonka.CloudWatchEvents.Types.ConnectionHttpParameters
import Amazonka.CloudWatchEvents.Types.ConnectionOAuthHttpMethod
import Amazonka.CloudWatchEvents.Types.CreateConnectionOAuthClientRequestParameters
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

-- | Contains the OAuth authorization parameters to use for the connection.
--
-- /See:/ 'newCreateConnectionOAuthRequestParameters' smart constructor.
data CreateConnectionOAuthRequestParameters = CreateConnectionOAuthRequestParameters'
  { -- | A @ConnectionHttpParameters@ object that contains details about the
    -- additional parameters to use for the connection.
    CreateConnectionOAuthRequestParameters
-> Maybe ConnectionHttpParameters
oAuthHttpParameters :: Prelude.Maybe ConnectionHttpParameters,
    -- | A @CreateConnectionOAuthClientRequestParameters@ object that contains
    -- the client parameters for OAuth authorization.
    CreateConnectionOAuthRequestParameters
-> CreateConnectionOAuthClientRequestParameters
clientParameters :: CreateConnectionOAuthClientRequestParameters,
    -- | The URL to the authorization endpoint when OAuth is specified as the
    -- authorization type.
    CreateConnectionOAuthRequestParameters -> Text
authorizationEndpoint :: Prelude.Text,
    -- | The method to use for the authorization request.
    CreateConnectionOAuthRequestParameters -> ConnectionOAuthHttpMethod
httpMethod :: ConnectionOAuthHttpMethod
  }
  deriving (CreateConnectionOAuthRequestParameters
-> CreateConnectionOAuthRequestParameters -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateConnectionOAuthRequestParameters
-> CreateConnectionOAuthRequestParameters -> Bool
$c/= :: CreateConnectionOAuthRequestParameters
-> CreateConnectionOAuthRequestParameters -> Bool
== :: CreateConnectionOAuthRequestParameters
-> CreateConnectionOAuthRequestParameters -> Bool
$c== :: CreateConnectionOAuthRequestParameters
-> CreateConnectionOAuthRequestParameters -> Bool
Prelude.Eq, ReadPrec [CreateConnectionOAuthRequestParameters]
ReadPrec CreateConnectionOAuthRequestParameters
Int -> ReadS CreateConnectionOAuthRequestParameters
ReadS [CreateConnectionOAuthRequestParameters]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateConnectionOAuthRequestParameters]
$creadListPrec :: ReadPrec [CreateConnectionOAuthRequestParameters]
readPrec :: ReadPrec CreateConnectionOAuthRequestParameters
$creadPrec :: ReadPrec CreateConnectionOAuthRequestParameters
readList :: ReadS [CreateConnectionOAuthRequestParameters]
$creadList :: ReadS [CreateConnectionOAuthRequestParameters]
readsPrec :: Int -> ReadS CreateConnectionOAuthRequestParameters
$creadsPrec :: Int -> ReadS CreateConnectionOAuthRequestParameters
Prelude.Read, Int -> CreateConnectionOAuthRequestParameters -> ShowS
[CreateConnectionOAuthRequestParameters] -> ShowS
CreateConnectionOAuthRequestParameters -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateConnectionOAuthRequestParameters] -> ShowS
$cshowList :: [CreateConnectionOAuthRequestParameters] -> ShowS
show :: CreateConnectionOAuthRequestParameters -> String
$cshow :: CreateConnectionOAuthRequestParameters -> String
showsPrec :: Int -> CreateConnectionOAuthRequestParameters -> ShowS
$cshowsPrec :: Int -> CreateConnectionOAuthRequestParameters -> ShowS
Prelude.Show, forall x.
Rep CreateConnectionOAuthRequestParameters x
-> CreateConnectionOAuthRequestParameters
forall x.
CreateConnectionOAuthRequestParameters
-> Rep CreateConnectionOAuthRequestParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateConnectionOAuthRequestParameters x
-> CreateConnectionOAuthRequestParameters
$cfrom :: forall x.
CreateConnectionOAuthRequestParameters
-> Rep CreateConnectionOAuthRequestParameters x
Prelude.Generic)

-- |
-- Create a value of 'CreateConnectionOAuthRequestParameters' 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:
--
-- 'oAuthHttpParameters', 'createConnectionOAuthRequestParameters_oAuthHttpParameters' - A @ConnectionHttpParameters@ object that contains details about the
-- additional parameters to use for the connection.
--
-- 'clientParameters', 'createConnectionOAuthRequestParameters_clientParameters' - A @CreateConnectionOAuthClientRequestParameters@ object that contains
-- the client parameters for OAuth authorization.
--
-- 'authorizationEndpoint', 'createConnectionOAuthRequestParameters_authorizationEndpoint' - The URL to the authorization endpoint when OAuth is specified as the
-- authorization type.
--
-- 'httpMethod', 'createConnectionOAuthRequestParameters_httpMethod' - The method to use for the authorization request.
newCreateConnectionOAuthRequestParameters ::
  -- | 'clientParameters'
  CreateConnectionOAuthClientRequestParameters ->
  -- | 'authorizationEndpoint'
  Prelude.Text ->
  -- | 'httpMethod'
  ConnectionOAuthHttpMethod ->
  CreateConnectionOAuthRequestParameters
newCreateConnectionOAuthRequestParameters :: CreateConnectionOAuthClientRequestParameters
-> Text
-> ConnectionOAuthHttpMethod
-> CreateConnectionOAuthRequestParameters
newCreateConnectionOAuthRequestParameters
  CreateConnectionOAuthClientRequestParameters
pClientParameters_
  Text
pAuthorizationEndpoint_
  ConnectionOAuthHttpMethod
pHttpMethod_ =
    CreateConnectionOAuthRequestParameters'
      { $sel:oAuthHttpParameters:CreateConnectionOAuthRequestParameters' :: Maybe ConnectionHttpParameters
oAuthHttpParameters =
          forall a. Maybe a
Prelude.Nothing,
        $sel:clientParameters:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthClientRequestParameters
clientParameters =
          CreateConnectionOAuthClientRequestParameters
pClientParameters_,
        $sel:authorizationEndpoint:CreateConnectionOAuthRequestParameters' :: Text
authorizationEndpoint =
          Text
pAuthorizationEndpoint_,
        $sel:httpMethod:CreateConnectionOAuthRequestParameters' :: ConnectionOAuthHttpMethod
httpMethod = ConnectionOAuthHttpMethod
pHttpMethod_
      }

-- | A @ConnectionHttpParameters@ object that contains details about the
-- additional parameters to use for the connection.
createConnectionOAuthRequestParameters_oAuthHttpParameters :: Lens.Lens' CreateConnectionOAuthRequestParameters (Prelude.Maybe ConnectionHttpParameters)
createConnectionOAuthRequestParameters_oAuthHttpParameters :: Lens'
  CreateConnectionOAuthRequestParameters
  (Maybe ConnectionHttpParameters)
createConnectionOAuthRequestParameters_oAuthHttpParameters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConnectionOAuthRequestParameters' {Maybe ConnectionHttpParameters
oAuthHttpParameters :: Maybe ConnectionHttpParameters
$sel:oAuthHttpParameters:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters
-> Maybe ConnectionHttpParameters
oAuthHttpParameters} -> Maybe ConnectionHttpParameters
oAuthHttpParameters) (\s :: CreateConnectionOAuthRequestParameters
s@CreateConnectionOAuthRequestParameters' {} Maybe ConnectionHttpParameters
a -> CreateConnectionOAuthRequestParameters
s {$sel:oAuthHttpParameters:CreateConnectionOAuthRequestParameters' :: Maybe ConnectionHttpParameters
oAuthHttpParameters = Maybe ConnectionHttpParameters
a} :: CreateConnectionOAuthRequestParameters)

-- | A @CreateConnectionOAuthClientRequestParameters@ object that contains
-- the client parameters for OAuth authorization.
createConnectionOAuthRequestParameters_clientParameters :: Lens.Lens' CreateConnectionOAuthRequestParameters CreateConnectionOAuthClientRequestParameters
createConnectionOAuthRequestParameters_clientParameters :: Lens'
  CreateConnectionOAuthRequestParameters
  CreateConnectionOAuthClientRequestParameters
createConnectionOAuthRequestParameters_clientParameters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConnectionOAuthRequestParameters' {CreateConnectionOAuthClientRequestParameters
clientParameters :: CreateConnectionOAuthClientRequestParameters
$sel:clientParameters:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters
-> CreateConnectionOAuthClientRequestParameters
clientParameters} -> CreateConnectionOAuthClientRequestParameters
clientParameters) (\s :: CreateConnectionOAuthRequestParameters
s@CreateConnectionOAuthRequestParameters' {} CreateConnectionOAuthClientRequestParameters
a -> CreateConnectionOAuthRequestParameters
s {$sel:clientParameters:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthClientRequestParameters
clientParameters = CreateConnectionOAuthClientRequestParameters
a} :: CreateConnectionOAuthRequestParameters)

-- | The URL to the authorization endpoint when OAuth is specified as the
-- authorization type.
createConnectionOAuthRequestParameters_authorizationEndpoint :: Lens.Lens' CreateConnectionOAuthRequestParameters Prelude.Text
createConnectionOAuthRequestParameters_authorizationEndpoint :: Lens' CreateConnectionOAuthRequestParameters Text
createConnectionOAuthRequestParameters_authorizationEndpoint = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConnectionOAuthRequestParameters' {Text
authorizationEndpoint :: Text
$sel:authorizationEndpoint:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters -> Text
authorizationEndpoint} -> Text
authorizationEndpoint) (\s :: CreateConnectionOAuthRequestParameters
s@CreateConnectionOAuthRequestParameters' {} Text
a -> CreateConnectionOAuthRequestParameters
s {$sel:authorizationEndpoint:CreateConnectionOAuthRequestParameters' :: Text
authorizationEndpoint = Text
a} :: CreateConnectionOAuthRequestParameters)

-- | The method to use for the authorization request.
createConnectionOAuthRequestParameters_httpMethod :: Lens.Lens' CreateConnectionOAuthRequestParameters ConnectionOAuthHttpMethod
createConnectionOAuthRequestParameters_httpMethod :: Lens'
  CreateConnectionOAuthRequestParameters ConnectionOAuthHttpMethod
createConnectionOAuthRequestParameters_httpMethod = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateConnectionOAuthRequestParameters' {ConnectionOAuthHttpMethod
httpMethod :: ConnectionOAuthHttpMethod
$sel:httpMethod:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters -> ConnectionOAuthHttpMethod
httpMethod} -> ConnectionOAuthHttpMethod
httpMethod) (\s :: CreateConnectionOAuthRequestParameters
s@CreateConnectionOAuthRequestParameters' {} ConnectionOAuthHttpMethod
a -> CreateConnectionOAuthRequestParameters
s {$sel:httpMethod:CreateConnectionOAuthRequestParameters' :: ConnectionOAuthHttpMethod
httpMethod = ConnectionOAuthHttpMethod
a} :: CreateConnectionOAuthRequestParameters)

instance
  Prelude.Hashable
    CreateConnectionOAuthRequestParameters
  where
  hashWithSalt :: Int -> CreateConnectionOAuthRequestParameters -> Int
hashWithSalt
    Int
_salt
    CreateConnectionOAuthRequestParameters' {Maybe ConnectionHttpParameters
Text
ConnectionOAuthHttpMethod
CreateConnectionOAuthClientRequestParameters
httpMethod :: ConnectionOAuthHttpMethod
authorizationEndpoint :: Text
clientParameters :: CreateConnectionOAuthClientRequestParameters
oAuthHttpParameters :: Maybe ConnectionHttpParameters
$sel:httpMethod:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters -> ConnectionOAuthHttpMethod
$sel:authorizationEndpoint:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters -> Text
$sel:clientParameters:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters
-> CreateConnectionOAuthClientRequestParameters
$sel:oAuthHttpParameters:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters
-> Maybe ConnectionHttpParameters
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ConnectionHttpParameters
oAuthHttpParameters
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` CreateConnectionOAuthClientRequestParameters
clientParameters
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
authorizationEndpoint
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ConnectionOAuthHttpMethod
httpMethod

instance
  Prelude.NFData
    CreateConnectionOAuthRequestParameters
  where
  rnf :: CreateConnectionOAuthRequestParameters -> ()
rnf CreateConnectionOAuthRequestParameters' {Maybe ConnectionHttpParameters
Text
ConnectionOAuthHttpMethod
CreateConnectionOAuthClientRequestParameters
httpMethod :: ConnectionOAuthHttpMethod
authorizationEndpoint :: Text
clientParameters :: CreateConnectionOAuthClientRequestParameters
oAuthHttpParameters :: Maybe ConnectionHttpParameters
$sel:httpMethod:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters -> ConnectionOAuthHttpMethod
$sel:authorizationEndpoint:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters -> Text
$sel:clientParameters:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters
-> CreateConnectionOAuthClientRequestParameters
$sel:oAuthHttpParameters:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters
-> Maybe ConnectionHttpParameters
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ConnectionHttpParameters
oAuthHttpParameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf CreateConnectionOAuthClientRequestParameters
clientParameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
authorizationEndpoint
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ConnectionOAuthHttpMethod
httpMethod

instance
  Data.ToJSON
    CreateConnectionOAuthRequestParameters
  where
  toJSON :: CreateConnectionOAuthRequestParameters -> Value
toJSON CreateConnectionOAuthRequestParameters' {Maybe ConnectionHttpParameters
Text
ConnectionOAuthHttpMethod
CreateConnectionOAuthClientRequestParameters
httpMethod :: ConnectionOAuthHttpMethod
authorizationEndpoint :: Text
clientParameters :: CreateConnectionOAuthClientRequestParameters
oAuthHttpParameters :: Maybe ConnectionHttpParameters
$sel:httpMethod:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters -> ConnectionOAuthHttpMethod
$sel:authorizationEndpoint:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters -> Text
$sel:clientParameters:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters
-> CreateConnectionOAuthClientRequestParameters
$sel:oAuthHttpParameters:CreateConnectionOAuthRequestParameters' :: CreateConnectionOAuthRequestParameters
-> Maybe ConnectionHttpParameters
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"OAuthHttpParameters" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ConnectionHttpParameters
oAuthHttpParameters,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ClientParameters" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= CreateConnectionOAuthClientRequestParameters
clientParameters),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"AuthorizationEndpoint"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
authorizationEndpoint
              ),
            forall a. a -> Maybe a
Prelude.Just (Key
"HttpMethod" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ConnectionOAuthHttpMethod
httpMethod)
          ]
      )