{-# 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-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)
--
-- 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 Amazonka.IoT.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:/ 'newDescribeRoleAlias' smart constructor.
data DescribeRoleAlias = DescribeRoleAlias'
  { -- | The role alias to describe.
    DescribeRoleAlias -> Text
roleAlias :: Prelude.Text
  }
  deriving (DescribeRoleAlias -> DescribeRoleAlias -> Bool
(DescribeRoleAlias -> DescribeRoleAlias -> Bool)
-> (DescribeRoleAlias -> DescribeRoleAlias -> Bool)
-> Eq DescribeRoleAlias
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]
(Int -> ReadS DescribeRoleAlias)
-> ReadS [DescribeRoleAlias]
-> ReadPrec DescribeRoleAlias
-> ReadPrec [DescribeRoleAlias]
-> Read 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
(Int -> DescribeRoleAlias -> ShowS)
-> (DescribeRoleAlias -> String)
-> ([DescribeRoleAlias] -> ShowS)
-> Show DescribeRoleAlias
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. DescribeRoleAlias -> Rep DescribeRoleAlias x)
-> (forall x. Rep DescribeRoleAlias x -> DescribeRoleAlias)
-> Generic DescribeRoleAlias
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' :: Text -> DescribeRoleAlias
DescribeRoleAlias' {$sel:roleAlias:DescribeRoleAlias' :: Text
roleAlias = Text
pRoleAlias_}

-- | The role alias to describe.
describeRoleAlias_roleAlias :: Lens.Lens' DescribeRoleAlias Prelude.Text
describeRoleAlias_roleAlias :: (Text -> f Text) -> DescribeRoleAlias -> f DescribeRoleAlias
describeRoleAlias_roleAlias = (DescribeRoleAlias -> Text)
-> (DescribeRoleAlias -> Text -> DescribeRoleAlias)
-> Lens DescribeRoleAlias DescribeRoleAlias Text Text
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 :: DescribeRoleAlias -> Request DescribeRoleAlias
request = Service -> DescribeRoleAlias -> Request DescribeRoleAlias
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeRoleAlias
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeRoleAlias)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeRoleAlias))
-> Logger
-> Service
-> Proxy DescribeRoleAlias
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeRoleAlias)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe RoleAliasDescription -> Int -> DescribeRoleAliasResponse
DescribeRoleAliasResponse'
            (Maybe RoleAliasDescription -> Int -> DescribeRoleAliasResponse)
-> Either String (Maybe RoleAliasDescription)
-> Either String (Int -> DescribeRoleAliasResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe RoleAliasDescription)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"roleAliasDescription")
            Either String (Int -> DescribeRoleAliasResponse)
-> Either String Int -> Either String DescribeRoleAliasResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeRoleAlias

instance Prelude.NFData DescribeRoleAlias

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

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

instance Core.ToQuery DescribeRoleAlias where
  toQuery :: DescribeRoleAlias -> QueryString
toQuery = QueryString -> DescribeRoleAlias -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DescribeRoleAliasResponse -> DescribeRoleAliasResponse -> Bool)
-> (DescribeRoleAliasResponse -> DescribeRoleAliasResponse -> Bool)
-> Eq DescribeRoleAliasResponse
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]
(Int -> ReadS DescribeRoleAliasResponse)
-> ReadS [DescribeRoleAliasResponse]
-> ReadPrec DescribeRoleAliasResponse
-> ReadPrec [DescribeRoleAliasResponse]
-> Read 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
(Int -> DescribeRoleAliasResponse -> ShowS)
-> (DescribeRoleAliasResponse -> String)
-> ([DescribeRoleAliasResponse] -> ShowS)
-> Show DescribeRoleAliasResponse
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.
 DescribeRoleAliasResponse -> Rep DescribeRoleAliasResponse x)
-> (forall x.
    Rep DescribeRoleAliasResponse x -> DescribeRoleAliasResponse)
-> Generic DescribeRoleAliasResponse
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' :: Maybe RoleAliasDescription -> Int -> DescribeRoleAliasResponse
DescribeRoleAliasResponse'
    { $sel:roleAliasDescription:DescribeRoleAliasResponse' :: Maybe RoleAliasDescription
roleAliasDescription =
        Maybe 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 :: (Maybe RoleAliasDescription -> f (Maybe RoleAliasDescription))
-> DescribeRoleAliasResponse -> f DescribeRoleAliasResponse
describeRoleAliasResponse_roleAliasDescription = (DescribeRoleAliasResponse -> Maybe RoleAliasDescription)
-> (DescribeRoleAliasResponse
    -> Maybe RoleAliasDescription -> DescribeRoleAliasResponse)
-> Lens
     DescribeRoleAliasResponse
     DescribeRoleAliasResponse
     (Maybe RoleAliasDescription)
     (Maybe 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 :: (Int -> f Int)
-> DescribeRoleAliasResponse -> f DescribeRoleAliasResponse
describeRoleAliasResponse_httpStatus = (DescribeRoleAliasResponse -> Int)
-> (DescribeRoleAliasResponse -> Int -> DescribeRoleAliasResponse)
-> Lens DescribeRoleAliasResponse DescribeRoleAliasResponse Int Int
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