{-# 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-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)
--
-- 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.Lens as Lens
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
(UpdateGlobalSettings -> UpdateGlobalSettings -> Bool)
-> (UpdateGlobalSettings -> UpdateGlobalSettings -> Bool)
-> Eq UpdateGlobalSettings
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]
(Int -> ReadS UpdateGlobalSettings)
-> ReadS [UpdateGlobalSettings]
-> ReadPrec UpdateGlobalSettings
-> ReadPrec [UpdateGlobalSettings]
-> Read 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
(Int -> UpdateGlobalSettings -> ShowS)
-> (UpdateGlobalSettings -> String)
-> ([UpdateGlobalSettings] -> ShowS)
-> Show UpdateGlobalSettings
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. UpdateGlobalSettings -> Rep UpdateGlobalSettings x)
-> (forall x. Rep UpdateGlobalSettings x -> UpdateGlobalSettings)
-> Generic UpdateGlobalSettings
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' :: Maybe (HashMap Text Text) -> UpdateGlobalSettings
UpdateGlobalSettings'
    { $sel:globalSettings:UpdateGlobalSettings' :: Maybe (HashMap Text Text)
globalSettings =
        Maybe (HashMap Text Text)
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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> UpdateGlobalSettings -> f UpdateGlobalSettings
updateGlobalSettings_globalSettings = (UpdateGlobalSettings -> Maybe (HashMap Text Text))
-> (UpdateGlobalSettings
    -> Maybe (HashMap Text Text) -> UpdateGlobalSettings)
-> Lens
     UpdateGlobalSettings
     UpdateGlobalSettings
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> UpdateGlobalSettings -> f UpdateGlobalSettings)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> UpdateGlobalSettings
-> f UpdateGlobalSettings
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
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 :: UpdateGlobalSettings -> Request UpdateGlobalSettings
request = Service -> UpdateGlobalSettings -> Request UpdateGlobalSettings
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateGlobalSettings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateGlobalSettings)))
response =
    AWSResponse UpdateGlobalSettings
-> Logger
-> Service
-> Proxy UpdateGlobalSettings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateGlobalSettings)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UpdateGlobalSettings
UpdateGlobalSettingsResponse
UpdateGlobalSettingsResponse'

instance Prelude.Hashable UpdateGlobalSettings

instance Prelude.NFData UpdateGlobalSettings

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"GlobalSettings" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
globalSettings
          ]
      )

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

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

-- | /See:/ 'newUpdateGlobalSettingsResponse' smart constructor.
data UpdateGlobalSettingsResponse = UpdateGlobalSettingsResponse'
  {
  }
  deriving (UpdateGlobalSettingsResponse
-> UpdateGlobalSettingsResponse -> Bool
(UpdateGlobalSettingsResponse
 -> UpdateGlobalSettingsResponse -> Bool)
-> (UpdateGlobalSettingsResponse
    -> UpdateGlobalSettingsResponse -> Bool)
-> Eq UpdateGlobalSettingsResponse
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]
(Int -> ReadS UpdateGlobalSettingsResponse)
-> ReadS [UpdateGlobalSettingsResponse]
-> ReadPrec UpdateGlobalSettingsResponse
-> ReadPrec [UpdateGlobalSettingsResponse]
-> Read 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
(Int -> UpdateGlobalSettingsResponse -> ShowS)
-> (UpdateGlobalSettingsResponse -> String)
-> ([UpdateGlobalSettingsResponse] -> ShowS)
-> Show UpdateGlobalSettingsResponse
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.
 UpdateGlobalSettingsResponse -> Rep UpdateGlobalSettingsResponse x)
-> (forall x.
    Rep UpdateGlobalSettingsResponse x -> UpdateGlobalSettingsResponse)
-> Generic UpdateGlobalSettingsResponse
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