{-# 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.GetInstanceProfile
-- 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)
--
-- Retrieves information about the specified instance profile, including
-- the instance profile\'s path, GUID, ARN, and role. For more information
-- about instance profiles, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/AboutInstanceProfiles.html About instance profiles>
-- in the /IAM User Guide/.
module Amazonka.IAM.GetInstanceProfile
  ( -- * Creating a Request
    GetInstanceProfile (..),
    newGetInstanceProfile,

    -- * Request Lenses
    getInstanceProfile_instanceProfileName,

    -- * Destructuring the Response
    GetInstanceProfileResponse (..),
    newGetInstanceProfileResponse,

    -- * Response Lenses
    getInstanceProfileResponse_httpStatus,
    getInstanceProfileResponse_instanceProfile,
  )
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:/ 'newGetInstanceProfile' smart constructor.
data GetInstanceProfile = GetInstanceProfile'
  { -- | The name of the instance profile to get information about.
    --
    -- This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- consisting of upper and lowercase alphanumeric characters with no
    -- spaces. You can also include any of the following characters: _+=,.\@-
    GetInstanceProfile -> Text
instanceProfileName :: Prelude.Text
  }
  deriving (GetInstanceProfile -> GetInstanceProfile -> Bool
(GetInstanceProfile -> GetInstanceProfile -> Bool)
-> (GetInstanceProfile -> GetInstanceProfile -> Bool)
-> Eq GetInstanceProfile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetInstanceProfile -> GetInstanceProfile -> Bool
$c/= :: GetInstanceProfile -> GetInstanceProfile -> Bool
== :: GetInstanceProfile -> GetInstanceProfile -> Bool
$c== :: GetInstanceProfile -> GetInstanceProfile -> Bool
Prelude.Eq, ReadPrec [GetInstanceProfile]
ReadPrec GetInstanceProfile
Int -> ReadS GetInstanceProfile
ReadS [GetInstanceProfile]
(Int -> ReadS GetInstanceProfile)
-> ReadS [GetInstanceProfile]
-> ReadPrec GetInstanceProfile
-> ReadPrec [GetInstanceProfile]
-> Read GetInstanceProfile
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetInstanceProfile]
$creadListPrec :: ReadPrec [GetInstanceProfile]
readPrec :: ReadPrec GetInstanceProfile
$creadPrec :: ReadPrec GetInstanceProfile
readList :: ReadS [GetInstanceProfile]
$creadList :: ReadS [GetInstanceProfile]
readsPrec :: Int -> ReadS GetInstanceProfile
$creadsPrec :: Int -> ReadS GetInstanceProfile
Prelude.Read, Int -> GetInstanceProfile -> ShowS
[GetInstanceProfile] -> ShowS
GetInstanceProfile -> String
(Int -> GetInstanceProfile -> ShowS)
-> (GetInstanceProfile -> String)
-> ([GetInstanceProfile] -> ShowS)
-> Show GetInstanceProfile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetInstanceProfile] -> ShowS
$cshowList :: [GetInstanceProfile] -> ShowS
show :: GetInstanceProfile -> String
$cshow :: GetInstanceProfile -> String
showsPrec :: Int -> GetInstanceProfile -> ShowS
$cshowsPrec :: Int -> GetInstanceProfile -> ShowS
Prelude.Show, (forall x. GetInstanceProfile -> Rep GetInstanceProfile x)
-> (forall x. Rep GetInstanceProfile x -> GetInstanceProfile)
-> Generic GetInstanceProfile
forall x. Rep GetInstanceProfile x -> GetInstanceProfile
forall x. GetInstanceProfile -> Rep GetInstanceProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetInstanceProfile x -> GetInstanceProfile
$cfrom :: forall x. GetInstanceProfile -> Rep GetInstanceProfile x
Prelude.Generic)

-- |
-- Create a value of 'GetInstanceProfile' 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:
--
-- 'instanceProfileName', 'getInstanceProfile_instanceProfileName' - The name of the instance profile to get information about.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
newGetInstanceProfile ::
  -- | 'instanceProfileName'
  Prelude.Text ->
  GetInstanceProfile
newGetInstanceProfile :: Text -> GetInstanceProfile
newGetInstanceProfile Text
pInstanceProfileName_ =
  GetInstanceProfile' :: Text -> GetInstanceProfile
GetInstanceProfile'
    { $sel:instanceProfileName:GetInstanceProfile' :: Text
instanceProfileName =
        Text
pInstanceProfileName_
    }

-- | The name of the instance profile to get information about.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
getInstanceProfile_instanceProfileName :: Lens.Lens' GetInstanceProfile Prelude.Text
getInstanceProfile_instanceProfileName :: (Text -> f Text) -> GetInstanceProfile -> f GetInstanceProfile
getInstanceProfile_instanceProfileName = (GetInstanceProfile -> Text)
-> (GetInstanceProfile -> Text -> GetInstanceProfile)
-> Lens GetInstanceProfile GetInstanceProfile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInstanceProfile' {Text
instanceProfileName :: Text
$sel:instanceProfileName:GetInstanceProfile' :: GetInstanceProfile -> Text
instanceProfileName} -> Text
instanceProfileName) (\s :: GetInstanceProfile
s@GetInstanceProfile' {} Text
a -> GetInstanceProfile
s {$sel:instanceProfileName:GetInstanceProfile' :: Text
instanceProfileName = Text
a} :: GetInstanceProfile)

instance Core.AWSRequest GetInstanceProfile where
  type
    AWSResponse GetInstanceProfile =
      GetInstanceProfileResponse
  request :: GetInstanceProfile -> Request GetInstanceProfile
request = Service -> GetInstanceProfile -> Request GetInstanceProfile
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy GetInstanceProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetInstanceProfile)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse GetInstanceProfile))
-> Logger
-> Service
-> Proxy GetInstanceProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetInstanceProfile)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"GetInstanceProfileResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> InstanceProfile -> GetInstanceProfileResponse
GetInstanceProfileResponse'
            (Int -> InstanceProfile -> GetInstanceProfileResponse)
-> Either String Int
-> Either String (InstanceProfile -> GetInstanceProfileResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (InstanceProfile -> GetInstanceProfileResponse)
-> Either String InstanceProfile
-> Either String GetInstanceProfileResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String InstanceProfile
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"InstanceProfile")
      )

instance Prelude.Hashable GetInstanceProfile

instance Prelude.NFData GetInstanceProfile

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

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

instance Core.ToQuery GetInstanceProfile where
  toQuery :: GetInstanceProfile -> QueryString
toQuery GetInstanceProfile' {Text
instanceProfileName :: Text
$sel:instanceProfileName:GetInstanceProfile' :: GetInstanceProfile -> 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
"GetInstanceProfile" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"InstanceProfileName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
instanceProfileName
      ]

-- | Contains the response to a successful GetInstanceProfile request.
--
-- /See:/ 'newGetInstanceProfileResponse' smart constructor.
data GetInstanceProfileResponse = GetInstanceProfileResponse'
  { -- | The response's http status code.
    GetInstanceProfileResponse -> Int
httpStatus :: Prelude.Int,
    -- | A structure containing details about the instance profile.
    GetInstanceProfileResponse -> InstanceProfile
instanceProfile :: InstanceProfile
  }
  deriving (GetInstanceProfileResponse -> GetInstanceProfileResponse -> Bool
(GetInstanceProfileResponse -> GetInstanceProfileResponse -> Bool)
-> (GetInstanceProfileResponse
    -> GetInstanceProfileResponse -> Bool)
-> Eq GetInstanceProfileResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetInstanceProfileResponse -> GetInstanceProfileResponse -> Bool
$c/= :: GetInstanceProfileResponse -> GetInstanceProfileResponse -> Bool
== :: GetInstanceProfileResponse -> GetInstanceProfileResponse -> Bool
$c== :: GetInstanceProfileResponse -> GetInstanceProfileResponse -> Bool
Prelude.Eq, ReadPrec [GetInstanceProfileResponse]
ReadPrec GetInstanceProfileResponse
Int -> ReadS GetInstanceProfileResponse
ReadS [GetInstanceProfileResponse]
(Int -> ReadS GetInstanceProfileResponse)
-> ReadS [GetInstanceProfileResponse]
-> ReadPrec GetInstanceProfileResponse
-> ReadPrec [GetInstanceProfileResponse]
-> Read GetInstanceProfileResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetInstanceProfileResponse]
$creadListPrec :: ReadPrec [GetInstanceProfileResponse]
readPrec :: ReadPrec GetInstanceProfileResponse
$creadPrec :: ReadPrec GetInstanceProfileResponse
readList :: ReadS [GetInstanceProfileResponse]
$creadList :: ReadS [GetInstanceProfileResponse]
readsPrec :: Int -> ReadS GetInstanceProfileResponse
$creadsPrec :: Int -> ReadS GetInstanceProfileResponse
Prelude.Read, Int -> GetInstanceProfileResponse -> ShowS
[GetInstanceProfileResponse] -> ShowS
GetInstanceProfileResponse -> String
(Int -> GetInstanceProfileResponse -> ShowS)
-> (GetInstanceProfileResponse -> String)
-> ([GetInstanceProfileResponse] -> ShowS)
-> Show GetInstanceProfileResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetInstanceProfileResponse] -> ShowS
$cshowList :: [GetInstanceProfileResponse] -> ShowS
show :: GetInstanceProfileResponse -> String
$cshow :: GetInstanceProfileResponse -> String
showsPrec :: Int -> GetInstanceProfileResponse -> ShowS
$cshowsPrec :: Int -> GetInstanceProfileResponse -> ShowS
Prelude.Show, (forall x.
 GetInstanceProfileResponse -> Rep GetInstanceProfileResponse x)
-> (forall x.
    Rep GetInstanceProfileResponse x -> GetInstanceProfileResponse)
-> Generic GetInstanceProfileResponse
forall x.
Rep GetInstanceProfileResponse x -> GetInstanceProfileResponse
forall x.
GetInstanceProfileResponse -> Rep GetInstanceProfileResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetInstanceProfileResponse x -> GetInstanceProfileResponse
$cfrom :: forall x.
GetInstanceProfileResponse -> Rep GetInstanceProfileResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetInstanceProfileResponse' 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:
--
-- 'httpStatus', 'getInstanceProfileResponse_httpStatus' - The response's http status code.
--
-- 'instanceProfile', 'getInstanceProfileResponse_instanceProfile' - A structure containing details about the instance profile.
newGetInstanceProfileResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'instanceProfile'
  InstanceProfile ->
  GetInstanceProfileResponse
newGetInstanceProfileResponse :: Int -> InstanceProfile -> GetInstanceProfileResponse
newGetInstanceProfileResponse
  Int
pHttpStatus_
  InstanceProfile
pInstanceProfile_ =
    GetInstanceProfileResponse' :: Int -> InstanceProfile -> GetInstanceProfileResponse
GetInstanceProfileResponse'
      { $sel:httpStatus:GetInstanceProfileResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:instanceProfile:GetInstanceProfileResponse' :: InstanceProfile
instanceProfile = InstanceProfile
pInstanceProfile_
      }

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

-- | A structure containing details about the instance profile.
getInstanceProfileResponse_instanceProfile :: Lens.Lens' GetInstanceProfileResponse InstanceProfile
getInstanceProfileResponse_instanceProfile :: (InstanceProfile -> f InstanceProfile)
-> GetInstanceProfileResponse -> f GetInstanceProfileResponse
getInstanceProfileResponse_instanceProfile = (GetInstanceProfileResponse -> InstanceProfile)
-> (GetInstanceProfileResponse
    -> InstanceProfile -> GetInstanceProfileResponse)
-> Lens
     GetInstanceProfileResponse
     GetInstanceProfileResponse
     InstanceProfile
     InstanceProfile
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInstanceProfileResponse' {InstanceProfile
instanceProfile :: InstanceProfile
$sel:instanceProfile:GetInstanceProfileResponse' :: GetInstanceProfileResponse -> InstanceProfile
instanceProfile} -> InstanceProfile
instanceProfile) (\s :: GetInstanceProfileResponse
s@GetInstanceProfileResponse' {} InstanceProfile
a -> GetInstanceProfileResponse
s {$sel:instanceProfile:GetInstanceProfileResponse' :: InstanceProfile
instanceProfile = InstanceProfile
a} :: GetInstanceProfileResponse)

instance Prelude.NFData GetInstanceProfileResponse