{-# 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.EnableLDAPS
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Activates the switch for the specific directory to always use LDAP
-- secure calls.
module Amazonka.DirectoryService.EnableLDAPS
  ( -- * Creating a Request
    EnableLDAPS (..),
    newEnableLDAPS,

    -- * Request Lenses
    enableLDAPS_directoryId,
    enableLDAPS_type,

    -- * Destructuring the Response
    EnableLDAPSResponse (..),
    newEnableLDAPSResponse,

    -- * Response Lenses
    enableLDAPSResponse_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

-- | /See:/ 'newEnableLDAPS' smart constructor.
data EnableLDAPS = EnableLDAPS'
  { -- | The identifier of the directory.
    EnableLDAPS -> Text
directoryId :: Prelude.Text,
    -- | The type of LDAP security to enable. Currently only the value @Client@
    -- is supported.
    EnableLDAPS -> LDAPSType
type' :: LDAPSType
  }
  deriving (EnableLDAPS -> EnableLDAPS -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableLDAPS -> EnableLDAPS -> Bool
$c/= :: EnableLDAPS -> EnableLDAPS -> Bool
== :: EnableLDAPS -> EnableLDAPS -> Bool
$c== :: EnableLDAPS -> EnableLDAPS -> Bool
Prelude.Eq, ReadPrec [EnableLDAPS]
ReadPrec EnableLDAPS
Int -> ReadS EnableLDAPS
ReadS [EnableLDAPS]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnableLDAPS]
$creadListPrec :: ReadPrec [EnableLDAPS]
readPrec :: ReadPrec EnableLDAPS
$creadPrec :: ReadPrec EnableLDAPS
readList :: ReadS [EnableLDAPS]
$creadList :: ReadS [EnableLDAPS]
readsPrec :: Int -> ReadS EnableLDAPS
$creadsPrec :: Int -> ReadS EnableLDAPS
Prelude.Read, Int -> EnableLDAPS -> ShowS
[EnableLDAPS] -> ShowS
EnableLDAPS -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableLDAPS] -> ShowS
$cshowList :: [EnableLDAPS] -> ShowS
show :: EnableLDAPS -> String
$cshow :: EnableLDAPS -> String
showsPrec :: Int -> EnableLDAPS -> ShowS
$cshowsPrec :: Int -> EnableLDAPS -> ShowS
Prelude.Show, forall x. Rep EnableLDAPS x -> EnableLDAPS
forall x. EnableLDAPS -> Rep EnableLDAPS x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnableLDAPS x -> EnableLDAPS
$cfrom :: forall x. EnableLDAPS -> Rep EnableLDAPS x
Prelude.Generic)

-- |
-- Create a value of 'EnableLDAPS' 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:
--
-- 'directoryId', 'enableLDAPS_directoryId' - The identifier of the directory.
--
-- 'type'', 'enableLDAPS_type' - The type of LDAP security to enable. Currently only the value @Client@
-- is supported.
newEnableLDAPS ::
  -- | 'directoryId'
  Prelude.Text ->
  -- | 'type''
  LDAPSType ->
  EnableLDAPS
newEnableLDAPS :: Text -> LDAPSType -> EnableLDAPS
newEnableLDAPS Text
pDirectoryId_ LDAPSType
pType_ =
  EnableLDAPS'
    { $sel:directoryId:EnableLDAPS' :: Text
directoryId = Text
pDirectoryId_,
      $sel:type':EnableLDAPS' :: LDAPSType
type' = LDAPSType
pType_
    }

-- | The identifier of the directory.
enableLDAPS_directoryId :: Lens.Lens' EnableLDAPS Prelude.Text
enableLDAPS_directoryId :: Lens' EnableLDAPS Text
enableLDAPS_directoryId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableLDAPS' {Text
directoryId :: Text
$sel:directoryId:EnableLDAPS' :: EnableLDAPS -> Text
directoryId} -> Text
directoryId) (\s :: EnableLDAPS
s@EnableLDAPS' {} Text
a -> EnableLDAPS
s {$sel:directoryId:EnableLDAPS' :: Text
directoryId = Text
a} :: EnableLDAPS)

-- | The type of LDAP security to enable. Currently only the value @Client@
-- is supported.
enableLDAPS_type :: Lens.Lens' EnableLDAPS LDAPSType
enableLDAPS_type :: Lens' EnableLDAPS LDAPSType
enableLDAPS_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableLDAPS' {LDAPSType
type' :: LDAPSType
$sel:type':EnableLDAPS' :: EnableLDAPS -> LDAPSType
type'} -> LDAPSType
type') (\s :: EnableLDAPS
s@EnableLDAPS' {} LDAPSType
a -> EnableLDAPS
s {$sel:type':EnableLDAPS' :: LDAPSType
type' = LDAPSType
a} :: EnableLDAPS)

instance Core.AWSRequest EnableLDAPS where
  type AWSResponse EnableLDAPS = EnableLDAPSResponse
  request :: (Service -> Service) -> EnableLDAPS -> Request EnableLDAPS
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 EnableLDAPS
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse EnableLDAPS)))
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 -> EnableLDAPSResponse
EnableLDAPSResponse'
            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 EnableLDAPS where
  hashWithSalt :: Int -> EnableLDAPS -> Int
hashWithSalt Int
_salt EnableLDAPS' {Text
LDAPSType
type' :: LDAPSType
directoryId :: Text
$sel:type':EnableLDAPS' :: EnableLDAPS -> LDAPSType
$sel:directoryId:EnableLDAPS' :: EnableLDAPS -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
directoryId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` LDAPSType
type'

instance Prelude.NFData EnableLDAPS where
  rnf :: EnableLDAPS -> ()
rnf EnableLDAPS' {Text
LDAPSType
type' :: LDAPSType
directoryId :: Text
$sel:type':EnableLDAPS' :: EnableLDAPS -> LDAPSType
$sel:directoryId:EnableLDAPS' :: EnableLDAPS -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
directoryId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf LDAPSType
type'

instance Data.ToHeaders EnableLDAPS where
  toHeaders :: EnableLDAPS -> 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.EnableLDAPS" ::
                          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 EnableLDAPS where
  toJSON :: EnableLDAPS -> Value
toJSON EnableLDAPS' {Text
LDAPSType
type' :: LDAPSType
directoryId :: Text
$sel:type':EnableLDAPS' :: EnableLDAPS -> LDAPSType
$sel:directoryId:EnableLDAPS' :: EnableLDAPS -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"DirectoryId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
directoryId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= LDAPSType
type')
          ]
      )

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

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

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

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

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

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