{-# 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.IoT.DescribeRoleAlias
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describes a role alias.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions DescribeRoleAlias>
-- action.
module Amazonka.IoT.DescribeRoleAlias
  ( -- * Creating a Request
    DescribeRoleAlias (..),
    newDescribeRoleAlias,

    -- * Request Lenses
    describeRoleAlias_roleAlias,

    -- * Destructuring the Response
    DescribeRoleAliasResponse (..),
    newDescribeRoleAliasResponse,

    -- * Response Lenses
    describeRoleAliasResponse_roleAliasDescription,
    describeRoleAliasResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'DescribeRoleAlias' 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:
--
-- 'roleAlias', 'describeRoleAlias_roleAlias' - The role alias to describe.
newDescribeRoleAlias ::
  -- | 'roleAlias'
  Prelude.Text ->
  DescribeRoleAlias
newDescribeRoleAlias :: Text -> DescribeRoleAlias
newDescribeRoleAlias Text
pRoleAlias_ =
  DescribeRoleAlias' {$sel:roleAlias:DescribeRoleAlias' :: Text
roleAlias = Text
pRoleAlias_}

-- | The role alias to describe.
describeRoleAlias_roleAlias :: Lens.Lens' DescribeRoleAlias Prelude.Text
describeRoleAlias_roleAlias :: Lens' DescribeRoleAlias Text
describeRoleAlias_roleAlias = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRoleAlias' {Text
roleAlias :: Text
$sel:roleAlias:DescribeRoleAlias' :: DescribeRoleAlias -> Text
roleAlias} -> Text
roleAlias) (\s :: DescribeRoleAlias
s@DescribeRoleAlias' {} Text
a -> DescribeRoleAlias
s {$sel:roleAlias:DescribeRoleAlias' :: Text
roleAlias = Text
a} :: DescribeRoleAlias)

instance Core.AWSRequest DescribeRoleAlias where
  type
    AWSResponse DescribeRoleAlias =
      DescribeRoleAliasResponse
  request :: (Service -> Service)
-> DescribeRoleAlias -> Request DescribeRoleAlias
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 DescribeRoleAlias
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeRoleAlias)))
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 RoleAliasDescription -> Int -> DescribeRoleAliasResponse
DescribeRoleAliasResponse'
            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
"roleAliasDescription")
            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 DescribeRoleAlias where
  hashWithSalt :: Int -> DescribeRoleAlias -> Int
hashWithSalt Int
_salt DescribeRoleAlias' {Text
roleAlias :: Text
$sel:roleAlias:DescribeRoleAlias' :: DescribeRoleAlias -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleAlias

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

instance Data.ToHeaders DescribeRoleAlias where
  toHeaders :: DescribeRoleAlias -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

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

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

-- |
-- Create a value of 'DescribeRoleAliasResponse' 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:
--
-- 'roleAliasDescription', 'describeRoleAliasResponse_roleAliasDescription' - The role alias description.
--
-- 'httpStatus', 'describeRoleAliasResponse_httpStatus' - The response's http status code.
newDescribeRoleAliasResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeRoleAliasResponse
newDescribeRoleAliasResponse :: Int -> DescribeRoleAliasResponse
newDescribeRoleAliasResponse Int
pHttpStatus_ =
  DescribeRoleAliasResponse'
    { $sel:roleAliasDescription:DescribeRoleAliasResponse' :: Maybe RoleAliasDescription
roleAliasDescription =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeRoleAliasResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The role alias description.
describeRoleAliasResponse_roleAliasDescription :: Lens.Lens' DescribeRoleAliasResponse (Prelude.Maybe RoleAliasDescription)
describeRoleAliasResponse_roleAliasDescription :: Lens' DescribeRoleAliasResponse (Maybe RoleAliasDescription)
describeRoleAliasResponse_roleAliasDescription = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRoleAliasResponse' {Maybe RoleAliasDescription
roleAliasDescription :: Maybe RoleAliasDescription
$sel:roleAliasDescription:DescribeRoleAliasResponse' :: DescribeRoleAliasResponse -> Maybe RoleAliasDescription
roleAliasDescription} -> Maybe RoleAliasDescription
roleAliasDescription) (\s :: DescribeRoleAliasResponse
s@DescribeRoleAliasResponse' {} Maybe RoleAliasDescription
a -> DescribeRoleAliasResponse
s {$sel:roleAliasDescription:DescribeRoleAliasResponse' :: Maybe RoleAliasDescription
roleAliasDescription = Maybe RoleAliasDescription
a} :: DescribeRoleAliasResponse)

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

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