{-# 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.EnableRadius
-- 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)
--
-- Enables multi-factor authentication (MFA) with the Remote Authentication
-- Dial In User Service (RADIUS) server for an AD Connector or Microsoft AD
-- directory.
module Amazonka.DirectoryService.EnableRadius
  ( -- * Creating a Request
    EnableRadius (..),
    newEnableRadius,

    -- * Request Lenses
    enableRadius_directoryId,
    enableRadius_radiusSettings,

    -- * Destructuring the Response
    EnableRadiusResponse (..),
    newEnableRadiusResponse,

    -- * Response Lenses
    enableRadiusResponse_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 EnableRadius operation.
--
-- /See:/ 'newEnableRadius' smart constructor.
data EnableRadius = EnableRadius'
  { -- | The identifier of the directory for which to enable MFA.
    EnableRadius -> Text
directoryId :: Prelude.Text,
    -- | A RadiusSettings object that contains information about the RADIUS
    -- server.
    EnableRadius -> RadiusSettings
radiusSettings :: RadiusSettings
  }
  deriving (EnableRadius -> EnableRadius -> Bool
(EnableRadius -> EnableRadius -> Bool)
-> (EnableRadius -> EnableRadius -> Bool) -> Eq EnableRadius
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableRadius -> EnableRadius -> Bool
$c/= :: EnableRadius -> EnableRadius -> Bool
== :: EnableRadius -> EnableRadius -> Bool
$c== :: EnableRadius -> EnableRadius -> Bool
Prelude.Eq, Int -> EnableRadius -> ShowS
[EnableRadius] -> ShowS
EnableRadius -> String
(Int -> EnableRadius -> ShowS)
-> (EnableRadius -> String)
-> ([EnableRadius] -> ShowS)
-> Show EnableRadius
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableRadius] -> ShowS
$cshowList :: [EnableRadius] -> ShowS
show :: EnableRadius -> String
$cshow :: EnableRadius -> String
showsPrec :: Int -> EnableRadius -> ShowS
$cshowsPrec :: Int -> EnableRadius -> ShowS
Prelude.Show, (forall x. EnableRadius -> Rep EnableRadius x)
-> (forall x. Rep EnableRadius x -> EnableRadius)
-> Generic EnableRadius
forall x. Rep EnableRadius x -> EnableRadius
forall x. EnableRadius -> Rep EnableRadius x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnableRadius x -> EnableRadius
$cfrom :: forall x. EnableRadius -> Rep EnableRadius x
Prelude.Generic)

-- |
-- Create a value of 'EnableRadius' 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', 'enableRadius_directoryId' - The identifier of the directory for which to enable MFA.
--
-- 'radiusSettings', 'enableRadius_radiusSettings' - A RadiusSettings object that contains information about the RADIUS
-- server.
newEnableRadius ::
  -- | 'directoryId'
  Prelude.Text ->
  -- | 'radiusSettings'
  RadiusSettings ->
  EnableRadius
newEnableRadius :: Text -> RadiusSettings -> EnableRadius
newEnableRadius Text
pDirectoryId_ RadiusSettings
pRadiusSettings_ =
  EnableRadius' :: Text -> RadiusSettings -> EnableRadius
EnableRadius'
    { $sel:directoryId:EnableRadius' :: Text
directoryId = Text
pDirectoryId_,
      $sel:radiusSettings:EnableRadius' :: RadiusSettings
radiusSettings = RadiusSettings
pRadiusSettings_
    }

-- | The identifier of the directory for which to enable MFA.
enableRadius_directoryId :: Lens.Lens' EnableRadius Prelude.Text
enableRadius_directoryId :: (Text -> f Text) -> EnableRadius -> f EnableRadius
enableRadius_directoryId = (EnableRadius -> Text)
-> (EnableRadius -> Text -> EnableRadius)
-> Lens EnableRadius EnableRadius Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableRadius' {Text
directoryId :: Text
$sel:directoryId:EnableRadius' :: EnableRadius -> Text
directoryId} -> Text
directoryId) (\s :: EnableRadius
s@EnableRadius' {} Text
a -> EnableRadius
s {$sel:directoryId:EnableRadius' :: Text
directoryId = Text
a} :: EnableRadius)

-- | A RadiusSettings object that contains information about the RADIUS
-- server.
enableRadius_radiusSettings :: Lens.Lens' EnableRadius RadiusSettings
enableRadius_radiusSettings :: (RadiusSettings -> f RadiusSettings)
-> EnableRadius -> f EnableRadius
enableRadius_radiusSettings = (EnableRadius -> RadiusSettings)
-> (EnableRadius -> RadiusSettings -> EnableRadius)
-> Lens EnableRadius EnableRadius RadiusSettings RadiusSettings
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableRadius' {RadiusSettings
radiusSettings :: RadiusSettings
$sel:radiusSettings:EnableRadius' :: EnableRadius -> RadiusSettings
radiusSettings} -> RadiusSettings
radiusSettings) (\s :: EnableRadius
s@EnableRadius' {} RadiusSettings
a -> EnableRadius
s {$sel:radiusSettings:EnableRadius' :: RadiusSettings
radiusSettings = RadiusSettings
a} :: EnableRadius)

instance Core.AWSRequest EnableRadius where
  type AWSResponse EnableRadius = EnableRadiusResponse
  request :: EnableRadius -> Request EnableRadius
request = Service -> EnableRadius -> Request EnableRadius
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy EnableRadius
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse EnableRadius)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse EnableRadius))
-> Logger
-> Service
-> Proxy EnableRadius
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse EnableRadius)))
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 -> EnableRadiusResponse
EnableRadiusResponse'
            (Int -> EnableRadiusResponse)
-> Either String Int -> Either String EnableRadiusResponse
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 EnableRadius

instance Prelude.NFData EnableRadius

instance Core.ToHeaders EnableRadius where
  toHeaders :: EnableRadius -> ResponseHeaders
toHeaders =
    ResponseHeaders -> EnableRadius -> 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.EnableRadius" ::
                          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 EnableRadius where
  toJSON :: EnableRadius -> Value
toJSON EnableRadius' {Text
RadiusSettings
radiusSettings :: RadiusSettings
directoryId :: Text
$sel:radiusSettings:EnableRadius' :: EnableRadius -> RadiusSettings
$sel:directoryId:EnableRadius' :: EnableRadius -> 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
"RadiusSettings" Text -> RadiusSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RadiusSettings
radiusSettings)
          ]
      )

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

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

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

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

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

instance Prelude.NFData EnableRadiusResponse