{-# 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.AuditManager.GetSettings
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the settings for the specified Amazon Web Services account.
module Amazonka.AuditManager.GetSettings
  ( -- * Creating a Request
    GetSettings (..),
    newGetSettings,

    -- * Request Lenses
    getSettings_attribute,

    -- * Destructuring the Response
    GetSettingsResponse (..),
    newGetSettingsResponse,

    -- * Response Lenses
    getSettingsResponse_settings,
    getSettingsResponse_httpStatus,
  )
where

import Amazonka.AuditManager.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:/ 'newGetSettings' smart constructor.
data GetSettings = GetSettings'
  { -- | The list of setting attribute enum values.
    GetSettings -> SettingAttribute
attribute :: SettingAttribute
  }
  deriving (GetSettings -> GetSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSettings -> GetSettings -> Bool
$c/= :: GetSettings -> GetSettings -> Bool
== :: GetSettings -> GetSettings -> Bool
$c== :: GetSettings -> GetSettings -> Bool
Prelude.Eq, ReadPrec [GetSettings]
ReadPrec GetSettings
Int -> ReadS GetSettings
ReadS [GetSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSettings]
$creadListPrec :: ReadPrec [GetSettings]
readPrec :: ReadPrec GetSettings
$creadPrec :: ReadPrec GetSettings
readList :: ReadS [GetSettings]
$creadList :: ReadS [GetSettings]
readsPrec :: Int -> ReadS GetSettings
$creadsPrec :: Int -> ReadS GetSettings
Prelude.Read, Int -> GetSettings -> ShowS
[GetSettings] -> ShowS
GetSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSettings] -> ShowS
$cshowList :: [GetSettings] -> ShowS
show :: GetSettings -> String
$cshow :: GetSettings -> String
showsPrec :: Int -> GetSettings -> ShowS
$cshowsPrec :: Int -> GetSettings -> ShowS
Prelude.Show, forall x. Rep GetSettings x -> GetSettings
forall x. GetSettings -> Rep GetSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSettings x -> GetSettings
$cfrom :: forall x. GetSettings -> Rep GetSettings x
Prelude.Generic)

-- |
-- Create a value of 'GetSettings' 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:
--
-- 'attribute', 'getSettings_attribute' - The list of setting attribute enum values.
newGetSettings ::
  -- | 'attribute'
  SettingAttribute ->
  GetSettings
newGetSettings :: SettingAttribute -> GetSettings
newGetSettings SettingAttribute
pAttribute_ =
  GetSettings' {$sel:attribute:GetSettings' :: SettingAttribute
attribute = SettingAttribute
pAttribute_}

-- | The list of setting attribute enum values.
getSettings_attribute :: Lens.Lens' GetSettings SettingAttribute
getSettings_attribute :: Lens' GetSettings SettingAttribute
getSettings_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSettings' {SettingAttribute
attribute :: SettingAttribute
$sel:attribute:GetSettings' :: GetSettings -> SettingAttribute
attribute} -> SettingAttribute
attribute) (\s :: GetSettings
s@GetSettings' {} SettingAttribute
a -> GetSettings
s {$sel:attribute:GetSettings' :: SettingAttribute
attribute = SettingAttribute
a} :: GetSettings)

instance Core.AWSRequest GetSettings where
  type AWSResponse GetSettings = GetSettingsResponse
  request :: (Service -> Service) -> GetSettings -> Request GetSettings
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetSettings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetSettings)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Settings -> Int -> GetSettingsResponse
GetSettingsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"settings")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetSettings where
  hashWithSalt :: Int -> GetSettings -> Int
hashWithSalt Int
_salt GetSettings' {SettingAttribute
attribute :: SettingAttribute
$sel:attribute:GetSettings' :: GetSettings -> SettingAttribute
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SettingAttribute
attribute

instance Prelude.NFData GetSettings where
  rnf :: GetSettings -> ()
rnf GetSettings' {SettingAttribute
attribute :: SettingAttribute
$sel:attribute:GetSettings' :: GetSettings -> SettingAttribute
..} = forall a. NFData a => a -> ()
Prelude.rnf SettingAttribute
attribute

