{-# 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.UpdateSettings
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates the configurable settings for the specified directory.
module Amazonka.DirectoryService.UpdateSettings
  ( -- * Creating a Request
    UpdateSettings (..),
    newUpdateSettings,

    -- * Request Lenses
    updateSettings_directoryId,
    updateSettings_settings,

    -- * Destructuring the Response
    UpdateSettingsResponse (..),
    newUpdateSettingsResponse,

    -- * Response Lenses
    updateSettingsResponse_directoryId,
    updateSettingsResponse_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:/ 'newUpdateSettings' smart constructor.
data UpdateSettings = UpdateSettings'
  { -- | The identifier of the directory for which to update settings.
    UpdateSettings -> Text
directoryId :: Prelude.Text,
    -- | The list of Setting objects.
    UpdateSettings -> [Setting]
settings :: [Setting]
  }
  deriving (UpdateSettings -> UpdateSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSettings -> UpdateSettings -> Bool
$c/= :: UpdateSettings -> UpdateSettings -> Bool
== :: UpdateSettings -> UpdateSettings -> Bool
$c== :: UpdateSettings -> UpdateSettings -> Bool
Prelude.Eq, ReadPrec [UpdateSettings]
ReadPrec UpdateSettings
Int -> ReadS UpdateSettings
ReadS [UpdateSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSettings]
$creadListPrec :: ReadPrec [UpdateSettings]
readPrec :: ReadPrec UpdateSettings
$creadPrec :: ReadPrec UpdateSettings
readList :: ReadS [UpdateSettings]
$creadList :: ReadS [UpdateSettings]
readsPrec :: Int -> ReadS UpdateSettings
$creadsPrec :: Int -> ReadS UpdateSettings
Prelude.Read, Int -> UpdateSettings -> ShowS
[UpdateSettings] -> ShowS
UpdateSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSettings] -> ShowS
$cshowList :: [UpdateSettings] -> ShowS
show :: UpdateSettings -> String
$cshow :: UpdateSettings -> String
showsPrec :: Int -> UpdateSettings -> ShowS
$cshowsPrec :: Int -> UpdateSettings -> ShowS
Prelude.Show, forall x. Rep UpdateSettings x -> UpdateSettings
forall x. UpdateSettings -> Rep UpdateSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateSettings x -> UpdateSettings
$cfrom :: forall x. UpdateSettings -> Rep UpdateSettings x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSettings' 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', 'updateSettings_directoryId' - The identifier of the directory for which to update settings.
--
-- 'settings', 'updateSettings_settings' - The list of Setting objects.
newUpdateSettings ::
  -- | 'directoryId'
  Prelude.Text ->
  UpdateSettings
newUpdateSettings :: Text -> UpdateSettings
newUpdateSettings Text
pDirectoryId_ =
  UpdateSettings'
    { $sel:directoryId:UpdateSettings' :: Text
directoryId = Text
pDirectoryId_,
      $sel:settings:UpdateSettings' :: [Setting]
settings = forall a. Monoid a => a
Prelude.mempty
    }

-- | The identifier of the directory for which to update settings.
updateSettings_directoryId :: Lens.Lens' UpdateSettings Prelude.Text
updateSettings_directoryId :: Lens' UpdateSettings Text
updateSettings_directoryId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSettings' {Text
directoryId :: Text
$sel:directoryId:UpdateSettings' :: UpdateSettings -> Text
directoryId} -> Text
directoryId) (\s :: UpdateSettings
s@UpdateSettings' {} Text
a -> UpdateSettings
s {$sel:directoryId:UpdateSettings' :: Text
directoryId = Text
a} :: UpdateSettings)

-- | The list of Setting objects.
updateSettings_settings :: Lens.Lens' UpdateSettings [Setting]
updateSettings_settings :: Lens' UpdateSettings [Setting]
updateSettings_settings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSettings' {[Setting]
settings :: [Setting]
$sel:settings:UpdateSettings' :: UpdateSettings -> [Setting]
settings} -> [Setting]
settings) (\s :: UpdateSettings
s@UpdateSettings' {} [Setting]
a -> UpdateSettings
s {$sel:settings:UpdateSettings' :: [Setting]
settings = [Setting]
a} :: UpdateSettings) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest UpdateSettings where
  type
    AWSResponse UpdateSettings =
      UpdateSettingsResponse
  request :: (Service -> Service) -> UpdateSettings -> Request UpdateSettings
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 UpdateSettings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateSettings)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> UpdateSettingsResponse
UpdateSettingsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"DirectoryId")
            forall (f :: * -> *) a b. Applicative f => 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 UpdateSettings where
  hashWithSalt :: Int -> UpdateSettings -> Int
hashWithSalt Int
_salt UpdateSettings' {[Setting]
Text
settings :: [Setting]
directoryId :: Text
$sel:settings:UpdateSettings' :: UpdateSettings -> [Setting]
$sel:directoryId:UpdateSettings' :: UpdateSettings -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
directoryId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Setting]
settings

instance Prelude.NFData UpdateSettings where
  rnf :: UpdateSettings -> ()
rnf UpdateSettings' {[Setting]
Text
settings :: [Setting]
directoryId :: Text
$sel:settings:UpdateSettings' :: UpdateSettings -> [Setting]
$sel:directoryId:UpdateSettings' :: UpdateSettings -> 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 [Setting]
settings

instance Data.ToHeaders UpdateSettings where
  toHeaders :: UpdateSettings -> 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.UpdateSettings" ::
                          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 UpdateSettings where
  toJSON :: UpdateSettings -> Value
toJSON UpdateSettings' {[Setting]
Text
settings :: [Setting]
directoryId :: Text
$sel:settings:UpdateSettings' :: UpdateSettings -> [Setting]
$sel:directoryId:UpdateSettings' :: UpdateSettings -> 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
"Settings" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Setting]
settings)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateSettingsResponse' 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', 'updateSettingsResponse_directoryId' - The identifier of the directory.
--
-- 'httpStatus', 'updateSettingsResponse_httpStatus' - The response's http status code.
newUpdateSettingsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateSettingsResponse
newUpdateSettingsResponse :: Int -> UpdateSettingsResponse
newUpdateSettingsResponse Int
pHttpStatus_ =
  UpdateSettingsResponse'
    { $sel:directoryId:UpdateSettingsResponse' :: Maybe Text
directoryId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateSettingsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

instance Prelude.NFData UpdateSettingsResponse where
  rnf :: UpdateSettingsResponse -> ()
rnf UpdateSettingsResponse' {Int
Maybe Text
httpStatus :: Int
directoryId :: Maybe Text
$sel:httpStatus:UpdateSettingsResponse' :: UpdateSettingsResponse -> Int
$sel:directoryId:UpdateSettingsResponse' :: UpdateSettingsResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
directoryId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus