{-# 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.Pinpoint.GetApps
-- 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)
--
-- Retrieves information about all the applications that are associated
-- with your Amazon Pinpoint account.
module Amazonka.Pinpoint.GetApps
  ( -- * Creating a Request
    GetApps (..),
    newGetApps,

    -- * Request Lenses
    getApps_token,
    getApps_pageSize,

    -- * Destructuring the Response
    GetAppsResponse (..),
    newGetAppsResponse,

    -- * Response Lenses
    getAppsResponse_httpStatus,
    getAppsResponse_applicationsResponse,
  )
where

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

-- | /See:/ 'newGetApps' smart constructor.
data GetApps = GetApps'
  { -- | The NextToken string that specifies which page of results to return in a
    -- paginated response.
    GetApps -> Maybe Text
token :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to include in each page of a paginated
    -- response. This parameter is not supported for application, campaign, and
    -- journey metrics.
    GetApps -> Maybe Text
pageSize :: Prelude.Maybe Prelude.Text
  }
  deriving (GetApps -> GetApps -> Bool
(GetApps -> GetApps -> Bool)
-> (GetApps -> GetApps -> Bool) -> Eq GetApps
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetApps -> GetApps -> Bool
$c/= :: GetApps -> GetApps -> Bool
== :: GetApps -> GetApps -> Bool
$c== :: GetApps -> GetApps -> Bool
Prelude.Eq, ReadPrec [GetApps]
ReadPrec GetApps
Int -> ReadS GetApps
ReadS [GetApps]
(Int -> ReadS GetApps)
-> ReadS [GetApps]
-> ReadPrec GetApps
-> ReadPrec [GetApps]
-> Read GetApps
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetApps]
$creadListPrec :: ReadPrec [GetApps]
readPrec :: ReadPrec GetApps
$creadPrec :: ReadPrec GetApps
readList :: ReadS [GetApps]
$creadList :: ReadS [GetApps]
readsPrec :: Int -> ReadS GetApps
$creadsPrec :: Int -> ReadS GetApps
Prelude.Read, Int -> GetApps -> ShowS
[GetApps] -> ShowS
GetApps -> String
(Int -> GetApps -> ShowS)
-> (GetApps -> String) -> ([GetApps] -> ShowS) -> Show GetApps
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetApps] -> ShowS
$cshowList :: [GetApps] -> ShowS
show :: GetApps -> String
$cshow :: GetApps -> String
showsPrec :: Int -> GetApps -> ShowS
$cshowsPrec :: Int -> GetApps -> ShowS
Prelude.Show, (forall x. GetApps -> Rep GetApps x)
-> (forall x. Rep GetApps x -> GetApps) -> Generic GetApps
forall x. Rep GetApps x -> GetApps
forall x. GetApps -> Rep GetApps x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetApps x -> GetApps
$cfrom :: forall x. GetApps -> Rep GetApps x
Prelude.Generic)

-- |
-- Create a value of 'GetApps' 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:
--
-- 'token', 'getApps_token' - The NextToken string that specifies which page of results to return in a
-- paginated response.
--
-- 'pageSize', 'getApps_pageSize' - The maximum number of items to include in each page of a paginated
-- response. This parameter is not supported for application, campaign, and
-- journey metrics.
newGetApps ::
  GetApps
newGetApps :: GetApps
newGetApps =
  GetApps' :: Maybe Text -> Maybe Text -> GetApps
GetApps'
    { $sel:token:GetApps' :: Maybe Text
token = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:pageSize:GetApps' :: Maybe Text
pageSize = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The NextToken string that specifies which page of results to return in a
-- paginated response.
getApps_token :: Lens.Lens' GetApps (Prelude.Maybe Prelude.Text)
getApps_token :: (Maybe Text -> f (Maybe Text)) -> GetApps -> f GetApps
getApps_token = (GetApps -> Maybe Text)
-> (GetApps -> Maybe Text -> GetApps)
-> Lens GetApps GetApps (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetApps' {Maybe Text
token :: Maybe Text
$sel:token:GetApps' :: GetApps -> Maybe Text
token} -> Maybe Text
token) (\s :: GetApps
s@GetApps' {} Maybe Text
a -> GetApps
s {$sel:token:GetApps' :: Maybe Text
token = Maybe Text
a} :: GetApps)

