{-# 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-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 sending SMS messages from your 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.Lens as Lens
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
(GetSMSAttributes -> GetSMSAttributes -> Bool)
-> (GetSMSAttributes -> GetSMSAttributes -> Bool)
-> Eq GetSMSAttributes
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]
(Int -> ReadS GetSMSAttributes)
-> ReadS [GetSMSAttributes]
-> ReadPrec GetSMSAttributes
-> ReadPrec [GetSMSAttributes]
-> Read 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
(Int -> GetSMSAttributes -> ShowS)
-> (GetSMSAttributes -> String)
-> ([GetSMSAttributes] -> ShowS)
-> Show GetSMSAttributes
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. GetSMSAttributes -> Rep GetSMSAttributes x)
-> (forall x. Rep GetSMSAttributes x -> GetSMSAttributes)
-> Generic GetSMSAttributes
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' :: Maybe [Text] -> GetSMSAttributes
GetSMSAttributes' {$sel:attributes:GetSMSAttributes' :: Maybe [Text]
attributes = Maybe [Text]
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 :: (Maybe [Text] -> f (Maybe [Text]))
-> GetSMSAttributes -> f GetSMSAttributes
getSMSAttributes_attributes = (GetSMSAttributes -> Maybe [Text])
-> (GetSMSAttributes -> Maybe [Text] -> GetSMSAttributes)
-> Lens
     GetSMSAttributes GetSMSAttributes (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> GetSMSAttributes -> f GetSMSAttributes)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> GetSMSAttributes
-> f GetSMSAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 :: GetSMSAttributes -> Request GetSMSAttributes
request = Service -> GetSMSAttributes -> Request GetSMSAttributes
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy GetSMSAttributes
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetSMSAttributes)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse GetSMSAttributes))
-> Logger
-> Service
-> Proxy GetSMSAttributes
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetSMSAttributes)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> 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'
            (Maybe (HashMap Text Text) -> Int -> GetSMSAttributesResponse)
-> Either String (Maybe (HashMap Text Text))
-> Either String (Int -> GetSMSAttributesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"attributes" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe (HashMap Text Text)))
-> Either String (Maybe (HashMap Text Text))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String (HashMap Text Text))
-> [Node] -> Either String (Maybe (HashMap Text Text))
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> Text -> Text -> [Node] -> Either String (HashMap Text Text)
forall k v.
(Eq k, Hashable k, FromText k, FromXML v) =>
Text -> Text -> Text -> [Node] -> Either String (HashMap k v)
Core.parseXMLMap Text
"entry" Text
"key" Text
"value")
                        )
            Either String (Int -> GetSMSAttributesResponse)
-> Either String Int -> Either String GetSMSAttributesResponse
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 GetSMSAttributes

instance Prelude.NFData GetSMSAttributes

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

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

instance Core.ToQuery GetSMSAttributes where
  toQuery :: GetSMSAttributes -> QueryString
toQuery GetSMSAttributes' {Maybe [Text]
attributes :: Maybe [Text]
$sel:attributes:GetSMSAttributes' :: GetSMSAttributes -> Maybe [Text]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"GetSMSAttributes" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-03-31" :: Prelude.ByteString),
        ByteString
"attributes"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
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
(GetSMSAttributesResponse -> GetSMSAttributesResponse -> Bool)
-> (GetSMSAttributesResponse -> GetSMSAttributesResponse -> Bool)
-> Eq GetSMSAttributesResponse
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]
(Int -> ReadS GetSMSAttributesResponse)
-> ReadS [GetSMSAttributesResponse]
-> ReadPrec GetSMSAttributesResponse
-> ReadPrec [GetSMSAttributesResponse]
-> Read 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
(Int -> GetSMSAttributesResponse -> ShowS)
-> (GetSMSAttributesResponse -> String)
-> ([GetSMSAttributesResponse] -> ShowS)
-> Show GetSMSAttributesResponse
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.
 GetSMSAttributesResponse -> Rep GetSMSAttributesResponse x)
-> (forall x.
    Rep GetSMSAttributesResponse x -> GetSMSAttributesResponse)
-> Generic GetSMSAttributesResponse
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' :: Maybe (HashMap Text Text) -> Int -> GetSMSAttributesResponse
GetSMSAttributesResponse'
    { $sel:attributes:GetSMSAttributesResponse' :: Maybe (HashMap Text Text)
attributes =
        Maybe (HashMap Text Text)
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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> GetSMSAttributesResponse -> f GetSMSAttributesResponse
getSMSAttributesResponse_attributes = (GetSMSAttributesResponse -> Maybe (HashMap Text Text))
-> (GetSMSAttributesResponse
    -> Maybe (HashMap Text Text) -> GetSMSAttributesResponse)
-> Lens
     GetSMSAttributesResponse
     GetSMSAttributesResponse
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> GetSMSAttributesResponse -> f GetSMSAttributesResponse)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> GetSMSAttributesResponse
-> f GetSMSAttributesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
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 :: (Int -> f Int)
-> GetSMSAttributesResponse -> f GetSMSAttributesResponse
getSMSAttributesResponse_httpStatus = (GetSMSAttributesResponse -> Int)
-> (GetSMSAttributesResponse -> Int -> GetSMSAttributesResponse)
-> Lens GetSMSAttributesResponse GetSMSAttributesResponse Int Int
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