{-# 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.SES.GetSendQuota
-- 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)
--
-- Provides the sending limits for the Amazon SES account.
--
-- You can execute this operation no more than once per second.
module Amazonka.SES.GetSendQuota
  ( -- * Creating a Request
    GetSendQuota (..),
    newGetSendQuota,

    -- * Destructuring the Response
    GetSendQuotaResponse (..),
    newGetSendQuotaResponse,

    -- * Response Lenses
    getSendQuotaResponse_maxSendRate,
    getSendQuotaResponse_sentLast24Hours,
    getSendQuotaResponse_max24HourSend,
    getSendQuotaResponse_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.SES.Types

-- | /See:/ 'newGetSendQuota' smart constructor.
data GetSendQuota = GetSendQuota'
  {
  }
  deriving (GetSendQuota -> GetSendQuota -> Bool
(GetSendQuota -> GetSendQuota -> Bool)
-> (GetSendQuota -> GetSendQuota -> Bool) -> Eq GetSendQuota
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSendQuota -> GetSendQuota -> Bool
$c/= :: GetSendQuota -> GetSendQuota -> Bool
== :: GetSendQuota -> GetSendQuota -> Bool
$c== :: GetSendQuota -> GetSendQuota -> Bool
Prelude.Eq, ReadPrec [GetSendQuota]
ReadPrec GetSendQuota
Int -> ReadS GetSendQuota
ReadS [GetSendQuota]
(Int -> ReadS GetSendQuota)
-> ReadS [GetSendQuota]
-> ReadPrec GetSendQuota
-> ReadPrec [GetSendQuota]
-> Read GetSendQuota
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSendQuota]
$creadListPrec :: ReadPrec [GetSendQuota]
readPrec :: ReadPrec GetSendQuota
$creadPrec :: ReadPrec GetSendQuota
readList :: ReadS [GetSendQuota]
$creadList :: ReadS [GetSendQuota]
readsPrec :: Int -> ReadS GetSendQuota
$creadsPrec :: Int -> ReadS GetSendQuota
Prelude.Read, Int -> GetSendQuota -> ShowS
[GetSendQuota] -> ShowS
GetSendQuota -> String
(Int -> GetSendQuota -> ShowS)
-> (GetSendQuota -> String)
-> ([GetSendQuota] -> ShowS)
-> Show GetSendQuota
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSendQuota] -> ShowS
$cshowList :: [GetSendQuota] -> ShowS
show :: GetSendQuota -> String
$cshow :: GetSendQuota -> String
showsPrec :: Int -> GetSendQuota -> ShowS
$cshowsPrec :: Int -> GetSendQuota -> ShowS
Prelude.Show, (forall x. GetSendQuota -> Rep GetSendQuota x)
-> (forall x. Rep GetSendQuota x -> GetSendQuota)
-> Generic GetSendQuota
forall x. Rep GetSendQuota x -> GetSendQuota
forall x. GetSendQuota -> Rep GetSendQuota x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSendQuota x -> GetSendQuota
$cfrom :: forall x. GetSendQuota -> Rep GetSendQuota x
Prelude.Generic)

-- |
-- Create a value of 'GetSendQuota' 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.
newGetSendQuota ::
  GetSendQuota
newGetSendQuota :: GetSendQuota
newGetSendQuota = GetSendQuota
GetSendQuota'

instance Core.AWSRequest GetSendQuota where
  type AWSResponse GetSendQuota = GetSendQuotaResponse
  request :: GetSendQuota -> Request GetSendQuota
request = Service -> GetSendQuota -> Request GetSendQuota
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy GetSendQuota
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetSendQuota)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse GetSendQuota))
-> Logger
-> Service
-> Proxy GetSendQuota
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetSendQuota)))
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
"GetSendQuotaResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Double
-> Maybe Double -> Maybe Double -> Int -> GetSendQuotaResponse
GetSendQuotaResponse'
            (Maybe Double
 -> Maybe Double -> Maybe Double -> Int -> GetSendQuotaResponse)
-> Either String (Maybe Double)
-> Either
     String
     (Maybe Double -> Maybe Double -> Int -> GetSendQuotaResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MaxSendRate")
            Either
  String
  (Maybe Double -> Maybe Double -> Int -> GetSendQuotaResponse)
-> Either String (Maybe Double)
-> Either String (Maybe Double -> Int -> GetSendQuotaResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SentLast24Hours")
            Either String (Maybe Double -> Int -> GetSendQuotaResponse)
-> Either String (Maybe Double)
-> Either String (Int -> GetSendQuotaResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Max24HourSend")
            Either String (Int -> GetSendQuotaResponse)
-> Either String Int -> Either String GetSendQuotaResponse
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 GetSendQuota

instance Prelude.NFData GetSendQuota

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

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

instance Core.ToQuery GetSendQuota where
  toQuery :: GetSendQuota -> QueryString
toQuery =
    QueryString -> GetSendQuota -> QueryString
forall a b. a -> b -> a
Prelude.const
      ( [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ ByteString
"Action"
              ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"GetSendQuota" :: Prelude.ByteString),
            ByteString
"Version"
              ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-12-01" :: Prelude.ByteString)
          ]
      )

-- | Represents your Amazon SES daily sending quota, maximum send rate, and
-- the number of emails you have sent in the last 24 hours.
--
-- /See:/ 'newGetSendQuotaResponse' smart constructor.
data GetSendQuotaResponse = GetSendQuotaResponse'
  { -- | The maximum number of emails that Amazon SES can accept from the user\'s
    -- account per second.
    --
    -- The rate at which Amazon SES accepts the user\'s messages might be less
    -- than the maximum send rate.
    GetSendQuotaResponse -> Maybe Double
maxSendRate :: Prelude.Maybe Prelude.Double,
    -- | The number of emails sent during the previous 24 hours.
    GetSendQuotaResponse -> Maybe Double
sentLast24Hours :: Prelude.Maybe Prelude.Double,
    -- | The maximum number of emails the user is allowed to send in a 24-hour
    -- interval. A value of -1 signifies an unlimited quota.
    GetSendQuotaResponse -> Maybe Double
max24HourSend :: Prelude.Maybe Prelude.Double,
    -- | The response's http status code.
    GetSendQuotaResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetSendQuotaResponse -> GetSendQuotaResponse -> Bool
(GetSendQuotaResponse -> GetSendQuotaResponse -> Bool)
-> (GetSendQuotaResponse -> GetSendQuotaResponse -> Bool)
-> Eq GetSendQuotaResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSendQuotaResponse -> GetSendQuotaResponse -> Bool
$c/= :: GetSendQuotaResponse -> GetSendQuotaResponse -> Bool
== :: GetSendQuotaResponse -> GetSendQuotaResponse -> Bool
$c== :: GetSendQuotaResponse -> GetSendQuotaResponse -> Bool
Prelude.Eq, ReadPrec [GetSendQuotaResponse]
ReadPrec GetSendQuotaResponse
Int -> ReadS GetSendQuotaResponse
ReadS [GetSendQuotaResponse]
(Int -> ReadS GetSendQuotaResponse)
-> ReadS [GetSendQuotaResponse]
-> ReadPrec GetSendQuotaResponse
-> ReadPrec [GetSendQuotaResponse]
-> Read GetSendQuotaResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSendQuotaResponse]
$creadListPrec :: ReadPrec [GetSendQuotaResponse]
readPrec :: ReadPrec GetSendQuotaResponse
$creadPrec :: ReadPrec GetSendQuotaResponse
readList :: ReadS [GetSendQuotaResponse]
$creadList :: ReadS [GetSendQuotaResponse]
readsPrec :: Int -> ReadS GetSendQuotaResponse
$creadsPrec :: Int -> ReadS GetSendQuotaResponse
Prelude.Read, Int -> GetSendQuotaResponse -> ShowS
[GetSendQuotaResponse] -> ShowS
GetSendQuotaResponse -> String
(Int -> GetSendQuotaResponse -> ShowS)
-> (GetSendQuotaResponse -> String)
-> ([GetSendQuotaResponse] -> ShowS)
-> Show GetSendQuotaResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSendQuotaResponse] -> ShowS
$cshowList :: [GetSendQuotaResponse] -> ShowS
show :: GetSendQuotaResponse -> String
$cshow :: GetSendQuotaResponse -> String
showsPrec :: Int -> GetSendQuotaResponse -> ShowS
$cshowsPrec :: Int -> GetSendQuotaResponse -> ShowS
Prelude.Show, (forall x. GetSendQuotaResponse -> Rep GetSendQuotaResponse x)
-> (forall x. Rep GetSendQuotaResponse x -> GetSendQuotaResponse)
-> Generic GetSendQuotaResponse
forall x. Rep GetSendQuotaResponse x -> GetSendQuotaResponse
forall x. GetSendQuotaResponse -> Rep GetSendQuotaResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSendQuotaResponse x -> GetSendQuotaResponse
$cfrom :: forall x. GetSendQuotaResponse -> Rep GetSendQuotaResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetSendQuotaResponse' 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:
--
-- 'maxSendRate', 'getSendQuotaResponse_maxSendRate' - The maximum number of emails that Amazon SES can accept from the user\'s
-- account per second.
--
-- The rate at which Amazon SES accepts the user\'s messages might be less
-- than the maximum send rate.
--
-- 'sentLast24Hours', 'getSendQuotaResponse_sentLast24Hours' - The number of emails sent during the previous 24 hours.
--
-- 'max24HourSend', 'getSendQuotaResponse_max24HourSend' - The maximum number of emails the user is allowed to send in a 24-hour
-- interval. A value of -1 signifies an unlimited quota.
--
-- 'httpStatus', 'getSendQuotaResponse_httpStatus' - The response's http status code.
newGetSendQuotaResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetSendQuotaResponse
newGetSendQuotaResponse :: Int -> GetSendQuotaResponse
newGetSendQuotaResponse Int
pHttpStatus_ =
  GetSendQuotaResponse' :: Maybe Double
-> Maybe Double -> Maybe Double -> Int -> GetSendQuotaResponse
GetSendQuotaResponse'
    { $sel:maxSendRate:GetSendQuotaResponse' :: Maybe Double
maxSendRate =
        Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:sentLast24Hours:GetSendQuotaResponse' :: Maybe Double
sentLast24Hours = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:max24HourSend:GetSendQuotaResponse' :: Maybe Double
max24HourSend = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetSendQuotaResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The maximum number of emails that Amazon SES can accept from the user\'s
-- account per second.
--
-- The rate at which Amazon SES accepts the user\'s messages might be less
-- than the maximum send rate.
getSendQuotaResponse_maxSendRate :: Lens.Lens' GetSendQuotaResponse (Prelude.Maybe Prelude.Double)
getSendQuotaResponse_maxSendRate :: (Maybe Double -> f (Maybe Double))
-> GetSendQuotaResponse -> f GetSendQuotaResponse
getSendQuotaResponse_maxSendRate = (GetSendQuotaResponse -> Maybe Double)
-> (GetSendQuotaResponse -> Maybe Double -> GetSendQuotaResponse)
-> Lens
     GetSendQuotaResponse
     GetSendQuotaResponse
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSendQuotaResponse' {Maybe Double
maxSendRate :: Maybe Double
$sel:maxSendRate:GetSendQuotaResponse' :: GetSendQuotaResponse -> Maybe Double
maxSendRate} -> Maybe Double
maxSendRate) (\s :: GetSendQuotaResponse
s@GetSendQuotaResponse' {} Maybe Double
a -> GetSendQuotaResponse
s {$sel:maxSendRate:GetSendQuotaResponse' :: Maybe Double
maxSendRate = Maybe Double
a} :: GetSendQuotaResponse)

