{-# 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-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)
--
-- Disables single-sign on for a directory.
module Amazonka.DirectoryService.DisableSso
  ( -- * Creating a Request
    DisableSso (..),
    newDisableSso,

    -- * Request Lenses
    disableSso_userName,
    disableSso_password,
    disableSso_directoryId,

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

    -- * Response Lenses
    disableSsoResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DirectoryService.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

-- | Contains the inputs for the DisableSso operation.
--
-- /See:/ 'newDisableSso' smart constructor.
data DisableSso = DisableSso'
  { -- | 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 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 (Core.Sensitive Prelude.Text),
    -- | The identifier of the directory for which to disable single-sign on.
    DisableSso -> Text
directoryId :: Prelude.Text
  }
  deriving (DisableSso -> DisableSso -> Bool
(DisableSso -> DisableSso -> Bool)
-> (DisableSso -> DisableSso -> Bool) -> Eq DisableSso
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
(Int -> DisableSso -> ShowS)
-> (DisableSso -> String)
-> ([DisableSso] -> ShowS)
-> Show DisableSso
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. DisableSso -> Rep DisableSso x)
-> (forall x. Rep DisableSso x -> DisableSso) -> Generic DisableSso
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:
--
-- '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.
--
-- '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.
--
-- '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' :: Maybe Text -> Maybe (Sensitive Text) -> Text -> DisableSso
DisableSso'
    { $sel:userName:DisableSso' :: Maybe Text
userName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:password:DisableSso' :: Maybe (Sensitive Text)
password = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:directoryId:DisableSso' :: Text
directoryId = Text
pDirectoryId_
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> DisableSso -> f DisableSso
disableSso_userName = (DisableSso -> Maybe Text)
-> (DisableSso -> Maybe Text -> DisableSso)
-> Lens DisableSso DisableSso (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text)) -> DisableSso -> f DisableSso
disableSso_password = (DisableSso -> Maybe (Sensitive Text))
-> (DisableSso -> Maybe (Sensitive Text) -> DisableSso)
-> Lens
     DisableSso
     DisableSso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
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) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> DisableSso -> f DisableSso)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> DisableSso
-> f DisableSso
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The identifier of the directory for which to disable single-sign on.
disableSso_directoryId :: Lens.Lens' DisableSso Prelude.Text
disableSso_directoryId :: (Text -> f Text) -> DisableSso -> f DisableSso
disableSso_directoryId = (DisableSso -> Text)
-> (DisableSso -> Text -> DisableSso)
-> Lens DisableSso DisableSso Text Text
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 :: DisableSso -> Request DisableSso
request = Service -> DisableSso -> Request DisableSso
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DisableSso
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DisableSso)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse DisableSso))
-> Logger
-> Service
-> Proxy DisableSso
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DisableSso)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DisableSsoResponse
DisableSsoResponse'
            (Int -> DisableSsoResponse)
-> Either String Int -> Either String DisableSsoResponse
forall (f :: * -> *) a b. Functor 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 DisableSso

instance Prelude.NFData DisableSso

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

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

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

instance Core.ToQuery DisableSso where
  toQuery :: DisableSso -> QueryString
toQuery = QueryString -> DisableSso -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DisableSsoResponse -> DisableSsoResponse -> Bool)
-> (DisableSsoResponse -> DisableSsoResponse -> Bool)
-> Eq DisableSsoResponse
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]
(Int -> ReadS DisableSsoResponse)
-> ReadS [DisableSsoResponse]
-> ReadPrec DisableSsoResponse
-> ReadPrec [DisableSsoResponse]
-> Read 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
(Int -> DisableSsoResponse -> ShowS)
-> (DisableSsoResponse -> String)
-> ([DisableSsoResponse] -> ShowS)
-> Show DisableSsoResponse
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. DisableSsoResponse -> Rep DisableSsoResponse x)
-> (forall x. Rep DisableSsoResponse x -> DisableSsoResponse)
-> Generic DisableSsoResponse
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' :: Int -> DisableSsoResponse
DisableSsoResponse' {$sel:httpStatus:DisableSsoResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
disableSsoResponse_httpStatus :: Lens.Lens' DisableSsoResponse Prelude.Int
disableSsoResponse_httpStatus :: (Int -> f Int) -> DisableSsoResponse -> f DisableSsoResponse
disableSsoResponse_httpStatus = (DisableSsoResponse -> Int)
-> (DisableSsoResponse -> Int -> DisableSsoResponse)
-> Lens DisableSsoResponse DisableSsoResponse Int Int
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