{-# 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-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)
--
-- 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 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:/ '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
(RemoveRoleFromInstanceProfile
 -> RemoveRoleFromInstanceProfile -> Bool)
-> (RemoveRoleFromInstanceProfile
    -> RemoveRoleFromInstanceProfile -> Bool)
-> Eq RemoveRoleFromInstanceProfile
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]
(Int -> ReadS RemoveRoleFromInstanceProfile)
-> ReadS [RemoveRoleFromInstanceProfile]
-> ReadPrec RemoveRoleFromInstanceProfile
-> ReadPrec [RemoveRoleFromInstanceProfile]
-> Read 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
(Int -> RemoveRoleFromInstanceProfile -> ShowS)
-> (RemoveRoleFromInstanceProfile -> String)
-> ([RemoveRoleFromInstanceProfile] -> ShowS)
-> Show RemoveRoleFromInstanceProfile
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.
 RemoveRoleFromInstanceProfile
 -> Rep RemoveRoleFromInstanceProfile x)
-> (forall x.
    Rep RemoveRoleFromInstanceProfile x
    -> RemoveRoleFromInstanceProfile)
-> Generic RemoveRoleFromInstanceProfile
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' :: Text -> Text -> RemoveRoleFromInstanceProfile
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 :: (Text -> f Text)
-> RemoveRoleFromInstanceProfile -> f RemoveRoleFromInstanceProfile
removeRoleFromInstanceProfile_instanceProfileName = (RemoveRoleFromInstanceProfile -> Text)
-> (RemoveRoleFromInstanceProfile
    -> Text -> RemoveRoleFromInstanceProfile)
-> Lens
     RemoveRoleFromInstanceProfile
     RemoveRoleFromInstanceProfile
     Text
     Text
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 :: (Text -> f Text)
-> RemoveRoleFromInstanceProfile -> f RemoveRoleFromInstanceProfile
removeRoleFromInstanceProfile_roleName = (RemoveRoleFromInstanceProfile -> Text)
-> (RemoveRoleFromInstanceProfile
    -> Text -> RemoveRoleFromInstanceProfile)
-> Lens
     RemoveRoleFromInstanceProfile
     RemoveRoleFromInstanceProfile
     Text
     Text
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 :: RemoveRoleFromInstanceProfile
-> Request RemoveRoleFromInstanceProfile
request = Service
-> RemoveRoleFromInstanceProfile
-> Request RemoveRoleFromInstanceProfile
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy RemoveRoleFromInstanceProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveRoleFromInstanceProfile)))
response =
    AWSResponse RemoveRoleFromInstanceProfile
-> Logger
-> Service
-> Proxy RemoveRoleFromInstanceProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveRoleFromInstanceProfile)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse RemoveRoleFromInstanceProfile
RemoveRoleFromInstanceProfileResponse
RemoveRoleFromInstanceProfileResponse'

instance
  Prelude.Hashable
    RemoveRoleFromInstanceProfile

instance Prelude.NFData RemoveRoleFromInstanceProfile

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

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

instance Core.ToQuery RemoveRoleFromInstanceProfile where
  toQuery :: RemoveRoleFromInstanceProfile -> QueryString
toQuery RemoveRoleFromInstanceProfile' {Text
roleName :: Text
instanceProfileName :: Text
$sel:roleName:RemoveRoleFromInstanceProfile' :: RemoveRoleFromInstanceProfile -> Text
$sel:instanceProfileName:RemoveRoleFromInstanceProfile' :: RemoveRoleFromInstanceProfile -> 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
"RemoveRoleFromInstanceProfile" ::
                      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,
        ByteString
"RoleName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
roleName
      ]

-- | /See:/ 'newRemoveRoleFromInstanceProfileResponse' smart constructor.
data RemoveRoleFromInstanceProfileResponse = RemoveRoleFromInstanceProfileResponse'
  {
  }
  deriving (RemoveRoleFromInstanceProfileResponse
-> RemoveRoleFromInstanceProfileResponse -> Bool
(RemoveRoleFromInstanceProfileResponse
 -> RemoveRoleFromInstanceProfileResponse -> Bool)
-> (RemoveRoleFromInstanceProfileResponse
    -> RemoveRoleFromInstanceProfileResponse -> Bool)
-> Eq RemoveRoleFromInstanceProfileResponse
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]
(Int -> ReadS RemoveRoleFromInstanceProfileResponse)
-> ReadS [RemoveRoleFromInstanceProfileResponse]
-> ReadPrec RemoveRoleFromInstanceProfileResponse
-> ReadPrec [RemoveRoleFromInstanceProfileResponse]
-> Read 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
(Int -> RemoveRoleFromInstanceProfileResponse -> ShowS)
-> (RemoveRoleFromInstanceProfileResponse -> String)
-> ([RemoveRoleFromInstanceProfileResponse] -> ShowS)
-> Show RemoveRoleFromInstanceProfileResponse
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.
 RemoveRoleFromInstanceProfileResponse
 -> Rep RemoveRoleFromInstanceProfileResponse x)
-> (forall x.
    Rep RemoveRoleFromInstanceProfileResponse x
    -> RemoveRoleFromInstanceProfileResponse)
-> Generic RemoveRoleFromInstanceProfileResponse
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