{-# 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.UpdateNumberOfDomainControllers
-- 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)
--
-- Adds or removes domain controllers to or from the directory. Based on
-- the difference between current value and new value (provided through
-- this API call), domain controllers will be added or removed. It may take
-- up to 45 minutes for any new domain controllers to become fully active
-- once the requested number of domain controllers is updated. During this
-- time, you cannot make another update request.
module Amazonka.DirectoryService.UpdateNumberOfDomainControllers
  ( -- * Creating a Request
    UpdateNumberOfDomainControllers (..),
    newUpdateNumberOfDomainControllers,

    -- * Request Lenses
    updateNumberOfDomainControllers_directoryId,
    updateNumberOfDomainControllers_desiredNumber,

    -- * Destructuring the Response
    UpdateNumberOfDomainControllersResponse (..),
    newUpdateNumberOfDomainControllersResponse,

    -- * Response Lenses
    updateNumberOfDomainControllersResponse_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:/ 'newUpdateNumberOfDomainControllers' smart constructor.
data UpdateNumberOfDomainControllers = UpdateNumberOfDomainControllers'
  { -- | Identifier of the directory to which the domain controllers will be
    -- added or removed.
    UpdateNumberOfDomainControllers -> Text
directoryId :: Prelude.Text,
    -- | The number of domain controllers desired in the directory.
    UpdateNumberOfDomainControllers -> Natural
desiredNumber :: Prelude.Natural
  }
  deriving (UpdateNumberOfDomainControllers
-> UpdateNumberOfDomainControllers -> Bool
(UpdateNumberOfDomainControllers
 -> UpdateNumberOfDomainControllers -> Bool)
-> (UpdateNumberOfDomainControllers
    -> UpdateNumberOfDomainControllers -> Bool)
-> Eq UpdateNumberOfDomainControllers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateNumberOfDomainControllers
-> UpdateNumberOfDomainControllers -> Bool
$c/= :: UpdateNumberOfDomainControllers
-> UpdateNumberOfDomainControllers -> Bool
== :: UpdateNumberOfDomainControllers
-> UpdateNumberOfDomainControllers -> Bool
$c== :: UpdateNumberOfDomainControllers
-> UpdateNumberOfDomainControllers -> Bool
Prelude.Eq, ReadPrec [UpdateNumberOfDomainControllers]
ReadPrec UpdateNumberOfDomainControllers
Int -> ReadS UpdateNumberOfDomainControllers
ReadS [UpdateNumberOfDomainControllers]
(Int -> ReadS UpdateNumberOfDomainControllers)
-> ReadS [UpdateNumberOfDomainControllers]
-> ReadPrec UpdateNumberOfDomainControllers
-> ReadPrec [UpdateNumberOfDomainControllers]
-> Read UpdateNumberOfDomainControllers
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateNumberOfDomainControllers]
$creadListPrec :: ReadPrec [UpdateNumberOfDomainControllers]
readPrec :: ReadPrec UpdateNumberOfDomainControllers
$creadPrec :: ReadPrec UpdateNumberOfDomainControllers
readList :: ReadS [UpdateNumberOfDomainControllers]
$creadList :: ReadS [UpdateNumberOfDomainControllers]
readsPrec :: Int -> ReadS UpdateNumberOfDomainControllers
$creadsPrec :: Int -> ReadS UpdateNumberOfDomainControllers
Prelude.Read, Int -> UpdateNumberOfDomainControllers -> ShowS
[UpdateNumberOfDomainControllers] -> ShowS
UpdateNumberOfDomainControllers -> String
(Int -> UpdateNumberOfDomainControllers -> ShowS)
-> (UpdateNumberOfDomainControllers -> String)
-> ([UpdateNumberOfDomainControllers] -> ShowS)
-> Show UpdateNumberOfDomainControllers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateNumberOfDomainControllers] -> ShowS
$cshowList :: [UpdateNumberOfDomainControllers] -> ShowS
show :: UpdateNumberOfDomainControllers -> String
$cshow :: UpdateNumberOfDomainControllers -> String
showsPrec :: Int -> UpdateNumberOfDomainControllers -> ShowS
$cshowsPrec :: Int -> UpdateNumberOfDomainControllers -> ShowS
Prelude.Show, (forall x.
 UpdateNumberOfDomainControllers
 -> Rep UpdateNumberOfDomainControllers x)
-> (forall x.
    Rep UpdateNumberOfDomainControllers x
    -> UpdateNumberOfDomainControllers)
-> Generic UpdateNumberOfDomainControllers
forall x.
Rep UpdateNumberOfDomainControllers x
-> UpdateNumberOfDomainControllers
forall x.
UpdateNumberOfDomainControllers
-> Rep UpdateNumberOfDomainControllers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateNumberOfDomainControllers x
-> UpdateNumberOfDomainControllers
$cfrom :: forall x.
UpdateNumberOfDomainControllers
-> Rep UpdateNumberOfDomainControllers x
Prelude.Generic)

-- |
-- Create a value of 'UpdateNumberOfDomainControllers' 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', 'updateNumberOfDomainControllers_directoryId' - Identifier of the directory to which the domain controllers will be
-- added or removed.
--
-- 'desiredNumber', 'updateNumberOfDomainControllers_desiredNumber' - The number of domain controllers desired in the directory.
newUpdateNumberOfDomainControllers ::
  -- | 'directoryId'
  Prelude.Text ->
  -- | 'desiredNumber'
  Prelude.Natural ->
  UpdateNumberOfDomainControllers
newUpdateNumberOfDomainControllers :: Text -> Natural -> UpdateNumberOfDomainControllers
newUpdateNumberOfDomainControllers
  Text
pDirectoryId_
  Natural
pDesiredNumber_ =
    UpdateNumberOfDomainControllers' :: Text -> Natural -> UpdateNumberOfDomainControllers
UpdateNumberOfDomainControllers'
      { $sel:directoryId:UpdateNumberOfDomainControllers' :: Text
directoryId =
          Text
pDirectoryId_,
        $sel:desiredNumber:UpdateNumberOfDomainControllers' :: Natural
desiredNumber = Natural
pDesiredNumber_
      }

-- | Identifier of the directory to which the domain controllers will be
-- added or removed.
updateNumberOfDomainControllers_directoryId :: Lens.Lens' UpdateNumberOfDomainControllers Prelude.Text
updateNumberOfDomainControllers_directoryId :: (Text -> f Text)
-> UpdateNumberOfDomainControllers
-> f UpdateNumberOfDomainControllers
updateNumberOfDomainControllers_directoryId = (UpdateNumberOfDomainControllers -> Text)
-> (UpdateNumberOfDomainControllers
    -> Text -> UpdateNumberOfDomainControllers)
-> Lens
     UpdateNumberOfDomainControllers
     UpdateNumberOfDomainControllers
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateNumberOfDomainControllers' {Text
directoryId :: Text
$sel:directoryId:UpdateNumberOfDomainControllers' :: UpdateNumberOfDomainControllers -> Text
directoryId} -> Text
directoryId) (\s :: UpdateNumberOfDomainControllers
s@UpdateNumberOfDomainControllers' {} Text
a -> UpdateNumberOfDomainControllers
s {$sel:directoryId:UpdateNumberOfDomainControllers' :: Text
directoryId = Text
a} :: UpdateNumberOfDomainControllers)

-- | The number of domain controllers desired in the directory.
updateNumberOfDomainControllers_desiredNumber :: Lens.Lens' UpdateNumberOfDomainControllers Prelude.Natural
updateNumberOfDomainControllers_desiredNumber :: (Natural -> f Natural)
-> UpdateNumberOfDomainControllers
-> f UpdateNumberOfDomainControllers
updateNumberOfDomainControllers_desiredNumber = (UpdateNumberOfDomainControllers -> Natural)
-> (UpdateNumberOfDomainControllers
    -> Natural -> UpdateNumberOfDomainControllers)
-> Lens
     UpdateNumberOfDomainControllers
     UpdateNumberOfDomainControllers
     Natural
     Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateNumberOfDomainControllers' {Natural
desiredNumber :: Natural
$sel:desiredNumber:UpdateNumberOfDomainControllers' :: UpdateNumberOfDomainControllers -> Natural
desiredNumber} -> Natural
desiredNumber) (\s :: UpdateNumberOfDomainControllers
s@UpdateNumberOfDomainControllers' {} Natural
a -> UpdateNumberOfDomainControllers
s {$sel:desiredNumber:UpdateNumberOfDomainControllers' :: Natural
desiredNumber = Natural
a} :: UpdateNumberOfDomainControllers)

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

instance
  Prelude.NFData
    UpdateNumberOfDomainControllers

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

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

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

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

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

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

instance
  Prelude.NFData
    UpdateNumberOfDomainControllersResponse