{-# 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.DirectoryService.DisableSso
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disables single-sign on for a directory.
module Amazonka.DirectoryService.DisableSso
  ( -- * Creating a Request
    DisableSso (..),
    newDisableSso,

    -- * Request Lenses
    disableSso_password,
    disableSso_userName,
    disableSso_directoryId,

    -- * Destructuring the Response
    DisableSsoResponse (..),
    newDisableSsoResponse,

    -- * Response Lenses
    disableSsoResponse_httpStatus,
  )
where

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

-- | Contains the inputs for the DisableSso operation.
--
-- /See:/ 'newDisableSso' smart constructor.
data DisableSso = DisableSso'
  { -- | The password of an alternate account to use to disable single-sign on.
    -- This is only used for AD Connector directories. For more information,
    -- see the /UserName/ parameter.
    DisableSso -> Maybe (Sensitive Text)
password :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The username of an alternate account to use to disable single-sign on.
    -- This is only used for AD Connector directories. This account must have
    -- privileges to remove a service principal name.
    --
    -- If the AD Connector service account does not have privileges to remove a
    -- service principal name, you can specify an alternate account with the
    -- /UserName/ and /Password/ parameters. These credentials are only used to
    -- disable single sign-on and are not stored by the service. The AD
    -- Connector service account is not changed.
    DisableSso -> Maybe Text
userName :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the directory for which to disable single-sign on.
    DisableSso -> Text
directoryId :: Prelude.Text
  }
  deriving (DisableSso -> DisableSso -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableSso -> DisableSso -> Bool
$c/= :: DisableSso -> DisableSso -> Bool
== :: DisableSso -> DisableSso -> Bool
$c== :: DisableSso -> DisableSso -> Bool
Prelude.Eq, Int -> DisableSso -> ShowS
[DisableSso] -> ShowS
DisableSso -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableSso] -> ShowS
$cshowList :: [DisableSso] -> ShowS
show :: DisableSso -> String
$cshow :: DisableSso -> String
showsPrec :: Int -> DisableSso -> ShowS
$cshowsPrec :: Int -> DisableSso -> ShowS
Prelude.Show, forall x. Rep DisableSso x -> DisableSso
forall x. DisableSso -> Rep DisableSso x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisableSso x -> DisableSso
$cfrom :: forall x. DisableSso -> Rep DisableSso x
Prelude.Generic)

-- |
-- Create a value of 'DisableSso' 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:
--
-- 'password', 'disableSso_password' - The password of an alternate account to use to disable single-sign on.
-- This is only used for AD Connector directories. For more information,
-- see the /UserName/ parameter.
--
-- 'userName', 'disableSso_userName' - The username of an alternate account to use to disable single-sign on.
-- This is only used for AD Connector directories. This account must have
-- privileges to remove a service principal name.
--
-- If the AD Connector service account does not have privileges to remove a
-- service principal name, you can specify an alternate account with the
-- /UserName/ and /Password/ parameters. These credentials are only used to
-- disable single sign-on and are not stored by the service. The AD
-- Connector service account is not changed.
--
-- 'directoryId', 'disableSso_directoryId' - The identifier of the directory for which to disable single-sign on.
newDisableSso ::
  -- | 'directoryId'
  Prelude.Text ->
  DisableSso
newDisableSso :: Text -> DisableSso
newDisableSso Text
pDirectoryId_ =
  DisableSso'
    { $sel:password:DisableSso' :: Maybe (Sensitive Text)
password = forall a. Maybe a
Prelude.Nothing,
      $sel:userName:DisableSso' :: Maybe Text
userName = forall a. Maybe a
Prelude.Nothing,
      $sel:directoryId:DisableSso' :: Text
directoryId = Text
pDirectoryId_
    }

-- | The password of an alternate account to use to disable single-sign on.
-- This is only used for AD Connector directories. For more information,
-- see the /UserName/ parameter.
disableSso_password :: Lens.Lens' DisableSso (Prelude.Maybe Prelude.Text)
disableSso_password :: Lens' DisableSso (Maybe Text)
disableSso_password = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableSso' {Maybe (Sensitive Text)
password :: Maybe (Sensitive Text)
$sel:password:DisableSso' :: DisableSso -> Maybe (Sensitive Text)
password} -> Maybe (Sensitive Text)
password) (\s :: DisableSso
s@DisableSso' {} Maybe (Sensitive Text)
a -> DisableSso
s {$sel:password:DisableSso' :: Maybe (Sensitive Text)
password = Maybe (Sensitive Text)
a} :: DisableSso) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The username of an alternate account to use to disable single-sign on.
-- This is only used for AD Connector directories. This account must have
-- privileges to remove a service principal name.
--
-- If the AD Connector service account does not have privileges to remove a
-- service principal name, you can specify an alternate account with the
-- /UserName/ and /Password/ parameters. These credentials are only used to
-- disable single sign-on and are not stored by the service. The AD
-- Connector service account is not changed.
disableSso_userName :: Lens.Lens' DisableSso (Prelude.Maybe Prelude.Text)
disableSso_userName :: Lens' DisableSso (Maybe Text)
disableSso_userName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableSso' {Maybe Text
userName :: Maybe Text
$sel:userName:DisableSso' :: DisableSso -> Maybe Text
userName} -> Maybe Text
userName) (\s :: DisableSso
s@DisableSso' {} Maybe Text
a -> DisableSso
s {$sel:userName:DisableSso' :: Maybe Text
userName = Maybe Text
a} :: DisableSso)

-- | The identifier of the directory for which to disable single-sign on.
disableSso_directoryId :: Lens.Lens' DisableSso Prelude.Text
disableSso_directoryId :: Lens' DisableSso Text
disableSso_directoryId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableSso' {Text
directoryId :: Text
$sel:directoryId:DisableSso' :: DisableSso -> Text
directoryId} -> Text
directoryId) (\s :: DisableSso
s@DisableSso' {} Text
a -> DisableSso
s {$sel:directoryId:DisableSso' :: Text
directoryId = Text
a} :: DisableSso)

instance Core.AWSRequest DisableSso where
  type AWSResponse DisableSso = DisableSsoResponse
  request :: (Service -> Service) -> DisableSso -> Request DisableSso
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 DisableSso
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DisableSso)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DisableSsoResponse
DisableSsoResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DisableSso where
  hashWithSalt :: Int -> DisableSso -> Int
hashWithSalt Int
_salt DisableSso' {Maybe Text
Maybe (Sensitive Text)
Text
directoryId :: Text
userName :: Maybe Text
password :: Maybe (Sensitive Text)
$sel:directoryId:DisableSso' :: DisableSso -> Text
$sel:userName:DisableSso' :: DisableSso -> Maybe Text
$sel:password:DisableSso' :: DisableSso -> Maybe (Sensitive Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
password
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
directoryId

instance Prelude.NFData DisableSso where
  rnf :: DisableSso -> ()
rnf DisableSso' {Maybe Text
Maybe (Sensitive Text)
Text
directoryId :: Text
userName :: Maybe Text
password :: Maybe (Sensitive Text)
$sel:directoryId:DisableSso' :: DisableSso -> Text
$sel:userName:DisableSso' :: DisableSso -> Maybe Text
$sel:password:DisableSso' :: DisableSso -> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
password
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
directoryId

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

instance Data.ToJSON DisableSso where
  toJSON :: DisableSso -> Value
toJSON DisableSso' {Maybe Text
Maybe (Sensitive Text)
Text
directoryId :: Text
userName :: Maybe Text
password :: Maybe (Sensitive Text)
$sel:directoryId:DisableSso' :: DisableSso -> Text
$sel:userName:DisableSso' :: DisableSso -> Maybe Text
$sel:password:DisableSso' :: DisableSso -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Password" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
password,
            (Key
"UserName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
userName,
            forall a. a -> Maybe a
Prelude.Just (Key
"DirectoryId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
directoryId)
          ]
      )

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

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

-- | Contains the results of the DisableSso operation.
--
-- /See:/ 'newDisableSsoResponse' smart constructor.
data DisableSsoResponse = DisableSsoResponse'
  { -- | The response's http status code.
    DisableSsoResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DisableSsoResponse -> DisableSsoResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableSsoResponse -> DisableSsoResponse -> Bool
$c/= :: DisableSsoResponse -> DisableSsoResponse -> Bool
== :: DisableSsoResponse -> DisableSsoResponse -> Bool
$c== :: DisableSsoResponse -> DisableSsoResponse -> Bool
Prelude.Eq, ReadPrec [DisableSsoResponse]
ReadPrec DisableSsoResponse
Int -> ReadS DisableSsoResponse
ReadS [DisableSsoResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableSsoResponse]
$creadListPrec :: ReadPrec [DisableSsoResponse]
readPrec :: ReadPrec DisableSsoResponse
$creadPrec :: ReadPrec DisableSsoResponse
readList :: ReadS [DisableSsoResponse]
$creadList :: ReadS [DisableSsoResponse]
readsPrec :: Int -> ReadS DisableSsoResponse
$creadsPrec :: Int -> ReadS DisableSsoResponse
Prelude.Read, Int -> DisableSsoResponse -> ShowS
[DisableSsoResponse] -> ShowS
DisableSsoResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableSsoResponse] -> ShowS
$cshowList :: [DisableSsoResponse] -> ShowS
show :: DisableSsoResponse -> String
$cshow :: DisableSsoResponse -> String
showsPrec :: Int -> DisableSsoResponse -> ShowS
$cshowsPrec :: Int -> DisableSsoResponse -> ShowS
Prelude.Show, forall x. Rep DisableSsoResponse x -> DisableSsoResponse
forall x. DisableSsoResponse -> Rep DisableSsoResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisableSsoResponse x -> DisableSsoResponse
$cfrom :: forall x. DisableSsoResponse -> Rep DisableSsoResponse x
Prelude.Generic)

-- |
-- Create a value of 'DisableSsoResponse' 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:
--
-- 'httpStatus', 'disableSsoResponse_httpStatus' - The response's http status code.
newDisableSsoResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisableSsoResponse
newDisableSsoResponse :: Int -> DisableSsoResponse
newDisableSsoResponse Int
pHttpStatus_ =
  DisableSsoResponse' {$sel:httpStatus:DisableSsoResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData DisableSsoResponse where
  rnf :: DisableSsoResponse -> ()
rnf DisableSsoResponse' {Int
httpStatus :: Int
$sel:httpStatus:DisableSsoResponse' :: DisableSsoResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus