{-# 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.CloudWatchEvents.PutTargets
-- 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)
--
-- Adds the specified targets to the specified rule, or updates the targets
-- if they are already associated with the rule.
--
-- Targets are the resources that are invoked when a rule is triggered.
--
-- You can configure the following as targets for Events:
--
-- -   <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-api-destinations.html API destination>
--
-- -   Amazon API Gateway REST API endpoints
--
-- -   API Gateway
--
-- -   Batch job queue
--
-- -   CloudWatch Logs group
--
-- -   CodeBuild project
--
-- -   CodePipeline
--
-- -   Amazon EC2 @CreateSnapshot@ API call
--
-- -   Amazon EC2 @RebootInstances@ API call
--
-- -   Amazon EC2 @StopInstances@ API call
--
-- -   Amazon EC2 @TerminateInstances@ API call
--
-- -   Amazon ECS tasks
--
-- -   Event bus in a different Amazon Web Services account or Region.
--
--     You can use an event bus in the US East (N. Virginia) us-east-1, US
--     West (Oregon) us-west-2, or Europe (Ireland) eu-west-1 Regions as a
--     target for a rule.
--
-- -   Firehose delivery stream (Kinesis Data Firehose)
--
-- -   Inspector assessment template (Amazon Inspector)
--
-- -   Kinesis stream (Kinesis Data Stream)
--
-- -   Lambda function
--
-- -   Redshift clusters (Data API statement execution)
--
-- -   Amazon SNS topic
--
-- -   Amazon SQS queues (includes FIFO queues
--
-- -   SSM Automation
--
-- -   SSM OpsItem
--
-- -   SSM Run Command
--
-- -   Step Functions state machines
--
-- Creating rules with built-in targets is supported only in the Amazon Web
-- Services Management Console. The built-in targets are
-- @EC2 CreateSnapshot API call@, @EC2 RebootInstances API call@,
-- @EC2 StopInstances API call@, and @EC2 TerminateInstances API call@.
--
-- For some target types, @PutTargets@ provides target-specific parameters.
-- If the target is a Kinesis data stream, you can optionally specify which
-- shard the event goes to by using the @KinesisParameters@ argument. To
-- invoke a command on multiple EC2 instances with one rule, you can use
-- the @RunCommandParameters@ field.
--
-- To be able to make API calls against the resources that you own, Amazon
-- EventBridge needs the appropriate permissions. For Lambda and Amazon SNS
-- resources, EventBridge relies on resource-based policies. For EC2
-- instances, Kinesis Data Streams, Step Functions state machines and API
-- Gateway REST APIs, EventBridge relies on IAM roles that you specify in
-- the @RoleARN@ argument in @PutTargets@. For more information, see
-- <https://docs.aws.amazon.com/eventbridge/latest/userguide/auth-and-access-control-eventbridge.html Authentication and Access Control>
-- in the /Amazon EventBridge User Guide/.
--
-- If another Amazon Web Services account is in the same region and has
-- granted you permission (using @PutPermission@), you can send events to
-- that account. Set that account\'s event bus as a target of the rules in
-- your account. To send the matched events to the other account, specify
-- that account\'s event bus as the @Arn@ value when you run @PutTargets@.
-- If your account sends events to another account, your account is charged
-- for each sent event. Each event sent to another account is charged as a
-- custom event. The account receiving the event is not charged. For more
-- information, see
-- <http://aws.amazon.com/eventbridge/pricing/ Amazon EventBridge Pricing>.
--
-- @Input@, @InputPath@, and @InputTransformer@ are not available with
-- @PutTarget@ if the target is an event bus of a different Amazon Web
-- Services account.
--
-- If you are setting the event bus of another account as the target, and
-- that account granted permission to your account through an organization
-- instead of directly by the account ID, then you must specify a @RoleArn@
-- with proper permissions in the @Target@ structure. For more information,
-- see
-- <https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-cross-account-event-delivery.html Sending and Receiving Events Between Amazon Web Services Accounts>
-- in the /Amazon EventBridge User Guide/.
--
-- For more information about enabling cross-account events, see
-- <https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutPermission.html PutPermission>.
--
-- __Input__, __InputPath__, and __InputTransformer__ are mutually
-- exclusive and optional parameters of a target. When a rule is triggered
-- due to a matched event:
--
-- -   If none of the following arguments are specified for a target, then
--     the entire event is passed to the target in JSON format (unless the
--     target is Amazon EC2 Run Command or Amazon ECS task, in which case
--     nothing from the event is passed to the target).
--
-- -   If __Input__ is specified in the form of valid JSON, then the
--     matched event is overridden with this constant.
--
-- -   If __InputPath__ is specified in the form of JSONPath (for example,
--     @$.detail@), then only the part of the event specified in the path
--     is passed to the target (for example, only the detail part of the
--     event is passed).
--
-- -   If __InputTransformer__ is specified, then one or more specified
--     JSONPaths are extracted from the event and used as values in a
--     template that you specify as the input to the target.
--
-- When you specify @InputPath@ or @InputTransformer@, you must use JSON
-- dot notation, not bracket notation.
--
-- When you add targets to a rule and the associated rule triggers soon
-- after, new or updated targets might not be immediately invoked. Allow a
-- short period of time for changes to take effect.
--
-- This action can partially fail if too many requests are made at the same
-- time. If that happens, @FailedEntryCount@ is non-zero in the response
-- and each entry in @FailedEntries@ provides the ID of the failed target
-- and the error code.
module Amazonka.CloudWatchEvents.PutTargets
  ( -- * Creating a Request
    PutTargets (..),
    newPutTargets,

    -- * Request Lenses
    putTargets_eventBusName,
    putTargets_rule,
    putTargets_targets,

    -- * Destructuring the Response
    PutTargetsResponse (..),
    newPutTargetsResponse,

    -- * Response Lenses
    putTargetsResponse_failedEntryCount,
    putTargetsResponse_failedEntries,
    putTargetsResponse_httpStatus,
  )
where

import Amazonka.CloudWatchEvents.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:/ 'newPutTargets' smart constructor.
data PutTargets = PutTargets'
  { -- | The name or ARN of the event bus associated with the rule. If you omit
    -- this, the default event bus is used.
    PutTargets -> Maybe Text
eventBusName :: Prelude.Maybe Prelude.Text,
    -- | The name of the rule.
    PutTargets -> Text
rule :: Prelude.Text,
    -- | The targets to update or add to the rule.
    PutTargets -> NonEmpty Target
targets :: Prelude.NonEmpty Target
  }
  deriving (PutTargets -> PutTargets -> Bool
(PutTargets -> PutTargets -> Bool)
-> (PutTargets -> PutTargets -> Bool) -> Eq PutTargets
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutTargets -> PutTargets -> Bool
$c/= :: PutTargets -> PutTargets -> Bool
== :: PutTargets -> PutTargets -> Bool
$c== :: PutTargets -> PutTargets -> Bool
Prelude.Eq, ReadPrec [PutTargets]
ReadPrec PutTargets
Int -> ReadS PutTargets
ReadS [PutTargets]
(Int -> ReadS PutTargets)
-> ReadS [PutTargets]
-> ReadPrec PutTargets
-> ReadPrec [PutTargets]
-> Read PutTargets
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutTargets]
$creadListPrec :: ReadPrec [PutTargets]
readPrec :: ReadPrec PutTargets
$creadPrec :: ReadPrec PutTargets
readList :: ReadS [PutTargets]
$creadList :: ReadS [PutTargets]
readsPrec :: Int -> ReadS PutTargets
$creadsPrec :: Int -> ReadS PutTargets
Prelude.Read, Int -> PutTargets -> ShowS
[PutTargets] -> ShowS
PutTargets -> String
(Int -> PutTargets -> ShowS)
-> (PutTargets -> String)
-> ([PutTargets] -> ShowS)
-> Show PutTargets
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutTargets] -> ShowS
$cshowList :: [PutTargets] -> ShowS
show :: PutTargets -> String
$cshow :: PutTargets -> String
showsPrec :: Int -> PutTargets -> ShowS
$cshowsPrec :: Int -> PutTargets -> ShowS
Prelude.Show, (forall x. PutTargets -> Rep PutTargets x)
-> (forall x. Rep PutTargets x -> PutTargets) -> Generic PutTargets
forall x. Rep PutTargets x -> PutTargets
forall x. PutTargets -> Rep PutTargets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutTargets x -> PutTargets
$cfrom :: forall x. PutTargets -> Rep PutTargets x
Prelude.Generic)

-- |
-- Create a value of 'PutTargets' 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:
--
-- 'eventBusName', 'putTargets_eventBusName' - The name or ARN of the event bus associated with the rule. If you omit
-- this, the default event bus is used.
--
-- 'rule', 'putTargets_rule' - The name of the rule.
--
-- 'targets', 'putTargets_targets' - The targets to update or add to the rule.
newPutTargets ::
  -- | 'rule'
  Prelude.Text ->
  -- | 'targets'
  Prelude.NonEmpty Target ->
  PutTargets
newPutTargets :: Text -> NonEmpty Target -> PutTargets
newPutTargets Text
pRule_ NonEmpty Target
pTargets_ =
  PutTargets' :: Maybe Text -> Text -> NonEmpty Target -> PutTargets
PutTargets'
    { $sel:eventBusName:PutTargets' :: Maybe Text
eventBusName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:rule:PutTargets' :: Text
rule = Text
pRule_,
      $sel:targets:PutTargets' :: NonEmpty Target
targets = Tagged (NonEmpty Target) (Identity (NonEmpty Target))
-> Tagged (NonEmpty Target) (Identity (NonEmpty Target))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Target) (Identity (NonEmpty Target))
 -> Tagged (NonEmpty Target) (Identity (NonEmpty Target)))
-> NonEmpty Target -> NonEmpty Target
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Target
pTargets_
    }

-- | The name or ARN of the event bus associated with the rule. If you omit
-- this, the default event bus is used.
putTargets_eventBusName :: Lens.Lens' PutTargets (Prelude.Maybe Prelude.Text)
putTargets_eventBusName :: (Maybe Text -> f (Maybe Text)) -> PutTargets -> f PutTargets
putTargets_eventBusName = (PutTargets -> Maybe Text)
-> (PutTargets -> Maybe Text -> PutTargets)
-> Lens PutTargets PutTargets (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTargets' {Maybe Text
eventBusName :: Maybe Text
$sel:eventBusName:PutTargets' :: PutTargets -> Maybe Text
eventBusName} -> Maybe Text
eventBusName) (\s :: PutTargets
s@PutTargets' {} Maybe Text
a -> PutTargets
s {$sel:eventBusName:PutTargets' :: Maybe Text
eventBusName = Maybe Text
a} :: PutTargets)

-- | The name of the rule.
putTargets_rule :: Lens.Lens' PutTargets Prelude.Text
putTargets_rule :: (Text -> f Text) -> PutTargets -> f PutTargets
putTargets_rule = (PutTargets -> Text)
-> (PutTargets -> Text -> PutTargets)
-> Lens PutTargets PutTargets Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTargets' {Text
rule :: Text
$sel:rule:PutTargets' :: PutTargets -> Text
rule} -> Text
rule) (\s :: PutTargets
s@PutTargets' {} Text
a -> PutTargets
s {$sel:rule:PutTargets' :: Text
rule = Text
a} :: PutTargets)

-- | The targets to update or add to the rule.
putTargets_targets :: Lens.Lens' PutTargets (Prelude.NonEmpty Target)
putTargets_targets :: (NonEmpty Target -> f (NonEmpty Target))
-> PutTargets -> f PutTargets
putTargets_targets = (PutTargets -> NonEmpty Target)
-> (PutTargets -> NonEmpty Target -> PutTargets)
-> Lens PutTargets PutTargets (NonEmpty Target) (NonEmpty Target)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTargets' {NonEmpty Target
targets :: NonEmpty Target
$sel:targets:PutTargets' :: PutTargets -> NonEmpty Target
targets} -> NonEmpty Target
targets) (\s :: PutTargets
s@PutTargets' {} NonEmpty Target
a -> PutTargets
s {$sel:targets:PutTargets' :: NonEmpty Target
targets = NonEmpty Target
a} :: PutTargets) ((NonEmpty Target -> f (NonEmpty Target))
 -> PutTargets -> f PutTargets)
-> ((NonEmpty Target -> f (NonEmpty Target))
    -> NonEmpty Target -> f (NonEmpty Target))
-> (NonEmpty Target -> f (NonEmpty Target))
-> PutTargets
-> f PutTargets
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Target -> f (NonEmpty Target))
-> NonEmpty Target -> f (NonEmpty Target)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest PutTargets where
  type AWSResponse PutTargets = PutTargetsResponse
  request :: PutTargets -> Request PutTargets
request = Service -> PutTargets -> Request PutTargets
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutTargets
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutTargets)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse PutTargets))
-> Logger
-> Service
-> Proxy PutTargets
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutTargets)))
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 Int
-> Maybe [PutTargetsResultEntry] -> Int -> PutTargetsResponse
PutTargetsResponse'
            (Maybe Int
 -> Maybe [PutTargetsResultEntry] -> Int -> PutTargetsResponse)
-> Either String (Maybe Int)
-> Either
     String (Maybe [PutTargetsResultEntry] -> Int -> PutTargetsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Int)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"FailedEntryCount")
            Either
  String (Maybe [PutTargetsResultEntry] -> Int -> PutTargetsResponse)
-> Either String (Maybe [PutTargetsResultEntry])
-> Either String (Int -> PutTargetsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Either String (Maybe (Maybe [PutTargetsResultEntry]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"FailedEntries" Either String (Maybe (Maybe [PutTargetsResultEntry]))
-> Maybe [PutTargetsResultEntry]
-> Either String (Maybe [PutTargetsResultEntry])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [PutTargetsResultEntry]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> PutTargetsResponse)
-> Either String Int -> Either String PutTargetsResponse
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 PutTargets

instance Prelude.NFData PutTargets

instance Core.ToHeaders PutTargets where
  toHeaders :: PutTargets -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutTargets -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"AWSEvents.PutTargets" :: Prelude.ByteString),
            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 PutTargets where
  toJSON :: PutTargets -> Value
toJSON PutTargets' {Maybe Text
NonEmpty Target
Text
targets :: NonEmpty Target
rule :: Text
eventBusName :: Maybe Text
$sel:targets:PutTargets' :: PutTargets -> NonEmpty Target
$sel:rule:PutTargets' :: PutTargets -> Text
$sel:eventBusName:PutTargets' :: PutTargets -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EventBusName" 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
eventBusName,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Rule" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
rule),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Targets" Text -> NonEmpty Target -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Target
targets)
          ]
      )

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

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

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

-- |
-- Create a value of 'PutTargetsResponse' 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:
--
-- 'failedEntryCount', 'putTargetsResponse_failedEntryCount' - The number of failed entries.
--
-- 'failedEntries', 'putTargetsResponse_failedEntries' - The failed target entries.
--
-- 'httpStatus', 'putTargetsResponse_httpStatus' - The response's http status code.
newPutTargetsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutTargetsResponse
newPutTargetsResponse :: Int -> PutTargetsResponse
newPutTargetsResponse Int
pHttpStatus_ =
  PutTargetsResponse' :: Maybe Int
-> Maybe [PutTargetsResultEntry] -> Int -> PutTargetsResponse
PutTargetsResponse'
    { $sel:failedEntryCount:PutTargetsResponse' :: Maybe Int
failedEntryCount =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:failedEntries:PutTargetsResponse' :: Maybe [PutTargetsResultEntry]
failedEntries = Maybe [PutTargetsResultEntry]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutTargetsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The number of failed entries.
putTargetsResponse_failedEntryCount :: Lens.Lens' PutTargetsResponse (Prelude.Maybe Prelude.Int)
putTargetsResponse_failedEntryCount :: (Maybe Int -> f (Maybe Int))
-> PutTargetsResponse -> f PutTargetsResponse
putTargetsResponse_failedEntryCount = (PutTargetsResponse -> Maybe Int)
-> (PutTargetsResponse -> Maybe Int -> PutTargetsResponse)
-> Lens
     PutTargetsResponse PutTargetsResponse (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTargetsResponse' {Maybe Int
failedEntryCount :: Maybe Int
$sel:failedEntryCount:PutTargetsResponse' :: PutTargetsResponse -> Maybe Int
failedEntryCount} -> Maybe Int
failedEntryCount) (\s :: PutTargetsResponse
s@PutTargetsResponse' {} Maybe Int
a -> PutTargetsResponse
s {$sel:failedEntryCount:PutTargetsResponse' :: Maybe Int
failedEntryCount = Maybe Int
a} :: PutTargetsResponse)

-- | The failed target entries.
putTargetsResponse_failedEntries :: Lens.Lens' PutTargetsResponse (Prelude.Maybe [PutTargetsResultEntry])
putTargetsResponse_failedEntries :: (Maybe [PutTargetsResultEntry]
 -> f (Maybe [PutTargetsResultEntry]))
-> PutTargetsResponse -> f PutTargetsResponse
putTargetsResponse_failedEntries = (PutTargetsResponse -> Maybe [PutTargetsResultEntry])
-> (PutTargetsResponse
    -> Maybe [PutTargetsResultEntry] -> PutTargetsResponse)
-> Lens
     PutTargetsResponse
     PutTargetsResponse
     (Maybe [PutTargetsResultEntry])
     (Maybe [PutTargetsResultEntry])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutTargetsResponse' {Maybe [PutTargetsResultEntry]
failedEntries :: Maybe [PutTargetsResultEntry]
$sel:failedEntries:PutTargetsResponse' :: PutTargetsResponse -> Maybe [PutTargetsResultEntry]
failedEntries} -> Maybe [PutTargetsResultEntry]
failedEntries) (\s :: PutTargetsResponse
s@PutTargetsResponse' {} Maybe [PutTargetsResultEntry]
a -> PutTargetsResponse
s {$sel:failedEntries:PutTargetsResponse' :: Maybe [PutTargetsResultEntry]
failedEntries = Maybe [PutTargetsResultEntry]
a} :: PutTargetsResponse) ((Maybe [PutTargetsResultEntry]
  -> f (Maybe [PutTargetsResultEntry]))
 -> PutTargetsResponse -> f PutTargetsResponse)
-> ((Maybe [PutTargetsResultEntry]
     -> f (Maybe [PutTargetsResultEntry]))
    -> Maybe [PutTargetsResultEntry]
    -> f (Maybe [PutTargetsResultEntry]))
-> (Maybe [PutTargetsResultEntry]
    -> f (Maybe [PutTargetsResultEntry]))
-> PutTargetsResponse
-> f PutTargetsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PutTargetsResultEntry]
  [PutTargetsResultEntry]
  [PutTargetsResultEntry]
  [PutTargetsResultEntry]
-> Iso
     (Maybe [PutTargetsResultEntry])
     (Maybe [PutTargetsResultEntry])
     (Maybe [PutTargetsResultEntry])
     (Maybe [PutTargetsResultEntry])
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
  [PutTargetsResultEntry]
  [PutTargetsResultEntry]
  [PutTargetsResultEntry]
  [PutTargetsResultEntry]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData PutTargetsResponse