{-# 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.UpdateSAMLProvider
-- 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)
--
-- Updates the metadata document for an existing SAML provider resource
-- object.
--
-- This operation requires
-- <https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html Signature Version 4>.
module Amazonka.IAM.UpdateSAMLProvider
  ( -- * Creating a Request
    UpdateSAMLProvider (..),
    newUpdateSAMLProvider,

    -- * Request Lenses
    updateSAMLProvider_sAMLMetadataDocument,
    updateSAMLProvider_sAMLProviderArn,

    -- * Destructuring the Response
    UpdateSAMLProviderResponse (..),
    newUpdateSAMLProviderResponse,

    -- * Response Lenses
    updateSAMLProviderResponse_sAMLProviderArn,
    updateSAMLProviderResponse_httpStatus,
  )
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:/ 'newUpdateSAMLProvider' smart constructor.
data UpdateSAMLProvider = UpdateSAMLProvider'
  { -- | An XML document generated by an identity provider (IdP) that supports
    -- SAML 2.0. The document includes the issuer\'s name, expiration
    -- information, and keys that can be used to validate the SAML
    -- authentication response (assertions) that are received from the IdP. You
    -- must generate the metadata document using the identity management
    -- software that is used as your organization\'s IdP.
    UpdateSAMLProvider -> Text
sAMLMetadataDocument :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the SAML provider to update.
    --
    -- For more information about ARNs, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
    -- in the /Amazon Web Services General Reference/.
    UpdateSAMLProvider -> Text
sAMLProviderArn :: Prelude.Text
  }
  deriving (UpdateSAMLProvider -> UpdateSAMLProvider -> Bool
(UpdateSAMLProvider -> UpdateSAMLProvider -> Bool)
-> (UpdateSAMLProvider -> UpdateSAMLProvider -> Bool)
-> Eq UpdateSAMLProvider
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSAMLProvider -> UpdateSAMLProvider -> Bool
$c/= :: UpdateSAMLProvider -> UpdateSAMLProvider -> Bool
== :: UpdateSAMLProvider -> UpdateSAMLProvider -> Bool
$c== :: UpdateSAMLProvider -> UpdateSAMLProvider -> Bool
Prelude.Eq, ReadPrec [UpdateSAMLProvider]
ReadPrec UpdateSAMLProvider
Int -> ReadS UpdateSAMLProvider
ReadS [UpdateSAMLProvider]
(Int -> ReadS UpdateSAMLProvider)
-> ReadS [UpdateSAMLProvider]
-> ReadPrec UpdateSAMLProvider
-> ReadPrec [UpdateSAMLProvider]
-> Read UpdateSAMLProvider
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSAMLProvider]
$creadListPrec :: ReadPrec [UpdateSAMLProvider]
readPrec :: ReadPrec UpdateSAMLProvider
$creadPrec :: ReadPrec UpdateSAMLProvider
readList :: ReadS [UpdateSAMLProvider]
$creadList :: ReadS [UpdateSAMLProvider]
readsPrec :: Int -> ReadS UpdateSAMLProvider
$creadsPrec :: Int -> ReadS UpdateSAMLProvider
Prelude.Read, Int -> UpdateSAMLProvider -> ShowS
[UpdateSAMLProvider] -> ShowS
UpdateSAMLProvider -> String
(Int -> UpdateSAMLProvider -> ShowS)
-> (UpdateSAMLProvider -> String)
-> ([UpdateSAMLProvider] -> ShowS)
-> Show UpdateSAMLProvider
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSAMLProvider] -> ShowS
$cshowList :: [UpdateSAMLProvider] -> ShowS
show :: UpdateSAMLProvider -> String
$cshow :: UpdateSAMLProvider -> String
showsPrec :: Int -> UpdateSAMLProvider -> ShowS
$cshowsPrec :: Int -> UpdateSAMLProvider -> ShowS
Prelude.Show, (forall x. UpdateSAMLProvider -> Rep UpdateSAMLProvider x)
-> (forall x. Rep UpdateSAMLProvider x -> UpdateSAMLProvider)
-> Generic UpdateSAMLProvider
forall x. Rep UpdateSAMLProvider x -> UpdateSAMLProvider
forall x. UpdateSAMLProvider -> Rep UpdateSAMLProvider x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateSAMLProvider x -> UpdateSAMLProvider
$cfrom :: forall x. UpdateSAMLProvider -> Rep UpdateSAMLProvider x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSAMLProvider' 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:
--
-- 'sAMLMetadataDocument', 'updateSAMLProvider_sAMLMetadataDocument' - An XML document generated by an identity provider (IdP) that supports
-- SAML 2.0. The document includes the issuer\'s name, expiration
-- information, and keys that can be used to validate the SAML
-- authentication response (assertions) that are received from the IdP. You
-- must generate the metadata document using the identity management
-- software that is used as your organization\'s IdP.
--
-- 'sAMLProviderArn', 'updateSAMLProvider_sAMLProviderArn' - The Amazon Resource Name (ARN) of the SAML provider to update.
--
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the /Amazon Web Services General Reference/.
newUpdateSAMLProvider ::
  -- | 'sAMLMetadataDocument'
  Prelude.Text ->
  -- | 'sAMLProviderArn'
  Prelude.Text ->
  UpdateSAMLProvider
newUpdateSAMLProvider :: Text -> Text -> UpdateSAMLProvider
newUpdateSAMLProvider
  Text
pSAMLMetadataDocument_
  Text
pSAMLProviderArn_ =
    UpdateSAMLProvider' :: Text -> Text -> UpdateSAMLProvider
UpdateSAMLProvider'
      { $sel:sAMLMetadataDocument:UpdateSAMLProvider' :: Text
sAMLMetadataDocument =
          Text
pSAMLMetadataDocument_,
        $sel:sAMLProviderArn:UpdateSAMLProvider' :: Text
sAMLProviderArn = Text
pSAMLProviderArn_
      }

-- | An XML document generated by an identity provider (IdP) that supports
-- SAML 2.0. The document includes the issuer\'s name, expiration
-- information, and keys that can be used to validate the SAML
-- authentication response (assertions) that are received from the IdP. You
-- must generate the metadata document using the identity management
-- software that is used as your organization\'s IdP.
updateSAMLProvider_sAMLMetadataDocument :: Lens.Lens' UpdateSAMLProvider Prelude.Text
updateSAMLProvider_sAMLMetadataDocument :: (Text -> f Text) -> UpdateSAMLProvider -> f UpdateSAMLProvider
updateSAMLProvider_sAMLMetadataDocument = (UpdateSAMLProvider -> Text)
-> (UpdateSAMLProvider -> Text -> UpdateSAMLProvider)
-> Lens UpdateSAMLProvider UpdateSAMLProvider Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSAMLProvider' {Text
sAMLMetadataDocument :: Text
$sel:sAMLMetadataDocument:UpdateSAMLProvider' :: UpdateSAMLProvider -> Text
sAMLMetadataDocument} -> Text
sAMLMetadataDocument) (\s :: UpdateSAMLProvider
s@UpdateSAMLProvider' {} Text
a -> UpdateSAMLProvider
s {$sel:sAMLMetadataDocument:UpdateSAMLProvider' :: Text
sAMLMetadataDocument = Text
a} :: UpdateSAMLProvider)

-- | The Amazon Resource Name (ARN) of the SAML provider to update.
--
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the /Amazon Web Services General Reference/.
updateSAMLProvider_sAMLProviderArn :: Lens.Lens' UpdateSAMLProvider Prelude.Text
updateSAMLProvider_sAMLProviderArn :: (Text -> f Text) -> UpdateSAMLProvider -> f UpdateSAMLProvider
updateSAMLProvider_sAMLProviderArn = (UpdateSAMLProvider -> Text)
-> (UpdateSAMLProvider -> Text -> UpdateSAMLProvider)
-> Lens UpdateSAMLProvider UpdateSAMLProvider Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSAMLProvider' {Text
sAMLProviderArn :: Text
$sel:sAMLProviderArn:UpdateSAMLProvider' :: UpdateSAMLProvider -> Text
sAMLProviderArn} -> Text
sAMLProviderArn) (\s :: UpdateSAMLProvider
s@UpdateSAMLProvider' {} Text
a -> UpdateSAMLProvider
s {$sel:sAMLProviderArn:UpdateSAMLProvider' :: Text
sAMLProviderArn = Text
a} :: UpdateSAMLProvider)

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

instance Prelude.Hashable UpdateSAMLProvider

instance Prelude.NFData UpdateSAMLProvider

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

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

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

