{-# 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.CodeStarNotifications.CreateNotificationRule
-- 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 a notification rule for a resource. The rule specifies the
-- events you want notifications about and the targets (such as SNS topics)
-- where you want to receive them.
module Amazonka.CodeStarNotifications.CreateNotificationRule
  ( -- * Creating a Request
    CreateNotificationRule (..),
    newCreateNotificationRule,

    -- * Request Lenses
    createNotificationRule_status,
    createNotificationRule_clientRequestToken,
    createNotificationRule_tags,
    createNotificationRule_name,
    createNotificationRule_eventTypeIds,
    createNotificationRule_resource,
    createNotificationRule_targets,
    createNotificationRule_detailType,

    -- * Destructuring the Response
    CreateNotificationRuleResponse (..),
    newCreateNotificationRuleResponse,

    -- * Response Lenses
    createNotificationRuleResponse_arn,
    createNotificationRuleResponse_httpStatus,
  )
where

import Amazonka.CodeStarNotifications.Types
import qualified Amazonka.Core as Core
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:/ 'newCreateNotificationRule' smart constructor.
data CreateNotificationRule = CreateNotificationRule'
  { -- | The status of the notification rule. The default value is ENABLED. If
    -- the status is set to DISABLED, notifications aren\'t sent for the
    -- notification rule.
    CreateNotificationRule -> Maybe NotificationRuleStatus
status :: Prelude.Maybe NotificationRuleStatus,
    -- | A unique, client-generated idempotency token that, when provided in a
    -- request, ensures the request cannot be repeated with a changed
    -- parameter. If a request with the same parameters is received and a token
    -- is included, the request returns information about the initial request
    -- that used that token.
    --
    -- The AWS SDKs prepopulate client request tokens. If you are using an AWS
    -- SDK, an idempotency token is created for you.
    CreateNotificationRule -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | A list of tags to apply to this notification rule. Key names cannot
    -- start with \"aws\".
    CreateNotificationRule -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name for the notification rule. Notifictaion rule names must be
    -- unique in your AWS account.
    CreateNotificationRule -> Sensitive Text
name :: Core.Sensitive Prelude.Text,
    -- | A list of event types associated with this notification rule. For a list
    -- of allowed events, see EventTypeSummary.
    CreateNotificationRule -> [Text]
eventTypeIds :: [Prelude.Text],
    -- | The Amazon Resource Name (ARN) of the resource to associate with the
    -- notification rule. Supported resources include pipelines in AWS
    -- CodePipeline, repositories in AWS CodeCommit, and build projects in AWS
    -- CodeBuild.
    CreateNotificationRule -> Text
resource :: Prelude.Text,
    -- | A list of Amazon Resource Names (ARNs) of SNS topics to associate with
    -- the notification rule.
    CreateNotificationRule -> [Target]
targets :: [Target],
    -- | The level of detail to include in the notifications for this resource.
    -- BASIC will include only the contents of the event as it would appear in
    -- AWS CloudWatch. FULL will include any supplemental information provided
    -- by AWS CodeStar Notifications and\/or the service for the resource for
    -- which the notification is created.
    CreateNotificationRule -> DetailType
detailType :: DetailType
  }
  deriving (CreateNotificationRule -> CreateNotificationRule -> Bool
(CreateNotificationRule -> CreateNotificationRule -> Bool)
-> (CreateNotificationRule -> CreateNotificationRule -> Bool)
-> Eq CreateNotificationRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateNotificationRule -> CreateNotificationRule -> Bool
$c/= :: CreateNotificationRule -> CreateNotificationRule -> Bool
== :: CreateNotificationRule -> CreateNotificationRule -> Bool
$c== :: CreateNotificationRule -> CreateNotificationRule -> Bool
Prelude.Eq, Int -> CreateNotificationRule -> ShowS
[CreateNotificationRule] -> ShowS
CreateNotificationRule -> String
(Int -> CreateNotificationRule -> ShowS)
-> (CreateNotificationRule -> String)
-> ([CreateNotificationRule] -> ShowS)
-> Show CreateNotificationRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateNotificationRule] -> ShowS
$cshowList :: [CreateNotificationRule] -> ShowS
show :: CreateNotificationRule -> String
$cshow :: CreateNotificationRule -> String
showsPrec :: Int -> CreateNotificationRule -> ShowS
$cshowsPrec :: Int -> CreateNotificationRule -> ShowS
Prelude.Show, (forall x. CreateNotificationRule -> Rep CreateNotificationRule x)
-> (forall x.
    Rep CreateNotificationRule x -> CreateNotificationRule)
-> Generic CreateNotificationRule
forall x. Rep CreateNotificationRule x -> CreateNotificationRule
forall x. CreateNotificationRule -> Rep CreateNotificationRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateNotificationRule x -> CreateNotificationRule
$cfrom :: forall x. CreateNotificationRule -> Rep CreateNotificationRule x
Prelude.Generic)

