{-# 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.DocumentDB.CreateEventSubscription
-- 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)
--
-- Creates an Amazon DocumentDB event notification subscription. This
-- action requires a topic Amazon Resource Name (ARN) created by using the
-- Amazon DocumentDB console, the Amazon SNS console, or the Amazon SNS
-- API. To obtain an ARN with Amazon SNS, you must create a topic in Amazon
-- SNS and subscribe to the topic. The ARN is displayed in the Amazon SNS
-- console.
--
-- You can specify the type of source (@SourceType@) that you want to be
-- notified of. You can also provide a list of Amazon DocumentDB sources
-- (@SourceIds@) that trigger the events, and you can provide a list of
-- event categories (@EventCategories@) for events that you want to be
-- notified of. For example, you can specify @SourceType = db-instance@,
-- @SourceIds = mydbinstance1, mydbinstance2@ and
-- @EventCategories = Availability, Backup@.
--
-- If you specify both the @SourceType@ and @SourceIds@ (such as
-- @SourceType = db-instance@ and @SourceIdentifier = myDBInstance1@), you
-- are notified of all the @db-instance@ events for the specified source.
-- If you specify a @SourceType@ but do not specify a @SourceIdentifier@,
-- you receive notice of the events for that source type for all your
-- Amazon DocumentDB sources. If you do not specify either the @SourceType@
-- or the @SourceIdentifier@, you are notified of events generated from all
-- Amazon DocumentDB sources belonging to your customer account.
module Amazonka.DocumentDB.CreateEventSubscription
  ( -- * Creating a Request
    CreateEventSubscription (..),
    newCreateEventSubscription,

    -- * Request Lenses
    createEventSubscription_enabled,
    createEventSubscription_sourceType,
    createEventSubscription_eventCategories,
    createEventSubscription_sourceIds,
    createEventSubscription_tags,
    createEventSubscription_subscriptionName,
    createEventSubscription_snsTopicArn,

    -- * Destructuring the Response
    CreateEventSubscriptionResponse (..),
    newCreateEventSubscriptionResponse,

    -- * Response Lenses
    createEventSubscriptionResponse_eventSubscription,
    createEventSubscriptionResponse_httpStatus,
  )
where

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

-- | Represents the input to CreateEventSubscription.
--
-- /See:/ 'newCreateEventSubscription' smart constructor.
data CreateEventSubscription = CreateEventSubscription'
  { -- | A Boolean value; set to @true@ to activate the subscription, set to
    -- @false@ to create the subscription but not active it.
    CreateEventSubscription -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The type of source that is generating the events. For example, if you
    -- want to be notified of events generated by an instance, you would set
    -- this parameter to @db-instance@. If this value is not specified, all
    -- events are returned.
    --
    -- Valid values: @db-instance@, @db-cluster@, @db-parameter-group@,
    -- @db-security-group@, @db-cluster-snapshot@
    CreateEventSubscription -> Maybe Text
sourceType :: Prelude.Maybe Prelude.Text,
    -- | A list of event categories for a @SourceType@ that you want to subscribe
    -- to.
    CreateEventSubscription -> Maybe [Text]
eventCategories :: Prelude.Maybe [Prelude.Text],
    -- | The list of identifiers of the event sources for which events are
    -- returned. If not specified, then all sources are included in the
    -- response. An identifier must begin with a letter and must contain only
    -- ASCII letters, digits, and hyphens; it can\'t end with a hyphen or
    -- contain two consecutive hyphens.
    --
    -- Constraints:
    --
    -- -   If @SourceIds@ are provided, @SourceType@ must also be provided.
    --
    -- -   If the source type is an instance, a @DBInstanceIdentifier@ must be
    --     provided.
    --
    -- -   If the source type is a security group, a @DBSecurityGroupName@ must
    --     be provided.
    --
    -- -   If the source type is a parameter group, a @DBParameterGroupName@
    --     must be provided.
    --
    -- -   If the source type is a snapshot, a @DBSnapshotIdentifier@ must be
    --     provided.
    CreateEventSubscription -> Maybe [Text]
sourceIds :: Prelude.Maybe [Prelude.Text],
    -- | The tags to be assigned to the event subscription.
    CreateEventSubscription -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name of the subscription.
    --
    -- Constraints: The name must be fewer than 255 characters.
    CreateEventSubscription -> Text
subscriptionName :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the SNS topic created for event
    -- notification. Amazon SNS creates the ARN when you create a topic and
    -- subscribe to it.
    CreateEventSubscription -> Text
snsTopicArn :: Prelude.Text
  }
  deriving (CreateEventSubscription -> CreateEventSubscription -> Bool
(CreateEventSubscription -> CreateEventSubscription -> Bool)
-> (CreateEventSubscription -> CreateEventSubscription -> Bool)
-> Eq CreateEventSubscription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateEventSubscription -> CreateEventSubscription -> Bool
$c/= :: CreateEventSubscription -> CreateEventSubscription -> Bool
== :: CreateEventSubscription -> CreateEventSubscription -> Bool
$c== :: CreateEventSubscription -> CreateEventSubscription -> Bool
Prelude.Eq, ReadPrec [CreateEventSubscription]
ReadPrec CreateEventSubscription
Int -> ReadS CreateEventSubscription
ReadS [CreateEventSubscription]
(Int -> ReadS CreateEventSubscription)
-> ReadS [CreateEventSubscription]
-> ReadPrec CreateEventSubscription
-> ReadPrec [CreateEventSubscription]
-> Read CreateEventSubscription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateEventSubscription]
$creadListPrec :: ReadPrec [CreateEventSubscription]
readPrec :: ReadPrec CreateEventSubscription
$creadPrec :: ReadPrec CreateEventSubscription
readList :: ReadS [CreateEventSubscription]
$creadList :: ReadS [CreateEventSubscription]
readsPrec :: Int -> ReadS CreateEventSubscription
$creadsPrec :: Int -> ReadS CreateEventSubscription
Prelude.Read, Int -> CreateEventSubscription -> ShowS
[CreateEventSubscription] -> ShowS
CreateEventSubscription -> String
(Int -> CreateEventSubscription -> ShowS)
-> (CreateEventSubscription -> String)
-> ([CreateEventSubscription] -> ShowS)
-> Show CreateEventSubscription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateEventSubscription] -> ShowS
$cshowList :: [CreateEventSubscription] -> ShowS
show :: CreateEventSubscription -> String
$cshow :: CreateEventSubscription -> String
showsPrec :: Int -> CreateEventSubscription -> ShowS
$cshowsPrec :: Int -> CreateEventSubscription -> ShowS
Prelude.Show, (forall x.
 CreateEventSubscription -> Rep CreateEventSubscription x)
-> (forall x.
    Rep CreateEventSubscription x -> CreateEventSubscription)
-> Generic CreateEventSubscription
forall x. Rep CreateEventSubscription x -> CreateEventSubscription
forall x. CreateEventSubscription -> Rep CreateEventSubscription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateEventSubscription x -> CreateEventSubscription
$cfrom :: forall x. CreateEventSubscription -> Rep CreateEventSubscription x
Prelude.Generic)

