{-# 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.SupportApp.GetAccountAlias
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the alias from an Amazon Web Services account ID. The alias
-- appears in the Amazon Web Services Support App page of the Amazon Web
-- Services Support Center. The alias also appears in Slack messages from
-- the Amazon Web Services Support App.
module Amazonka.SupportApp.GetAccountAlias
  ( -- * Creating a Request
    GetAccountAlias (..),
    newGetAccountAlias,

    -- * Destructuring the Response
    GetAccountAliasResponse (..),
    newGetAccountAliasResponse,

    -- * Response Lenses
    getAccountAliasResponse_accountAlias,
    getAccountAliasResponse_httpStatus,
  )
where

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
import Amazonka.SupportApp.Types

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

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

instance Core.AWSRequest GetAccountAlias where
  type
    AWSResponse GetAccountAlias =
      GetAccountAliasResponse
  request :: (Service -> Service) -> GetAccountAlias -> Request GetAccountAlias
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 GetAccountAlias
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAccountAlias)))
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 ->
          Maybe Text -> Int -> GetAccountAliasResponse
GetAccountAliasResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"accountAlias")
            forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable GetAccountAlias where
  hashWithSalt :: Int -> GetAccountAlias -> Int
hashWithSalt Int
_salt GetAccountAlias
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

instance Prelude.NFData GetAccountAlias where
  rnf :: GetAccountAlias -> ()
rnf GetAccountAlias
_ = ()

instance Data.ToHeaders GetAccountAlias where
  toHeaders :: GetAccountAlias -> 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 GetAccountAlias where
  toJSON :: GetAccountAlias -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath GetAccountAlias where
  toPath :: GetAccountAlias -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/control/get-account-alias"

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

-- | /See:/ 'newGetAccountAliasResponse' smart constructor.
data GetAccountAliasResponse = GetAccountAliasResponse'
  { -- | An alias or short name for an Amazon Web Services account.
    GetAccountAliasResponse -> Maybe Text
accountAlias :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetAccountAliasResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetAccountAliasResponse -> GetAccountAliasResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAccountAliasResponse -> GetAccountAliasResponse -> Bool
$c/= :: GetAccountAliasResponse -> GetAccountAliasResponse -> Bool
== :: GetAccountAliasResponse -> GetAccountAliasResponse -> Bool
$c== :: GetAccountAliasResponse -> GetAccountAliasResponse -> Bool
Prelude.Eq, ReadPrec [GetAccountAliasResponse]
ReadPrec GetAccountAliasResponse
Int -> ReadS GetAccountAliasResponse
ReadS [GetAccountAliasResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAccountAliasResponse]
$creadListPrec :: ReadPrec [GetAccountAliasResponse]
readPrec :: ReadPrec GetAccountAliasResponse
$creadPrec :: ReadPrec GetAccountAliasResponse
readList :: ReadS [GetAccountAliasResponse]
$creadList :: ReadS [GetAccountAliasResponse]
readsPrec :: Int -> ReadS GetAccountAliasResponse
$creadsPrec :: Int -> ReadS GetAccountAliasResponse
Prelude.Read, Int -> GetAccountAliasResponse -> ShowS
[GetAccountAliasResponse] -> ShowS
GetAccountAliasResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAccountAliasResponse] -> ShowS
$cshowList :: [GetAccountAliasResponse] -> ShowS
show :: GetAccountAliasResponse -> String
$cshow :: GetAccountAliasResponse -> String
showsPrec :: Int -> GetAccountAliasResponse -> ShowS
$cshowsPrec :: Int -> GetAccountAliasResponse -> ShowS
Prelude.Show, forall x. Rep GetAccountAliasResponse x -> GetAccountAliasResponse
forall x. GetAccountAliasResponse -> Rep GetAccountAliasResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAccountAliasResponse x -> GetAccountAliasResponse
$cfrom :: forall x. GetAccountAliasResponse -> Rep GetAccountAliasResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetAccountAliasResponse' 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', 'getAccountAliasResponse_accountAlias' - An alias or short name for an Amazon Web Services account.
--
-- 'httpStatus', 'getAccountAliasResponse_httpStatus' - The response's http status code.
newGetAccountAliasResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAccountAliasResponse
newGetAccountAliasResponse :: Int -> GetAccountAliasResponse
newGetAccountAliasResponse Int
pHttpStatus_ =
  GetAccountAliasResponse'
    { $sel:accountAlias:GetAccountAliasResponse' :: Maybe Text
accountAlias =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetAccountAliasResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An alias or short name for an Amazon Web Services account.
getAccountAliasResponse_accountAlias :: Lens.Lens' GetAccountAliasResponse (Prelude.Maybe Prelude.Text)
getAccountAliasResponse_accountAlias :: Lens' GetAccountAliasResponse (Maybe Text)
getAccountAliasResponse_accountAlias = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAccountAliasResponse' {Maybe Text
accountAlias :: Maybe Text
$sel:accountAlias:GetAccountAliasResponse' :: GetAccountAliasResponse -> Maybe Text
accountAlias} -> Maybe Text
accountAlias) (\s :: GetAccountAliasResponse
s@GetAccountAliasResponse' {} Maybe Text
a -> GetAccountAliasResponse
s {$sel:accountAlias:GetAccountAliasResponse' :: Maybe Text
accountAlias = Maybe Text
a} :: GetAccountAliasResponse)

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

instance Prelude.NFData GetAccountAliasResponse where
  rnf :: GetAccountAliasResponse -> ()
rnf GetAccountAliasResponse' {Int
Maybe Text
httpStatus :: Int
accountAlias :: Maybe Text
$sel:httpStatus:GetAccountAliasResponse' :: GetAccountAliasResponse -> Int
$sel:accountAlias:GetAccountAliasResponse' :: GetAccountAliasResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountAlias
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus