{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Pinpoint.Types.SegmentsResponse
-- 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)
module Amazonka.Pinpoint.Types.SegmentsResponse where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.SegmentResponse
import qualified Amazonka.Prelude as Prelude

-- | Provides information about all the segments that are associated with an
-- application.
--
-- /See:/ 'newSegmentsResponse' smart constructor.
data SegmentsResponse = SegmentsResponse'
  { -- | The string to use in a subsequent request to get the next page of
    -- results in a paginated response. This value is null if there are no
    -- additional pages.
    SegmentsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of responses, one for each segment that\'s associated with the
    -- application (Segments resource) or each version of a segment that\'s
    -- associated with the application (Segment Versions resource).
    SegmentsResponse -> [SegmentResponse]
item :: [SegmentResponse]
  }
  deriving (SegmentsResponse -> SegmentsResponse -> Bool
(SegmentsResponse -> SegmentsResponse -> Bool)
-> (SegmentsResponse -> SegmentsResponse -> Bool)
-> Eq SegmentsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SegmentsResponse -> SegmentsResponse -> Bool
$c/= :: SegmentsResponse -> SegmentsResponse -> Bool
== :: SegmentsResponse -> SegmentsResponse -> Bool
$c== :: SegmentsResponse -> SegmentsResponse -> Bool
Prelude.Eq, ReadPrec [SegmentsResponse]
ReadPrec SegmentsResponse
Int -> ReadS SegmentsResponse
ReadS [SegmentsResponse]
(Int -> ReadS SegmentsResponse)
-> ReadS [SegmentsResponse]
-> ReadPrec SegmentsResponse
-> ReadPrec [SegmentsResponse]
-> Read SegmentsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SegmentsResponse]
$creadListPrec :: ReadPrec [SegmentsResponse]
readPrec :: ReadPrec SegmentsResponse
$creadPrec :: ReadPrec SegmentsResponse
readList :: ReadS [SegmentsResponse]
$creadList :: ReadS [SegmentsResponse]
readsPrec :: Int -> ReadS SegmentsResponse
$creadsPrec :: Int -> ReadS SegmentsResponse
Prelude.Read, Int -> SegmentsResponse -> ShowS
[SegmentsResponse] -> ShowS
SegmentsResponse -> String
(Int -> SegmentsResponse -> ShowS)
-> (SegmentsResponse -> String)
-> ([SegmentsResponse] -> ShowS)
-> Show SegmentsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SegmentsResponse] -> ShowS
$cshowList :: [SegmentsResponse] -> ShowS
show :: SegmentsResponse -> String
$cshow :: SegmentsResponse -> String
showsPrec :: Int -> SegmentsResponse -> ShowS
$cshowsPrec :: Int -> SegmentsResponse -> ShowS
Prelude.Show, (forall x. SegmentsResponse -> Rep SegmentsResponse x)
-> (forall x. Rep SegmentsResponse x -> SegmentsResponse)
-> Generic SegmentsResponse
forall x. Rep SegmentsResponse x -> SegmentsResponse
forall x. SegmentsResponse -> Rep SegmentsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SegmentsResponse x -> SegmentsResponse
$cfrom :: forall x. SegmentsResponse -> Rep SegmentsResponse x
Prelude.Generic)

-- |
-- Create a value of 'SegmentsResponse' 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', 'segmentsResponse_nextToken' - The string to use in a subsequent request to get the next page of
-- results in a paginated response. This value is null if there are no
-- additional pages.
--
-- 'item', 'segmentsResponse_item' - An array of responses, one for each segment that\'s associated with the
-- application (Segments resource) or each version of a segment that\'s
-- associated with the application (Segment Versions resource).
newSegmentsResponse ::
  SegmentsResponse
newSegmentsResponse :: SegmentsResponse
newSegmentsResponse =
  SegmentsResponse' :: Maybe Text -> [SegmentResponse] -> SegmentsResponse
SegmentsResponse'
    { $sel:nextToken:SegmentsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:item:SegmentsResponse' :: [SegmentResponse]
item = [SegmentResponse]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The string to use in a subsequent request to get the next page of
-- results in a paginated response. This value is null if there are no
-- additional pages.
segmentsResponse_nextToken :: Lens.Lens' SegmentsResponse (Prelude.Maybe Prelude.Text)
segmentsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> SegmentsResponse -> f SegmentsResponse
segmentsResponse_nextToken = (SegmentsResponse -> Maybe Text)
-> (SegmentsResponse -> Maybe Text -> SegmentsResponse)
-> Lens SegmentsResponse SegmentsResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SegmentsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SegmentsResponse' :: SegmentsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SegmentsResponse
s@SegmentsResponse' {} Maybe Text
a -> SegmentsResponse
s {$sel:nextToken:SegmentsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: SegmentsResponse)

-- | An array of responses, one for each segment that\'s associated with the
-- application (Segments resource) or each version of a segment that\'s
-- associated with the application (Segment Versions resource).
segmentsResponse_item :: Lens.Lens' SegmentsResponse [SegmentResponse]
segmentsResponse_item :: ([SegmentResponse] -> f [SegmentResponse])
-> SegmentsResponse -> f SegmentsResponse
segmentsResponse_item = (SegmentsResponse -> [SegmentResponse])
-> (SegmentsResponse -> [SegmentResponse] -> SegmentsResponse)
-> Lens
     SegmentsResponse
     SegmentsResponse
     [SegmentResponse]
     [SegmentResponse]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SegmentsResponse' {[SegmentResponse]
item :: [SegmentResponse]
$sel:item:SegmentsResponse' :: SegmentsResponse -> [SegmentResponse]
item} -> [SegmentResponse]
item) (\s :: SegmentsResponse
s@SegmentsResponse' {} [SegmentResponse]
a -> SegmentsResponse
s {$sel:item:SegmentsResponse' :: [SegmentResponse]
item = [SegmentResponse]
a} :: SegmentsResponse) (([SegmentResponse] -> f [SegmentResponse])
 -> SegmentsResponse -> f SegmentsResponse)
-> (([SegmentResponse] -> f [SegmentResponse])
    -> [SegmentResponse] -> f [SegmentResponse])
-> ([SegmentResponse] -> f [SegmentResponse])
-> SegmentsResponse
-> f SegmentsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([SegmentResponse] -> f [SegmentResponse])
-> [SegmentResponse] -> f [SegmentResponse]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON SegmentsResponse where
  parseJSON :: Value -> Parser SegmentsResponse
parseJSON =
    String
-> (Object -> Parser SegmentsResponse)
-> Value
-> Parser SegmentsResponse
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SegmentsResponse"
      ( \Object
x ->
          Maybe Text -> [SegmentResponse] -> SegmentsResponse
SegmentsResponse'
            (Maybe Text -> [SegmentResponse] -> SegmentsResponse)
-> Parser (Maybe Text)
-> Parser ([SegmentResponse] -> SegmentsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NextToken")
            Parser ([SegmentResponse] -> SegmentsResponse)
-> Parser [SegmentResponse] -> Parser SegmentsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [SegmentResponse])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Item" Parser (Maybe [SegmentResponse])
-> [SegmentResponse] -> Parser [SegmentResponse]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [SegmentResponse]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable SegmentsResponse

instance Prelude.NFData SegmentsResponse