{-# 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.RemoveRoleFromInstanceProfile
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes the specified IAM role from the specified EC2 instance profile.
--
-- Make sure that you do not have any Amazon EC2 instances running with the
-- role you are about to remove from the instance profile. Removing a role
-- from an instance profile that is associated with a running instance
-- might break any applications running on the instance.
--
-- For more information about IAM roles, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/WorkingWithRoles.html Working with roles>.
-- For more information about instance profiles, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/AboutInstanceProfiles.html About instance profiles>.
module Amazonka.IAM.RemoveRoleFromInstanceProfile
  ( -- * Creating a Request
    RemoveRoleFromInstanceProfile (..),
    newRemoveRoleFromInstanceProfile,

    -- * Request Lenses
    removeRoleFromInstanceProfile_instanceProfileName,
    removeRoleFromInstanceProfile_roleName,

    -- * Destructuring the Response
    RemoveRoleFromInstanceProfileResponse (..),
    newRemoveRoleFromInstanceProfileResponse,
  )
where

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

-- | /See:/ 'newRemoveRoleFromInstanceProfile' smart constructor.
data RemoveRoleFromInstanceProfile = RemoveRoleFromInstanceProfile'
  { -- | The name of the instance profile to update.
    --
    -- 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: _+=,.\@-
    RemoveRoleFromInstanceProfile -> Text
instanceProfileName :: Prelude.Text,
    -- | The name of the role to remove.
    --
    -- 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: _+=,.\@-
    RemoveRoleFromInstanceProfile -> Text
roleName :: Prelude.Text
  }
  deriving (RemoveRoleFromInstanceProfile
-> RemoveRoleFromInstanceProfile -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveRoleFromInstanceProfile
-> RemoveRoleFromInstanceProfile -> Bool
$c/= :: RemoveRoleFromInstanceProfile
-> RemoveRoleFromInstanceProfile -> Bool
== :: RemoveRoleFromInstanceProfile
-> RemoveRoleFromInstanceProfile -> Bool
$c== :: RemoveRoleFromInstanceProfile
-> RemoveRoleFromInstanceProfile -> Bool
Prelude.Eq, ReadPrec [RemoveRoleFromInstanceProfile]
ReadPrec RemoveRoleFromInstanceProfile
Int -> ReadS RemoveRoleFromInstanceProfile
ReadS [RemoveRoleFromInstanceProfile]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveRoleFromInstanceProfile]
$creadListPrec :: ReadPrec [RemoveRoleFromInstanceProfile]
readPrec :: ReadPrec RemoveRoleFromInstanceProfile
$creadPrec :: ReadPrec RemoveRoleFromInstanceProfile
readList :: ReadS [RemoveRoleFromInstanceProfile]
$creadList :: ReadS [RemoveRoleFromInstanceProfile]
readsPrec :: Int -> ReadS RemoveRoleFromInstanceProfile
$creadsPrec :: Int -> ReadS RemoveRoleFromInstanceProfile
Prelude.Read, Int -> RemoveRoleFromInstanceProfile -> ShowS
[RemoveRoleFromInstanceProfile] -> ShowS
RemoveRoleFromInstanceProfile -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveRoleFromInstanceProfile] -> ShowS
$cshowList :: [RemoveRoleFromInstanceProfile] -> ShowS
show :: RemoveRoleFromInstanceProfile -> String
$cshow :: RemoveRoleFromInstanceProfile -> String
showsPrec :: Int -> RemoveRoleFromInstanceProfile -> ShowS
$cshowsPrec :: Int -> RemoveRoleFromInstanceProfile -> ShowS
Prelude.Show, forall x.
Rep RemoveRoleFromInstanceProfile x
-> RemoveRoleFromInstanceProfile
forall x.
RemoveRoleFromInstanceProfile
-> Rep RemoveRoleFromInstanceProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RemoveRoleFromInstanceProfile x
-> RemoveRoleFromInstanceProfile
$cfrom :: forall x.
RemoveRoleFromInstanceProfile
-> Rep RemoveRoleFromInstanceProfile x
Prelude.Generic)

-- |
-- Create a value of 'RemoveRoleFromInstanceProfile' 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', 'removeRoleFromInstanceProfile_instanceProfileName' - The name of the instance profile to update.
--
-- 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: _+=,.\@-
--
-- 'roleName', 'removeRoleFromInstanceProfile_roleName' - The name of the role to remove.
--
-- 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: _+=,.\@-
newRemoveRoleFromInstanceProfile ::
  -- | 'instanceProfileName'
  Prelude.Text ->
  -- | 'roleName'
  Prelude.Text ->
  RemoveRoleFromInstanceProfile
newRemoveRoleFromInstanceProfile :: Text -> Text -> RemoveRoleFromInstanceProfile
newRemoveRoleFromInstanceProfile
  Text
pInstanceProfileName_
  Text
pRoleName_ =
    RemoveRoleFromInstanceProfile'
      { $sel:instanceProfileName:RemoveRoleFromInstanceProfile' :: Text
instanceProfileName =
          Text
pInstanceProfileName_,
        $sel:roleName:RemoveRoleFromInstanceProfile' :: Text
roleName = Text
pRoleName_
      }

-- | The name of the instance profile to update.
--
-- 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: _+=,.\@-
removeRoleFromInstanceProfile_instanceProfileName :: Lens.Lens' RemoveRoleFromInstanceProfile Prelude.Text
removeRoleFromInstanceProfile_instanceProfileName :: Lens' RemoveRoleFromInstanceProfile Text
removeRoleFromInstanceProfile_instanceProfileName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveRoleFromInstanceProfile' {Text
instanceProfileName :: Text
$sel:instanceProfileName:RemoveRoleFromInstanceProfile' :: RemoveRoleFromInstanceProfile -> Text
instanceProfileName} -> Text
instanceProfileName) (\s :: RemoveRoleFromInstanceProfile
s@RemoveRoleFromInstanceProfile' {} Text
a -> RemoveRoleFromInstanceProfile
s {$sel:instanceProfileName:RemoveRoleFromInstanceProfile' :: Text
instanceProfileName = Text
a} :: RemoveRoleFromInstanceProfile)

-- | The name of the role to remove.
--
-- 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: _+=,.\@-
removeRoleFromInstanceProfile_roleName :: Lens.Lens' RemoveRoleFromInstanceProfile Prelude.Text
removeRoleFromInstanceProfile_roleName :: Lens' RemoveRoleFromInstanceProfile Text
removeRoleFromInstanceProfile_roleName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveRoleFromInstanceProfile' {Text
roleName :: Text
$sel:roleName:RemoveRoleFromInstanceProfile' :: RemoveRoleFromInstanceProfile -> Text
roleName} -> Text
roleName) (\s :: RemoveRoleFromInstanceProfile
s@RemoveRoleFromInstanceProfile' {} Text
a -> RemoveRoleFromInstanceProfile
s {$sel:roleName:RemoveRoleFromInstanceProfile' :: Text
roleName = Text
a} :: RemoveRoleFromInstanceProfile)

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

instance
  Prelude.Hashable
    RemoveRoleFromInstanceProfile
  where
  hashWithSalt :: Int -> RemoveRoleFromInstanceProfile -> Int
hashWithSalt Int
_salt RemoveRoleFromInstanceProfile' {Text
roleName :: Text
instanceProfileName :: Text
$sel:roleName:RemoveRoleFromInstanceProfile' :: RemoveRoleFromInstanceProfile -> Text
$sel:instanceProfileName:RemoveRoleFromInstanceProfile' :: RemoveRoleFromInstanceProfile -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceProfileName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleName

instance Prelude.NFData RemoveRoleFromInstanceProfile where
  rnf :: RemoveRoleFromInstanceProfile -> ()
rnf RemoveRoleFromInstanceProfile' {Text
roleName :: Text
instanceProfileName :: Text
$sel:roleName:RemoveRoleFromInstanceProfile' :: RemoveRoleFromInstanceProfile -> Text
$sel:instanceProfileName:RemoveRoleFromInstanceProfile' :: RemoveRoleFromInstanceProfile -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
instanceProfileName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
roleName

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

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

instance Data.ToQuery RemoveRoleFromInstanceProfile where
  toQuery :: RemoveRoleFromInstanceProfile -> QueryString
toQuery RemoveRoleFromInstanceProfile' {Text
roleName :: Text
instanceProfileName :: Text
$sel:roleName:RemoveRoleFromInstanceProfile' :: RemoveRoleFromInstanceProfile -> Text
$sel:instanceProfileName:RemoveRoleFromInstanceProfile' :: RemoveRoleFromInstanceProfile -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: ( ByteString
"RemoveRoleFromInstanceProfile" ::
                      Prelude.ByteString
                  ),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"InstanceProfileName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
instanceProfileName,
        ByteString
"RoleName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
roleName
      ]

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

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

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