-- |
-- Create a value of 'CreateNotificationRule' 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:
--
-- 'status', 'createNotificationRule_status' - The status of the notification rule. The default value is ENABLED. If
-- the status is set to DISABLED, notifications aren\'t sent for the
-- notification rule.
--
-- 'clientRequestToken', 'createNotificationRule_clientRequestToken' - A unique, client-generated idempotency token that, when provided in a
-- request, ensures the request cannot be repeated with a changed
-- parameter. If a request with the same parameters is received and a token
-- is included, the request returns information about the initial request
-- that used that token.
--
-- The AWS SDKs prepopulate client request tokens. If you are using an AWS
-- SDK, an idempotency token is created for you.
--
-- 'tags', 'createNotificationRule_tags' - A list of tags to apply to this notification rule. Key names cannot
-- start with \"aws\".
--
-- 'name', 'createNotificationRule_name' - The name for the notification rule. Notifictaion rule names must be
-- unique in your AWS account.
--
-- 'eventTypeIds', 'createNotificationRule_eventTypeIds' - A list of event types associated with this notification rule. For a list
-- of allowed events, see EventTypeSummary.
--
-- 'resource', 'createNotificationRule_resource' - The Amazon Resource Name (ARN) of the resource to associate with the
-- notification rule. Supported resources include pipelines in AWS
-- CodePipeline, repositories in AWS CodeCommit, and build projects in AWS
-- CodeBuild.
--
-- 'targets', 'createNotificationRule_targets' - A list of Amazon Resource Names (ARNs) of SNS topics to associate with
-- the notification rule.
--
-- 'detailType', 'createNotificationRule_detailType' - The level of detail to include in the notifications for this resource.
-- BASIC will include only the contents of the event as it would appear in
-- AWS CloudWatch. FULL will include any supplemental information provided
-- by AWS CodeStar Notifications and\/or the service for the resource for
-- which the notification is created.
newCreateNotificationRule ::
  -- | 'name'
  Prelude.Text ->
  -- | 'resource'
  Prelude.Text ->
  -- | 'detailType'
  DetailType ->
  CreateNotificationRule
newCreateNotificationRule :: Text -> Text -> DetailType -> CreateNotificationRule
newCreateNotificationRule
  Text
pName_
  Text
pResource_
  DetailType
pDetailType_ =
    CreateNotificationRule' :: Maybe NotificationRuleStatus
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Sensitive Text
-> [Text]
-> Text
-> [Target]
-> DetailType
-> CreateNotificationRule
CreateNotificationRule'
      { $sel:status:CreateNotificationRule' :: Maybe NotificationRuleStatus
status = Maybe NotificationRuleStatus
forall a. Maybe a
Prelude.Nothing,
        $sel:clientRequestToken:CreateNotificationRule' :: Maybe Text
clientRequestToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateNotificationRule' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:name:CreateNotificationRule' :: Sensitive Text
name = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pName_,
        $sel:eventTypeIds:CreateNotificationRule' :: [Text]
eventTypeIds = [Text]
forall a. Monoid a => a
Prelude.mempty,
        $sel:resource:CreateNotificationRule' :: Text
resource = Text
pResource_,
        $sel:targets:CreateNotificationRule' :: [Target]
targets = [Target]
forall a. Monoid a => a
Prelude.mempty,
        $sel:detailType:CreateNotificationRule' :: DetailType
detailType = DetailType
pDetailType_
      }

-- | The status of the notification rule. The default value is ENABLED. If
-- the status is set to DISABLED, notifications aren\'t sent for the
-- notification rule.
createNotificationRule_status :: Lens.Lens' CreateNotificationRule (Prelude.Maybe NotificationRuleStatus)
createNotificationRule_status :: (Maybe NotificationRuleStatus -> f (Maybe NotificationRuleStatus))
-> CreateNotificationRule -> f CreateNotificationRule
createNotificationRule_status = (CreateNotificationRule -> Maybe NotificationRuleStatus)
-> (CreateNotificationRule
    -> Maybe NotificationRuleStatus -> CreateNotificationRule)
-> Lens
     CreateNotificationRule
     CreateNotificationRule
     (Maybe NotificationRuleStatus)
     (Maybe NotificationRuleStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNotificationRule' {Maybe NotificationRuleStatus
status :: Maybe NotificationRuleStatus
$sel:status:CreateNotificationRule' :: CreateNotificationRule -> Maybe NotificationRuleStatus
status} -> Maybe NotificationRuleStatus
status) (\s :: CreateNotificationRule
s@CreateNotificationRule' {} Maybe NotificationRuleStatus
a -> CreateNotificationRule
s {$sel:status:CreateNotificationRule' :: Maybe NotificationRuleStatus
status = Maybe NotificationRuleStatus
a} :: CreateNotificationRule)

-- | A unique, client-generated idempotency token that, when provided in a
-- request, ensures the request cannot be repeated with a changed
-- parameter. If a request with the same parameters is received and a token
-- is included, the request returns information about the initial request
-- that used that token.
--
-- The AWS SDKs prepopulate client request tokens. If you are using an AWS
-- SDK, an idempotency token is created for you.
createNotificationRule_clientRequestToken :: Lens.Lens' CreateNotificationRule (Prelude.Maybe Prelude.Text)
createNotificationRule_clientRequestToken :: (Maybe Text -> f (Maybe Text))
-> CreateNotificationRule -> f CreateNotificationRule
createNotificationRule_clientRequestToken = (CreateNotificationRule -> Maybe Text)
-> (CreateNotificationRule -> Maybe Text -> CreateNotificationRule)
-> Lens
     CreateNotificationRule
     CreateNotificationRule
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNotificationRule' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:CreateNotificationRule' :: CreateNotificationRule -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: CreateNotificationRule
s@CreateNotificationRule' {} Maybe Text
a -> CreateNotificationRule
s {$sel:clientRequestToken:CreateNotificationRule' :: Maybe Text
clientRequestToken = Maybe Text
a} :: CreateNotificationRule)

-- | A list of tags to apply to this notification rule. Key names cannot
-- start with \"aws\".
createNotificationRule_tags :: Lens.Lens' CreateNotificationRule (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createNotificationRule_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateNotificationRule -> f CreateNotificationRule
createNotificationRule_tags = (CreateNotificationRule -> Maybe (HashMap Text Text))
-> (CreateNotificationRule
    -> Maybe (HashMap Text Text) -> CreateNotificationRule)
-> Lens
     CreateNotificationRule
     CreateNotificationRule
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNotificationRule' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateNotificationRule' :: CreateNotificationRule -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateNotificationRule
s@CreateNotificationRule' {} Maybe (HashMap Text Text)
a -> CreateNotificationRule
s {$sel:tags:CreateNotificationRule' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateNotificationRule) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateNotificationRule -> f CreateNotificationRule)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateNotificationRule
-> f CreateNotificationRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name for the notification rule. Notifictaion rule names must be
-- unique in your AWS account.
createNotificationRule_name :: Lens.Lens' CreateNotificationRule Prelude.Text
createNotificationRule_name :: (Text -> f Text)
-> CreateNotificationRule -> f CreateNotificationRule
createNotificationRule_name = (CreateNotificationRule -> Sensitive Text)
-> (CreateNotificationRule
    -> Sensitive Text -> CreateNotificationRule)
-> Lens
     CreateNotificationRule
     CreateNotificationRule
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNotificationRule' {Sensitive Text
name :: Sensitive Text
$sel:name:CreateNotificationRule' :: CreateNotificationRule -> Sensitive Text
name} -> Sensitive Text
name) (\s :: CreateNotificationRule
s@CreateNotificationRule' {} Sensitive Text
a -> CreateNotificationRule
s {$sel:name:CreateNotificationRule' :: Sensitive Text
name = Sensitive Text
a} :: CreateNotificationRule) ((Sensitive Text -> f (Sensitive Text))
 -> CreateNotificationRule -> f CreateNotificationRule)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> CreateNotificationRule
-> f CreateNotificationRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | A list of event types associated with this notification rule. For a list
-- of allowed events, see EventTypeSummary.
createNotificationRule_eventTypeIds :: Lens.Lens' CreateNotificationRule [Prelude.Text]
createNotificationRule_eventTypeIds :: ([Text] -> f [Text])
-> CreateNotificationRule -> f CreateNotificationRule
createNotificationRule_eventTypeIds = (CreateNotificationRule -> [Text])
-> (CreateNotificationRule -> [Text] -> CreateNotificationRule)
-> Lens CreateNotificationRule CreateNotificationRule [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNotificationRule' {[Text]
eventTypeIds :: [Text]
$sel:eventTypeIds:CreateNotificationRule' :: CreateNotificationRule -> [Text]
eventTypeIds} -> [Text]
eventTypeIds) (\s :: CreateNotificationRule
s@CreateNotificationRule' {} [Text]
a -> CreateNotificationRule
s {$sel:eventTypeIds:CreateNotificationRule' :: [Text]
eventTypeIds = [Text]
a} :: CreateNotificationRule) (([Text] -> f [Text])
 -> CreateNotificationRule -> f CreateNotificationRule)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> CreateNotificationRule
-> f CreateNotificationRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) of the resource to associate with the
-- notification rule. Supported resources include pipelines in AWS
-- CodePipeline, repositories in AWS CodeCommit, and build projects in AWS
-- CodeBuild.
createNotificationRule_resource :: Lens.Lens' CreateNotificationRule Prelude.Text
createNotificationRule_resource :: (Text -> f Text)
-> CreateNotificationRule -> f CreateNotificationRule
createNotificationRule_resource = (CreateNotificationRule -> Text)
-> (CreateNotificationRule -> Text -> CreateNotificationRule)
-> Lens CreateNotificationRule CreateNotificationRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNotificationRule' {Text
resource :: Text
$sel:resource:CreateNotificationRule' :: CreateNotificationRule -> Text
resource} -> Text
resource) (\s :: CreateNotificationRule
s@CreateNotificationRule' {} Text
a -> CreateNotificationRule
s {$sel:resource:CreateNotificationRule' :: Text
resource = Text
a} :: CreateNotificationRule)

-- | A list of Amazon Resource Names (ARNs) of SNS topics to associate with
-- the notification rule.
createNotificationRule_targets :: Lens.Lens' CreateNotificationRule [Target]
createNotificationRule_targets :: ([Target] -> f [Target])
-> CreateNotificationRule -> f CreateNotificationRule
createNotificationRule_targets = (CreateNotificationRule -> [Target])
-> (CreateNotificationRule -> [Target] -> CreateNotificationRule)
-> Lens
     CreateNotificationRule CreateNotificationRule [Target] [Target]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNotificationRule' {[Target]
targets :: [Target]
$sel:targets:CreateNotificationRule' :: CreateNotificationRule -> [Target]
targets} -> [Target]
targets) (\s :: CreateNotificationRule
s@CreateNotificationRule' {} [Target]
a -> CreateNotificationRule
s {$sel:targets:CreateNotificationRule' :: [Target]
targets = [Target]
a} :: CreateNotificationRule) (([Target] -> f [Target])
 -> CreateNotificationRule -> f CreateNotificationRule)
-> (([Target] -> f [Target]) -> [Target] -> f [Target])
-> ([Target] -> f [Target])
-> CreateNotificationRule
-> f CreateNotificationRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Target] -> f [Target]) -> [Target] -> f [Target]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The level of detail to include in the notifications for this resource.
-- BASIC will include only the contents of the event as it would appear in
-- AWS CloudWatch. FULL will include any supplemental information provided
-- by AWS CodeStar Notifications and\/or the service for the resource for
-- which the notification is created.
createNotificationRule_detailType :: Lens.Lens' CreateNotificationRule DetailType
createNotificationRule_detailType :: (DetailType -> f DetailType)
-> CreateNotificationRule -> f CreateNotificationRule
createNotificationRule_detailType = (CreateNotificationRule -> DetailType)
-> (CreateNotificationRule -> DetailType -> CreateNotificationRule)
-> Lens
     CreateNotificationRule CreateNotificationRule DetailType DetailType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNotificationRule' {DetailType
detailType :: DetailType
$sel:detailType:CreateNotificationRule' :: CreateNotificationRule -> DetailType
detailType} -> DetailType
detailType) (\s :: CreateNotificationRule
s@CreateNotificationRule' {} DetailType
a -> CreateNotificationRule
s {$sel:detailType:CreateNotificationRule' :: DetailType
detailType = DetailType
a} :: CreateNotificationRule)

instance Core.AWSRequest CreateNotificationRule where
  type
    AWSResponse CreateNotificationRule =
      CreateNotificationRuleResponse
  request :: CreateNotificationRule -> Request CreateNotificationRule
