{-# 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.ListTargetsByRule
-- 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)
--
-- Lists the targets assigned to the specified rule.
--
-- This operation returns paginated results.
module Amazonka.CloudWatchEvents.ListTargetsByRule
  ( -- * Creating a Request
    ListTargetsByRule (..),
    newListTargetsByRule,

    -- * Request Lenses
    listTargetsByRule_nextToken,
    listTargetsByRule_eventBusName,
    listTargetsByRule_limit,
    listTargetsByRule_rule,

    -- * Destructuring the Response
    ListTargetsByRuleResponse (..),
    newListTargetsByRuleResponse,

    -- * Response Lenses
    listTargetsByRuleResponse_nextToken,
    listTargetsByRuleResponse_targets,
    listTargetsByRuleResponse_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:/ 'newListTargetsByRule' smart constructor.
data ListTargetsByRule = ListTargetsByRule'
  { -- | The token returned by a previous call to retrieve the next set of
    -- results.
    ListTargetsByRule -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name or ARN of the event bus associated with the rule. If you omit
    -- this, the default event bus is used.
    ListTargetsByRule -> Maybe Text
eventBusName :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return.
    ListTargetsByRule -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | The name of the rule.
    ListTargetsByRule -> Text
rule :: Prelude.Text
  }
  deriving (ListTargetsByRule -> ListTargetsByRule -> Bool
(ListTargetsByRule -> ListTargetsByRule -> Bool)
-> (ListTargetsByRule -> ListTargetsByRule -> Bool)
-> Eq ListTargetsByRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTargetsByRule -> ListTargetsByRule -> Bool
$c/= :: ListTargetsByRule -> ListTargetsByRule -> Bool
== :: ListTargetsByRule -> ListTargetsByRule -> Bool
$c== :: ListTargetsByRule -> ListTargetsByRule -> Bool
Prelude.Eq, ReadPrec [ListTargetsByRule]
ReadPrec ListTargetsByRule
Int -> ReadS ListTargetsByRule
ReadS [ListTargetsByRule]
(Int -> ReadS ListTargetsByRule)
-> ReadS [ListTargetsByRule]
-> ReadPrec ListTargetsByRule
-> ReadPrec [ListTargetsByRule]
-> Read ListTargetsByRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTargetsByRule]
$creadListPrec :: ReadPrec [ListTargetsByRule]
readPrec :: ReadPrec ListTargetsByRule
$creadPrec :: ReadPrec ListTargetsByRule
readList :: ReadS [ListTargetsByRule]
$creadList :: ReadS [ListTargetsByRule]
readsPrec :: Int -> ReadS ListTargetsByRule
$creadsPrec :: Int -> ReadS ListTargetsByRule
Prelude.Read, Int -> ListTargetsByRule -> ShowS
[ListTargetsByRule] -> ShowS
ListTargetsByRule -> String
(Int -> ListTargetsByRule -> ShowS)
-> (ListTargetsByRule -> String)
-> ([ListTargetsByRule] -> ShowS)
-> Show ListTargetsByRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTargetsByRule] -> ShowS
$cshowList :: [ListTargetsByRule] -> ShowS
show :: ListTargetsByRule -> String
$cshow :: ListTargetsByRule -> String
showsPrec :: Int -> ListTargetsByRule -> ShowS
$cshowsPrec :: Int -> ListTargetsByRule -> ShowS
Prelude.Show, (forall x. ListTargetsByRule -> Rep ListTargetsByRule x)
-> (forall x. Rep ListTargetsByRule x -> ListTargetsByRule)
-> Generic ListTargetsByRule
forall x. Rep ListTargetsByRule x -> ListTargetsByRule
forall x. ListTargetsByRule -> Rep ListTargetsByRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTargetsByRule x -> ListTargetsByRule
$cfrom :: forall x. ListTargetsByRule -> Rep ListTargetsByRule x
Prelude.Generic)

-- |
-- Create a value of 'ListTargetsByRule' 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:
--
-- 'nextToken', 'listTargetsByRule_nextToken' - The token returned by a previous call to retrieve the next set of
-- results.
--
-- 'eventBusName', 'listTargetsByRule_eventBusName' - The name or ARN of the event bus associated with the rule. If you omit
-- this, the default event bus is used.
--
-- 'limit', 'listTargetsByRule_limit' - The maximum number of results to return.
--
-- 'rule', 'listTargetsByRule_rule' - The name of the rule.
newListTargetsByRule ::
  -- | 'rule'
  Prelude.Text ->
  ListTargetsByRule
newListTargetsByRule :: Text -> ListTargetsByRule
newListTargetsByRule Text
pRule_ =
  ListTargetsByRule' :: Maybe Text
-> Maybe Text -> Maybe Natural -> Text -> ListTargetsByRule
ListTargetsByRule'
    { $sel:nextToken:ListTargetsByRule' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eventBusName:ListTargetsByRule' :: Maybe Text
eventBusName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:ListTargetsByRule' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:rule:ListTargetsByRule' :: Text
rule = Text
pRule_
    }

-- | The token returned by a previous call to retrieve the next set of
-- results.
listTargetsByRule_nextToken :: Lens.Lens' ListTargetsByRule (Prelude.Maybe Prelude.Text)
listTargetsByRule_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListTargetsByRule -> f ListTargetsByRule
listTargetsByRule_nextToken = (ListTargetsByRule -> Maybe Text)
-> (ListTargetsByRule -> Maybe Text -> ListTargetsByRule)
-> Lens
     ListTargetsByRule ListTargetsByRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsByRule' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTargetsByRule' :: ListTargetsByRule -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTargetsByRule
s@ListTargetsByRule' {} Maybe Text
a -> ListTargetsByRule
s {$sel:nextToken:ListTargetsByRule' :: Maybe Text
nextToken = Maybe Text
a} :: ListTargetsByRule)

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

-- | The maximum number of results to return.
listTargetsByRule_limit :: Lens.Lens' ListTargetsByRule (Prelude.Maybe Prelude.Natural)
listTargetsByRule_limit :: (Maybe Natural -> f (Maybe Natural))
-> ListTargetsByRule -> f ListTargetsByRule
listTargetsByRule_limit = (ListTargetsByRule -> Maybe Natural)
-> (ListTargetsByRule -> Maybe Natural -> ListTargetsByRule)
-> Lens
     ListTargetsByRule ListTargetsByRule (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsByRule' {Maybe Natural
limit :: Maybe Natural
$sel:limit:ListTargetsByRule' :: ListTargetsByRule -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: ListTargetsByRule
s@ListTargetsByRule' {} Maybe Natural
a -> ListTargetsByRule
s {$sel:limit:ListTargetsByRule' :: Maybe Natural
limit = Maybe Natural
a} :: ListTargetsByRule)

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

instance Core.AWSPager ListTargetsByRule where
  page :: ListTargetsByRule
-> AWSResponse ListTargetsByRule -> Maybe ListTargetsByRule
page ListTargetsByRule
rq AWSResponse ListTargetsByRule
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListTargetsByRule
ListTargetsByRuleResponse
rs
            ListTargetsByRuleResponse
-> Getting (First Text) ListTargetsByRuleResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListTargetsByRuleResponse
-> Const (First Text) ListTargetsByRuleResponse
Lens' ListTargetsByRuleResponse (Maybe Text)
listTargetsByRuleResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListTargetsByRuleResponse
 -> Const (First Text) ListTargetsByRuleResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListTargetsByRuleResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListTargetsByRule
forall a. Maybe a
Prelude.Nothing
    | Maybe [Target] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListTargetsByRule
ListTargetsByRuleResponse
rs
            ListTargetsByRuleResponse
-> Getting (First [Target]) ListTargetsByRuleResponse [Target]
-> Maybe [Target]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe (NonEmpty Target)
 -> Const (First [Target]) (Maybe (NonEmpty Target)))
-> ListTargetsByRuleResponse
-> Const (First [Target]) ListTargetsByRuleResponse
Lens' ListTargetsByRuleResponse (Maybe (NonEmpty Target))
listTargetsByRuleResponse_targets
              ((Maybe (NonEmpty Target)
  -> Const (First [Target]) (Maybe (NonEmpty Target)))
 -> ListTargetsByRuleResponse
 -> Const (First [Target]) ListTargetsByRuleResponse)
-> (([Target] -> Const (First [Target]) [Target])
    -> Maybe (NonEmpty Target)
    -> Const (First [Target]) (Maybe (NonEmpty Target)))
-> Getting (First [Target]) ListTargetsByRuleResponse [Target]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Target -> Const (First [Target]) (NonEmpty Target))
-> Maybe (NonEmpty Target)
-> Const (First [Target]) (Maybe (NonEmpty Target))
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
              ((NonEmpty Target -> Const (First [Target]) (NonEmpty Target))
 -> Maybe (NonEmpty Target)
 -> Const (First [Target]) (Maybe (NonEmpty Target)))
-> (([Target] -> Const (First [Target]) [Target])
    -> NonEmpty Target -> Const (First [Target]) (NonEmpty Target))
-> ([Target] -> Const (First [Target]) [Target])
-> Maybe (NonEmpty Target)
-> Const (First [Target]) (Maybe (NonEmpty Target))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Target -> [Target])
-> ([Target] -> Const (First [Target]) [Target])
-> NonEmpty Target
-> Const (First [Target]) (NonEmpty Target)
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to NonEmpty Target -> [Target]
forall l. IsList l => l -> [Item l]
Prelude.toList
        ) =
      Maybe ListTargetsByRule
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListTargetsByRule -> Maybe ListTargetsByRule
forall a. a -> Maybe a
Prelude.Just (ListTargetsByRule -> Maybe ListTargetsByRule)
-> ListTargetsByRule -> Maybe ListTargetsByRule
forall a b. (a -> b) -> a -> b
Prelude.$
        ListTargetsByRule
rq
          ListTargetsByRule
-> (ListTargetsByRule -> ListTargetsByRule) -> ListTargetsByRule
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListTargetsByRule -> Identity ListTargetsByRule
Lens ListTargetsByRule ListTargetsByRule (Maybe Text) (Maybe Text)
listTargetsByRule_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListTargetsByRule -> Identity ListTargetsByRule)
-> Maybe Text -> ListTargetsByRule -> ListTargetsByRule
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListTargetsByRule
ListTargetsByRuleResponse
rs
          ListTargetsByRuleResponse
-> Getting (First Text) ListTargetsByRuleResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListTargetsByRuleResponse
-> Const (First Text) ListTargetsByRuleResponse
Lens' ListTargetsByRuleResponse (Maybe Text)
listTargetsByRuleResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListTargetsByRuleResponse
 -> Const (First Text) ListTargetsByRuleResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListTargetsByRuleResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListTargetsByRule where
  type
    AWSResponse ListTargetsByRule =
      ListTargetsByRuleResponse
  request :: ListTargetsByRule -> Request ListTargetsByRule
request = Service -> ListTargetsByRule -> Request ListTargetsByRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListTargetsByRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListTargetsByRule)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListTargetsByRule))
-> Logger
-> Service
-> Proxy ListTargetsByRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListTargetsByRule)))
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
-> Maybe (NonEmpty Target) -> Int -> ListTargetsByRuleResponse
ListTargetsByRuleResponse'
            (Maybe Text
 -> Maybe (NonEmpty Target) -> Int -> ListTargetsByRuleResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe (NonEmpty Target) -> Int -> ListTargetsByRuleResponse)
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
"NextToken")
            Either
  String
  (Maybe (NonEmpty Target) -> Int -> ListTargetsByRuleResponse)
-> Either String (Maybe (NonEmpty Target))
-> Either String (Int -> ListTargetsByRuleResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (NonEmpty Target))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Targets")
            Either String (Int -> ListTargetsByRuleResponse)
-> Either String Int -> Either String ListTargetsByRuleResponse
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 ListTargetsByRule

instance Prelude.NFData ListTargetsByRule

instance Core.ToHeaders ListTargetsByRule where
  toHeaders :: ListTargetsByRule -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListTargetsByRule -> 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.ListTargetsByRule" ::
                          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 ListTargetsByRule where
  toJSON :: ListTargetsByRule -> Value
