{-# 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.SetSecurityTokenServicePreferences
-- 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)
--
-- Sets the specified version of the global endpoint token as the token
-- version used for the Amazon Web Services account.
--
-- By default, Security Token Service (STS) is available as a global
-- service, and all STS requests go to a single endpoint at
-- @https:\/\/sts.amazonaws.com@. Amazon Web Services recommends using
-- Regional STS endpoints to reduce latency, build in redundancy, and
-- increase session token availability. For information about Regional
-- endpoints for STS, see
-- <https://docs.aws.amazon.com/general/latest/gr/sts.html Security Token Service endpoints and quotas>
-- in the /Amazon Web Services General Reference/.
--
-- If you make an STS call to the global endpoint, the resulting session
-- tokens might be valid in some Regions but not others. It depends on the
-- version that is set in this operation. Version 1 tokens are valid only
-- in Amazon Web Services Regions that are available by default. These
-- tokens do not work in manually enabled Regions, such as Asia Pacific
-- (Hong Kong). Version 2 tokens are valid in all Regions. However, version
-- 2 tokens are longer and might affect systems where you temporarily store
-- tokens. For information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html Activating and deactivating STS in an Amazon Web Services Region>
-- in the /IAM User Guide/.
--
-- To view the current session token version, see the
-- @GlobalEndpointTokenVersion@ entry in the response of the
-- GetAccountSummary operation.
module Amazonka.IAM.SetSecurityTokenServicePreferences
  ( -- * Creating a Request
    SetSecurityTokenServicePreferences (..),
    newSetSecurityTokenServicePreferences,

    -- * Request Lenses
    setSecurityTokenServicePreferences_globalEndpointTokenVersion,

    -- * Destructuring the Response
    SetSecurityTokenServicePreferencesResponse (..),
    newSetSecurityTokenServicePreferencesResponse,
  )
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:/ 'newSetSecurityTokenServicePreferences' smart constructor.
data SetSecurityTokenServicePreferences = SetSecurityTokenServicePreferences'
  { -- | The version of the global endpoint token. Version 1 tokens are valid
    -- only in Amazon Web Services Regions that are available by default. These
    -- tokens do not work in manually enabled Regions, such as Asia Pacific
    -- (Hong Kong). Version 2 tokens are valid in all Regions. However, version
    -- 2 tokens are longer and might affect systems where you temporarily store
    -- tokens.
    --
    -- For information, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html Activating and deactivating STS in an Amazon Web Services Region>
    -- in the /IAM User Guide/.
    SetSecurityTokenServicePreferences -> GlobalEndpointTokenVersion
globalEndpointTokenVersion :: GlobalEndpointTokenVersion
  }
  deriving (SetSecurityTokenServicePreferences
-> SetSecurityTokenServicePreferences -> Bool
(SetSecurityTokenServicePreferences
 -> SetSecurityTokenServicePreferences -> Bool)
-> (SetSecurityTokenServicePreferences
    -> SetSecurityTokenServicePreferences -> Bool)
-> Eq SetSecurityTokenServicePreferences
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetSecurityTokenServicePreferences
-> SetSecurityTokenServicePreferences -> Bool
$c/= :: SetSecurityTokenServicePreferences
-> SetSecurityTokenServicePreferences -> Bool
== :: SetSecurityTokenServicePreferences
-> SetSecurityTokenServicePreferences -> Bool
$c== :: SetSecurityTokenServicePreferences
-> SetSecurityTokenServicePreferences -> Bool
Prelude.Eq, ReadPrec [SetSecurityTokenServicePreferences]
ReadPrec SetSecurityTokenServicePreferences
Int -> ReadS SetSecurityTokenServicePreferences
ReadS [SetSecurityTokenServicePreferences]
(Int -> ReadS SetSecurityTokenServicePreferences)
-> ReadS [SetSecurityTokenServicePreferences]
-> ReadPrec SetSecurityTokenServicePreferences
-> ReadPrec [SetSecurityTokenServicePreferences]
-> Read SetSecurityTokenServicePreferences
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetSecurityTokenServicePreferences]
$creadListPrec :: ReadPrec [SetSecurityTokenServicePreferences]
readPrec :: ReadPrec SetSecurityTokenServicePreferences
$creadPrec :: ReadPrec SetSecurityTokenServicePreferences
readList :: ReadS [SetSecurityTokenServicePreferences]
$creadList :: ReadS [SetSecurityTokenServicePreferences]
readsPrec :: Int -> ReadS SetSecurityTokenServicePreferences
$creadsPrec :: Int -> ReadS SetSecurityTokenServicePreferences
Prelude.Read, Int -> SetSecurityTokenServicePreferences -> ShowS
[SetSecurityTokenServicePreferences] -> ShowS
SetSecurityTokenServicePreferences -> String
(Int -> SetSecurityTokenServicePreferences -> ShowS)
-> (SetSecurityTokenServicePreferences -> String)
-> ([SetSecurityTokenServicePreferences] -> ShowS)
-> Show SetSecurityTokenServicePreferences
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetSecurityTokenServicePreferences] -> ShowS
$cshowList :: [SetSecurityTokenServicePreferences] -> ShowS
show :: SetSecurityTokenServicePreferences -> String
$cshow :: SetSecurityTokenServicePreferences -> String
showsPrec :: Int -> SetSecurityTokenServicePreferences -> ShowS
$cshowsPrec :: Int -> SetSecurityTokenServicePreferences -> ShowS
Prelude.Show, (forall x.
 SetSecurityTokenServicePreferences
 -> Rep SetSecurityTokenServicePreferences x)
