{-# 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.Personalize.ListCampaigns
-- 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)
--
-- Returns a list of campaigns that use the given solution. When a solution
-- is not specified, all the campaigns associated with the account are
-- listed. The response provides the properties for each campaign,
-- including the Amazon Resource Name (ARN). For more information on
-- campaigns, see CreateCampaign.
--
-- This operation returns paginated results.
module Amazonka.Personalize.ListCampaigns
  ( -- * Creating a Request
    ListCampaigns (..),
    newListCampaigns,

    -- * Request Lenses
    listCampaigns_solutionArn,
    listCampaigns_nextToken,
    listCampaigns_maxResults,

    -- * Destructuring the Response
    ListCampaignsResponse (..),
    newListCampaignsResponse,

    -- * Response Lenses
    listCampaignsResponse_campaigns,
    listCampaignsResponse_nextToken,
    listCampaignsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Personalize.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListCampaigns' smart constructor.
data ListCampaigns = ListCampaigns'
  { -- | The Amazon Resource Name (ARN) of the solution to list the campaigns
    -- for. When a solution is not specified, all the campaigns associated with
    -- the account are listed.
    ListCampaigns -> Maybe Text
solutionArn :: Prelude.Maybe Prelude.Text,
    -- | A token returned from the previous call to @ListCampaigns@ for getting
    -- the next set of campaigns (if they exist).
    ListCampaigns -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of campaigns to return.
    ListCampaigns -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListCampaigns -> ListCampaigns -> Bool
(ListCampaigns -> ListCampaigns -> Bool)
-> (ListCampaigns -> ListCampaigns -> Bool) -> Eq ListCampaigns
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCampaigns -> ListCampaigns -> Bool
$c/= :: ListCampaigns -> ListCampaigns -> Bool
== :: ListCampaigns -> ListCampaigns -> Bool
$c== :: ListCampaigns -> ListCampaigns -> Bool
Prelude.Eq, ReadPrec [ListCampaigns]
ReadPrec ListCampaigns
Int -> ReadS ListCampaigns
ReadS [ListCampaigns]
(Int -> ReadS ListCampaigns)
-> ReadS [ListCampaigns]
-> ReadPrec ListCampaigns
-> ReadPrec [ListCampaigns]
-> Read ListCampaigns
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCampaigns]
$creadListPrec :: ReadPrec [ListCampaigns]
readPrec :: ReadPrec ListCampaigns
$creadPrec :: ReadPrec ListCampaigns
readList :: ReadS [ListCampaigns]
$creadList :: ReadS [ListCampaigns]
readsPrec :: Int -> ReadS ListCampaigns
$creadsPrec :: Int -> ReadS ListCampaigns
Prelude.Read, Int -> ListCampaigns -> ShowS
[ListCampaigns] -> ShowS
ListCampaigns -> String
(Int -> ListCampaigns -> ShowS)
-> (ListCampaigns -> String)
-> ([ListCampaigns] -> ShowS)
-> Show ListCampaigns
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCampaigns] -> ShowS
$cshowList :: [ListCampaigns] -> ShowS
show :: ListCampaigns -> String
$cshow :: ListCampaigns -> String
showsPrec :: Int -> ListCampaigns -> ShowS
$cshowsPrec :: Int -> ListCampaigns -> ShowS
Prelude.Show, (forall x. ListCampaigns -> Rep ListCampaigns x)
-> (forall x. Rep ListCampaigns x -> ListCampaigns)
-> Generic ListCampaigns
forall x. Rep ListCampaigns x -> ListCampaigns
forall x. ListCampaigns -> Rep ListCampaigns x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListCampaigns x -> ListCampaigns
$cfrom :: forall x. ListCampaigns -> Rep ListCampaigns x
Prelude.Generic)

-- |
-- Create a value of 'ListCampaigns' 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:
--
-- 'solutionArn', 'listCampaigns_solutionArn' - The Amazon Resource Name (ARN) of the solution to list the campaigns
-- for. When a solution is not specified, all the campaigns associated with
-- the account are listed.
--
-- 'nextToken', 'listCampaigns_nextToken' - A token returned from the previous call to @ListCampaigns@ for getting
-- the next set of campaigns (if they exist).
--
-- 'maxResults', 'listCampaigns_maxResults' - The maximum number of campaigns to return.
newListCampaigns ::
  ListCampaigns
newListCampaigns :: ListCampaigns
newListCampaigns =
  ListCampaigns' :: Maybe Text -> Maybe Text -> Maybe Natural -> ListCampaigns
ListCampaigns'
    { $sel:solutionArn:ListCampaigns' :: Maybe Text
solutionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListCampaigns' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListCampaigns' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the solution to list the campaigns
-- for. When a solution is not specified, all the campaigns associated with
-- the account are listed.
listCampaigns_solutionArn :: Lens.Lens' ListCampaigns (Prelude.Maybe Prelude.Text)
listCampaigns_solutionArn :: (Maybe Text -> f (Maybe Text)) -> ListCampaigns -> f ListCampaigns
listCampaigns_solutionArn = (ListCampaigns -> Maybe Text)
-> (ListCampaigns -> Maybe Text -> ListCampaigns)
-> Lens ListCampaigns ListCampaigns (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCampaigns' {Maybe Text
solutionArn :: Maybe Text
$sel:solutionArn:ListCampaigns' :: ListCampaigns -> Maybe Text
solutionArn} -> Maybe Text
solutionArn) (\s :: ListCampaigns
s@ListCampaigns' {} Maybe Text
a -> ListCampaigns
s {$sel:solutionArn:ListCampaigns' :: Maybe Text
solutionArn = Maybe Text
a} :: ListCampaigns)

-- | A token returned from the previous call to @ListCampaigns@ for getting
-- the next set of campaigns (if they exist).
listCampaigns_nextToken :: Lens.Lens' ListCampaigns (Prelude.Maybe Prelude.Text)
listCampaigns_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListCampaigns -> f ListCampaigns
listCampaigns_nextToken = (ListCampaigns -> Maybe Text)
-> (ListCampaigns -> Maybe Text -> ListCampaigns)
-> Lens ListCampaigns ListCampaigns (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCampaigns' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListCampaigns' :: ListCampaigns -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListCampaigns
s@ListCampaigns' {} Maybe Text
a -> ListCampaigns
s {$sel:nextToken:ListCampaigns' :: Maybe Text
nextToken = Maybe Text
a} :: ListCampaigns)

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

instance Core.AWSPager ListCampaigns where
  page :: ListCampaigns -> AWSResponse ListCampaigns -> Maybe ListCampaigns
page ListCampaigns
rq AWSResponse ListCampaigns
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListCampaigns
ListCampaignsResponse
rs
            ListCampaignsResponse
-> Getting (First Text) ListCampaignsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListCampaignsResponse
-> Const (First Text) ListCampaignsResponse
Lens' ListCampaignsResponse (Maybe Text)
listCampaignsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListCampaignsResponse
 -> Const (First Text) ListCampaignsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListCampaignsResponse 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 ListCampaigns
forall a. Maybe a
Prelude.Nothing
    | Maybe [CampaignSummary] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListCampaigns
ListCampaignsResponse
rs
            ListCampaignsResponse
-> Getting
     (First [CampaignSummary]) ListCampaignsResponse [CampaignSummary]
-> Maybe [CampaignSummary]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [CampaignSummary]
 -> Const (First [CampaignSummary]) (Maybe [CampaignSummary]))
-> ListCampaignsResponse
-> Const (First [CampaignSummary]) ListCampaignsResponse
Lens' ListCampaignsResponse (Maybe [CampaignSummary])
listCampaignsResponse_campaigns ((Maybe [CampaignSummary]
  -> Const (First [CampaignSummary]) (Maybe [CampaignSummary]))
 -> ListCampaignsResponse
 -> Const (First [CampaignSummary]) ListCampaignsResponse)
-> (([CampaignSummary]
     -> Const (First [CampaignSummary]) [CampaignSummary])
    -> Maybe [CampaignSummary]
    -> Const (First [CampaignSummary]) (Maybe [CampaignSummary]))
-> Getting
     (First [CampaignSummary]) ListCampaignsResponse [CampaignSummary]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([CampaignSummary]
 -> Const (First [CampaignSummary]) [CampaignSummary])
-> Maybe [CampaignSummary]
-> Const (First [CampaignSummary]) (Maybe [CampaignSummary])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListCampaigns
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListCampaigns -> Maybe ListCampaigns
forall a. a -> Maybe a
Prelude.Just (ListCampaigns -> Maybe ListCampaigns)
-> ListCampaigns -> Maybe ListCampaigns
forall a b. (a -> b) -> a -> b
Prelude.$
        ListCampaigns
rq
          ListCampaigns -> (ListCampaigns -> ListCampaigns) -> ListCampaigns
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListCampaigns -> Identity ListCampaigns
Lens ListCampaigns ListCampaigns (Maybe Text) (Maybe Text)
listCampaigns_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListCampaigns -> Identity ListCampaigns)
-> Maybe Text -> ListCampaigns -> ListCampaigns
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListCampaigns
ListCampaignsResponse
rs
          ListCampaignsResponse
-> Getting (First Text) ListCampaignsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListCampaignsResponse
-> Const (First Text) ListCampaignsResponse
Lens' ListCampaignsResponse (Maybe Text)
listCampaignsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListCampaignsResponse
 -> Const (First Text) ListCampaignsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListCampaignsResponse 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 ListCampaigns where
  type
    AWSResponse ListCampaigns =
      ListCampaignsResponse
  request :: ListCampaigns -> Request ListCampaigns
request = Service -> ListCampaigns -> Request ListCampaigns
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListCampaigns
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListCampaigns)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListCampaigns))
-> Logger
-> Service
-> Proxy ListCampaigns
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListCampaigns)))
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 [CampaignSummary]
-> Maybe Text -> Int -> ListCampaignsResponse
ListCampaignsResponse'
            (Maybe [CampaignSummary]
 -> Maybe Text -> Int -> ListCampaignsResponse)
-> Either String (Maybe [CampaignSummary])
-> Either String (Maybe Text -> Int -> ListCampaignsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [CampaignSummary]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"campaigns" Either String (Maybe (Maybe [CampaignSummary]))
-> Maybe [CampaignSummary]
-> Either String (Maybe [CampaignSummary])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [CampaignSummary]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> ListCampaignsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListCampaignsResponse)
forall (f :: * -> *) a b. Applicative f => 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 (Int -> ListCampaignsResponse)
-> Either String Int -> Either String ListCampaignsResponse
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 ListCampaigns

instance Prelude.NFData ListCampaigns

instance Core.ToHeaders ListCampaigns where
  toHeaders :: ListCampaigns -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListCampaigns -> 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
"AmazonPersonalize.ListCampaigns" ::
                          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 ListCampaigns where
  toJSON :: ListCampaigns -> Value
toJSON ListCampaigns' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
solutionArn :: Maybe Text
$sel:maxResults:ListCampaigns' :: ListCampaigns -> Maybe Natural
$sel:nextToken:ListCampaigns' :: ListCampaigns -> Maybe Text
$sel:solutionArn:ListCampaigns' :: ListCampaigns -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"solutionArn" 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
solutionArn,
            (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
"maxResults" 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
maxResults
          ]
      )

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

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

-- | /See:/ 'newListCampaignsResponse' smart constructor.
data ListCampaignsResponse = ListCampaignsResponse'
  { -- | A list of the campaigns.
    ListCampaignsResponse -> Maybe [CampaignSummary]
campaigns :: Prelude.Maybe [CampaignSummary],
    -- | A token for getting the next set of campaigns (if they exist).
    ListCampaignsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListCampaignsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListCampaignsResponse -> ListCampaignsResponse -> Bool
(ListCampaignsResponse -> ListCampaignsResponse -> Bool)
-> (ListCampaignsResponse -> ListCampaignsResponse -> Bool)
-> Eq ListCampaignsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCampaignsResponse -> ListCampaignsResponse -> Bool
$c/= :: ListCampaignsResponse -> ListCampaignsResponse -> Bool
== :: ListCampaignsResponse -> ListCampaignsResponse -> Bool
$c== :: ListCampaignsResponse -> ListCampaignsResponse -> Bool
Prelude.Eq, ReadPrec [ListCampaignsResponse]
ReadPrec ListCampaignsResponse
Int -> ReadS ListCampaignsResponse
ReadS [ListCampaignsResponse]
(Int -> ReadS ListCampaignsResponse)
-> ReadS [ListCampaignsResponse]
-> ReadPrec ListCampaignsResponse
-> ReadPrec [ListCampaignsResponse]
-> Read ListCampaignsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCampaignsResponse]
$creadListPrec :: ReadPrec [ListCampaignsResponse]
readPrec :: ReadPrec ListCampaignsResponse
$creadPrec :: ReadPrec ListCampaignsResponse
readList :: ReadS [ListCampaignsResponse]
$creadList :: ReadS [ListCampaignsResponse]
readsPrec :: Int -> ReadS ListCampaignsResponse
$creadsPrec :: Int -> ReadS ListCampaignsResponse
Prelude.Read, Int -> ListCampaignsResponse -> ShowS
[ListCampaignsResponse] -> ShowS
ListCampaignsResponse -> String
(Int -> ListCampaignsResponse -> ShowS)
-> (ListCampaignsResponse -> String)
-> ([ListCampaignsResponse] -> ShowS)
-> Show ListCampaignsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCampaignsResponse] -> ShowS
$cshowList :: [ListCampaignsResponse] -> ShowS
show :: ListCampaignsResponse -> String
$cshow :: ListCampaignsResponse -> String
showsPrec :: Int -> ListCampaignsResponse -> ShowS
$cshowsPrec :: Int -> ListCampaignsResponse -> ShowS
Prelude.Show, (forall x. ListCampaignsResponse -> Rep ListCampaignsResponse x)
-> (forall x. Rep ListCampaignsResponse x -> ListCampaignsResponse)
-> Generic ListCampaignsResponse
forall x. Rep ListCampaignsResponse x -> ListCampaignsResponse
forall x. ListCampaignsResponse -> Rep ListCampaignsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListCampaignsResponse x -> ListCampaignsResponse
$cfrom :: forall x. ListCampaignsResponse -> Rep ListCampaignsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListCampaignsResponse' 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:
--
-- 'campaigns', 'listCampaignsResponse_campaigns' - A list of the campaigns.
--
-- 'nextToken', 'listCampaignsResponse_nextToken' - A token for getting the next set of campaigns (if they exist).
--
-- 'httpStatus', 'listCampaignsResponse_httpStatus' - The response's http status code.
newListCampaignsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListCampaignsResponse
newListCampaignsResponse :: Int -> ListCampaignsResponse
newListCampaignsResponse Int
pHttpStatus_ =
  ListCampaignsResponse' :: Maybe [CampaignSummary]
-> Maybe Text -> Int -> ListCampaignsResponse
ListCampaignsResponse'
    { $sel:campaigns:ListCampaignsResponse' :: Maybe [CampaignSummary]
campaigns = Maybe [CampaignSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListCampaignsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListCampaignsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of the campaigns.
listCampaignsResponse_campaigns :: Lens.Lens' ListCampaignsResponse (Prelude.Maybe [CampaignSummary])
listCampaignsResponse_campaigns :: (Maybe [CampaignSummary] -> f (Maybe [CampaignSummary]))
-> ListCampaignsResponse -> f ListCampaignsResponse
listCampaignsResponse_campaigns = (ListCampaignsResponse -> Maybe [CampaignSummary])
-> (ListCampaignsResponse
    -> Maybe [CampaignSummary] -> ListCampaignsResponse)
-> Lens' ListCampaignsResponse (Maybe [CampaignSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCampaignsResponse' {Maybe [CampaignSummary]
campaigns :: Maybe [CampaignSummary]
$sel:campaigns:ListCampaignsResponse' :: ListCampaignsResponse -> Maybe [CampaignSummary]
campaigns} -> Maybe [CampaignSummary]
campaigns) (\s :: ListCampaignsResponse
s@ListCampaignsResponse' {} Maybe [CampaignSummary]
a -> ListCampaignsResponse
s {$sel:campaigns:ListCampaignsResponse' :: Maybe [CampaignSummary]
campaigns = Maybe [CampaignSummary]
a} :: ListCampaignsResponse) ((Maybe [CampaignSummary] -> f (Maybe [CampaignSummary]))
 -> ListCampaignsResponse -> f ListCampaignsResponse)
-> ((Maybe [CampaignSummary] -> f (Maybe [CampaignSummary]))
    -> Maybe [CampaignSummary] -> f (Maybe [CampaignSummary]))
-> (Maybe [CampaignSummary] -> f (Maybe [CampaignSummary]))
-> ListCampaignsResponse
-> f ListCampaignsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CampaignSummary]
  [CampaignSummary]
  [CampaignSummary]
  [CampaignSummary]
-> Iso
     (Maybe [CampaignSummary])
     (Maybe [CampaignSummary])
     (Maybe [CampaignSummary])
     (Maybe [CampaignSummary])
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
  [CampaignSummary]
  [CampaignSummary]
  [CampaignSummary]
  [CampaignSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A token for getting the next set of campaigns (if they exist).
listCampaignsResponse_nextToken :: Lens.Lens' ListCampaignsResponse (Prelude.Maybe Prelude.Text)
listCampaignsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListCampaignsResponse -> f ListCampaignsResponse
listCampaignsResponse_nextToken = (ListCampaignsResponse -> Maybe Text)
-> (ListCampaignsResponse -> Maybe Text -> ListCampaignsResponse)
-> Lens' ListCampaignsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCampaignsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListCampaignsResponse' :: ListCampaignsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListCampaignsResponse
s@ListCampaignsResponse' {} Maybe Text
a -> ListCampaignsResponse
s {$sel:nextToken:ListCampaignsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListCampaignsResponse)

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

instance Prelude.NFData ListCampaignsResponse