{-# 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-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)
--
-- 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 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

-- | /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
(EnableLDAPS -> EnableLDAPS -> Bool)
-> (EnableLDAPS -> EnableLDAPS -> Bool) -> Eq EnableLDAPS
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]
(Int -> ReadS EnableLDAPS)
-> ReadS [EnableLDAPS]
-> ReadPrec EnableLDAPS
-> ReadPrec [EnableLDAPS]
-> Read 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
(Int -> EnableLDAPS -> ShowS)
-> (EnableLDAPS -> String)
-> ([EnableLDAPS] -> ShowS)
-> Show EnableLDAPS
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. EnableLDAPS -> Rep EnableLDAPS x)
-> (forall x. Rep EnableLDAPS x -> EnableLDAPS)
-> Generic EnableLDAPS
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' :: Text -> LDAPSType -> EnableLDAPS
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 :: (Text -> f Text) -> EnableLDAPS -> f EnableLDAPS
enableLDAPS_directoryId = (EnableLDAPS -> Text)
-> (EnableLDAPS -> Text -> EnableLDAPS)
-> Lens EnableLDAPS EnableLDAPS Text Text
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 :: (LDAPSType -> f LDAPSType) -> EnableLDAPS -> f EnableLDAPS
enableLDAPS_type = (EnableLDAPS -> LDAPSType)
-> (EnableLDAPS -> LDAPSType -> EnableLDAPS)
-> Lens EnableLDAPS EnableLDAPS LDAPSType LDAPSType
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 :: EnableLDAPS -> Request EnableLDAPS
request = Service -> EnableLDAPS -> Request EnableLDAPS
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy EnableLDAPS
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse EnableLDAPS)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse EnableLDAPS))
-> Logger
-> Service
-> Proxy EnableLDAPS
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse EnableLDAPS)))
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 -> EnableLDAPSResponse
EnableLDAPSResponse'
            (Int -> EnableLDAPSResponse)
-> Either String Int -> Either String EnableLDAPSResponse
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 EnableLDAPS

instance Prelude.NFData EnableLDAPS

instance Core.ToHeaders EnableLDAPS where
  toHeaders :: EnableLDAPS -> ResponseHeaders
toHeaders =
    ResponseHeaders -> EnableLDAPS -> 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.EnableLDAPS" ::
                          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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> LDAPSType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LDAPSType
type')
          ]
      )

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

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

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