{-# 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.SecurityLake.CreateDatalakeExceptionsSubscription
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates the specified notification subscription in Amazon Security Lake
-- for the organization you specify.
module Amazonka.SecurityLake.CreateDatalakeExceptionsSubscription
  ( -- * Creating a Request
    CreateDatalakeExceptionsSubscription (..),
    newCreateDatalakeExceptionsSubscription,

    -- * Request Lenses
    createDatalakeExceptionsSubscription_notificationEndpoint,
    createDatalakeExceptionsSubscription_subscriptionProtocol,

    -- * Destructuring the Response
    CreateDatalakeExceptionsSubscriptionResponse (..),
    newCreateDatalakeExceptionsSubscriptionResponse,

    -- * Response Lenses
    createDatalakeExceptionsSubscriptionResponse_httpStatus,
  )
where

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
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SecurityLake.Types

-- | /See:/ 'newCreateDatalakeExceptionsSubscription' smart constructor.
data CreateDatalakeExceptionsSubscription = CreateDatalakeExceptionsSubscription'
  { -- | The Amazon Web Services account where you want to receive exception
    -- notifications.
    CreateDatalakeExceptionsSubscription -> Text
notificationEndpoint :: Prelude.Text,
    -- | The subscription protocol to which exception notifications are posted.
    CreateDatalakeExceptionsSubscription -> SubscriptionProtocolType
subscriptionProtocol :: SubscriptionProtocolType
  }
  deriving (CreateDatalakeExceptionsSubscription
-> CreateDatalakeExceptionsSubscription -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDatalakeExceptionsSubscription
-> CreateDatalakeExceptionsSubscription -> Bool
$c/= :: CreateDatalakeExceptionsSubscription
-> CreateDatalakeExceptionsSubscription -> Bool
== :: CreateDatalakeExceptionsSubscription
-> CreateDatalakeExceptionsSubscription -> Bool
$c== :: CreateDatalakeExceptionsSubscription
-> CreateDatalakeExceptionsSubscription -> Bool
Prelude.Eq, ReadPrec [CreateDatalakeExceptionsSubscription]
ReadPrec CreateDatalakeExceptionsSubscription
Int -> ReadS CreateDatalakeExceptionsSubscription
ReadS [CreateDatalakeExceptionsSubscription]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDatalakeExceptionsSubscription]
$creadListPrec :: ReadPrec [CreateDatalakeExceptionsSubscription]
readPrec :: ReadPrec CreateDatalakeExceptionsSubscription
$creadPrec :: ReadPrec CreateDatalakeExceptionsSubscription
readList :: ReadS [CreateDatalakeExceptionsSubscription]
$creadList :: ReadS [CreateDatalakeExceptionsSubscription]
readsPrec :: Int -> ReadS CreateDatalakeExceptionsSubscription
$creadsPrec :: Int -> ReadS CreateDatalakeExceptionsSubscription
Prelude.Read, Int -> CreateDatalakeExceptionsSubscription -> ShowS
[CreateDatalakeExceptionsSubscription] -> ShowS
CreateDatalakeExceptionsSubscription -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDatalakeExceptionsSubscription] -> ShowS
$cshowList :: [CreateDatalakeExceptionsSubscription] -> ShowS
show :: CreateDatalakeExceptionsSubscription -> String
$cshow :: CreateDatalakeExceptionsSubscription -> String
showsPrec :: Int -> CreateDatalakeExceptionsSubscription -> ShowS
$cshowsPrec :: Int -> CreateDatalakeExceptionsSubscription -> ShowS
Prelude.Show, forall x.
Rep CreateDatalakeExceptionsSubscription x
-> CreateDatalakeExceptionsSubscription
forall x.
CreateDatalakeExceptionsSubscription
-> Rep CreateDatalakeExceptionsSubscription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDatalakeExceptionsSubscription x
-> CreateDatalakeExceptionsSubscription
$cfrom :: forall x.
CreateDatalakeExceptionsSubscription
-> Rep CreateDatalakeExceptionsSubscription x
Prelude.Generic)

-- |
-- Create a value of 'CreateDatalakeExceptionsSubscription' 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:
--
-- 'notificationEndpoint', 'createDatalakeExceptionsSubscription_notificationEndpoint' - The Amazon Web Services account where you want to receive exception
-- notifications.
--
-- 'subscriptionProtocol', 'createDatalakeExceptionsSubscription_subscriptionProtocol' - The subscription protocol to which exception notifications are posted.
newCreateDatalakeExceptionsSubscription ::
  -- | 'notificationEndpoint'
  Prelude.Text ->
  -- | 'subscriptionProtocol'
  SubscriptionProtocolType ->
  CreateDatalakeExceptionsSubscription
newCreateDatalakeExceptionsSubscription :: Text
-> SubscriptionProtocolType -> CreateDatalakeExceptionsSubscription
newCreateDatalakeExceptionsSubscription
  Text
pNotificationEndpoint_
  SubscriptionProtocolType
pSubscriptionProtocol_ =
    CreateDatalakeExceptionsSubscription'
      { $sel:notificationEndpoint:CreateDatalakeExceptionsSubscription' :: Text
notificationEndpoint =
          Text
pNotificationEndpoint_,
        $sel:subscriptionProtocol:CreateDatalakeExceptionsSubscription' :: SubscriptionProtocolType
subscriptionProtocol =
          SubscriptionProtocolType
pSubscriptionProtocol_
      }

-- | The Amazon Web Services account where you want to receive exception
-- notifications.
createDatalakeExceptionsSubscription_notificationEndpoint :: Lens.Lens' CreateDatalakeExceptionsSubscription Prelude.Text
createDatalakeExceptionsSubscription_notificationEndpoint :: Lens' CreateDatalakeExceptionsSubscription Text
createDatalakeExceptionsSubscription_notificationEndpoint = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDatalakeExceptionsSubscription' {Text
notificationEndpoint :: Text
$sel:notificationEndpoint:CreateDatalakeExceptionsSubscription' :: CreateDatalakeExceptionsSubscription -> Text
notificationEndpoint} -> Text
notificationEndpoint) (\s :: CreateDatalakeExceptionsSubscription
s@CreateDatalakeExceptionsSubscription' {} Text
a -> CreateDatalakeExceptionsSubscription
s {$sel:notificationEndpoint:CreateDatalakeExceptionsSubscription' :: Text
notificationEndpoint = Text
a} :: CreateDatalakeExceptionsSubscription)

-- | The subscription protocol to which exception notifications are posted.
createDatalakeExceptionsSubscription_subscriptionProtocol :: Lens.Lens' CreateDatalakeExceptionsSubscription SubscriptionProtocolType
createDatalakeExceptionsSubscription_subscriptionProtocol :: Lens' CreateDatalakeExceptionsSubscription SubscriptionProtocolType
createDatalakeExceptionsSubscription_subscriptionProtocol = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDatalakeExceptionsSubscription' {SubscriptionProtocolType
subscriptionProtocol :: SubscriptionProtocolType
$sel:subscriptionProtocol:CreateDatalakeExceptionsSubscription' :: CreateDatalakeExceptionsSubscription -> SubscriptionProtocolType
subscriptionProtocol} -> SubscriptionProtocolType
subscriptionProtocol) (\s :: CreateDatalakeExceptionsSubscription
s@CreateDatalakeExceptionsSubscription' {} SubscriptionProtocolType
a -> CreateDatalakeExceptionsSubscription
s {$sel:subscriptionProtocol:CreateDatalakeExceptionsSubscription' :: SubscriptionProtocolType
subscriptionProtocol = SubscriptionProtocolType
a} :: CreateDatalakeExceptionsSubscription)

instance
  Core.AWSRequest
    CreateDatalakeExceptionsSubscription
  where
  type
    AWSResponse CreateDatalakeExceptionsSubscription =
      CreateDatalakeExceptionsSubscriptionResponse
  request :: (Service -> Service)
-> CreateDatalakeExceptionsSubscription
-> Request CreateDatalakeExceptionsSubscription
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 CreateDatalakeExceptionsSubscription
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse CreateDatalakeExceptionsSubscription)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> CreateDatalakeExceptionsSubscriptionResponse
CreateDatalakeExceptionsSubscriptionResponse'
            forall (f :: * -> *) a b. Functor 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
    CreateDatalakeExceptionsSubscription
  where
  hashWithSalt :: Int -> CreateDatalakeExceptionsSubscription -> Int
hashWithSalt
    Int
_salt
    CreateDatalakeExceptionsSubscription' {Text
SubscriptionProtocolType
subscriptionProtocol :: SubscriptionProtocolType
notificationEndpoint :: Text
$sel:subscriptionProtocol:CreateDatalakeExceptionsSubscription' :: CreateDatalakeExceptionsSubscription -> SubscriptionProtocolType
$sel:notificationEndpoint:CreateDatalakeExceptionsSubscription' :: CreateDatalakeExceptionsSubscription -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
notificationEndpoint
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SubscriptionProtocolType
subscriptionProtocol

instance
  Prelude.NFData
    CreateDatalakeExceptionsSubscription
  where
  rnf :: CreateDatalakeExceptionsSubscription -> ()
rnf CreateDatalakeExceptionsSubscription' {Text
SubscriptionProtocolType
subscriptionProtocol :: SubscriptionProtocolType
notificationEndpoint :: Text
$sel:subscriptionProtocol:CreateDatalakeExceptionsSubscription' :: CreateDatalakeExceptionsSubscription -> SubscriptionProtocolType
$sel:notificationEndpoint:CreateDatalakeExceptionsSubscription' :: CreateDatalakeExceptionsSubscription -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
notificationEndpoint
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SubscriptionProtocolType
subscriptionProtocol

instance
  Data.ToHeaders
    CreateDatalakeExceptionsSubscription
  where
  toHeaders :: CreateDatalakeExceptionsSubscription -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance
  Data.ToJSON
    CreateDatalakeExceptionsSubscription
  where
  toJSON :: CreateDatalakeExceptionsSubscription -> Value
toJSON CreateDatalakeExceptionsSubscription' {Text
SubscriptionProtocolType
subscriptionProtocol :: SubscriptionProtocolType
notificationEndpoint :: Text
$sel:subscriptionProtocol:CreateDatalakeExceptionsSubscription' :: CreateDatalakeExceptionsSubscription -> SubscriptionProtocolType
$sel:notificationEndpoint:CreateDatalakeExceptionsSubscription' :: CreateDatalakeExceptionsSubscription -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"notificationEndpoint"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
notificationEndpoint
              ),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"subscriptionProtocol"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SubscriptionProtocolType
subscriptionProtocol
              )
          ]
      )

instance
  Data.ToPath
    CreateDatalakeExceptionsSubscription
  where
  toPath :: CreateDatalakeExceptionsSubscription -> ByteString
toPath =
    forall a b. a -> b -> a
Prelude.const
      ByteString
"/v1/datalake/exceptions/subscription"

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