toJSON ListTargetsByRule' {Maybe Natural
Maybe Text
Text
rule :: Text
limit :: Maybe Natural
eventBusName :: Maybe Text
nextToken :: Maybe Text
$sel:rule:ListTargetsByRule' :: ListTargetsByRule -> Text
$sel:limit:ListTargetsByRule' :: ListTargetsByRule -> Maybe Natural
$sel:eventBusName:ListTargetsByRule' :: ListTargetsByRule -> Maybe Text
$sel:nextToken:ListTargetsByRule' :: ListTargetsByRule -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextToken" 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
nextToken,
            (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,
            (Text
"Limit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
limit,
            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)
          ]
      )

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

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

-- | /See:/ 'newListTargetsByRuleResponse' smart constructor.
data ListTargetsByRuleResponse = ListTargetsByRuleResponse'
  { -- | Indicates whether there are additional results to retrieve. If there are
    -- no more results, the value is null.
    ListTargetsByRuleResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The targets assigned to the rule.
    ListTargetsByRuleResponse -> Maybe (NonEmpty Target)
targets :: Prelude.Maybe (Prelude.NonEmpty Target),
    -- | The response's http status code.
    ListTargetsByRuleResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListTargetsByRuleResponse -> ListTargetsByRuleResponse -> Bool
(ListTargetsByRuleResponse -> ListTargetsByRuleResponse -> Bool)
-> (ListTargetsByRuleResponse -> ListTargetsByRuleResponse -> Bool)
-> Eq ListTargetsByRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTargetsByRuleResponse -> ListTargetsByRuleResponse -> Bool
$c/= :: ListTargetsByRuleResponse -> ListTargetsByRuleResponse -> Bool
== :: ListTargetsByRuleResponse -> ListTargetsByRuleResponse -> Bool
$c== :: ListTargetsByRuleResponse -> ListTargetsByRuleResponse -> Bool
Prelude.Eq, ReadPrec [ListTargetsByRuleResponse]
ReadPrec ListTargetsByRuleResponse
Int -> ReadS ListTargetsByRuleResponse
ReadS [ListTargetsByRuleResponse]
(Int -> ReadS ListTargetsByRuleResponse)
-> ReadS [ListTargetsByRuleResponse]
-> ReadPrec ListTargetsByRuleResponse
-> ReadPrec [ListTargetsByRuleResponse]
-> Read ListTargetsByRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTargetsByRuleResponse]
$creadListPrec :: ReadPrec [ListTargetsByRuleResponse]
readPrec :: ReadPrec ListTargetsByRuleResponse
$creadPrec :: ReadPrec ListTargetsByRuleResponse
readList :: ReadS [ListTargetsByRuleResponse]
$creadList :: ReadS [ListTargetsByRuleResponse]
readsPrec :: Int -> ReadS ListTargetsByRuleResponse
$creadsPrec :: Int -> ReadS ListTargetsByRuleResponse
Prelude.Read, Int -> ListTargetsByRuleResponse -> ShowS
[ListTargetsByRuleResponse] -> ShowS
ListTargetsByRuleResponse -> String
(Int -> ListTargetsByRuleResponse -> ShowS)
-> (ListTargetsByRuleResponse -> String)
-> ([ListTargetsByRuleResponse] -> ShowS)
-> Show ListTargetsByRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTargetsByRuleResponse] -> ShowS
$cshowList :: [ListTargetsByRuleResponse] -> ShowS
show :: ListTargetsByRuleResponse -> String
$cshow :: ListTargetsByRuleResponse -> String
showsPrec :: Int -> ListTargetsByRuleResponse -> ShowS
$cshowsPrec :: Int -> ListTargetsByRuleResponse -> ShowS
Prelude.Show, (forall x.
 ListTargetsByRuleResponse -> Rep ListTargetsByRuleResponse x)
-> (forall x.
    Rep ListTargetsByRuleResponse x -> ListTargetsByRuleResponse)
-> Generic ListTargetsByRuleResponse
forall x.
Rep ListTargetsByRuleResponse x -> ListTargetsByRuleResponse
forall x.
ListTargetsByRuleResponse -> Rep ListTargetsByRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListTargetsByRuleResponse x -> ListTargetsByRuleResponse
$cfrom :: forall x.
ListTargetsByRuleResponse -> Rep ListTargetsByRuleResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListTargetsByRuleResponse' 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:
--
-- 'nextToken', 'listTargetsByRuleResponse_nextToken' - Indicates whether there are additional results to retrieve. If there are
-- no more results, the value is null.
--
-- 'targets', 'listTargetsByRuleResponse_targets' - The targets assigned to the rule.
--
-- 'httpStatus', 'listTargetsByRuleResponse_httpStatus' - The response's http status code.
newListTargetsByRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListTargetsByRuleResponse
newListTargetsByRuleResponse :: Int -> ListTargetsByRuleResponse
newListTargetsByRuleResponse Int
pHttpStatus_ =
  ListTargetsByRuleResponse' :: Maybe Text
-> Maybe (NonEmpty Target) -> Int -> ListTargetsByRuleResponse
ListTargetsByRuleResponse'
    { $sel:nextToken:ListTargetsByRuleResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targets:ListTargetsByRuleResponse' :: Maybe (NonEmpty Target)
targets = Maybe (NonEmpty Target)
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListTargetsByRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Indicates whether there are additional results to retrieve. If there are
-- no more results, the value is null.
listTargetsByRuleResponse_nextToken :: Lens.Lens' ListTargetsByRuleResponse (Prelude.Maybe Prelude.Text)
listTargetsByRuleResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListTargetsByRuleResponse -> f ListTargetsByRuleResponse
listTargetsByRuleResponse_nextToken = (ListTargetsByRuleResponse -> Maybe Text)
-> (ListTargetsByRuleResponse
    -> Maybe Text -> ListTargetsByRuleResponse)
-> Lens' ListTargetsByRuleResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsByRuleResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTargetsByRuleResponse' :: ListTargetsByRuleResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTargetsByRuleResponse
s@ListTargetsByRuleResponse' {} Maybe Text
a -> ListTargetsByRuleResponse
s {$sel:nextToken:ListTargetsByRuleResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListTargetsByRuleResponse)

-- | The targets assigned to the rule.
listTargetsByRuleResponse_targets :: Lens.Lens' ListTargetsByRuleResponse (Prelude.Maybe (Prelude.NonEmpty Target))
listTargetsByRuleResponse_targets :: (Maybe (NonEmpty Target) -> f (Maybe (NonEmpty Target)))
-> ListTargetsByRuleResponse -> f ListTargetsByRuleResponse
listTargetsByRuleResponse_targets = (ListTargetsByRuleResponse -> Maybe (NonEmpty Target))
-> (ListTargetsByRuleResponse
    -> Maybe (NonEmpty Target) -> ListTargetsByRuleResponse)
-> Lens' ListTargetsByRuleResponse (Maybe (NonEmpty Target))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsByRuleResponse' {Maybe (NonEmpty Target)
targets :: Maybe (NonEmpty Target)
$sel:targets:ListTargetsByRuleResponse' :: ListTargetsByRuleResponse -> Maybe (NonEmpty Target)
targets} -> Maybe (NonEmpty Target)
targets) (\s :: ListTargetsByRuleResponse
s@ListTargetsByRuleResponse' {} Maybe (NonEmpty Target)
a -> ListTargetsByRuleResponse
s {$sel:targets:ListTargetsByRuleResponse' :: Maybe (NonEmpty Target)
targets = Maybe (NonEmpty Target)
a} :: ListTargetsByRuleResponse) ((Maybe (NonEmpty Target) -> f (Maybe (NonEmpty Target)))
 -> ListTargetsByRuleResponse -> f ListTargetsByRuleResponse)
-> ((Maybe (NonEmpty Target) -> f (Maybe (NonEmpty Target)))
    -> Maybe (NonEmpty Target) -> f (Maybe (NonEmpty Target)))
-> (Maybe (NonEmpty Target) -> f (Maybe (NonEmpty Target)))
-> ListTargetsByRuleResponse
-> f ListTargetsByRuleResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Target)
  (NonEmpty Target)
  (NonEmpty Target)
  (NonEmpty Target)
-> Iso
     (Maybe (NonEmpty Target))
     (Maybe (NonEmpty Target))
     (Maybe (NonEmpty Target))
     (Maybe (NonEmpty Target))
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
  (NonEmpty Target)
  (NonEmpty Target)
  (NonEmpty Target)
  (NonEmpty Target)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListTargetsByRuleResponse