{-# 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.Amplify.GetApp
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns an existing Amplify app by appID.
module Amazonka.Amplify.GetApp
  ( -- * Creating a Request
    GetApp (..),
    newGetApp,

    -- * Request Lenses
    getApp_appId,

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

    -- * Response Lenses
    getAppResponse_httpStatus,
    getAppResponse_app,
  )
where

import Amazonka.Amplify.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | The request structure for the get app request.
--
-- /See:/ 'newGetApp' smart constructor.
data GetApp = GetApp'
  { -- | The unique ID for an Amplify app.
    GetApp -> Text
appId :: Prelude.Text
  }
  deriving (GetApp -> GetApp -> Bool
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]
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
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. 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:
--
-- 'appId', 'getApp_appId' - The unique ID for an Amplify app.
newGetApp ::
  -- | 'appId'
  Prelude.Text ->
  GetApp
newGetApp :: Text -> GetApp
newGetApp Text
pAppId_ = GetApp' {$sel:appId:GetApp' :: Text
appId = Text
pAppId_}

-- | The unique ID for an Amplify app.
getApp_appId :: Lens.Lens' GetApp Prelude.Text
getApp_appId :: Lens' GetApp Text
getApp_appId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetApp' {Text
appId :: Text
$sel:appId:GetApp' :: GetApp -> Text
appId} -> Text
appId) (\s :: GetApp
s@GetApp' {} Text
a -> GetApp
s {$sel:appId:GetApp' :: Text
appId = Text
a} :: GetApp)

instance Core.AWSRequest GetApp where
  type AWSResponse GetApp = GetAppResponse
  request :: (Service -> Service) -> GetApp -> Request GetApp
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetApp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetApp)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> App -> GetAppResponse
GetAppResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"app")
      )

instance Prelude.Hashable GetApp where
  hashWithSalt :: Int -> GetApp -> Int
hashWithSalt Int
_salt GetApp' {Text
appId :: Text
$sel:appId:GetApp' :: GetApp -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
appId

instance Prelude.NFData GetApp where
  rnf :: GetApp -> ()
rnf GetApp' {Text
appId :: Text
$sel:appId:GetApp' :: GetApp -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
appId

instance Data.ToHeaders GetApp where
  toHeaders :: GetApp -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath GetApp where
  toPath :: GetApp -> ByteString
toPath GetApp' {Text
appId :: Text
$sel:appId:GetApp' :: GetApp -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/apps/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
appId]

instance Data.ToQuery GetApp where
  toQuery :: GetApp -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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 -> App
app :: App
  }
  deriving (GetAppResponse -> GetAppResponse -> Bool
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, Int -> GetAppResponse -> ShowS
[GetAppResponse] -> ShowS
GetAppResponse -> String
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. 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.
--
-- 'app', 'getAppResponse_app' - Undocumented member.
newGetAppResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'app'
  App ->
  GetAppResponse
newGetAppResponse :: Int -> App -> GetAppResponse
newGetAppResponse Int
pHttpStatus_ App
pApp_ =
  GetAppResponse'
    { $sel:httpStatus:GetAppResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:app:GetAppResponse' :: App
app = App
pApp_
    }

-- | The response's http status code.
getAppResponse_httpStatus :: Lens.Lens' GetAppResponse Prelude.Int
getAppResponse_httpStatus :: Lens' GetAppResponse Int
getAppResponse_httpStatus = 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_app :: Lens.Lens' GetAppResponse App
getAppResponse_app :: Lens' GetAppResponse App
getAppResponse_app = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAppResponse' {App
app :: App
$sel:app:GetAppResponse' :: GetAppResponse -> App
app} -> App
app) (\s :: GetAppResponse
s@GetAppResponse' {} App
a -> GetAppResponse
s {$sel:app:GetAppResponse' :: App
app = App
a} :: GetAppResponse)

instance Prelude.NFData GetAppResponse where
  rnf :: GetAppResponse -> ()
rnf GetAppResponse' {Int
App
app :: App
httpStatus :: Int
$sel:app:GetAppResponse' :: GetAppResponse -> App
$sel:httpStatus:GetAppResponse' :: GetAppResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf App
app