-- | The maximum number of items to include in each page of a paginated
-- response. This parameter is not supported for application, campaign, and
-- journey metrics.
getApps_pageSize :: Lens.Lens' GetApps (Prelude.Maybe Prelude.Text)
getApps_pageSize :: (Maybe Text -> f (Maybe Text)) -> GetApps -> f GetApps
getApps_pageSize = (GetApps -> Maybe Text)
-> (GetApps -> Maybe Text -> GetApps)
-> Lens GetApps GetApps (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetApps' {Maybe Text
pageSize :: Maybe Text
$sel:pageSize:GetApps' :: GetApps -> Maybe Text
pageSize} -> Maybe Text
pageSize) (\s :: GetApps
s@GetApps' {} Maybe Text
a -> GetApps
s {$sel:pageSize:GetApps' :: Maybe Text
pageSize = Maybe Text
a} :: GetApps)

instance Core.AWSRequest GetApps where
  type AWSResponse GetApps = GetAppsResponse
  request :: GetApps -> Request GetApps
request = Service -> GetApps -> Request GetApps
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetApps
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetApps)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetApps))
-> Logger
-> Service
-> Proxy GetApps
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetApps)))
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 ->
          Int -> ApplicationsResponse -> GetAppsResponse
GetAppsResponse'
            (Int -> ApplicationsResponse -> GetAppsResponse)
-> Either String Int
-> Either String (ApplicationsResponse -> GetAppsResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (ApplicationsResponse -> GetAppsResponse)
-> Either String ApplicationsResponse
-> Either String GetAppsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String ApplicationsResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

instance Prelude.Hashable GetApps

instance Prelude.NFData GetApps

instance Core.ToHeaders GetApps where
  toHeaders :: GetApps -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetApps -> 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.ToPath GetApps where
  toPath :: GetApps -> ByteString
toPath = ByteString -> GetApps -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/v1/apps"

instance Core.ToQuery GetApps where
  toQuery :: GetApps -> QueryString
toQuery GetApps' {Maybe Text
pageSize :: Maybe Text
token :: Maybe Text
$sel:pageSize:GetApps' :: GetApps -> Maybe Text
$sel:token:GetApps' :: GetApps -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"token" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
token, ByteString
"page-size" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
pageSize]

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

-- |
-- Create a value of 'GetAppsResponse' 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:
--
-- 'httpStatus', 'getAppsResponse_httpStatus' - The response's http status code.
--
-- 'applicationsResponse', 'getAppsResponse_applicationsResponse' - Undocumented member.
newGetAppsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'applicationsResponse'
  ApplicationsResponse ->
  GetAppsResponse
newGetAppsResponse :: Int -> ApplicationsResponse -> GetAppsResponse
newGetAppsResponse
  Int
pHttpStatus_
  ApplicationsResponse
pApplicationsResponse_ =
    GetAppsResponse' :: Int -> ApplicationsResponse -> GetAppsResponse
GetAppsResponse'
      { $sel:httpStatus:GetAppsResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:applicationsResponse:GetAppsResponse' :: ApplicationsResponse
applicationsResponse = ApplicationsResponse
pApplicationsResponse_
      }

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

-- | Undocumented member.
getAppsResponse_applicationsResponse :: Lens.Lens' GetAppsResponse ApplicationsResponse
getAppsResponse_applicationsResponse :: (ApplicationsResponse -> f ApplicationsResponse)
-> GetAppsResponse -> f GetAppsResponse
getAppsResponse_applicationsResponse = (GetAppsResponse -> ApplicationsResponse)
-> (GetAppsResponse -> ApplicationsResponse -> GetAppsResponse)
-> Lens
     GetAppsResponse
     GetAppsResponse
     ApplicationsResponse
     ApplicationsResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAppsResponse' {ApplicationsResponse
applicationsResponse :: ApplicationsResponse
$sel:applicationsResponse:GetAppsResponse' :: GetAppsResponse -> ApplicationsResponse
applicationsResponse} -> ApplicationsResponse
applicationsResponse) (\s :: GetAppsResponse
s@GetAppsResponse' {} ApplicationsResponse
a -> GetAppsResponse
s {$sel:applicationsResponse:GetAppsResponse' :: ApplicationsResponse
applicationsResponse = ApplicationsResponse
a} :: GetAppsResponse)

instance Prelude.NFData GetAppsResponse