-- | The number of emails sent during the previous 24 hours.
getSendQuotaResponse_sentLast24Hours :: Lens.Lens' GetSendQuotaResponse (Prelude.Maybe Prelude.Double)
getSendQuotaResponse_sentLast24Hours :: (Maybe Double -> f (Maybe Double))
-> GetSendQuotaResponse -> f GetSendQuotaResponse
getSendQuotaResponse_sentLast24Hours = (GetSendQuotaResponse -> Maybe Double)
-> (GetSendQuotaResponse -> Maybe Double -> GetSendQuotaResponse)
-> Lens
     GetSendQuotaResponse
     GetSendQuotaResponse
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSendQuotaResponse' {Maybe Double
sentLast24Hours :: Maybe Double
$sel:sentLast24Hours:GetSendQuotaResponse' :: GetSendQuotaResponse -> Maybe Double
sentLast24Hours} -> Maybe Double
sentLast24Hours) (\s :: GetSendQuotaResponse
s@GetSendQuotaResponse' {} Maybe Double
a -> GetSendQuotaResponse
s {$sel:sentLast24Hours:GetSendQuotaResponse' :: Maybe Double
sentLast24Hours = Maybe Double
a} :: GetSendQuotaResponse)

-- | The maximum number of emails the user is allowed to send in a 24-hour
-- interval. A value of -1 signifies an unlimited quota.
getSendQuotaResponse_max24HourSend :: Lens.Lens' GetSendQuotaResponse (Prelude.Maybe Prelude.Double)
getSendQuotaResponse_max24HourSend :: (Maybe Double -> f (Maybe Double))
-> GetSendQuotaResponse -> f GetSendQuotaResponse
getSendQuotaResponse_max24HourSend = (GetSendQuotaResponse -> Maybe Double)
-> (GetSendQuotaResponse -> Maybe Double -> GetSendQuotaResponse)
-> Lens
     GetSendQuotaResponse
     GetSendQuotaResponse
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSendQuotaResponse' {Maybe Double
max24HourSend :: Maybe Double
$sel:max24HourSend:GetSendQuotaResponse' :: GetSendQuotaResponse -> Maybe Double
max24HourSend} -> Maybe Double
max24HourSend) (\s :: GetSendQuotaResponse
s@GetSendQuotaResponse' {} Maybe Double
a -> GetSendQuotaResponse
s {$sel:max24HourSend:GetSendQuotaResponse' :: Maybe Double
max24HourSend = Maybe Double
a} :: GetSendQuotaResponse)

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

instance Prelude.NFData GetSendQuotaResponse