-- | /See:/ 'newCreateDatalakeExceptionsSubscriptionResponse' smart constructor.
data CreateDatalakeExceptionsSubscriptionResponse = CreateDatalakeExceptionsSubscriptionResponse'
  { -- | The response's http status code.
    CreateDatalakeExceptionsSubscriptionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateDatalakeExceptionsSubscriptionResponse
-> CreateDatalakeExceptionsSubscriptionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDatalakeExceptionsSubscriptionResponse
-> CreateDatalakeExceptionsSubscriptionResponse -> Bool
$c/= :: CreateDatalakeExceptionsSubscriptionResponse
-> CreateDatalakeExceptionsSubscriptionResponse -> Bool
== :: CreateDatalakeExceptionsSubscriptionResponse
-> CreateDatalakeExceptionsSubscriptionResponse -> Bool
$c== :: CreateDatalakeExceptionsSubscriptionResponse
-> CreateDatalakeExceptionsSubscriptionResponse -> Bool
Prelude.Eq, ReadPrec [CreateDatalakeExceptionsSubscriptionResponse]
ReadPrec CreateDatalakeExceptionsSubscriptionResponse
Int -> ReadS CreateDatalakeExceptionsSubscriptionResponse
ReadS [CreateDatalakeExceptionsSubscriptionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDatalakeExceptionsSubscriptionResponse]
$creadListPrec :: ReadPrec [CreateDatalakeExceptionsSubscriptionResponse]
readPrec :: ReadPrec CreateDatalakeExceptionsSubscriptionResponse
$creadPrec :: ReadPrec CreateDatalakeExceptionsSubscriptionResponse
readList :: ReadS [CreateDatalakeExceptionsSubscriptionResponse]
$creadList :: ReadS [CreateDatalakeExceptionsSubscriptionResponse]
readsPrec :: Int -> ReadS CreateDatalakeExceptionsSubscriptionResponse
$creadsPrec :: Int -> ReadS CreateDatalakeExceptionsSubscriptionResponse
Prelude.Read, Int -> CreateDatalakeExceptionsSubscriptionResponse -> ShowS
[CreateDatalakeExceptionsSubscriptionResponse] -> ShowS
CreateDatalakeExceptionsSubscriptionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDatalakeExceptionsSubscriptionResponse] -> ShowS
$cshowList :: [CreateDatalakeExceptionsSubscriptionResponse] -> ShowS
show :: CreateDatalakeExceptionsSubscriptionResponse -> String
$cshow :: CreateDatalakeExceptionsSubscriptionResponse -> String
showsPrec :: Int -> CreateDatalakeExceptionsSubscriptionResponse -> ShowS
$cshowsPrec :: Int -> CreateDatalakeExceptionsSubscriptionResponse -> ShowS
Prelude.Show, forall x.
Rep CreateDatalakeExceptionsSubscriptionResponse x
-> CreateDatalakeExceptionsSubscriptionResponse
forall x.
CreateDatalakeExceptionsSubscriptionResponse
-> Rep CreateDatalakeExceptionsSubscriptionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDatalakeExceptionsSubscriptionResponse x
-> CreateDatalakeExceptionsSubscriptionResponse
$cfrom :: forall x.
CreateDatalakeExceptionsSubscriptionResponse
-> Rep CreateDatalakeExceptionsSubscriptionResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateDatalakeExceptionsSubscriptionResponse' 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:
--
-- 'httpStatus', 'createDatalakeExceptionsSubscriptionResponse_httpStatus' - The response's http status code.
newCreateDatalakeExceptionsSubscriptionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateDatalakeExceptionsSubscriptionResponse
newCreateDatalakeExceptionsSubscriptionResponse :: Int -> CreateDatalakeExceptionsSubscriptionResponse
newCreateDatalakeExceptionsSubscriptionResponse
  Int
pHttpStatus_ =
    CreateDatalakeExceptionsSubscriptionResponse'
      { $sel:httpStatus:CreateDatalakeExceptionsSubscriptionResponse' :: Int
httpStatus =
          Int
pHttpStatus_
      }

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

instance
  Prelude.NFData
    CreateDatalakeExceptionsSubscriptionResponse
  where
  rnf :: CreateDatalakeExceptionsSubscriptionResponse -> ()
rnf CreateDatalakeExceptionsSubscriptionResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateDatalakeExceptionsSubscriptionResponse' :: CreateDatalakeExceptionsSubscriptionResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus