{-# 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.RolesAnywhere.EnableProfile
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Enables the roles in a profile to receive session credentials in
-- <https://docs.aws.amazon.com/rolesanywhere/latest/APIReference/API_CreateSession.html CreateSession>.
--
-- __Required permissions:__ @rolesanywhere:EnableProfile@.
module Amazonka.RolesAnywhere.EnableProfile
  ( -- * Creating a Request
    EnableProfile (..),
    newEnableProfile,

    -- * Request Lenses
    enableProfile_profileId,

    -- * Destructuring the Response
    ProfileDetailResponse (..),
    newProfileDetailResponse,

    -- * Response Lenses
    profileDetailResponse_profile,
  )
where

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

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

-- |
-- Create a value of 'EnableProfile' 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:
--
-- 'profileId', 'enableProfile_profileId' - The unique identifier of the profile.
newEnableProfile ::
  -- | 'profileId'
  Prelude.Text ->
  EnableProfile
newEnableProfile :: Text -> EnableProfile
newEnableProfile Text
pProfileId_ =
  EnableProfile' {$sel:profileId:EnableProfile' :: Text
profileId = Text
pProfileId_}

-- | The unique identifier of the profile.
enableProfile_profileId :: Lens.Lens' EnableProfile Prelude.Text
enableProfile_profileId :: Lens' EnableProfile Text
enableProfile_profileId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableProfile' {Text
profileId :: Text
$sel:profileId:EnableProfile' :: EnableProfile -> Text
profileId} -> Text
profileId) (\s :: EnableProfile
s@EnableProfile' {} Text
a -> EnableProfile
s {$sel:profileId:EnableProfile' :: Text
profileId = Text
a} :: EnableProfile)

instance Core.AWSRequest EnableProfile where
  type
    AWSResponse EnableProfile =
      ProfileDetailResponse
  request :: (Service -> Service) -> EnableProfile -> Request EnableProfile
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy EnableProfile
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse EnableProfile)))
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 -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

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

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

instance Data.ToHeaders EnableProfile where
  toHeaders :: EnableProfile -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON EnableProfile where
  toJSON :: EnableProfile -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath EnableProfile where
  toPath :: EnableProfile -> ByteString
toPath EnableProfile' {Text
profileId :: Text
$sel:profileId:EnableProfile' :: EnableProfile -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/profile/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
profileId, ByteString
"/enable"]

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