-> (forall x.
    Rep SetSecurityTokenServicePreferences x
    -> SetSecurityTokenServicePreferences)
-> Generic SetSecurityTokenServicePreferences
forall x.
Rep SetSecurityTokenServicePreferences x
-> SetSecurityTokenServicePreferences
forall x.
SetSecurityTokenServicePreferences
-> Rep SetSecurityTokenServicePreferences x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SetSecurityTokenServicePreferences x
-> SetSecurityTokenServicePreferences
$cfrom :: forall x.
SetSecurityTokenServicePreferences
-> Rep SetSecurityTokenServicePreferences x
Prelude.Generic)

-- |
-- Create a value of 'SetSecurityTokenServicePreferences' 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:
--
-- 'globalEndpointTokenVersion', 'setSecurityTokenServicePreferences_globalEndpointTokenVersion' - The version of the global endpoint token. Version 1 tokens are valid
-- only in Amazon Web Services Regions that are available by default. These
-- tokens do not work in manually enabled Regions, such as Asia Pacific
-- (Hong Kong). Version 2 tokens are valid in all Regions. However, version
-- 2 tokens are longer and might affect systems where you temporarily store
-- tokens.
--
-- For information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html Activating and deactivating STS in an Amazon Web Services Region>
-- in the /IAM User Guide/.
newSetSecurityTokenServicePreferences ::
  -- | 'globalEndpointTokenVersion'
  GlobalEndpointTokenVersion ->
  SetSecurityTokenServicePreferences
newSetSecurityTokenServicePreferences :: GlobalEndpointTokenVersion -> SetSecurityTokenServicePreferences
newSetSecurityTokenServicePreferences
  GlobalEndpointTokenVersion
pGlobalEndpointTokenVersion_ =
    SetSecurityTokenServicePreferences' :: GlobalEndpointTokenVersion -> SetSecurityTokenServicePreferences
SetSecurityTokenServicePreferences'
      { $sel:globalEndpointTokenVersion:SetSecurityTokenServicePreferences' :: GlobalEndpointTokenVersion
globalEndpointTokenVersion =
          GlobalEndpointTokenVersion
pGlobalEndpointTokenVersion_
      }

-- | The version of the global endpoint token. Version 1 tokens are valid
-- only in Amazon Web Services Regions that are available by default. These
-- tokens do not work in manually enabled Regions, such as Asia Pacific
-- (Hong Kong). Version 2 tokens are valid in all Regions. However, version
-- 2 tokens are longer and might affect systems where you temporarily store
-- tokens.
--
-- For information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html Activating and deactivating STS in an Amazon Web Services Region>
-- in the /IAM User Guide/.
setSecurityTokenServicePreferences_globalEndpointTokenVersion :: Lens.Lens' SetSecurityTokenServicePreferences GlobalEndpointTokenVersion
setSecurityTokenServicePreferences_globalEndpointTokenVersion :: (GlobalEndpointTokenVersion -> f GlobalEndpointTokenVersion)
-> SetSecurityTokenServicePreferences
-> f SetSecurityTokenServicePreferences
setSecurityTokenServicePreferences_globalEndpointTokenVersion = (SetSecurityTokenServicePreferences -> GlobalEndpointTokenVersion)
-> (SetSecurityTokenServicePreferences
    -> GlobalEndpointTokenVersion
    -> SetSecurityTokenServicePreferences)
-> Lens
     SetSecurityTokenServicePreferences
     SetSecurityTokenServicePreferences
     GlobalEndpointTokenVersion
     GlobalEndpointTokenVersion
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetSecurityTokenServicePreferences' {GlobalEndpointTokenVersion
globalEndpointTokenVersion :: GlobalEndpointTokenVersion
$sel:globalEndpointTokenVersion:SetSecurityTokenServicePreferences' :: SetSecurityTokenServicePreferences -> GlobalEndpointTokenVersion
globalEndpointTokenVersion} -> GlobalEndpointTokenVersion
globalEndpointTokenVersion) (\s :: SetSecurityTokenServicePreferences
s@SetSecurityTokenServicePreferences' {} GlobalEndpointTokenVersion
a -> SetSecurityTokenServicePreferences
s {$sel:globalEndpointTokenVersion:SetSecurityTokenServicePreferences' :: GlobalEndpointTokenVersion
globalEndpointTokenVersion = GlobalEndpointTokenVersion
a} :: SetSecurityTokenServicePreferences)

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

instance
  Prelude.Hashable
    SetSecurityTokenServicePreferences

instance
  Prelude.NFData
    SetSecurityTokenServicePreferences

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

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

instance
  Core.ToQuery
    SetSecurityTokenServicePreferences
  where
  toQuery :: SetSecurityTokenServicePreferences -> QueryString
toQuery SetSecurityTokenServicePreferences' {GlobalEndpointTokenVersion
globalEndpointTokenVersion :: GlobalEndpointTokenVersion
$sel:globalEndpointTokenVersion:SetSecurityTokenServicePreferences' :: SetSecurityTokenServicePreferences -> GlobalEndpointTokenVersion
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ( ByteString
"SetSecurityTokenServicePreferences" ::
                      Prelude.ByteString
                  ),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"GlobalEndpointTokenVersion"
          ByteString -> GlobalEndpointTokenVersion -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: GlobalEndpointTokenVersion
globalEndpointTokenVersion
      ]

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

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

instance
  Prelude.NFData
    SetSecurityTokenServicePreferencesResponse