{-# 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.IAM.CreateAccountAlias
-- 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)
--
-- Creates an alias for your Amazon Web Services account. For information
-- about using an Amazon Web Services account alias, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/AccountAlias.html Using an alias for your Amazon Web Services account ID>
-- in the /IAM User Guide/.
module Amazonka.IAM.CreateAccountAlias
  ( -- * Creating a Request
    CreateAccountAlias (..),
    newCreateAccountAlias,

    -- * Request Lenses
    createAccountAlias_accountAlias,

    -- * Destructuring the Response
    CreateAccountAliasResponse (..),
    newCreateAccountAliasResponse,
  )
where

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

-- | /See:/ 'newCreateAccountAlias' smart constructor.
data CreateAccountAlias = CreateAccountAlias'
  { -- | The account alias to create.
    --
    -- This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- consisting of lowercase letters, digits, and dashes. You cannot start or
    -- finish with a dash, nor can you have two dashes in a row.
    CreateAccountAlias -> Text
accountAlias :: Prelude.Text
  }
  deriving (CreateAccountAlias -> CreateAccountAlias -> Bool
(CreateAccountAlias -> CreateAccountAlias -> Bool)
-> (CreateAccountAlias -> CreateAccountAlias -> Bool)
-> Eq CreateAccountAlias
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAccountAlias -> CreateAccountAlias -> Bool
$c/= :: CreateAccountAlias -> CreateAccountAlias -> Bool
== :: CreateAccountAlias -> CreateAccountAlias -> Bool
$c== :: CreateAccountAlias -> CreateAccountAlias -> Bool
Prelude.Eq, ReadPrec [CreateAccountAlias]
ReadPrec CreateAccountAlias
Int -> ReadS CreateAccountAlias
ReadS [CreateAccountAlias]
(Int -> ReadS CreateAccountAlias)
-> ReadS [CreateAccountAlias]
-> ReadPrec CreateAccountAlias
-> ReadPrec [CreateAccountAlias]
-> Read CreateAccountAlias
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAccountAlias]
$creadListPrec :: ReadPrec [CreateAccountAlias]
readPrec :: ReadPrec CreateAccountAlias
$creadPrec :: ReadPrec CreateAccountAlias
readList :: ReadS [CreateAccountAlias]
$creadList :: ReadS [CreateAccountAlias]
readsPrec :: Int -> ReadS CreateAccountAlias
$creadsPrec :: Int -> ReadS CreateAccountAlias
Prelude.Read, Int -> CreateAccountAlias -> ShowS
[CreateAccountAlias] -> ShowS
CreateAccountAlias -> String
(Int -> CreateAccountAlias -> ShowS)
-> (CreateAccountAlias -> String)
-> ([CreateAccountAlias] -> ShowS)
-> Show CreateAccountAlias
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAccountAlias] -> ShowS
$cshowList :: [CreateAccountAlias] -> ShowS
show :: CreateAccountAlias -> String
$cshow :: CreateAccountAlias -> String
showsPrec :: Int -> CreateAccountAlias -> ShowS
$cshowsPrec :: Int -> CreateAccountAlias -> ShowS
Prelude.Show, (forall x. CreateAccountAlias -> Rep CreateAccountAlias x)
-> (forall x. Rep CreateAccountAlias x -> CreateAccountAlias)
-> Generic CreateAccountAlias
forall x. Rep CreateAccountAlias x -> CreateAccountAlias
forall x. CreateAccountAlias -> Rep CreateAccountAlias x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAccountAlias x -> CreateAccountAlias
$cfrom :: forall x. CreateAccountAlias -> Rep CreateAccountAlias x
Prelude.Generic)

-- |
-- Create a value of 'CreateAccountAlias' 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:
--
-- 'accountAlias', 'createAccountAlias_accountAlias' - The account alias to create.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of lowercase letters, digits, and dashes. You cannot start or
-- finish with a dash, nor can you have two dashes in a row.
newCreateAccountAlias ::
  -- | 'accountAlias'
  Prelude.Text ->
  CreateAccountAlias
newCreateAccountAlias :: Text -> CreateAccountAlias
newCreateAccountAlias Text
pAccountAlias_ =
  CreateAccountAlias' :: Text -> CreateAccountAlias
CreateAccountAlias' {$sel:accountAlias:CreateAccountAlias' :: Text
accountAlias = Text
pAccountAlias_}

-- | The account alias to create.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of lowercase letters, digits, and dashes. You cannot start or
-- finish with a dash, nor can you have two dashes in a row.
createAccountAlias_accountAlias :: Lens.Lens' CreateAccountAlias Prelude.Text
createAccountAlias_accountAlias :: (Text -> f Text) -> CreateAccountAlias -> f CreateAccountAlias
createAccountAlias_accountAlias = (CreateAccountAlias -> Text)
-> (CreateAccountAlias -> Text -> CreateAccountAlias)
-> Lens CreateAccountAlias CreateAccountAlias Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAccountAlias' {Text
accountAlias :: Text
$sel:accountAlias:CreateAccountAlias' :: CreateAccountAlias -> Text
accountAlias} -> Text
accountAlias) (\s :: CreateAccountAlias
s@CreateAccountAlias' {} Text
a -> CreateAccountAlias
s {$sel:accountAlias:CreateAccountAlias' :: Text
accountAlias = Text
a} :: CreateAccountAlias)

instance Core.AWSRequest CreateAccountAlias where
  type
    AWSResponse CreateAccountAlias =
      CreateAccountAliasResponse
  request :: CreateAccountAlias -> Request CreateAccountAlias
request = Service -> CreateAccountAlias -> Request CreateAccountAlias
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateAccountAlias
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateAccountAlias)))
response =
    AWSResponse CreateAccountAlias
-> Logger
-> Service
-> Proxy CreateAccountAlias
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateAccountAlias)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse CreateAccountAlias
CreateAccountAliasResponse
CreateAccountAliasResponse'

instance Prelude.Hashable CreateAccountAlias

instance Prelude.NFData CreateAccountAlias

instance Core.ToHeaders CreateAccountAlias where
  toHeaders :: CreateAccountAlias -> [Header]
toHeaders = [Header] -> CreateAccountAlias -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath CreateAccountAlias where
  toPath :: CreateAccountAlias -> ByteString
toPath = ByteString -> CreateAccountAlias -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery CreateAccountAlias where
  toQuery :: CreateAccountAlias -> QueryString
toQuery CreateAccountAlias' {Text
accountAlias :: Text
$sel:accountAlias:CreateAccountAlias' :: CreateAccountAlias -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"CreateAccountAlias" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"AccountAlias" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
accountAlias
      ]

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

-- |
-- Create a value of 'CreateAccountAliasResponse' 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.
newCreateAccountAliasResponse ::
  CreateAccountAliasResponse
newCreateAccountAliasResponse :: CreateAccountAliasResponse
newCreateAccountAliasResponse =
  CreateAccountAliasResponse
CreateAccountAliasResponse'

instance Prelude.NFData CreateAccountAliasResponse