{-# 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-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)
--
-- 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.Lens as Lens
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 @SettingAttribute@ enum values.
    GetSettings -> SettingAttribute
attribute :: SettingAttribute
  }
  deriving (GetSettings -> GetSettings -> Bool
(GetSettings -> GetSettings -> Bool)
-> (GetSettings -> GetSettings -> Bool) -> Eq GetSettings
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]
(Int -> ReadS GetSettings)
-> ReadS [GetSettings]
-> ReadPrec GetSettings
-> ReadPrec [GetSettings]
-> Read 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
(Int -> GetSettings -> ShowS)
-> (GetSettings -> String)
-> ([GetSettings] -> ShowS)
-> Show GetSettings
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. GetSettings -> Rep GetSettings x)
-> (forall x. Rep GetSettings x -> GetSettings)
-> Generic GetSettings
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 @SettingAttribute@ enum values.
newGetSettings ::
  -- | 'attribute'
  SettingAttribute ->
  GetSettings
newGetSettings :: SettingAttribute -> GetSettings
newGetSettings SettingAttribute
pAttribute_ =
  GetSettings' :: SettingAttribute -> GetSettings
GetSettings' {$sel:attribute:GetSettings' :: SettingAttribute
attribute = SettingAttribute
pAttribute_}

-- | The list of @SettingAttribute@ enum values.
getSettings_attribute :: Lens.Lens' GetSettings SettingAttribute
getSettings_attribute :: (SettingAttribute -> f SettingAttribute)
-> GetSettings -> f GetSettings
getSettings_attribute = (GetSettings -> SettingAttribute)
-> (GetSettings -> SettingAttribute -> GetSettings)
-> Lens GetSettings GetSettings SettingAttribute SettingAttribute
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 :: GetSettings -> Request GetSettings
request = Service -> GetSettings -> Request GetSettings
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetSettings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetSettings)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetSettings))
-> Logger
-> Service
-> Proxy GetSettings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetSettings)))
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 Settings -> Int -> GetSettingsResponse
GetSettingsResponse'
            (Maybe Settings -> Int -> GetSettingsResponse)
-> Either String (Maybe Settings)
-> Either String (Int -> GetSettingsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe Settings)
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"settings")
            Either String (Int -> GetSettingsResponse)
-> Either String Int -> Either String GetSettingsResponse
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 GetSettings

instance Prelude.NFData GetSettings

instance Core.ToHeaders GetSettings where
  toHeaders :: GetSettings -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetSettings -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath GetSettings where
  toPath :: GetSettings -> ByteString
toPath GetSettings' {SettingAttribute
attribute :: SettingAttribute
$sel:attribute:GetSettings' :: GetSettings -> SettingAttribute
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/settings/", SettingAttribute -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS SettingAttribute
attribute]

instance Core.ToQuery GetSettings where
  toQuery :: GetSettings -> QueryString
toQuery = QueryString -> GetSettings -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetSettingsResponse -> GetSettingsResponse -> Bool)
-> (GetSettingsResponse -> GetSettingsResponse -> Bool)
-> Eq GetSettingsResponse
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]
(Int -> ReadS GetSettingsResponse)
-> ReadS [GetSettingsResponse]
-> ReadPrec GetSettingsResponse
-> ReadPrec [GetSettingsResponse]
-> Read 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
(Int -> GetSettingsResponse -> ShowS)
-> (GetSettingsResponse -> String)
-> ([GetSettingsResponse] -> ShowS)
-> Show GetSettingsResponse
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. GetSettingsResponse -> Rep GetSettingsResponse x)
-> (forall x. Rep GetSettingsResponse x -> GetSettingsResponse)
-> Generic GetSettingsResponse
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' :: Maybe Settings -> Int -> GetSettingsResponse
GetSettingsResponse'
    { $sel:settings:GetSettingsResponse' :: Maybe Settings
settings = Maybe 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 :: (Maybe Settings -> f (Maybe Settings))
-> GetSettingsResponse -> f GetSettingsResponse
getSettingsResponse_settings = (GetSettingsResponse -> Maybe Settings)
-> (GetSettingsResponse -> Maybe Settings -> GetSettingsResponse)
-> Lens
     GetSettingsResponse
     GetSettingsResponse
     (Maybe Settings)
     (Maybe 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 :: (Int -> f Int) -> GetSettingsResponse -> f GetSettingsResponse
getSettingsResponse_httpStatus = (GetSettingsResponse -> Int)
-> (GetSettingsResponse -> Int -> GetSettingsResponse)
-> Lens GetSettingsResponse GetSettingsResponse Int Int
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