instance Data.ToHeaders GetSettings where
  toHeaders :: GetSettings -> ResponseHeaders
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 -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath GetSettings where
  toPath :: GetSettings -> ByteString
toPath GetSettings' {SettingAttribute
attribute :: SettingAttribute
$sel:attribute:GetSettings' :: GetSettings -> SettingAttribute
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/settings/", forall a. ToByteString a => a -> ByteString
Data.toBS SettingAttribute
attribute]

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

-- | /See:/ 'newGetSettingsResponse' smart constructor.
data GetSettingsResponse = GetSettingsResponse'
  { -- | The settings object that holds all supported Audit Manager settings.
    GetSettingsResponse -> Maybe Settings
settings :: Prelude.Maybe Settings,
    -- | The response's http status code.
    GetSettingsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetSettingsResponse -> GetSettingsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSettingsResponse -> GetSettingsResponse -> Bool
$c/= :: GetSettingsResponse -> GetSettingsResponse -> Bool
== :: GetSettingsResponse -> GetSettingsResponse -> Bool
$c== :: GetSettingsResponse -> GetSettingsResponse -> Bool
Prelude.Eq, ReadPrec [GetSettingsResponse]
ReadPrec GetSettingsResponse
Int -> ReadS GetSettingsResponse
ReadS [GetSettingsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSettingsResponse]
$creadListPrec :: ReadPrec [GetSettingsResponse]
readPrec :: ReadPrec GetSettingsResponse
$creadPrec :: ReadPrec GetSettingsResponse
readList :: ReadS [GetSettingsResponse]
$creadList :: ReadS [GetSettingsResponse]
readsPrec :: Int -> ReadS GetSettingsResponse
$creadsPrec :: Int -> ReadS GetSettingsResponse
Prelude.Read, Int -> GetSettingsResponse -> ShowS
[GetSettingsResponse] -> ShowS
GetSettingsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSettingsResponse] -> ShowS
$cshowList :: [GetSettingsResponse] -> ShowS
show :: GetSettingsResponse -> String
$cshow :: GetSettingsResponse -> String
showsPrec :: Int -> GetSettingsResponse -> ShowS
$cshowsPrec :: Int -> GetSettingsResponse -> ShowS
Prelude.Show, forall x. Rep GetSettingsResponse x -> GetSettingsResponse
forall x. GetSettingsResponse -> Rep GetSettingsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSettingsResponse x -> GetSettingsResponse
$cfrom :: forall x. GetSettingsResponse -> Rep GetSettingsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetSettingsResponse' 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:
--
-- 'settings', 'getSettingsResponse_settings' - The settings object that holds all supported Audit Manager settings.
--
-- 'httpStatus', 'getSettingsResponse_httpStatus' - The response's http status code.
newGetSettingsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetSettingsResponse
newGetSettingsResponse :: Int -> GetSettingsResponse
newGetSettingsResponse Int
pHttpStatus_ =
  GetSettingsResponse'
    { $sel:settings:GetSettingsResponse' :: Maybe Settings
settings = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetSettingsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The settings object that holds all supported Audit Manager settings.
getSettingsResponse_settings :: Lens.Lens' GetSettingsResponse (Prelude.Maybe Settings)
getSettingsResponse_settings :: Lens' GetSettingsResponse (Maybe Settings)
getSettingsResponse_settings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSettingsResponse' {Maybe Settings
settings :: Maybe Settings
$sel:settings:GetSettingsResponse' :: GetSettingsResponse -> Maybe Settings
settings} -> Maybe Settings
settings) (\s :: GetSettingsResponse
s@GetSettingsResponse' {} Maybe Settings
a -> GetSettingsResponse
s {$sel:settings:GetSettingsResponse' :: Maybe Settings
settings = Maybe Settings
a} :: GetSettingsResponse)

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

instance Prelude.NFData GetSettingsResponse where
  rnf :: GetSettingsResponse -> ()
rnf GetSettingsResponse' {Int
Maybe Settings
httpStatus :: Int
settings :: Maybe Settings
$sel:httpStatus:GetSettingsResponse' :: GetSettingsResponse -> Int
$sel:settings:GetSettingsResponse' :: GetSettingsResponse -> Maybe Settings
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Settings
settings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus