{-# 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.SNS.GetSMSAttributes
-- 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 sending SMS messages from your Amazon Web
-- Services account.
--
-- These settings are set with the @SetSMSAttributes@ action.
module Amazonka.SNS.GetSMSAttributes
  ( -- * Creating a Request
    GetSMSAttributes (..),
    newGetSMSAttributes,

    -- * Request Lenses
    getSMSAttributes_attributes,

    -- * Destructuring the Response
    GetSMSAttributesResponse (..),
    newGetSMSAttributesResponse,

    -- * Response Lenses
    getSMSAttributesResponse_attributes,
    getSMSAttributesResponse_httpStatus,
  )
where

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

-- | The input for the @GetSMSAttributes@ request.
--
-- /See:/ 'newGetSMSAttributes' smart constructor.
data GetSMSAttributes = GetSMSAttributes'
  { -- | A list of the individual attribute names, such as @MonthlySpendLimit@,
    -- for which you want values.
    --
    -- For all attribute names, see
    -- <https://docs.aws.amazon.com/sns/latest/api/API_SetSMSAttributes.html SetSMSAttributes>.
    --
    -- If you don\'t use this parameter, Amazon SNS returns all SMS attributes.
    GetSMSAttributes -> Maybe [Text]
attributes :: Prelude.Maybe [Prelude.Text]
  }
  deriving (GetSMSAttributes -> GetSMSAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSMSAttributes -> GetSMSAttributes -> Bool
$c/= :: GetSMSAttributes -> GetSMSAttributes -> Bool
== :: GetSMSAttributes -> GetSMSAttributes -> Bool
$c== :: GetSMSAttributes -> GetSMSAttributes -> Bool
Prelude.Eq, ReadPrec [GetSMSAttributes]
ReadPrec GetSMSAttributes
Int -> ReadS GetSMSAttributes
ReadS [GetSMSAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSMSAttributes]
$creadListPrec :: ReadPrec [GetSMSAttributes]
readPrec :: ReadPrec GetSMSAttributes
$creadPrec :: ReadPrec GetSMSAttributes
readList :: ReadS [GetSMSAttributes]
$creadList :: ReadS [GetSMSAttributes]
readsPrec :: Int -> ReadS GetSMSAttributes
$creadsPrec :: Int -> ReadS GetSMSAttributes
Prelude.Read, Int -> GetSMSAttributes -> ShowS
[GetSMSAttributes] -> ShowS
GetSMSAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSMSAttributes] -> ShowS
$cshowList :: [GetSMSAttributes] -> ShowS
show :: GetSMSAttributes -> String
$cshow :: GetSMSAttributes -> String
showsPrec :: Int -> GetSMSAttributes -> ShowS
$cshowsPrec :: Int -> GetSMSAttributes -> ShowS
Prelude.Show, forall x. Rep GetSMSAttributes x -> GetSMSAttributes
forall x. GetSMSAttributes -> Rep GetSMSAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSMSAttributes x -> GetSMSAttributes
$cfrom :: forall x. GetSMSAttributes -> Rep GetSMSAttributes x
Prelude.Generic)

-- |
-- Create a value of 'GetSMSAttributes' 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:
--
-- 'attributes', 'getSMSAttributes_attributes' - A list of the individual attribute names, such as @MonthlySpendLimit@,
-- for which you want values.
--
-- For all attribute names, see
-- <https://docs.aws.amazon.com/sns/latest/api/API_SetSMSAttributes.html SetSMSAttributes>.
--
-- If you don\'t use this parameter, Amazon SNS returns all SMS attributes.
newGetSMSAttributes ::
  GetSMSAttributes
newGetSMSAttributes :: GetSMSAttributes
newGetSMSAttributes =
  GetSMSAttributes' {$sel:attributes:GetSMSAttributes' :: Maybe [Text]
attributes = forall a. Maybe a
Prelude.Nothing}

-- | A list of the individual attribute names, such as @MonthlySpendLimit@,
-- for which you want values.
--
-- For all attribute names, see
-- <https://docs.aws.amazon.com/sns/latest/api/API_SetSMSAttributes.html SetSMSAttributes>.
--
-- If you don\'t use this parameter, Amazon SNS returns all SMS attributes.
getSMSAttributes_attributes :: Lens.Lens' GetSMSAttributes (Prelude.Maybe [Prelude.Text])
getSMSAttributes_attributes :: Lens' GetSMSAttributes (Maybe [Text])
getSMSAttributes_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSMSAttributes' {Maybe [Text]
attributes :: Maybe [Text]
$sel:attributes:GetSMSAttributes' :: GetSMSAttributes -> Maybe [Text]
attributes} -> Maybe [Text]
attributes) (\s :: GetSMSAttributes
s@GetSMSAttributes' {} Maybe [Text]
a -> GetSMSAttributes
s {$sel:attributes:GetSMSAttributes' :: Maybe [Text]
attributes = Maybe [Text]
a} :: GetSMSAttributes) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest GetSMSAttributes where
  type
    AWSResponse GetSMSAttributes =
      GetSMSAttributesResponse
  request :: (Service -> Service)
-> GetSMSAttributes -> Request GetSMSAttributes
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetSMSAttributes
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetSMSAttributes)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"GetSMSAttributesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe (HashMap Text Text) -> Int -> GetSMSAttributesResponse
GetSMSAttributesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                            forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"attributes"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall k v.
(Eq k, Hashable k, FromText k, FromXML v) =>
Text -> Text -> Text -> [Node] -> Either String (HashMap k v)
Data.parseXMLMap Text
"entry" Text
"key" Text
"value")
                        )
            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 GetSMSAttributes where
  hashWithSalt :: Int -> GetSMSAttributes -> Int
hashWithSalt Int
_salt GetSMSAttributes' {Maybe [Text]
attributes :: Maybe [Text]
$sel:attributes:GetSMSAttributes' :: GetSMSAttributes -> Maybe [Text]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
attributes

instance Prelude.NFData GetSMSAttributes where
  rnf :: GetSMSAttributes -> ()
rnf GetSMSAttributes' {Maybe [Text]
attributes :: Maybe [Text]
$sel:attributes:GetSMSAttributes' :: GetSMSAttributes -> Maybe [Text]
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
attributes

instance Data.ToHeaders GetSMSAttributes where
  toHeaders :: GetSMSAttributes -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery GetSMSAttributes where
  toQuery :: GetSMSAttributes -> QueryString
toQuery GetSMSAttributes' {Maybe [Text]
attributes :: Maybe [Text]
$sel:attributes:GetSMSAttributes' :: GetSMSAttributes -> Maybe [Text]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"GetSMSAttributes" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-03-31" :: Prelude.ByteString),
        ByteString
"attributes"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
attributes)
      ]

-- | The response from the @GetSMSAttributes@ request.
--
-- /See:/ 'newGetSMSAttributesResponse' smart constructor.
data GetSMSAttributesResponse = GetSMSAttributesResponse'
  { -- | The SMS attribute names and their values.
    GetSMSAttributesResponse -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The response's http status code.
    GetSMSAttributesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetSMSAttributesResponse -> GetSMSAttributesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSMSAttributesResponse -> GetSMSAttributesResponse -> Bool
$c/= :: GetSMSAttributesResponse -> GetSMSAttributesResponse -> Bool
== :: GetSMSAttributesResponse -> GetSMSAttributesResponse -> Bool
$c== :: GetSMSAttributesResponse -> GetSMSAttributesResponse -> Bool
Prelude.Eq, ReadPrec [GetSMSAttributesResponse]
ReadPrec GetSMSAttributesResponse
Int -> ReadS GetSMSAttributesResponse
ReadS [GetSMSAttributesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSMSAttributesResponse]
$creadListPrec :: ReadPrec [GetSMSAttributesResponse]
readPrec :: ReadPrec GetSMSAttributesResponse
$creadPrec :: ReadPrec GetSMSAttributesResponse
readList :: ReadS [GetSMSAttributesResponse]
$creadList :: ReadS [GetSMSAttributesResponse]
readsPrec :: Int -> ReadS GetSMSAttributesResponse
$creadsPrec :: Int -> ReadS GetSMSAttributesResponse
Prelude.Read, Int -> GetSMSAttributesResponse -> ShowS
[GetSMSAttributesResponse] -> ShowS
GetSMSAttributesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSMSAttributesResponse] -> ShowS
$cshowList :: [GetSMSAttributesResponse] -> ShowS
show :: GetSMSAttributesResponse -> String
$cshow :: GetSMSAttributesResponse -> String
showsPrec :: Int -> GetSMSAttributesResponse -> ShowS
$cshowsPrec :: Int -> GetSMSAttributesResponse -> ShowS
Prelude.Show, forall x.
Rep GetSMSAttributesResponse x -> GetSMSAttributesResponse
forall x.
GetSMSAttributesResponse -> Rep GetSMSAttributesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetSMSAttributesResponse x -> GetSMSAttributesResponse
$cfrom :: forall x.
GetSMSAttributesResponse -> Rep GetSMSAttributesResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetSMSAttributesResponse' 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:
--
-- 'attributes', 'getSMSAttributesResponse_attributes' - The SMS attribute names and their values.
--
-- 'httpStatus', 'getSMSAttributesResponse_httpStatus' - The response's http status code.
newGetSMSAttributesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetSMSAttributesResponse
newGetSMSAttributesResponse :: Int -> GetSMSAttributesResponse
newGetSMSAttributesResponse Int
pHttpStatus_ =
  GetSMSAttributesResponse'
    { $sel:attributes:GetSMSAttributesResponse' :: Maybe (HashMap Text Text)
attributes =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetSMSAttributesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The SMS attribute names and their values.
getSMSAttributesResponse_attributes :: Lens.Lens' GetSMSAttributesResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
getSMSAttributesResponse_attributes :: Lens' GetSMSAttributesResponse (Maybe (HashMap Text Text))
getSMSAttributesResponse_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSMSAttributesResponse' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:GetSMSAttributesResponse' :: GetSMSAttributesResponse -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: GetSMSAttributesResponse
s@GetSMSAttributesResponse' {} Maybe (HashMap Text Text)
a -> GetSMSAttributesResponse
s {$sel:attributes:GetSMSAttributesResponse' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: GetSMSAttributesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData GetSMSAttributesResponse where
  rnf :: GetSMSAttributesResponse -> ()
rnf GetSMSAttributesResponse' {Int
Maybe (HashMap Text Text)
httpStatus :: Int
attributes :: Maybe (HashMap Text Text)
$sel:httpStatus:GetSMSAttributesResponse' :: GetSMSAttributesResponse -> Int
$sel:attributes:GetSMSAttributesResponse' :: GetSMSAttributesResponse -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus