amazonka-discovery-2.0: gen/Amazonka/Discovery/CreateApplication.hs
{-# 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.Discovery.CreateApplication
-- 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 with the given name and description.
module Amazonka.Discovery.CreateApplication
( -- * Creating a Request
CreateApplication (..),
newCreateApplication,
-- * Request Lenses
createApplication_description,
createApplication_name,
-- * Destructuring the Response
CreateApplicationResponse (..),
newCreateApplicationResponse,
-- * Response Lenses
createApplicationResponse_configurationId,
createApplicationResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Discovery.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
-- | /See:/ 'newCreateApplication' smart constructor.
data CreateApplication = CreateApplication'
{ -- | Description of the application to be created.
description :: Prelude.Maybe Prelude.Text,
-- | Name of the application to be created.
name :: Prelude.Text
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'CreateApplication' 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:
--
-- 'description', 'createApplication_description' - Description of the application to be created.
--
-- 'name', 'createApplication_name' - Name of the application to be created.
newCreateApplication ::
-- | 'name'
Prelude.Text ->
CreateApplication
newCreateApplication pName_ =
CreateApplication'
{ description = Prelude.Nothing,
name = pName_
}
-- | Description of the application to be created.
createApplication_description :: Lens.Lens' CreateApplication (Prelude.Maybe Prelude.Text)
createApplication_description = Lens.lens (\CreateApplication' {description} -> description) (\s@CreateApplication' {} a -> s {description = a} :: CreateApplication)
-- | Name of the application to be created.
createApplication_name :: Lens.Lens' CreateApplication Prelude.Text
createApplication_name = Lens.lens (\CreateApplication' {name} -> name) (\s@CreateApplication' {} a -> s {name = a} :: CreateApplication)
instance Core.AWSRequest CreateApplication where
type
AWSResponse CreateApplication =
CreateApplicationResponse
request overrides =
Request.postJSON (overrides defaultService)
response =
Response.receiveJSON
( \s h x ->
CreateApplicationResponse'
Prelude.<$> (x Data..?> "configurationId")
Prelude.<*> (Prelude.pure (Prelude.fromEnum s))
)
instance Prelude.Hashable CreateApplication where
hashWithSalt _salt CreateApplication' {..} =
_salt
`Prelude.hashWithSalt` description
`Prelude.hashWithSalt` name
instance Prelude.NFData CreateApplication where
rnf CreateApplication' {..} =
Prelude.rnf description
`Prelude.seq` Prelude.rnf name
instance Data.ToHeaders CreateApplication where
toHeaders =
Prelude.const
( Prelude.mconcat
[ "X-Amz-Target"
Data.=# ( "AWSPoseidonService_V2015_11_01.CreateApplication" ::
Prelude.ByteString
),
"Content-Type"
Data.=# ( "application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON CreateApplication where
toJSON CreateApplication' {..} =
Data.object
( Prelude.catMaybes
[ ("description" Data..=) Prelude.<$> description,
Prelude.Just ("name" Data..= name)
]
)
instance Data.ToPath CreateApplication where
toPath = Prelude.const "/"
instance Data.ToQuery CreateApplication where
toQuery = Prelude.const Prelude.mempty
-- | /See:/ 'newCreateApplicationResponse' smart constructor.
data CreateApplicationResponse = CreateApplicationResponse'
{ -- | Configuration ID of an application to be created.
configurationId :: Prelude.Maybe Prelude.Text,
-- | The response's http status code.
httpStatus :: Prelude.Int
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'CreateApplicationResponse' 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:
--
-- 'configurationId', 'createApplicationResponse_configurationId' - Configuration ID of an application to be created.
--
-- 'httpStatus', 'createApplicationResponse_httpStatus' - The response's http status code.
newCreateApplicationResponse ::
-- | 'httpStatus'
Prelude.Int ->
CreateApplicationResponse
newCreateApplicationResponse pHttpStatus_ =
CreateApplicationResponse'
{ configurationId =
Prelude.Nothing,
httpStatus = pHttpStatus_
}
-- | Configuration ID of an application to be created.
createApplicationResponse_configurationId :: Lens.Lens' CreateApplicationResponse (Prelude.Maybe Prelude.Text)
createApplicationResponse_configurationId = Lens.lens (\CreateApplicationResponse' {configurationId} -> configurationId) (\s@CreateApplicationResponse' {} a -> s {configurationId = a} :: CreateApplicationResponse)
-- | The response's http status code.
createApplicationResponse_httpStatus :: Lens.Lens' CreateApplicationResponse Prelude.Int
createApplicationResponse_httpStatus = Lens.lens (\CreateApplicationResponse' {httpStatus} -> httpStatus) (\s@CreateApplicationResponse' {} a -> s {httpStatus = a} :: CreateApplicationResponse)
instance Prelude.NFData CreateApplicationResponse where
rnf CreateApplicationResponse' {..} =
Prelude.rnf configurationId
`Prelude.seq` Prelude.rnf httpStatus