{-# 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.Backup.UpdateGlobalSettings
-- 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 whether the Amazon Web Services account is opted in to
-- cross-account backup. Returns an error if the account is not an
-- Organizations management account. Use the @DescribeGlobalSettings@ API
-- to determine the current settings.
module Amazonka.Backup.UpdateGlobalSettings
  ( -- * Creating a Request
    UpdateGlobalSettings (..),
    newUpdateGlobalSettings,

    -- * Request Lenses
    updateGlobalSettings_globalSettings,

    -- * Destructuring the Response
    UpdateGlobalSettingsResponse (..),
    newUpdateGlobalSettingsResponse,
  )
where

import Amazonka.Backup.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateGlobalSettings' smart constructor.
data UpdateGlobalSettings = UpdateGlobalSettings'
  { -- | A value for @isCrossAccountBackupEnabled@ and a Region. Example:
    -- @update-global-settings --global-settings isCrossAccountBackupEnabled=false --region us-west-2@.
    UpdateGlobalSettings -> Maybe (HashMap Text Text)
globalSettings :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (UpdateGlobalSettings -> UpdateGlobalSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateGlobalSettings -> UpdateGlobalSettings -> Bool
$c/= :: UpdateGlobalSettings -> UpdateGlobalSettings -> Bool
== :: UpdateGlobalSettings -> UpdateGlobalSettings -> Bool
$c== :: UpdateGlobalSettings -> UpdateGlobalSettings -> Bool
Prelude.Eq, ReadPrec [UpdateGlobalSettings]
ReadPrec UpdateGlobalSettings
Int -> ReadS UpdateGlobalSettings
ReadS [UpdateGlobalSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateGlobalSettings]
$creadListPrec :: ReadPrec [UpdateGlobalSettings]
readPrec :: ReadPrec UpdateGlobalSettings
$creadPrec :: ReadPrec UpdateGlobalSettings
readList :: ReadS [UpdateGlobalSettings]
$creadList :: ReadS [UpdateGlobalSettings]
readsPrec :: Int -> ReadS UpdateGlobalSettings
$creadsPrec :: Int -> ReadS UpdateGlobalSettings
Prelude.Read, Int -> UpdateGlobalSettings -> ShowS
[UpdateGlobalSettings] -> ShowS
UpdateGlobalSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateGlobalSettings] -> ShowS
$cshowList :: [UpdateGlobalSettings] -> ShowS
show :: UpdateGlobalSettings -> String
$cshow :: UpdateGlobalSettings -> String
showsPrec :: Int -> UpdateGlobalSettings -> ShowS
$cshowsPrec :: Int -> UpdateGlobalSettings -> ShowS
Prelude.Show, forall x. Rep UpdateGlobalSettings x -> UpdateGlobalSettings
forall x. UpdateGlobalSettings -> Rep UpdateGlobalSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateGlobalSettings x -> UpdateGlobalSettings
$cfrom :: forall x. UpdateGlobalSettings -> Rep UpdateGlobalSettings x
Prelude.Generic)

-- |
-- Create a value of 'UpdateGlobalSettings' 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:
--
-- 'globalSettings', 'updateGlobalSettings_globalSettings' - A value for @isCrossAccountBackupEnabled@ and a Region. Example:
-- @update-global-settings --global-settings isCrossAccountBackupEnabled=false --region us-west-2@.
newUpdateGlobalSettings ::
  UpdateGlobalSettings
newUpdateGlobalSettings :: UpdateGlobalSettings
newUpdateGlobalSettings =
  UpdateGlobalSettings'
    { $sel:globalSettings:UpdateGlobalSettings' :: Maybe (HashMap Text Text)
globalSettings =
        forall a. Maybe a
Prelude.Nothing
    }

-- | A value for @isCrossAccountBackupEnabled@ and a Region. Example:
-- @update-global-settings --global-settings isCrossAccountBackupEnabled=false --region us-west-2@.
updateGlobalSettings_globalSettings :: Lens.Lens' UpdateGlobalSettings (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
updateGlobalSettings_globalSettings :: Lens' UpdateGlobalSettings (Maybe (HashMap Text Text))
updateGlobalSettings_globalSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGlobalSettings' {Maybe (HashMap Text Text)
globalSettings :: Maybe (HashMap Text Text)
$sel:globalSettings:UpdateGlobalSettings' :: UpdateGlobalSettings -> Maybe (HashMap Text Text)
globalSettings} -> Maybe (HashMap Text Text)
globalSettings) (\s :: UpdateGlobalSettings
s@UpdateGlobalSettings' {} Maybe (HashMap Text Text)
a -> UpdateGlobalSettings
s {$sel:globalSettings:UpdateGlobalSettings' :: Maybe (HashMap Text Text)
globalSettings = Maybe (HashMap Text Text)
a} :: UpdateGlobalSettings) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest UpdateGlobalSettings where
  type
    AWSResponse UpdateGlobalSettings =
      UpdateGlobalSettingsResponse
  request :: (Service -> Service)
-> UpdateGlobalSettings -> Request UpdateGlobalSettings
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateGlobalSettings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateGlobalSettings)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull UpdateGlobalSettingsResponse
UpdateGlobalSettingsResponse'

instance Prelude.Hashable UpdateGlobalSettings where
  hashWithSalt :: Int -> UpdateGlobalSettings -> Int
hashWithSalt Int
_salt UpdateGlobalSettings' {Maybe (HashMap Text Text)
globalSettings :: Maybe (HashMap Text Text)
$sel:globalSettings:UpdateGlobalSettings' :: UpdateGlobalSettings -> Maybe (HashMap Text Text)
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
globalSettings

instance Prelude.NFData UpdateGlobalSettings where
  rnf :: UpdateGlobalSettings -> ()
rnf UpdateGlobalSettings' {Maybe (HashMap Text Text)
globalSettings :: Maybe (HashMap Text Text)
$sel:globalSettings:UpdateGlobalSettings' :: UpdateGlobalSettings -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
globalSettings

instance Data.ToHeaders UpdateGlobalSettings where
  toHeaders :: UpdateGlobalSettings -> [Header]
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateGlobalSettings where
  toJSON :: UpdateGlobalSettings -> Value
toJSON UpdateGlobalSettings' {Maybe (HashMap Text Text)
globalSettings :: Maybe (HashMap Text Text)
$sel:globalSettings:UpdateGlobalSettings' :: UpdateGlobalSettings -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"GlobalSettings" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
globalSettings
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateGlobalSettingsResponse' 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.
newUpdateGlobalSettingsResponse ::
  UpdateGlobalSettingsResponse
newUpdateGlobalSettingsResponse :: UpdateGlobalSettingsResponse
newUpdateGlobalSettingsResponse =
  UpdateGlobalSettingsResponse
UpdateGlobalSettingsResponse'

instance Prelude.NFData UpdateGlobalSettingsResponse where
  rnf :: UpdateGlobalSettingsResponse -> ()
rnf UpdateGlobalSettingsResponse
_ = ()