-- | Contains the response to a successful UpdateSAMLProvider request.
--
-- /See:/ 'newUpdateSAMLProviderResponse' smart constructor.
data UpdateSAMLProviderResponse = UpdateSAMLProviderResponse'
  { -- | The Amazon Resource Name (ARN) of the SAML provider that was updated.
    UpdateSAMLProviderResponse -> Maybe Text
sAMLProviderArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    UpdateSAMLProviderResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateSAMLProviderResponse -> UpdateSAMLProviderResponse -> Bool
(UpdateSAMLProviderResponse -> UpdateSAMLProviderResponse -> Bool)
-> (UpdateSAMLProviderResponse
    -> UpdateSAMLProviderResponse -> Bool)
-> Eq UpdateSAMLProviderResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSAMLProviderResponse -> UpdateSAMLProviderResponse -> Bool
$c/= :: UpdateSAMLProviderResponse -> UpdateSAMLProviderResponse -> Bool
== :: UpdateSAMLProviderResponse -> UpdateSAMLProviderResponse -> Bool
$c== :: UpdateSAMLProviderResponse -> UpdateSAMLProviderResponse -> Bool
Prelude.Eq, ReadPrec [UpdateSAMLProviderResponse]
ReadPrec UpdateSAMLProviderResponse
Int -> ReadS UpdateSAMLProviderResponse
ReadS [UpdateSAMLProviderResponse]
(Int -> ReadS UpdateSAMLProviderResponse)
-> ReadS [UpdateSAMLProviderResponse]
-> ReadPrec UpdateSAMLProviderResponse
-> ReadPrec [UpdateSAMLProviderResponse]
-> Read UpdateSAMLProviderResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSAMLProviderResponse]
$creadListPrec :: ReadPrec [UpdateSAMLProviderResponse]
readPrec :: ReadPrec UpdateSAMLProviderResponse
$creadPrec :: ReadPrec UpdateSAMLProviderResponse
readList :: ReadS [UpdateSAMLProviderResponse]
$creadList :: ReadS [UpdateSAMLProviderResponse]
readsPrec :: Int -> ReadS UpdateSAMLProviderResponse
$creadsPrec :: Int -> ReadS UpdateSAMLProviderResponse
Prelude.Read, Int -> UpdateSAMLProviderResponse -> ShowS
[UpdateSAMLProviderResponse] -> ShowS
UpdateSAMLProviderResponse -> String
(Int -> UpdateSAMLProviderResponse -> ShowS)
-> (UpdateSAMLProviderResponse -> String)
-> ([UpdateSAMLProviderResponse] -> ShowS)
-> Show UpdateSAMLProviderResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSAMLProviderResponse] -> ShowS
$cshowList :: [UpdateSAMLProviderResponse] -> ShowS
show :: UpdateSAMLProviderResponse -> String
$cshow :: UpdateSAMLProviderResponse -> String
showsPrec :: Int -> UpdateSAMLProviderResponse -> ShowS
$cshowsPrec :: Int -> UpdateSAMLProviderResponse -> ShowS
Prelude.Show, (forall x.
 UpdateSAMLProviderResponse -> Rep UpdateSAMLProviderResponse x)
-> (forall x.
    Rep UpdateSAMLProviderResponse x -> UpdateSAMLProviderResponse)
-> Generic UpdateSAMLProviderResponse
forall x.
Rep UpdateSAMLProviderResponse x -> UpdateSAMLProviderResponse
forall x.
UpdateSAMLProviderResponse -> Rep UpdateSAMLProviderResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateSAMLProviderResponse x -> UpdateSAMLProviderResponse
$cfrom :: forall x.
UpdateSAMLProviderResponse -> Rep UpdateSAMLProviderResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSAMLProviderResponse' 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:
--
-- 'sAMLProviderArn', 'updateSAMLProviderResponse_sAMLProviderArn' - The Amazon Resource Name (ARN) of the SAML provider that was updated.
--
-- 'httpStatus', 'updateSAMLProviderResponse_httpStatus' - The response's http status code.
newUpdateSAMLProviderResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateSAMLProviderResponse
newUpdateSAMLProviderResponse :: Int -> UpdateSAMLProviderResponse
newUpdateSAMLProviderResponse Int
pHttpStatus_ =
  UpdateSAMLProviderResponse' :: Maybe Text -> Int -> UpdateSAMLProviderResponse
UpdateSAMLProviderResponse'
    { $sel:sAMLProviderArn:UpdateSAMLProviderResponse' :: Maybe Text
sAMLProviderArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateSAMLProviderResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the SAML provider that was updated.
updateSAMLProviderResponse_sAMLProviderArn :: Lens.Lens' UpdateSAMLProviderResponse (Prelude.Maybe Prelude.Text)
updateSAMLProviderResponse_sAMLProviderArn :: (Maybe Text -> f (Maybe Text))
-> UpdateSAMLProviderResponse -> f UpdateSAMLProviderResponse
updateSAMLProviderResponse_sAMLProviderArn = (UpdateSAMLProviderResponse -> Maybe Text)
-> (UpdateSAMLProviderResponse
    -> Maybe Text -> UpdateSAMLProviderResponse)
-> Lens
     UpdateSAMLProviderResponse
     UpdateSAMLProviderResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSAMLProviderResponse' {Maybe Text
sAMLProviderArn :: Maybe Text
$sel:sAMLProviderArn:UpdateSAMLProviderResponse' :: UpdateSAMLProviderResponse -> Maybe Text
sAMLProviderArn} -> Maybe Text
sAMLProviderArn) (\s :: UpdateSAMLProviderResponse
s@UpdateSAMLProviderResponse' {} Maybe Text
a -> UpdateSAMLProviderResponse
s {$sel:sAMLProviderArn:UpdateSAMLProviderResponse' :: Maybe Text
sAMLProviderArn = Maybe Text
a} :: UpdateSAMLProviderResponse)

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

instance Prelude.NFData UpdateSAMLProviderResponse