{-# 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-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)
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.Lens as Lens
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
(CreateConnectionOAuthRequestParameters
 -> CreateConnectionOAuthRequestParameters -> Bool)
-> (CreateConnectionOAuthRequestParameters
    -> CreateConnectionOAuthRequestParameters -> Bool)
-> Eq CreateConnectionOAuthRequestParameters
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]
(Int -> ReadS CreateConnectionOAuthRequestParameters)
-> ReadS [CreateConnectionOAuthRequestParameters]
-> ReadPrec CreateConnectionOAuthRequestParameters
-> ReadPrec [CreateConnectionOAuthRequestParameters]
-> Read 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
(Int -> CreateConnectionOAuthRequestParameters -> ShowS)
-> (CreateConnectionOAuthRequestParameters -> String)
-> ([CreateConnectionOAuthRequestParameters] -> ShowS)
-> Show CreateConnectionOAuthRequestParameters
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.
 CreateConnectionOAuthRequestParameters
 -> Rep CreateConnectionOAuthRequestParameters x)
-> (forall x.
    Rep CreateConnectionOAuthRequestParameters x
    -> CreateConnectionOAuthRequestParameters)
-> Generic CreateConnectionOAuthRequestParameters
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' :: Maybe ConnectionHttpParameters
-> CreateConnectionOAuthClientRequestParameters
-> Text
-> ConnectionOAuthHttpMethod
-> CreateConnectionOAuthRequestParameters
CreateConnectionOAuthRequestParameters'
      { $sel:oAuthHttpParameters:CreateConnectionOAuthRequestParameters' :: Maybe ConnectionHttpParameters
oAuthHttpParameters =
          Maybe ConnectionHttpParameters
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 :: (Maybe ConnectionHttpParameters
 -> f (Maybe ConnectionHttpParameters))
-> CreateConnectionOAuthRequestParameters
-> f CreateConnectionOAuthRequestParameters
createConnectionOAuthRequestParameters_oAuthHttpParameters = (CreateConnectionOAuthRequestParameters
 -> Maybe ConnectionHttpParameters)
-> (CreateConnectionOAuthRequestParameters
    -> Maybe ConnectionHttpParameters
    -> CreateConnectionOAuthRequestParameters)
-> Lens
     CreateConnectionOAuthRequestParameters
     CreateConnectionOAuthRequestParameters
     (Maybe ConnectionHttpParameters)
     (Maybe ConnectionHttpParameters)
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 :: (CreateConnectionOAuthClientRequestParameters
 -> f CreateConnectionOAuthClientRequestParameters)
-> CreateConnectionOAuthRequestParameters
-> f CreateConnectionOAuthRequestParameters
createConnectionOAuthRequestParameters_clientParameters = (CreateConnectionOAuthRequestParameters
 -> CreateConnectionOAuthClientRequestParameters)
-> (CreateConnectionOAuthRequestParameters
    -> CreateConnectionOAuthClientRequestParameters
    -> CreateConnectionOAuthRequestParameters)
-> Lens
     CreateConnectionOAuthRequestParameters
     CreateConnectionOAuthRequestParameters
     CreateConnectionOAuthClientRequestParameters
     CreateConnectionOAuthClientRequestParameters
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 :: (Text -> f Text)
-> CreateConnectionOAuthRequestParameters
-> f CreateConnectionOAuthRequestParameters
createConnectionOAuthRequestParameters_authorizationEndpoint = (CreateConnectionOAuthRequestParameters -> Text)
-> (CreateConnectionOAuthRequestParameters
    -> Text -> CreateConnectionOAuthRequestParameters)
-> Lens
     CreateConnectionOAuthRequestParameters
     CreateConnectionOAuthRequestParameters
     Text
     Text
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 :: (ConnectionOAuthHttpMethod -> f ConnectionOAuthHttpMethod)
-> CreateConnectionOAuthRequestParameters
-> f CreateConnectionOAuthRequestParameters
createConnectionOAuthRequestParameters_httpMethod = (CreateConnectionOAuthRequestParameters
 -> ConnectionOAuthHttpMethod)
-> (CreateConnectionOAuthRequestParameters
    -> ConnectionOAuthHttpMethod
    -> CreateConnectionOAuthRequestParameters)
-> Lens
     CreateConnectionOAuthRequestParameters
     CreateConnectionOAuthRequestParameters
     ConnectionOAuthHttpMethod
     ConnectionOAuthHttpMethod
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

instance
  Prelude.NFData
    CreateConnectionOAuthRequestParameters

instance
  Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"OAuthHttpParameters" Text -> ConnectionHttpParameters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ConnectionHttpParameters -> Pair)
-> Maybe ConnectionHttpParameters -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ConnectionHttpParameters
oAuthHttpParameters,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ClientParameters" Text -> CreateConnectionOAuthClientRequestParameters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= CreateConnectionOAuthClientRequestParameters
clientParameters),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"AuthorizationEndpoint"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
authorizationEndpoint
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"HttpMethod" Text -> ConnectionOAuthHttpMethod -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ConnectionOAuthHttpMethod
httpMethod)
          ]
      )