{-# 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.SSM.UpdateServiceSetting
-- 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)
--
-- @ServiceSetting@ is an account-level setting for an Amazon Web Services
-- service. This setting defines how a user interacts with or uses a
-- service or a feature of a service. For example, if an Amazon Web
-- Services service charges money to the account based on feature or
-- service usage, then the Amazon Web Services service team might create a
-- default setting of \"false\". This means the user can\'t use this
-- feature unless they change the setting to \"true\" and intentionally opt
-- in for a paid feature.
--
-- Services map a @SettingId@ object to a setting value. Amazon Web
-- Services services teams define the default value for a @SettingId@. You
-- can\'t create a new @SettingId@, but you can overwrite the default value
-- if you have the @ssm:UpdateServiceSetting@ permission for the setting.
-- Use the GetServiceSetting API operation to view the current value. Or,
-- use the ResetServiceSetting to change the value back to the original
-- value defined by the Amazon Web Services service team.
--
-- Update the service setting for the account.
module Amazonka.SSM.UpdateServiceSetting
  ( -- * Creating a Request
    UpdateServiceSetting (..),
    newUpdateServiceSetting,

    -- * Request Lenses
    updateServiceSetting_settingId,
    updateServiceSetting_settingValue,

    -- * Destructuring the Response
    UpdateServiceSettingResponse (..),
    newUpdateServiceSettingResponse,

    -- * Response Lenses
    updateServiceSettingResponse_httpStatus,
  )
where

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
import Amazonka.SSM.Types

-- | The request body of the UpdateServiceSetting API operation.
--
-- /See:/ 'newUpdateServiceSetting' smart constructor.
data UpdateServiceSetting = UpdateServiceSetting'
  { -- | The Amazon Resource Name (ARN) of the service setting to reset. For
    -- example,
    -- @arn:aws:ssm:us-east-1:111122223333:servicesetting\/ssm\/parameter-store\/high-throughput-enabled@.
    -- The setting ID can be one of the following.
    --
    -- -   @\/ssm\/automation\/customer-script-log-destination@
    --
    -- -   @\/ssm\/automation\/customer-script-log-group-name@
    --
    -- -   @\/ssm\/documents\/console\/public-sharing-permission@
    --
    -- -   @\/ssm\/parameter-store\/default-parameter-tier@
    --
    -- -   @\/ssm\/parameter-store\/high-throughput-enabled@
    --
    -- -   @\/ssm\/managed-instance\/activation-tier@
    UpdateServiceSetting -> Text
settingId :: Prelude.Text,
    -- | The new value to specify for the service setting. The following list
    -- specifies the available values for each setting.
    --
    -- -   @\/ssm\/parameter-store\/default-parameter-tier@: @Standard@,
    --     @Advanced@, @Intelligent-Tiering@
    --
    -- -   @\/ssm\/parameter-store\/high-throughput-enabled@: @true@ or @false@
    --
    -- -   @\/ssm\/managed-instance\/activation-tier@: @true@ or @false@
    --
    -- -   @\/ssm\/automation\/customer-script-log-destination@: @CloudWatch@
    --
    -- -   @\/ssm\/automation\/customer-script-log-group-name@: the name of an
    --     Amazon CloudWatch Logs log group
    --
    -- -   @\/ssm\/documents\/console\/public-sharing-permission@: @Enable@ or
    --     @Disable@
    --
    -- -   @\/ssm\/managed-instance\/activation-tier@: @standard@ or @advanced@
    UpdateServiceSetting -> Text
settingValue :: Prelude.Text
  }
  deriving (UpdateServiceSetting -> UpdateServiceSetting -> Bool
(UpdateServiceSetting -> UpdateServiceSetting -> Bool)
-> (UpdateServiceSetting -> UpdateServiceSetting -> Bool)
-> Eq UpdateServiceSetting
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateServiceSetting -> UpdateServiceSetting -> Bool
$c/= :: UpdateServiceSetting -> UpdateServiceSetting -> Bool
== :: UpdateServiceSetting -> UpdateServiceSetting -> Bool
$c== :: UpdateServiceSetting -> UpdateServiceSetting -> Bool
Prelude.Eq, ReadPrec [UpdateServiceSetting]
ReadPrec UpdateServiceSetting
Int -> ReadS UpdateServiceSetting
ReadS [UpdateServiceSetting]
(Int -> ReadS UpdateServiceSetting)
-> ReadS [UpdateServiceSetting]
-> ReadPrec UpdateServiceSetting
-> ReadPrec [UpdateServiceSetting]
-> Read UpdateServiceSetting
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateServiceSetting]
$creadListPrec :: ReadPrec [UpdateServiceSetting]
readPrec :: ReadPrec UpdateServiceSetting
$creadPrec :: ReadPrec UpdateServiceSetting
readList :: ReadS [UpdateServiceSetting]
$creadList :: ReadS [UpdateServiceSetting]
readsPrec :: Int -> ReadS UpdateServiceSetting
$creadsPrec :: Int -> ReadS UpdateServiceSetting
Prelude.Read, Int -> UpdateServiceSetting -> ShowS
[UpdateServiceSetting] -> ShowS
UpdateServiceSetting -> String
(Int -> UpdateServiceSetting -> ShowS)
-> (UpdateServiceSetting -> String)
-> ([UpdateServiceSetting] -> ShowS)
-> Show UpdateServiceSetting
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateServiceSetting] -> ShowS
$cshowList :: [UpdateServiceSetting] -> ShowS
show :: UpdateServiceSetting -> String
$cshow :: UpdateServiceSetting -> String
showsPrec :: Int -> UpdateServiceSetting -> ShowS
$cshowsPrec :: Int -> UpdateServiceSetting -> ShowS
Prelude.Show, (forall x. UpdateServiceSetting -> Rep UpdateServiceSetting x)
-> (forall x. Rep UpdateServiceSetting x -> UpdateServiceSetting)
-> Generic UpdateServiceSetting
forall x. Rep UpdateServiceSetting x -> UpdateServiceSetting
forall x. UpdateServiceSetting -> Rep UpdateServiceSetting x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateServiceSetting x -> UpdateServiceSetting
$cfrom :: forall x. UpdateServiceSetting -> Rep UpdateServiceSetting x
Prelude.Generic)

-- |
-- Create a value of 'UpdateServiceSetting' 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:
--
-- 'settingId', 'updateServiceSetting_settingId' - The Amazon Resource Name (ARN) of the service setting to reset. For
-- example,
-- @arn:aws:ssm:us-east-1:111122223333:servicesetting\/ssm\/parameter-store\/high-throughput-enabled@.
-- The setting ID can be one of the following.
--
-- -   @\/ssm\/automation\/customer-script-log-destination@
--
-- -   @\/ssm\/automation\/customer-script-log-group-name@
--
-- -   @\/ssm\/documents\/console\/public-sharing-permission@
--
-- -   @\/ssm\/parameter-store\/default-parameter-tier@
--
-- -   @\/ssm\/parameter-store\/high-throughput-enabled@
--
-- -   @\/ssm\/managed-instance\/activation-tier@
--
-- 'settingValue', 'updateServiceSetting_settingValue' - The new value to specify for the service setting. The following list
-- specifies the available values for each setting.
--
-- -   @\/ssm\/parameter-store\/default-parameter-tier@: @Standard@,
--     @Advanced@, @Intelligent-Tiering@
--
-- -   @\/ssm\/parameter-store\/high-throughput-enabled@: @true@ or @false@
--
-- -   @\/ssm\/managed-instance\/activation-tier@: @true@ or @false@
--
-- -   @\/ssm\/automation\/customer-script-log-destination@: @CloudWatch@
--
-- -   @\/ssm\/automation\/customer-script-log-group-name@: the name of an
--     Amazon CloudWatch Logs log group
--
-- -   @\/ssm\/documents\/console\/public-sharing-permission@: @Enable@ or
--     @Disable@
--
-- -   @\/ssm\/managed-instance\/activation-tier@: @standard@ or @advanced@
newUpdateServiceSetting ::
  -- | 'settingId'
  Prelude.Text ->
  -- | 'settingValue'
  Prelude.Text ->
  UpdateServiceSetting
newUpdateServiceSetting :: Text -> Text -> UpdateServiceSetting
newUpdateServiceSetting Text
pSettingId_ Text
pSettingValue_ =
  UpdateServiceSetting' :: Text -> Text -> UpdateServiceSetting
UpdateServiceSetting'
    { $sel:settingId:UpdateServiceSetting' :: Text
settingId = Text
pSettingId_,
      $sel:settingValue:UpdateServiceSetting' :: Text
settingValue = Text
pSettingValue_
    }

-- | The Amazon Resource Name (ARN) of the service setting to reset. For
-- example,
-- @arn:aws:ssm:us-east-1:111122223333:servicesetting\/ssm\/parameter-store\/high-throughput-enabled@.
-- The setting ID can be one of the following.
--
-- -   @\/ssm\/automation\/customer-script-log-destination@
--
-- -   @\/ssm\/automation\/customer-script-log-group-name@
--
-- -   @\/ssm\/documents\/console\/public-sharing-permission@
--
-- -   @\/ssm\/parameter-store\/default-parameter-tier@
--
-- -   @\/ssm\/parameter-store\/high-throughput-enabled@
--
-- -   @\/ssm\/managed-instance\/activation-tier@
updateServiceSetting_settingId :: Lens.Lens' UpdateServiceSetting Prelude.Text
updateServiceSetting_settingId :: (Text -> f Text) -> UpdateServiceSetting -> f UpdateServiceSetting
updateServiceSetting_settingId = (UpdateServiceSetting -> Text)
-> (UpdateServiceSetting -> Text -> UpdateServiceSetting)
-> Lens UpdateServiceSetting UpdateServiceSetting Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateServiceSetting' {Text
settingId :: Text
$sel:settingId:UpdateServiceSetting' :: UpdateServiceSetting -> Text
settingId} -> Text
settingId) (\s :: UpdateServiceSetting
s@UpdateServiceSetting' {} Text
a -> UpdateServiceSetting
s {$sel:settingId:UpdateServiceSetting' :: Text
settingId = Text
a} :: UpdateServiceSetting)

-- | The new value to specify for the service setting. The following list
-- specifies the available values for each setting.
--
-- -   @\/ssm\/parameter-store\/default-parameter-tier@: @Standard@,
--     @Advanced@, @Intelligent-Tiering@
--
-- -   @\/ssm\/parameter-store\/high-throughput-enabled@: @true@ or @false@
--
-- -   @\/ssm\/managed-instance\/activation-tier@: @true@ or @false@
--
-- -   @\/ssm\/automation\/customer-script-log-destination@: @CloudWatch@
--
-- -   @\/ssm\/automation\/customer-script-log-group-name@: the name of an
--     Amazon CloudWatch Logs log group
--
-- -   @\/ssm\/documents\/console\/public-sharing-permission@: @Enable@ or
--     @Disable@
--
-- -   @\/ssm\/managed-instance\/activation-tier@: @standard@ or @advanced@
updateServiceSetting_settingValue :: Lens.Lens' UpdateServiceSetting Prelude.Text
updateServiceSetting_settingValue :: (Text -> f Text) -> UpdateServiceSetting -> f UpdateServiceSetting
updateServiceSetting_settingValue = (UpdateServiceSetting -> Text)
-> (UpdateServiceSetting -> Text -> UpdateServiceSetting)
-> Lens UpdateServiceSetting UpdateServiceSetting Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateServiceSetting' {Text
settingValue :: Text
$sel:settingValue:UpdateServiceSetting' :: UpdateServiceSetting -> Text
settingValue} -> Text
settingValue) (\s :: UpdateServiceSetting
s@UpdateServiceSetting' {} Text
a -> UpdateServiceSetting
s {$sel:settingValue:UpdateServiceSetting' :: Text
settingValue = Text
a} :: UpdateServiceSetting)

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

instance Prelude.NFData UpdateServiceSetting

instance Core.ToHeaders UpdateServiceSetting where
  toHeaders :: UpdateServiceSetting -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateServiceSetting -> 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
"AmazonSSM.UpdateServiceSetting" ::
                          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 UpdateServiceSetting where
  toJSON :: UpdateServiceSetting -> Value
toJSON UpdateServiceSetting' {Text
settingValue :: Text
settingId :: Text
$sel:settingValue:UpdateServiceSetting' :: UpdateServiceSetting -> Text
$sel:settingId:UpdateServiceSetting' :: UpdateServiceSetting -> 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
"SettingId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
settingId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SettingValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
settingValue)
          ]
      )

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

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

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

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

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

instance Prelude.NFData UpdateServiceSettingResponse