request = Service -> CreateNotificationRule -> Request CreateNotificationRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateNotificationRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateNotificationRule)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateNotificationRule))
-> Logger
-> Service
-> Proxy CreateNotificationRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateNotificationRule)))
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 -> Int -> CreateNotificationRuleResponse
CreateNotificationRuleResponse'
            (Maybe Text -> Int -> CreateNotificationRuleResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateNotificationRuleResponse)
forall (f :: * -> *) a b. Functor 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
"Arn")
            Either String (Int -> CreateNotificationRuleResponse)
-> Either String Int
-> Either String CreateNotificationRuleResponse
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 CreateNotificationRule

instance Prelude.NFData CreateNotificationRule

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

instance Core.ToJSON CreateNotificationRule where
  toJSON :: CreateNotificationRule -> Value
toJSON CreateNotificationRule' {[Text]
[Target]
Maybe Text
Maybe (HashMap Text Text)
Maybe NotificationRuleStatus
Text
Sensitive Text
DetailType
detailType :: DetailType
targets :: [Target]
resource :: Text
eventTypeIds :: [Text]
name :: Sensitive Text
tags :: Maybe (HashMap Text Text)
clientRequestToken :: Maybe Text
status :: Maybe NotificationRuleStatus
$sel:detailType:CreateNotificationRule' :: CreateNotificationRule -> DetailType
$sel:targets:CreateNotificationRule' :: CreateNotificationRule -> [Target]
$sel:resource:CreateNotificationRule' :: CreateNotificationRule -> Text
$sel:eventTypeIds:CreateNotificationRule' :: CreateNotificationRule -> [Text]
$sel:name:CreateNotificationRule' :: CreateNotificationRule -> Sensitive Text
$sel:tags:CreateNotificationRule' :: CreateNotificationRule -> Maybe (HashMap Text Text)
$sel:clientRequestToken:CreateNotificationRule' :: CreateNotificationRule -> Maybe Text
$sel:status:CreateNotificationRule' :: CreateNotificationRule -> Maybe NotificationRuleStatus
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Status" Text -> NotificationRuleStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NotificationRuleStatus -> Pair)
-> Maybe NotificationRuleStatus -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NotificationRuleStatus
status,
            (Text
"ClientRequestToken" 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
clientRequestToken,
            (Text
"Tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"EventTypeIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
eventTypeIds),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Resource" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resource),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Targets" Text -> [Target] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Target]
targets),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DetailType" Text -> DetailType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DetailType
detailType)
          ]
      )

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

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

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

-- |
-- Create a value of 'CreateNotificationRuleResponse' 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:
--
-- 'arn', 'createNotificationRuleResponse_arn' - The Amazon Resource Name (ARN) of the notification rule.
--
-- 'httpStatus', 'createNotificationRuleResponse_httpStatus' - The response's http status code.
newCreateNotificationRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateNotificationRuleResponse
newCreateNotificationRuleResponse :: Int -> CreateNotificationRuleResponse
newCreateNotificationRuleResponse Int
pHttpStatus_ =
  CreateNotificationRuleResponse' :: Maybe Text -> Int -> CreateNotificationRuleResponse
CreateNotificationRuleResponse'
    { $sel:arn:CreateNotificationRuleResponse' :: Maybe Text
arn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateNotificationRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the notification rule.
createNotificationRuleResponse_arn :: Lens.Lens' CreateNotificationRuleResponse (Prelude.Maybe Prelude.Text)
createNotificationRuleResponse_arn :: (Maybe Text -> f (Maybe Text))
-> CreateNotificationRuleResponse
-> f CreateNotificationRuleResponse
createNotificationRuleResponse_arn = (CreateNotificationRuleResponse -> Maybe Text)
-> (CreateNotificationRuleResponse
    -> Maybe Text -> CreateNotificationRuleResponse)
-> Lens
     CreateNotificationRuleResponse
     CreateNotificationRuleResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNotificationRuleResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:CreateNotificationRuleResponse' :: CreateNotificationRuleResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: CreateNotificationRuleResponse
s@CreateNotificationRuleResponse' {} Maybe Text
a -> CreateNotificationRuleResponse
s {$sel:arn:CreateNotificationRuleResponse' :: Maybe Text
arn = Maybe Text
a} :: CreateNotificationRuleResponse)

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

instance
  Prelude.NFData
    CreateNotificationRuleResponse