{-# 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.GetApp
-- 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 an application.
module Amazonka.Pinpoint.GetApp
  ( -- * Creating a Request
    GetApp (..),
    newGetApp,

    -- * Request Lenses
    getApp_applicationId,

    -- * Destructuring the Response
    GetAppResponse (..),
    newGetAppResponse,

    -- * Response Lenses
    getAppResponse_httpStatus,
    getAppResponse_applicationResponse,
  )
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:/ 'newGetApp' smart constructor.
data GetApp = GetApp'
  { -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    GetApp -> Text
applicationId :: Prelude.Text
  }
  deriving (GetApp -> GetApp -> Bool
(GetApp -> GetApp -> Bool)
-> (GetApp -> GetApp -> Bool) -> Eq GetApp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetApp -> GetApp -> Bool
$c/= :: GetApp -> GetApp -> Bool
== :: GetApp -> GetApp -> Bool
$c== :: GetApp -> GetApp -> Bool
Prelude.Eq, ReadPrec [GetApp]
ReadPrec GetApp
Int -> ReadS GetApp
ReadS [GetApp]
(Int -> ReadS GetApp)
-> ReadS [GetApp]
-> ReadPrec GetApp
-> ReadPrec [GetApp]
-> Read GetApp
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetApp]
$creadListPrec :: ReadPrec [GetApp]
readPrec :: ReadPrec GetApp
$creadPrec :: ReadPrec GetApp
readList :: ReadS [GetApp]
$creadList :: ReadS [GetApp]
readsPrec :: Int -> ReadS GetApp
$creadsPrec :: Int -> ReadS GetApp
Prelude.Read, Int -> GetApp -> ShowS
[GetApp] -> ShowS
GetApp -> String
(Int -> GetApp -> ShowS)
-> (GetApp -> String) -> ([GetApp] -> ShowS) -> Show GetApp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetApp] -> ShowS
$cshowList :: [GetApp] -> ShowS
show :: GetApp -> String
$cshow :: GetApp -> String
showsPrec :: Int -> GetApp -> ShowS
$cshowsPrec :: Int -> GetApp -> ShowS
Prelude.Show, (forall x. GetApp -> Rep GetApp x)
-> (forall x. Rep GetApp x -> GetApp) -> Generic GetApp
forall x. Rep GetApp x -> GetApp
forall x. GetApp -> Rep GetApp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetApp x -> GetApp
$cfrom :: forall x. GetApp -> Rep GetApp x
Prelude.Generic)

-- |
-- Create a value of 'GetApp' 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:
--
-- 'applicationId', 'getApp_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
newGetApp ::
  -- | 'applicationId'
  Prelude.Text ->
  GetApp
newGetApp :: Text -> GetApp
newGetApp Text
pApplicationId_ =
  GetApp' :: Text -> GetApp
GetApp' {$sel:applicationId:GetApp' :: Text
applicationId = Text
pApplicationId_}

-- | The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
getApp_applicationId :: Lens.Lens' GetApp Prelude.Text
getApp_applicationId :: (Text -> f Text) -> GetApp -> f GetApp
getApp_applicationId = (GetApp -> Text)
-> (GetApp -> Text -> GetApp) -> Lens GetApp GetApp Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetApp' {Text
applicationId :: Text
$sel:applicationId:GetApp' :: GetApp -> Text
applicationId} -> Text
applicationId) (\s :: GetApp
s@GetApp' {} Text
a -> GetApp
s {$sel:applicationId:GetApp' :: Text
applicationId = Text
a} :: GetApp)

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

instance Prelude.Hashable GetApp

instance Prelude.NFData GetApp

instance Core.ToHeaders GetApp where
  toHeaders :: GetApp -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetApp -> 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 GetApp where
  toPath :: GetApp -> ByteString
toPath GetApp' {Text
applicationId :: Text
$sel:applicationId:GetApp' :: GetApp -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/apps/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId]

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

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

-- |
-- Create a value of 'GetAppResponse' 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', 'getAppResponse_httpStatus' - The response's http status code.
--
-- 'applicationResponse', 'getAppResponse_applicationResponse' - Undocumented member.
newGetAppResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'applicationResponse'
  ApplicationResponse ->
  GetAppResponse
newGetAppResponse :: Int -> ApplicationResponse -> GetAppResponse
newGetAppResponse Int
pHttpStatus_ ApplicationResponse
pApplicationResponse_ =
  GetAppResponse' :: Int -> ApplicationResponse -> GetAppResponse
GetAppResponse'
    { $sel:httpStatus:GetAppResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:applicationResponse:GetAppResponse' :: ApplicationResponse
applicationResponse = ApplicationResponse
pApplicationResponse_
    }

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

-- | Undocumented member.
getAppResponse_applicationResponse :: Lens.Lens' GetAppResponse ApplicationResponse
getAppResponse_applicationResponse :: (ApplicationResponse -> f ApplicationResponse)
-> GetAppResponse -> f GetAppResponse
getAppResponse_applicationResponse = (GetAppResponse -> ApplicationResponse)
-> (GetAppResponse -> ApplicationResponse -> GetAppResponse)
-> Lens
     GetAppResponse
     GetAppResponse
     ApplicationResponse
     ApplicationResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAppResponse' {ApplicationResponse
applicationResponse :: ApplicationResponse
$sel:applicationResponse:GetAppResponse' :: GetAppResponse -> ApplicationResponse
applicationResponse} -> ApplicationResponse
applicationResponse) (\s :: GetAppResponse
s@GetAppResponse' {} ApplicationResponse
a -> GetAppResponse
s {$sel:applicationResponse:GetAppResponse' :: ApplicationResponse
applicationResponse = ApplicationResponse
a} :: GetAppResponse)

instance Prelude.NFData GetAppResponse