{-# 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.GetServiceSetting
-- 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 UpdateServiceSetting API operation to change the default
-- setting. Or use the ResetServiceSetting to change the value back to the
-- original value defined by the Amazon Web Services service team.
--
-- Query the current service setting for the Amazon Web Services account.
module Amazonka.SSM.GetServiceSetting
  ( -- * Creating a Request
    GetServiceSetting (..),
    newGetServiceSetting,

    -- * Request Lenses
    getServiceSetting_settingId,

    -- * Destructuring the Response
    GetServiceSettingResponse (..),
    newGetServiceSettingResponse,

    -- * Response Lenses
    getServiceSettingResponse_serviceSetting,
    getServiceSettingResponse_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 GetServiceSetting API operation.
--
-- /See:/ 'newGetServiceSetting' smart constructor.
data GetServiceSetting = GetServiceSetting'
  { -- | The ID of the service setting to get. 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@
    GetServiceSetting -> Text
settingId :: Prelude.Text
  }
  deriving (GetServiceSetting -> GetServiceSetting -> Bool
(GetServiceSetting -> GetServiceSetting -> Bool)
-> (GetServiceSetting -> GetServiceSetting -> Bool)
-> Eq GetServiceSetting
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetServiceSetting -> GetServiceSetting -> Bool
$c/= :: GetServiceSetting -> GetServiceSetting -> Bool
== :: GetServiceSetting -> GetServiceSetting -> Bool
$c== :: GetServiceSetting -> GetServiceSetting -> Bool
Prelude.Eq, ReadPrec [GetServiceSetting]
ReadPrec GetServiceSetting
Int -> ReadS GetServiceSetting
ReadS [GetServiceSetting]
(Int -> ReadS GetServiceSetting)
-> ReadS [GetServiceSetting]
-> ReadPrec GetServiceSetting
-> ReadPrec [GetServiceSetting]
-> Read GetServiceSetting
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetServiceSetting]
$creadListPrec :: ReadPrec [GetServiceSetting]
readPrec :: ReadPrec GetServiceSetting
$creadPrec :: ReadPrec GetServiceSetting
readList :: ReadS [GetServiceSetting]
$creadList :: ReadS [GetServiceSetting]
readsPrec :: Int -> ReadS GetServiceSetting
$creadsPrec :: Int -> ReadS GetServiceSetting
Prelude.Read, Int -> GetServiceSetting -> ShowS
[GetServiceSetting] -> ShowS
GetServiceSetting -> String
(Int -> GetServiceSetting -> ShowS)
-> (GetServiceSetting -> String)
-> ([GetServiceSetting] -> ShowS)
-> Show GetServiceSetting
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetServiceSetting] -> ShowS
$cshowList :: [GetServiceSetting] -> ShowS
show :: GetServiceSetting -> String
$cshow :: GetServiceSetting -> String
showsPrec :: Int -> GetServiceSetting -> ShowS
$cshowsPrec :: Int -> GetServiceSetting -> ShowS
Prelude.Show, (forall x. GetServiceSetting -> Rep GetServiceSetting x)
-> (forall x. Rep GetServiceSetting x -> GetServiceSetting)
-> Generic GetServiceSetting
forall x. Rep GetServiceSetting x -> GetServiceSetting
forall x. GetServiceSetting -> Rep GetServiceSetting x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetServiceSetting x -> GetServiceSetting
$cfrom :: forall x. GetServiceSetting -> Rep GetServiceSetting x
Prelude.Generic)

-- |
-- Create a value of 'GetServiceSetting' 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', 'getServiceSetting_settingId' - The ID of the service setting to get. 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@
newGetServiceSetting ::
  -- | 'settingId'
  Prelude.Text ->
  GetServiceSetting
newGetServiceSetting :: Text -> GetServiceSetting
newGetServiceSetting Text
pSettingId_ =
  GetServiceSetting' :: Text -> GetServiceSetting
GetServiceSetting' {$sel:settingId:GetServiceSetting' :: Text
settingId = Text
pSettingId_}

-- | The ID of the service setting to get. 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@
getServiceSetting_settingId :: Lens.Lens' GetServiceSetting Prelude.Text
getServiceSetting_settingId :: (Text -> f Text) -> GetServiceSetting -> f GetServiceSetting
getServiceSetting_settingId = (GetServiceSetting -> Text)
-> (GetServiceSetting -> Text -> GetServiceSetting)
-> Lens GetServiceSetting GetServiceSetting Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceSetting' {Text
settingId :: Text
$sel:settingId:GetServiceSetting' :: GetServiceSetting -> Text
settingId} -> Text
settingId) (\s :: GetServiceSetting
s@GetServiceSetting' {} Text
a -> GetServiceSetting
s {$sel:settingId:GetServiceSetting' :: Text
settingId = Text
a} :: GetServiceSetting)

instance Core.AWSRequest GetServiceSetting where
  type
    AWSResponse GetServiceSetting =
      GetServiceSettingResponse
  request :: GetServiceSetting -> Request GetServiceSetting
request = Service -> GetServiceSetting -> Request GetServiceSetting
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetServiceSetting
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetServiceSetting)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetServiceSetting))
-> Logger
-> Service
-> Proxy GetServiceSetting
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetServiceSetting)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ServiceSetting -> Int -> GetServiceSettingResponse
GetServiceSettingResponse'
            (Maybe ServiceSetting -> Int -> GetServiceSettingResponse)
-> Either String (Maybe ServiceSetting)
-> Either String (Int -> GetServiceSettingResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ServiceSetting)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ServiceSetting")
            Either String (Int -> GetServiceSettingResponse)
-> Either String Int -> Either String GetServiceSettingResponse
forall (f :: * -> *) a b. Applicative f => 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 GetServiceSetting

instance Prelude.NFData GetServiceSetting

instance Core.ToHeaders GetServiceSetting where
  toHeaders :: GetServiceSetting -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetServiceSetting -> 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.GetServiceSetting" ::
                          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 GetServiceSetting where
  toJSON :: GetServiceSetting -> Value
toJSON GetServiceSetting' {Text
settingId :: Text
$sel:settingId:GetServiceSetting' :: GetServiceSetting -> 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)]
      )

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

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

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

-- |
-- Create a value of 'GetServiceSettingResponse' 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:
--
-- 'serviceSetting', 'getServiceSettingResponse_serviceSetting' - The query result of the current service setting.
--
-- 'httpStatus', 'getServiceSettingResponse_httpStatus' - The response's http status code.
newGetServiceSettingResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetServiceSettingResponse
newGetServiceSettingResponse :: Int -> GetServiceSettingResponse
newGetServiceSettingResponse Int
pHttpStatus_ =
  GetServiceSettingResponse' :: Maybe ServiceSetting -> Int -> GetServiceSettingResponse
GetServiceSettingResponse'
    { $sel:serviceSetting:GetServiceSettingResponse' :: Maybe ServiceSetting
serviceSetting =
        Maybe ServiceSetting
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetServiceSettingResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The query result of the current service setting.
getServiceSettingResponse_serviceSetting :: Lens.Lens' GetServiceSettingResponse (Prelude.Maybe ServiceSetting)
getServiceSettingResponse_serviceSetting :: (Maybe ServiceSetting -> f (Maybe ServiceSetting))
-> GetServiceSettingResponse -> f GetServiceSettingResponse
getServiceSettingResponse_serviceSetting = (GetServiceSettingResponse -> Maybe ServiceSetting)
-> (GetServiceSettingResponse
    -> Maybe ServiceSetting -> GetServiceSettingResponse)
-> Lens
     GetServiceSettingResponse
     GetServiceSettingResponse
     (Maybe ServiceSetting)
     (Maybe ServiceSetting)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceSettingResponse' {Maybe ServiceSetting
serviceSetting :: Maybe ServiceSetting
$sel:serviceSetting:GetServiceSettingResponse' :: GetServiceSettingResponse -> Maybe ServiceSetting
serviceSetting} -> Maybe ServiceSetting
serviceSetting) (\s :: GetServiceSettingResponse
s@GetServiceSettingResponse' {} Maybe ServiceSetting
a -> GetServiceSettingResponse
s {$sel:serviceSetting:GetServiceSettingResponse' :: Maybe ServiceSetting
serviceSetting = Maybe ServiceSetting
a} :: GetServiceSettingResponse)

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

instance Prelude.NFData GetServiceSettingResponse