{-# 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.UpdateRegionSettings
-- 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 the current service opt-in settings for the Region. If
-- service-opt-in is enabled for a service, Backup tries to protect that
-- service\'s resources in this Region, when the resource is included in an
-- on-demand backup or scheduled backup plan. Otherwise, Backup does not
-- try to protect that service\'s resources in this Region. Use the
-- @DescribeRegionSettings@ API to determine the resource types that are
-- supported.
module Amazonka.Backup.UpdateRegionSettings
  ( -- * Creating a Request
    UpdateRegionSettings (..),
    newUpdateRegionSettings,

    -- * Request Lenses
    updateRegionSettings_resourceTypeOptInPreference,

    -- * Destructuring the Response
    UpdateRegionSettingsResponse (..),
    newUpdateRegionSettingsResponse,
  )
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:/ 'newUpdateRegionSettings' smart constructor.
data UpdateRegionSettings = UpdateRegionSettings'
  { -- | Updates the list of services along with the opt-in preferences for the
    -- Region.
    UpdateRegionSettings -> Maybe (HashMap Text Bool)
resourceTypeOptInPreference :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Bool)
  }
  deriving (UpdateRegionSettings -> UpdateRegionSettings -> Bool
(UpdateRegionSettings -> UpdateRegionSettings -> Bool)
-> (UpdateRegionSettings -> UpdateRegionSettings -> Bool)
-> Eq UpdateRegionSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRegionSettings -> UpdateRegionSettings -> Bool
$c/= :: UpdateRegionSettings -> UpdateRegionSettings -> Bool
== :: UpdateRegionSettings -> UpdateRegionSettings -> Bool
$c== :: UpdateRegionSettings -> UpdateRegionSettings -> Bool
Prelude.Eq, ReadPrec [UpdateRegionSettings]
ReadPrec UpdateRegionSettings
Int -> ReadS UpdateRegionSettings
ReadS [UpdateRegionSettings]
(Int -> ReadS UpdateRegionSettings)
-> ReadS [UpdateRegionSettings]
-> ReadPrec UpdateRegionSettings
-> ReadPrec [UpdateRegionSettings]
-> Read UpdateRegionSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRegionSettings]
$creadListPrec :: ReadPrec [UpdateRegionSettings]
readPrec :: ReadPrec UpdateRegionSettings
$creadPrec :: ReadPrec UpdateRegionSettings
readList :: ReadS [UpdateRegionSettings]
$creadList :: ReadS [UpdateRegionSettings]
readsPrec :: Int -> ReadS UpdateRegionSettings
$creadsPrec :: Int -> ReadS UpdateRegionSettings
Prelude.Read, Int -> UpdateRegionSettings -> ShowS
[UpdateRegionSettings] -> ShowS
UpdateRegionSettings -> String
(Int -> UpdateRegionSettings -> ShowS)
-> (UpdateRegionSettings -> String)
-> ([UpdateRegionSettings] -> ShowS)
-> Show UpdateRegionSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRegionSettings] -> ShowS
$cshowList :: [UpdateRegionSettings] -> ShowS
show :: UpdateRegionSettings -> String
$cshow :: UpdateRegionSettings -> String
showsPrec :: Int -> UpdateRegionSettings -> ShowS
$cshowsPrec :: Int -> UpdateRegionSettings -> ShowS
Prelude.Show, (forall x. UpdateRegionSettings -> Rep UpdateRegionSettings x)
-> (forall x. Rep UpdateRegionSettings x -> UpdateRegionSettings)
-> Generic UpdateRegionSettings
forall x. Rep UpdateRegionSettings x -> UpdateRegionSettings
forall x. UpdateRegionSettings -> Rep UpdateRegionSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRegionSettings x -> UpdateRegionSettings
$cfrom :: forall x. UpdateRegionSettings -> Rep UpdateRegionSettings x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRegionSettings' 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:
--
-- 'resourceTypeOptInPreference', 'updateRegionSettings_resourceTypeOptInPreference' - Updates the list of services along with the opt-in preferences for the
-- Region.
newUpdateRegionSettings ::
  UpdateRegionSettings
newUpdateRegionSettings :: UpdateRegionSettings
newUpdateRegionSettings =
  UpdateRegionSettings' :: Maybe (HashMap Text Bool) -> UpdateRegionSettings
UpdateRegionSettings'
    { $sel:resourceTypeOptInPreference:UpdateRegionSettings' :: Maybe (HashMap Text Bool)
resourceTypeOptInPreference =
        Maybe (HashMap Text Bool)
forall a. Maybe a
Prelude.Nothing
    }

-- | Updates the list of services along with the opt-in preferences for the
-- Region.
updateRegionSettings_resourceTypeOptInPreference :: Lens.Lens' UpdateRegionSettings (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Bool))
updateRegionSettings_resourceTypeOptInPreference :: (Maybe (HashMap Text Bool) -> f (Maybe (HashMap Text Bool)))
-> UpdateRegionSettings -> f UpdateRegionSettings
updateRegionSettings_resourceTypeOptInPreference = (UpdateRegionSettings -> Maybe (HashMap Text Bool))
-> (UpdateRegionSettings
    -> Maybe (HashMap Text Bool) -> UpdateRegionSettings)
-> Lens
     UpdateRegionSettings
     UpdateRegionSettings
     (Maybe (HashMap Text Bool))
     (Maybe (HashMap Text Bool))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRegionSettings' {Maybe (HashMap Text Bool)
resourceTypeOptInPreference :: Maybe (HashMap Text Bool)
$sel:resourceTypeOptInPreference:UpdateRegionSettings' :: UpdateRegionSettings -> Maybe (HashMap Text Bool)
resourceTypeOptInPreference} -> Maybe (HashMap Text Bool)
resourceTypeOptInPreference) (\s :: UpdateRegionSettings
s@UpdateRegionSettings' {} Maybe (HashMap Text Bool)
a -> UpdateRegionSettings
s {$sel:resourceTypeOptInPreference:UpdateRegionSettings' :: Maybe (HashMap Text Bool)
resourceTypeOptInPreference = Maybe (HashMap Text Bool)
a} :: UpdateRegionSettings) ((Maybe (HashMap Text Bool) -> f (Maybe (HashMap Text Bool)))
 -> UpdateRegionSettings -> f UpdateRegionSettings)
-> ((Maybe (HashMap Text Bool) -> f (Maybe (HashMap Text Bool)))
    -> Maybe (HashMap Text Bool) -> f (Maybe (HashMap Text Bool)))
-> (Maybe (HashMap Text Bool) -> f (Maybe (HashMap Text Bool)))
-> UpdateRegionSettings
-> f UpdateRegionSettings
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Bool)
  (HashMap Text Bool)
  (HashMap Text Bool)
  (HashMap Text Bool)
-> Iso
     (Maybe (HashMap Text Bool))
     (Maybe (HashMap Text Bool))
     (Maybe (HashMap Text Bool))
     (Maybe (HashMap Text Bool))
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 Bool)
  (HashMap Text Bool)
  (HashMap Text Bool)
  (HashMap Text Bool)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable UpdateRegionSettings

instance Prelude.NFData UpdateRegionSettings

instance Core.ToHeaders UpdateRegionSettings where
  toHeaders :: UpdateRegionSettings -> [Header]
toHeaders =
    [Header] -> UpdateRegionSettings -> [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 UpdateRegionSettings where
  toJSON :: UpdateRegionSettings -> Value
toJSON UpdateRegionSettings' {Maybe (HashMap Text Bool)
resourceTypeOptInPreference :: Maybe (HashMap Text Bool)
$sel:resourceTypeOptInPreference:UpdateRegionSettings' :: UpdateRegionSettings -> Maybe (HashMap Text Bool)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ResourceTypeOptInPreference" Text -> HashMap Text Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Bool -> Pair)
-> Maybe (HashMap Text Bool) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Bool)
resourceTypeOptInPreference
          ]
      )

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

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

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

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

instance Prelude.NFData UpdateRegionSettingsResponse