{-# 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.ServiceQuotas.GetServiceQuota
-- 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)
--
-- Retrieves the applied quota value for the specified quota. For some
-- quotas, only the default values are available. If the applied quota
-- value is not available for a quota, the quota is not retrieved.
module Amazonka.ServiceQuotas.GetServiceQuota
  ( -- * Creating a Request
    GetServiceQuota (..),
    newGetServiceQuota,

    -- * Request Lenses
    getServiceQuota_serviceCode,
    getServiceQuota_quotaCode,

    -- * Destructuring the Response
    GetServiceQuotaResponse (..),
    newGetServiceQuotaResponse,

    -- * Response Lenses
    getServiceQuotaResponse_quota,
    getServiceQuotaResponse_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.ServiceQuotas.Types

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

-- |
-- Create a value of 'GetServiceQuota' 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:
--
-- 'serviceCode', 'getServiceQuota_serviceCode' - The service identifier.
--
-- 'quotaCode', 'getServiceQuota_quotaCode' - The quota identifier.
newGetServiceQuota ::
  -- | 'serviceCode'
  Prelude.Text ->
  -- | 'quotaCode'
  Prelude.Text ->
  GetServiceQuota
newGetServiceQuota :: Text -> Text -> GetServiceQuota
newGetServiceQuota Text
pServiceCode_ Text
pQuotaCode_ =
  GetServiceQuota' :: Text -> Text -> GetServiceQuota
GetServiceQuota'
    { $sel:serviceCode:GetServiceQuota' :: Text
serviceCode = Text
pServiceCode_,
      $sel:quotaCode:GetServiceQuota' :: Text
quotaCode = Text
pQuotaCode_
    }

-- | The service identifier.
getServiceQuota_serviceCode :: Lens.Lens' GetServiceQuota Prelude.Text
getServiceQuota_serviceCode :: (Text -> f Text) -> GetServiceQuota -> f GetServiceQuota
getServiceQuota_serviceCode = (GetServiceQuota -> Text)
-> (GetServiceQuota -> Text -> GetServiceQuota)
-> Lens GetServiceQuota GetServiceQuota Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceQuota' {Text
serviceCode :: Text
$sel:serviceCode:GetServiceQuota' :: GetServiceQuota -> Text
serviceCode} -> Text
serviceCode) (\s :: GetServiceQuota
s@GetServiceQuota' {} Text
a -> GetServiceQuota
s {$sel:serviceCode:GetServiceQuota' :: Text
serviceCode = Text
a} :: GetServiceQuota)

-- | The quota identifier.
getServiceQuota_quotaCode :: Lens.Lens' GetServiceQuota Prelude.Text
getServiceQuota_quotaCode :: (Text -> f Text) -> GetServiceQuota -> f GetServiceQuota
getServiceQuota_quotaCode = (GetServiceQuota -> Text)
-> (GetServiceQuota -> Text -> GetServiceQuota)
-> Lens GetServiceQuota GetServiceQuota Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceQuota' {Text
quotaCode :: Text
$sel:quotaCode:GetServiceQuota' :: GetServiceQuota -> Text
quotaCode} -> Text
quotaCode) (\s :: GetServiceQuota
s@GetServiceQuota' {} Text
a -> GetServiceQuota
s {$sel:quotaCode:GetServiceQuota' :: Text
quotaCode = Text
a} :: GetServiceQuota)

instance Core.AWSRequest GetServiceQuota where
  type
    AWSResponse GetServiceQuota =
      GetServiceQuotaResponse
  request :: GetServiceQuota -> Request GetServiceQuota
request = Service -> GetServiceQuota -> Request GetServiceQuota
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetServiceQuota
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetServiceQuota)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetServiceQuota))
-> Logger
-> Service
-> Proxy GetServiceQuota
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetServiceQuota)))
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 ServiceQuota -> Int -> GetServiceQuotaResponse
GetServiceQuotaResponse'
            (Maybe ServiceQuota -> Int -> GetServiceQuotaResponse)
-> Either String (Maybe ServiceQuota)
-> Either String (Int -> GetServiceQuotaResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ServiceQuota)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Quota")
            Either String (Int -> GetServiceQuotaResponse)
-> Either String Int -> Either String GetServiceQuotaResponse
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 GetServiceQuota

instance Prelude.NFData GetServiceQuota

instance Core.ToHeaders GetServiceQuota where
  toHeaders :: GetServiceQuota -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetServiceQuota -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"ServiceQuotasV20190624.GetServiceQuota" ::
                          Prelude.ByteString
                      ),
            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.ToJSON GetServiceQuota where
  toJSON :: GetServiceQuota -> Value
toJSON GetServiceQuota' {Text
quotaCode :: Text
serviceCode :: Text
$sel:quotaCode:GetServiceQuota' :: GetServiceQuota -> Text
$sel:serviceCode:GetServiceQuota' :: GetServiceQuota -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ServiceCode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
serviceCode),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"QuotaCode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
quotaCode)
          ]
      )

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

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

-- | /See:/ 'newGetServiceQuotaResponse' smart constructor.
data GetServiceQuotaResponse = GetServiceQuotaResponse'
  { -- | Information about the quota.
    GetServiceQuotaResponse -> Maybe ServiceQuota
quota :: Prelude.Maybe ServiceQuota,
    -- | The response's http status code.
    GetServiceQuotaResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetServiceQuotaResponse -> GetServiceQuotaResponse -> Bool
(GetServiceQuotaResponse -> GetServiceQuotaResponse -> Bool)
-> (GetServiceQuotaResponse -> GetServiceQuotaResponse -> Bool)
-> Eq GetServiceQuotaResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetServiceQuotaResponse -> GetServiceQuotaResponse -> Bool
$c/= :: GetServiceQuotaResponse -> GetServiceQuotaResponse -> Bool
== :: GetServiceQuotaResponse -> GetServiceQuotaResponse -> Bool
$c== :: GetServiceQuotaResponse -> GetServiceQuotaResponse -> Bool
Prelude.Eq, ReadPrec [GetServiceQuotaResponse]
ReadPrec GetServiceQuotaResponse
Int -> ReadS GetServiceQuotaResponse
ReadS [GetServiceQuotaResponse]
(Int -> ReadS GetServiceQuotaResponse)
-> ReadS [GetServiceQuotaResponse]
-> ReadPrec GetServiceQuotaResponse
-> ReadPrec [GetServiceQuotaResponse]
-> Read GetServiceQuotaResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetServiceQuotaResponse]
$creadListPrec :: ReadPrec [GetServiceQuotaResponse]
readPrec :: ReadPrec GetServiceQuotaResponse
$creadPrec :: ReadPrec GetServiceQuotaResponse
readList :: ReadS [GetServiceQuotaResponse]
$creadList :: ReadS [GetServiceQuotaResponse]
readsPrec :: Int -> ReadS GetServiceQuotaResponse
$creadsPrec :: Int -> ReadS GetServiceQuotaResponse
Prelude.Read, Int -> GetServiceQuotaResponse -> ShowS
[GetServiceQuotaResponse] -> ShowS
GetServiceQuotaResponse -> String
(Int -> GetServiceQuotaResponse -> ShowS)
-> (GetServiceQuotaResponse -> String)
-> ([GetServiceQuotaResponse] -> ShowS)
-> Show GetServiceQuotaResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetServiceQuotaResponse] -> ShowS
$cshowList :: [GetServiceQuotaResponse] -> ShowS
show :: GetServiceQuotaResponse -> String
$cshow :: GetServiceQuotaResponse -> String
showsPrec :: Int -> GetServiceQuotaResponse -> ShowS
$cshowsPrec :: Int -> GetServiceQuotaResponse -> ShowS
Prelude.Show, (forall x.
 GetServiceQuotaResponse -> Rep GetServiceQuotaResponse x)
-> (forall x.
    Rep GetServiceQuotaResponse x -> GetServiceQuotaResponse)
-> Generic GetServiceQuotaResponse
forall x. Rep GetServiceQuotaResponse x -> GetServiceQuotaResponse
forall x. GetServiceQuotaResponse -> Rep GetServiceQuotaResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetServiceQuotaResponse x -> GetServiceQuotaResponse
$cfrom :: forall x. GetServiceQuotaResponse -> Rep GetServiceQuotaResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetServiceQuotaResponse' 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:
--
-- 'quota', 'getServiceQuotaResponse_quota' - Information about the quota.
--
-- 'httpStatus', 'getServiceQuotaResponse_httpStatus' - The response's http status code.
newGetServiceQuotaResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetServiceQuotaResponse
newGetServiceQuotaResponse :: Int -> GetServiceQuotaResponse
newGetServiceQuotaResponse Int
pHttpStatus_ =
  GetServiceQuotaResponse' :: Maybe ServiceQuota -> Int -> GetServiceQuotaResponse
GetServiceQuotaResponse'
    { $sel:quota:GetServiceQuotaResponse' :: Maybe ServiceQuota
quota = Maybe ServiceQuota
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetServiceQuotaResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the quota.
getServiceQuotaResponse_quota :: Lens.Lens' GetServiceQuotaResponse (Prelude.Maybe ServiceQuota)
getServiceQuotaResponse_quota :: (Maybe ServiceQuota -> f (Maybe ServiceQuota))
-> GetServiceQuotaResponse -> f GetServiceQuotaResponse
getServiceQuotaResponse_quota = (GetServiceQuotaResponse -> Maybe ServiceQuota)
-> (GetServiceQuotaResponse
    -> Maybe ServiceQuota -> GetServiceQuotaResponse)
-> Lens
     GetServiceQuotaResponse
     GetServiceQuotaResponse
     (Maybe ServiceQuota)
     (Maybe ServiceQuota)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceQuotaResponse' {Maybe ServiceQuota
quota :: Maybe ServiceQuota
$sel:quota:GetServiceQuotaResponse' :: GetServiceQuotaResponse -> Maybe ServiceQuota
quota} -> Maybe ServiceQuota
quota) (\s :: GetServiceQuotaResponse
s@GetServiceQuotaResponse' {} Maybe ServiceQuota
a -> GetServiceQuotaResponse
s {$sel:quota:GetServiceQuotaResponse' :: Maybe ServiceQuota
quota = Maybe ServiceQuota
a} :: GetServiceQuotaResponse)

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

instance Prelude.NFData GetServiceQuotaResponse