-- |
-- Create a value of 'CreateEventSubscription' 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:
--
-- 'enabled', 'createEventSubscription_enabled' - A Boolean value; set to @true@ to activate the subscription, set to
-- @false@ to create the subscription but not active it.
--
-- 'sourceType', 'createEventSubscription_sourceType' - The type of source that is generating the events. For example, if you
-- want to be notified of events generated by an instance, you would set
-- this parameter to @db-instance@. If this value is not specified, all
-- events are returned.
--
-- Valid values: @db-instance@, @db-cluster@, @db-parameter-group@,
-- @db-security-group@, @db-cluster-snapshot@
--
-- 'eventCategories', 'createEventSubscription_eventCategories' - A list of event categories for a @SourceType@ that you want to subscribe
-- to.
--
-- 'sourceIds', 'createEventSubscription_sourceIds' - The list of identifiers of the event sources for which events are
-- returned. If not specified, then all sources are included in the
-- response. An identifier must begin with a letter and must contain only
-- ASCII letters, digits, and hyphens; it can\'t end with a hyphen or
-- contain two consecutive hyphens.
--
-- Constraints:
--
-- -   If @SourceIds@ are provided, @SourceType@ must also be provided.
--
-- -   If the source type is an instance, a @DBInstanceIdentifier@ must be
--     provided.
--
-- -   If the source type is a security group, a @DBSecurityGroupName@ must
--     be provided.
--
-- -   If the source type is a parameter group, a @DBParameterGroupName@
--     must be provided.
--
-- -   If the source type is a snapshot, a @DBSnapshotIdentifier@ must be
--     provided.
--
-- 'tags', 'createEventSubscription_tags' - The tags to be assigned to the event subscription.
--
-- 'subscriptionName', 'createEventSubscription_subscriptionName' - The name of the subscription.
--
-- Constraints: The name must be fewer than 255 characters.
--
-- 'snsTopicArn', 'createEventSubscription_snsTopicArn' - The Amazon Resource Name (ARN) of the SNS topic created for event
-- notification. Amazon SNS creates the ARN when you create a topic and
-- subscribe to it.
newCreateEventSubscription ::
  -- | 'subscriptionName'
  Prelude.Text ->
  -- | 'snsTopicArn'
  Prelude.Text ->
  CreateEventSubscription
newCreateEventSubscription :: Text -> Text -> CreateEventSubscription
newCreateEventSubscription
  Text
pSubscriptionName_
  Text
pSnsTopicArn_ =
    CreateEventSubscription' :: Maybe Bool
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Tag]
-> Text
-> Text
-> CreateEventSubscription
CreateEventSubscription'
      { $sel:enabled:CreateEventSubscription' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:sourceType:CreateEventSubscription' :: Maybe Text
sourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:eventCategories:CreateEventSubscription' :: Maybe [Text]
eventCategories = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:sourceIds:CreateEventSubscription' :: Maybe [Text]
sourceIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateEventSubscription' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
        $sel:subscriptionName:CreateEventSubscription' :: Text
subscriptionName = Text
pSubscriptionName_,
        $sel:snsTopicArn:CreateEventSubscription' :: Text
snsTopicArn = Text
pSnsTopicArn_
      }

-- | A Boolean value; set to @true@ to activate the subscription, set to
-- @false@ to create the subscription but not active it.
createEventSubscription_enabled :: Lens.Lens' CreateEventSubscription (Prelude.Maybe Prelude.Bool)
createEventSubscription_enabled :: (Maybe Bool -> f (Maybe Bool))
-> CreateEventSubscription -> f CreateEventSubscription
createEventSubscription_enabled = (CreateEventSubscription -> Maybe Bool)
-> (CreateEventSubscription
    -> Maybe Bool -> CreateEventSubscription)
-> Lens
     CreateEventSubscription
     CreateEventSubscription
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEventSubscription' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:CreateEventSubscription' :: CreateEventSubscription -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: CreateEventSubscription
s@CreateEventSubscription' {} Maybe Bool
a -> CreateEventSubscription
s {$sel:enabled:CreateEventSubscription' :: Maybe Bool
enabled = Maybe Bool
a} :: CreateEventSubscription)

-- | The type of source that is generating the events. For example, if you
-- want to be notified of events generated by an instance, you would set
-- this parameter to @db-instance@. If this value is not specified, all
-- events are returned.
--
-- Valid values: @db-instance@, @db-cluster@, @db-parameter-group@,
-- @db-security-group@, @db-cluster-snapshot@
createEventSubscription_sourceType :: Lens.Lens' CreateEventSubscription (Prelude.Maybe Prelude.Text)
createEventSubscription_sourceType :: (Maybe Text -> f (Maybe Text))
-> CreateEventSubscription -> f CreateEventSubscription
createEventSubscription_sourceType = (CreateEventSubscription -> Maybe Text)
-> (CreateEventSubscription
    -> Maybe Text -> CreateEventSubscription)
-> Lens
     CreateEventSubscription
     CreateEventSubscription
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEventSubscription' {Maybe Text
sourceType :: Maybe Text
$sel:sourceType:CreateEventSubscription' :: CreateEventSubscription -> Maybe Text
sourceType} -> Maybe Text
sourceType) (\s :: CreateEventSubscription
s@CreateEventSubscription' {} Maybe Text
a -> CreateEventSubscription
s {$sel:sourceType:CreateEventSubscription' :: Maybe Text
sourceType = Maybe Text
a} :: CreateEventSubscription)

-- | A list of event categories for a @SourceType@ that you want to subscribe
-- to.
createEventSubscription_eventCategories :: Lens.Lens' CreateEventSubscription (Prelude.Maybe [Prelude.Text])
createEventSubscription_eventCategories :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateEventSubscription -> f CreateEventSubscription
createEventSubscription_eventCategories = (CreateEventSubscription -> Maybe [Text])
-> (CreateEventSubscription
    -> Maybe [Text] -> CreateEventSubscription)
-> Lens
     CreateEventSubscription
     CreateEventSubscription
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEventSubscription' {Maybe [Text]
eventCategories :: Maybe [Text]
$sel:eventCategories:CreateEventSubscription' :: CreateEventSubscription -> Maybe [Text]
eventCategories} -> Maybe [Text]
eventCategories) (\s :: CreateEventSubscription
s@CreateEventSubscription' {} Maybe [Text]
a -> CreateEventSubscription
s {$sel:eventCategories:CreateEventSubscription' :: Maybe [Text]
eventCategories = Maybe [Text]
a} :: CreateEventSubscription) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateEventSubscription -> f CreateEventSubscription)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateEventSubscription
-> f CreateEventSubscription
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 list of identifiers of the event sources for which events are
-- returned. If not specified, then all sources are included in the
-- response. An identifier must begin with a letter and must contain only
-- ASCII letters, digits, and hyphens; it can\'t end with a hyphen or
-- contain two consecutive hyphens.
--
-- Constraints:
--
-- -   If @SourceIds@ are provided, @SourceType@ must also be provided.
--
-- -   If the source type is an instance, a @DBInstanceIdentifier@ must be
--     provided.
--
-- -   If the source type is a security group, a @DBSecurityGroupName@ must
--     be provided.
--
-- -   If the source type is a parameter group, a @DBParameterGroupName@
--     must be provided.
--
-- -   If the source type is a snapshot, a @DBSnapshotIdentifier@ must be
--     provided.
createEventSubscription_sourceIds :: Lens.Lens' CreateEventSubscription (Prelude.Maybe [Prelude.Text])
createEventSubscription_sourceIds :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateEventSubscription -> f CreateEventSubscription
createEventSubscription_sourceIds = (CreateEventSubscription -> Maybe [Text])
-> (CreateEventSubscription
    -> Maybe [Text] -> CreateEventSubscription)
-> Lens
     CreateEventSubscription
     CreateEventSubscription
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEventSubscription' {Maybe [Text]
sourceIds :: Maybe [Text]
$sel:sourceIds:CreateEventSubscription' :: CreateEventSubscription -> Maybe [Text]
sourceIds} -> Maybe [Text]
sourceIds) (\s :: CreateEventSubscription
s@CreateEventSubscription' {} Maybe [Text]
a -> CreateEventSubscription
s {$sel:sourceIds:CreateEventSubscription' :: Maybe [Text]
sourceIds = Maybe [Text]
a} :: CreateEventSubscription) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateEventSubscription -> f CreateEventSubscription)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateEventSubscription
-> f CreateEventSubscription
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 tags to be assigned to the event subscription.
createEventSubscription_tags :: Lens.Lens' CreateEventSubscription (Prelude.Maybe [Tag])
createEventSubscription_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateEventSubscription -> f CreateEventSubscription
createEventSubscription_tags = (CreateEventSubscription -> Maybe [Tag])
-> (CreateEventSubscription
    -> Maybe [Tag] -> CreateEventSubscription)
-> Lens
     CreateEventSubscription
     CreateEventSubscription
     (Maybe [Tag])
     (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEventSubscription' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateEventSubscription' :: CreateEventSubscription -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateEventSubscription
s@CreateEventSubscription' {} Maybe [Tag]
a -> CreateEventSubscription
s {$sel:tags:CreateEventSubscription' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateEventSubscription) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateEventSubscription -> f CreateEventSubscription)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateEventSubscription
-> f CreateEventSubscription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the subscription.
--
-- Constraints: The name must be fewer than 255 characters.
createEventSubscription_subscriptionName :: Lens.Lens' CreateEventSubscription Prelude.Text
createEventSubscription_subscriptionName :: (Text -> f Text)
-> CreateEventSubscription -> f CreateEventSubscription
createEventSubscription_subscriptionName = (CreateEventSubscription -> Text)
-> (CreateEventSubscription -> Text -> CreateEventSubscription)
-> Lens CreateEventSubscription CreateEventSubscription Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEventSubscription' {Text
subscriptionName :: Text
$sel:subscriptionName:CreateEventSubscription' :: CreateEventSubscription -> Text
subscriptionName} -> Text
subscriptionName) (\s :: CreateEventSubscription
s@CreateEventSubscription' {} Text
a -> CreateEventSubscription
s {$sel:subscriptionName:CreateEventSubscription' :: Text
subscriptionName = Text
a} :: CreateEventSubscription)

-- | The Amazon Resource Name (ARN) of the SNS topic created for event
-- notification. Amazon SNS creates the ARN when you create a topic and
-- subscribe to it.
createEventSubscription_snsTopicArn :: Lens.Lens' CreateEventSubscription Prelude.Text
createEventSubscription_snsTopicArn :: (Text -> f Text)
-> CreateEventSubscription -> f CreateEventSubscription
createEventSubscription_snsTopicArn = (CreateEventSubscription -> Text)
-> (CreateEventSubscription -> Text -> CreateEventSubscription)
-> Lens CreateEventSubscription CreateEventSubscription Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEventSubscription' {Text
snsTopicArn :: Text
$sel:snsTopicArn:CreateEventSubscription' :: CreateEventSubscription -> Text
snsTopicArn} -> Text
snsTopicArn) (\s :: CreateEventSubscription
s@CreateEventSubscription' {} Text
a -> CreateEventSubscription
s {$sel:snsTopicArn:CreateEventSubscription' :: Text
snsTopicArn = Text
a} :: CreateEventSubscription)

instance Core.AWSRequest CreateEventSubscription where
  type
    AWSResponse CreateEventSubscription =
      CreateEventSubscriptionResponse
  request :: CreateEventSubscription -> Request CreateEventSubscription
request = Service
-> CreateEventSubscription -> Request CreateEventSubscription
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateEventSubscription
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateEventSubscription)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse CreateEventSubscription))
-> Logger
-> Service
-> Proxy CreateEventSubscription
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateEventSubscription)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"CreateEventSubscriptionResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe EventSubscription -> Int -> CreateEventSubscriptionResponse
CreateEventSubscriptionResponse'
            (Maybe EventSubscription -> Int -> CreateEventSubscriptionResponse)
-> Either String (Maybe EventSubscription)
-> Either String (Int -> CreateEventSubscriptionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe EventSubscription)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"EventSubscription")
            Either String (Int -> CreateEventSubscriptionResponse)
-> Either String Int
-> Either String CreateEventSubscriptionResponse
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 CreateEventSubscription

instance Prelude.NFData CreateEventSubscription

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

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

instance Core.ToQuery CreateEventSubscription where
  toQuery :: CreateEventSubscription -> QueryString
toQuery CreateEventSubscription' {Maybe Bool
Maybe [Text]
Maybe [Tag]
Maybe Text
Text
snsTopicArn :: Text
subscriptionName :: Text
tags :: Maybe [Tag]
sourceIds :: Maybe [Text]
eventCategories :: Maybe [Text]
sourceType :: Maybe Text
enabled :: Maybe Bool
$sel:snsTopicArn:CreateEventSubscription' :: CreateEventSubscription -> Text
$sel:subscriptionName:CreateEventSubscription' :: CreateEventSubscription -> Text
$sel:tags:CreateEventSubscription' :: CreateEventSubscription -> Maybe [Tag]
$sel:sourceIds:CreateEventSubscription' :: CreateEventSubscription -> Maybe [Text]
$sel:eventCategories:CreateEventSubscription' :: CreateEventSubscription -> Maybe [Text]
$sel:sourceType:CreateEventSubscription' :: CreateEventSubscription -> Maybe Text
$sel:enabled:CreateEventSubscription' :: CreateEventSubscription -> Maybe Bool
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"CreateEventSubscription" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2014-10-31" :: Prelude.ByteString),
        ByteString
"Enabled" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
enabled,
        ByteString
"SourceType" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
sourceType,
        ByteString
"EventCategories"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"EventCategory"
                ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
eventCategories
            ),
        ByteString
"SourceIds"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"SourceId" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
sourceIds),
        ByteString
"Tags"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Tag] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"Tag" ([Tag] -> QueryString) -> Maybe [Tag] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags),
        ByteString
"SubscriptionName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
subscriptionName,
        ByteString
"SnsTopicArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
snsTopicArn
      ]

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

-- |
-- Create a value of 'CreateEventSubscriptionResponse' 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:
--
-- 'eventSubscription', 'createEventSubscriptionResponse_eventSubscription' - Undocumented member.
--
-- 'httpStatus', 'createEventSubscriptionResponse_httpStatus' - The response's http status code.
newCreateEventSubscriptionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateEventSubscriptionResponse
newCreateEventSubscriptionResponse :: Int -> CreateEventSubscriptionResponse
newCreateEventSubscriptionResponse Int
pHttpStatus_ =
  CreateEventSubscriptionResponse' :: Maybe EventSubscription -> Int -> CreateEventSubscriptionResponse
CreateEventSubscriptionResponse'
    { $sel:eventSubscription:CreateEventSubscriptionResponse' :: Maybe EventSubscription
eventSubscription =
        Maybe EventSubscription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateEventSubscriptionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
createEventSubscriptionResponse_eventSubscription :: Lens.Lens' CreateEventSubscriptionResponse (Prelude.Maybe EventSubscription)
createEventSubscriptionResponse_eventSubscription :: (Maybe EventSubscription -> f (Maybe EventSubscription))
-> CreateEventSubscriptionResponse
-> f CreateEventSubscriptionResponse
createEventSubscriptionResponse_eventSubscription = (CreateEventSubscriptionResponse -> Maybe EventSubscription)
-> (CreateEventSubscriptionResponse
    -> Maybe EventSubscription -> CreateEventSubscriptionResponse)
-> Lens
     CreateEventSubscriptionResponse
     CreateEventSubscriptionResponse
     (Maybe EventSubscription)
     (Maybe EventSubscription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEventSubscriptionResponse' {Maybe EventSubscription
eventSubscription :: Maybe EventSubscription
$sel:eventSubscription:CreateEventSubscriptionResponse' :: CreateEventSubscriptionResponse -> Maybe EventSubscription
eventSubscription} -> Maybe EventSubscription
eventSubscription) (\s :: CreateEventSubscriptionResponse
s@CreateEventSubscriptionResponse' {} Maybe EventSubscription
a -> CreateEventSubscriptionResponse
s {$sel:eventSubscription:CreateEventSubscriptionResponse' :: Maybe EventSubscription
eventSubscription = Maybe EventSubscription
a} :: CreateEventSubscriptionResponse)

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

instance
  Prelude.NFData
    CreateEventSubscriptionResponse