{-# 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.CreateApp
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates an application.
module Amazonka.Pinpoint.CreateApp
  ( -- * Creating a Request
    CreateApp (..),
    newCreateApp,

    -- * Request Lenses
    createApp_createApplicationRequest,

    -- * Destructuring the Response
    CreateAppResponse (..),
    newCreateAppResponse,

    -- * Response Lenses
    createAppResponse_httpStatus,
    createAppResponse_applicationResponse,
  )
where

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

-- | /See:/ 'newCreateApp' smart constructor.
data CreateApp = CreateApp'
  { CreateApp -> CreateApplicationRequest
createApplicationRequest :: CreateApplicationRequest
  }
  deriving (CreateApp -> CreateApp -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateApp -> CreateApp -> Bool
$c/= :: CreateApp -> CreateApp -> Bool
== :: CreateApp -> CreateApp -> Bool
$c== :: CreateApp -> CreateApp -> Bool
Prelude.Eq, ReadPrec [CreateApp]
ReadPrec CreateApp
Int -> ReadS CreateApp
ReadS [CreateApp]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateApp]
$creadListPrec :: ReadPrec [CreateApp]
readPrec :: ReadPrec CreateApp
$creadPrec :: ReadPrec CreateApp
readList :: ReadS [CreateApp]
$creadList :: ReadS [CreateApp]
readsPrec :: Int -> ReadS CreateApp
$creadsPrec :: Int -> ReadS CreateApp
Prelude.Read, Int -> CreateApp -> ShowS
[CreateApp] -> ShowS
CreateApp -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateApp] -> ShowS
$cshowList :: [CreateApp] -> ShowS
show :: CreateApp -> String
$cshow :: CreateApp -> String
showsPrec :: Int -> CreateApp -> ShowS
$cshowsPrec :: Int -> CreateApp -> ShowS
Prelude.Show, forall x. Rep CreateApp x -> CreateApp
forall x. CreateApp -> Rep CreateApp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateApp x -> CreateApp
$cfrom :: forall x. CreateApp -> Rep CreateApp x
Prelude.Generic)

-- |
-- Create a value of 'CreateApp' 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:
--
-- 'createApplicationRequest', 'createApp_createApplicationRequest' - Undocumented member.
newCreateApp ::
  -- | 'createApplicationRequest'
  CreateApplicationRequest ->
  CreateApp
newCreateApp :: CreateApplicationRequest -> CreateApp
newCreateApp CreateApplicationRequest
pCreateApplicationRequest_ =
  CreateApp'
    { $sel:createApplicationRequest:CreateApp' :: CreateApplicationRequest
createApplicationRequest =
        CreateApplicationRequest
pCreateApplicationRequest_
    }

-- | Undocumented member.
createApp_createApplicationRequest :: Lens.Lens' CreateApp CreateApplicationRequest
createApp_createApplicationRequest :: Lens' CreateApp CreateApplicationRequest
createApp_createApplicationRequest = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApp' {CreateApplicationRequest
createApplicationRequest :: CreateApplicationRequest
$sel:createApplicationRequest:CreateApp' :: CreateApp -> CreateApplicationRequest
createApplicationRequest} -> CreateApplicationRequest
createApplicationRequest) (\s :: CreateApp
s@CreateApp' {} CreateApplicationRequest
a -> CreateApp
s {$sel:createApplicationRequest:CreateApp' :: CreateApplicationRequest
createApplicationRequest = CreateApplicationRequest
a} :: CreateApp)

instance Core.AWSRequest CreateApp where
  type AWSResponse CreateApp = CreateAppResponse
  request :: (Service -> Service) -> CreateApp -> Request CreateApp
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateApp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateApp)))
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 -> ApplicationResponse -> CreateAppResponse
CreateAppResponse'
            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.<*> (forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)
      )

instance Prelude.Hashable CreateApp where
  hashWithSalt :: Int -> CreateApp -> Int
hashWithSalt Int
_salt CreateApp' {CreateApplicationRequest
createApplicationRequest :: CreateApplicationRequest
$sel:createApplicationRequest:CreateApp' :: CreateApp -> CreateApplicationRequest
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` CreateApplicationRequest
createApplicationRequest

instance Prelude.NFData CreateApp where
  rnf :: CreateApp -> ()
rnf CreateApp' {CreateApplicationRequest
createApplicationRequest :: CreateApplicationRequest
$sel:createApplicationRequest:CreateApp' :: CreateApp -> CreateApplicationRequest
..} =
    forall a. NFData a => a -> ()
Prelude.rnf CreateApplicationRequest
createApplicationRequest

instance Data.ToHeaders CreateApp where
  toHeaders :: CreateApp -> 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.ToJSON CreateApp where
  toJSON :: CreateApp -> Value
toJSON CreateApp' {CreateApplicationRequest
createApplicationRequest :: CreateApplicationRequest
$sel:createApplicationRequest:CreateApp' :: CreateApp -> CreateApplicationRequest
..} =
    forall a. ToJSON a => a -> Value
Data.toJSON CreateApplicationRequest
createApplicationRequest

instance Data.ToPath CreateApp where
  toPath :: CreateApp -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/v1/apps"

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

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

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

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

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

instance Prelude.NFData CreateAppResponse where
  rnf :: CreateAppResponse -> ()
rnf CreateAppResponse' {Int
ApplicationResponse
applicationResponse :: ApplicationResponse
httpStatus :: Int
$sel:applicationResponse:CreateAppResponse' :: CreateAppResponse -> ApplicationResponse
$sel:httpStatus:CreateAppResponse' :: CreateAppResponse -> 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 ApplicationResponse
applicationResponse