{-# 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.DirectoryService.GetSnapshotLimits
-- 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)
--
-- Obtains the manual snapshot limits for a directory.
module Amazonka.DirectoryService.GetSnapshotLimits
  ( -- * Creating a Request
    GetSnapshotLimits (..),
    newGetSnapshotLimits,

    -- * Request Lenses
    getSnapshotLimits_directoryId,

    -- * Destructuring the Response
    GetSnapshotLimitsResponse (..),
    newGetSnapshotLimitsResponse,

    -- * Response Lenses
    getSnapshotLimitsResponse_snapshotLimits,
    getSnapshotLimitsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DirectoryService.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Contains the inputs for the GetSnapshotLimits operation.
--
-- /See:/ 'newGetSnapshotLimits' smart constructor.
data GetSnapshotLimits = GetSnapshotLimits'
  { -- | Contains the identifier of the directory to obtain the limits for.
    GetSnapshotLimits -> Text
directoryId :: Prelude.Text
  }
  deriving (GetSnapshotLimits -> GetSnapshotLimits -> Bool
(GetSnapshotLimits -> GetSnapshotLimits -> Bool)
-> (GetSnapshotLimits -> GetSnapshotLimits -> Bool)
-> Eq GetSnapshotLimits
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSnapshotLimits -> GetSnapshotLimits -> Bool
$c/= :: GetSnapshotLimits -> GetSnapshotLimits -> Bool
== :: GetSnapshotLimits -> GetSnapshotLimits -> Bool
$c== :: GetSnapshotLimits -> GetSnapshotLimits -> Bool
Prelude.Eq, ReadPrec [GetSnapshotLimits]
ReadPrec GetSnapshotLimits
Int -> ReadS GetSnapshotLimits
ReadS [GetSnapshotLimits]
(Int -> ReadS GetSnapshotLimits)
-> ReadS [GetSnapshotLimits]
-> ReadPrec GetSnapshotLimits
-> ReadPrec [GetSnapshotLimits]
-> Read GetSnapshotLimits
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSnapshotLimits]
$creadListPrec :: ReadPrec [GetSnapshotLimits]
readPrec :: ReadPrec GetSnapshotLimits
$creadPrec :: ReadPrec GetSnapshotLimits
readList :: ReadS [GetSnapshotLimits]
$creadList :: ReadS [GetSnapshotLimits]
readsPrec :: Int -> ReadS GetSnapshotLimits
$creadsPrec :: Int -> ReadS GetSnapshotLimits
Prelude.Read, Int -> GetSnapshotLimits -> ShowS
[GetSnapshotLimits] -> ShowS
GetSnapshotLimits -> String
(Int -> GetSnapshotLimits -> ShowS)
-> (GetSnapshotLimits -> String)
-> ([GetSnapshotLimits] -> ShowS)
-> Show GetSnapshotLimits
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSnapshotLimits] -> ShowS
$cshowList :: [GetSnapshotLimits] -> ShowS
show :: GetSnapshotLimits -> String
$cshow :: GetSnapshotLimits -> String
showsPrec :: Int -> GetSnapshotLimits -> ShowS
$cshowsPrec :: Int -> GetSnapshotLimits -> ShowS
Prelude.Show, (forall x. GetSnapshotLimits -> Rep GetSnapshotLimits x)
-> (forall x. Rep GetSnapshotLimits x -> GetSnapshotLimits)
-> Generic GetSnapshotLimits
forall x. Rep GetSnapshotLimits x -> GetSnapshotLimits
forall x. GetSnapshotLimits -> Rep GetSnapshotLimits x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSnapshotLimits x -> GetSnapshotLimits
$cfrom :: forall x. GetSnapshotLimits -> Rep GetSnapshotLimits x
Prelude.Generic)

-- |
-- Create a value of 'GetSnapshotLimits' 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:
--
-- 'directoryId', 'getSnapshotLimits_directoryId' - Contains the identifier of the directory to obtain the limits for.
newGetSnapshotLimits ::
  -- | 'directoryId'
  Prelude.Text ->
  GetSnapshotLimits
newGetSnapshotLimits :: Text -> GetSnapshotLimits
newGetSnapshotLimits Text
pDirectoryId_ =
  GetSnapshotLimits' :: Text -> GetSnapshotLimits
GetSnapshotLimits' {$sel:directoryId:GetSnapshotLimits' :: Text
directoryId = Text
pDirectoryId_}

-- | Contains the identifier of the directory to obtain the limits for.
getSnapshotLimits_directoryId :: Lens.Lens' GetSnapshotLimits Prelude.Text
getSnapshotLimits_directoryId :: (Text -> f Text) -> GetSnapshotLimits -> f GetSnapshotLimits
getSnapshotLimits_directoryId = (GetSnapshotLimits -> Text)
-> (GetSnapshotLimits -> Text -> GetSnapshotLimits)
-> Lens GetSnapshotLimits GetSnapshotLimits Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSnapshotLimits' {Text
directoryId :: Text
$sel:directoryId:GetSnapshotLimits' :: GetSnapshotLimits -> Text
directoryId} -> Text
directoryId) (\s :: GetSnapshotLimits
s@GetSnapshotLimits' {} Text
a -> GetSnapshotLimits
s {$sel:directoryId:GetSnapshotLimits' :: Text
directoryId = Text
a} :: GetSnapshotLimits)

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

instance Prelude.NFData GetSnapshotLimits

instance Core.ToHeaders GetSnapshotLimits where
  toHeaders :: GetSnapshotLimits -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetSnapshotLimits -> 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
"DirectoryService_20150416.GetSnapshotLimits" ::
                          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 GetSnapshotLimits where
  toJSON :: GetSnapshotLimits -> Value
toJSON GetSnapshotLimits' {Text
directoryId :: Text
$sel:directoryId:GetSnapshotLimits' :: GetSnapshotLimits -> 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
"DirectoryId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
directoryId)]
      )

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

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

-- | Contains the results of the GetSnapshotLimits operation.
--
-- /See:/ 'newGetSnapshotLimitsResponse' smart constructor.
data GetSnapshotLimitsResponse = GetSnapshotLimitsResponse'
  { -- | A SnapshotLimits object that contains the manual snapshot limits for the
    -- specified directory.
    GetSnapshotLimitsResponse -> Maybe SnapshotLimits
snapshotLimits :: Prelude.Maybe SnapshotLimits,
    -- | The response's http status code.
    GetSnapshotLimitsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetSnapshotLimitsResponse -> GetSnapshotLimitsResponse -> Bool
(GetSnapshotLimitsResponse -> GetSnapshotLimitsResponse -> Bool)
-> (GetSnapshotLimitsResponse -> GetSnapshotLimitsResponse -> Bool)
-> Eq GetSnapshotLimitsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSnapshotLimitsResponse -> GetSnapshotLimitsResponse -> Bool
$c/= :: GetSnapshotLimitsResponse -> GetSnapshotLimitsResponse -> Bool
== :: GetSnapshotLimitsResponse -> GetSnapshotLimitsResponse -> Bool
$c== :: GetSnapshotLimitsResponse -> GetSnapshotLimitsResponse -> Bool
Prelude.Eq, ReadPrec [GetSnapshotLimitsResponse]
ReadPrec GetSnapshotLimitsResponse
Int -> ReadS GetSnapshotLimitsResponse
ReadS [GetSnapshotLimitsResponse]
(Int -> ReadS GetSnapshotLimitsResponse)
-> ReadS [GetSnapshotLimitsResponse]
-> ReadPrec GetSnapshotLimitsResponse
-> ReadPrec [GetSnapshotLimitsResponse]
-> Read GetSnapshotLimitsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSnapshotLimitsResponse]
$creadListPrec :: ReadPrec [GetSnapshotLimitsResponse]
readPrec :: ReadPrec GetSnapshotLimitsResponse
$creadPrec :: ReadPrec GetSnapshotLimitsResponse
readList :: ReadS [GetSnapshotLimitsResponse]
$creadList :: ReadS [GetSnapshotLimitsResponse]
readsPrec :: Int -> ReadS GetSnapshotLimitsResponse
$creadsPrec :: Int -> ReadS GetSnapshotLimitsResponse
Prelude.Read, Int -> GetSnapshotLimitsResponse -> ShowS
[GetSnapshotLimitsResponse] -> ShowS
GetSnapshotLimitsResponse -> String
(Int -> GetSnapshotLimitsResponse -> ShowS)
-> (GetSnapshotLimitsResponse -> String)
-> ([GetSnapshotLimitsResponse] -> ShowS)
-> Show GetSnapshotLimitsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSnapshotLimitsResponse] -> ShowS
$cshowList :: [GetSnapshotLimitsResponse] -> ShowS
show :: GetSnapshotLimitsResponse -> String
$cshow :: GetSnapshotLimitsResponse -> String
showsPrec :: Int -> GetSnapshotLimitsResponse -> ShowS
$cshowsPrec :: Int -> GetSnapshotLimitsResponse -> ShowS
Prelude.Show, (forall x.
 GetSnapshotLimitsResponse -> Rep GetSnapshotLimitsResponse x)
-> (forall x.
    Rep GetSnapshotLimitsResponse x -> GetSnapshotLimitsResponse)
-> Generic GetSnapshotLimitsResponse
forall x.
Rep GetSnapshotLimitsResponse x -> GetSnapshotLimitsResponse
forall x.
GetSnapshotLimitsResponse -> Rep GetSnapshotLimitsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetSnapshotLimitsResponse x -> GetSnapshotLimitsResponse
$cfrom :: forall x.
GetSnapshotLimitsResponse -> Rep GetSnapshotLimitsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetSnapshotLimitsResponse' 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:
--
-- 'snapshotLimits', 'getSnapshotLimitsResponse_snapshotLimits' - A SnapshotLimits object that contains the manual snapshot limits for the
-- specified directory.
--
-- 'httpStatus', 'getSnapshotLimitsResponse_httpStatus' - The response's http status code.
newGetSnapshotLimitsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetSnapshotLimitsResponse
newGetSnapshotLimitsResponse :: Int -> GetSnapshotLimitsResponse
newGetSnapshotLimitsResponse Int
pHttpStatus_ =
  GetSnapshotLimitsResponse' :: Maybe SnapshotLimits -> Int -> GetSnapshotLimitsResponse
GetSnapshotLimitsResponse'
    { $sel:snapshotLimits:GetSnapshotLimitsResponse' :: Maybe SnapshotLimits
snapshotLimits =
        Maybe SnapshotLimits
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetSnapshotLimitsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A SnapshotLimits object that contains the manual snapshot limits for the
-- specified directory.
getSnapshotLimitsResponse_snapshotLimits :: Lens.Lens' GetSnapshotLimitsResponse (Prelude.Maybe SnapshotLimits)
getSnapshotLimitsResponse_snapshotLimits :: (Maybe SnapshotLimits -> f (Maybe SnapshotLimits))
-> GetSnapshotLimitsResponse -> f GetSnapshotLimitsResponse
getSnapshotLimitsResponse_snapshotLimits = (GetSnapshotLimitsResponse -> Maybe SnapshotLimits)
-> (GetSnapshotLimitsResponse
    -> Maybe SnapshotLimits -> GetSnapshotLimitsResponse)
-> Lens
     GetSnapshotLimitsResponse
     GetSnapshotLimitsResponse
     (Maybe SnapshotLimits)
     (Maybe SnapshotLimits)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSnapshotLimitsResponse' {Maybe SnapshotLimits
snapshotLimits :: Maybe SnapshotLimits
$sel:snapshotLimits:GetSnapshotLimitsResponse' :: GetSnapshotLimitsResponse -> Maybe SnapshotLimits
snapshotLimits} -> Maybe SnapshotLimits
snapshotLimits) (\s :: GetSnapshotLimitsResponse
s@GetSnapshotLimitsResponse' {} Maybe SnapshotLimits
a -> GetSnapshotLimitsResponse
s {$sel:snapshotLimits:GetSnapshotLimitsResponse' :: Maybe SnapshotLimits
snapshotLimits = Maybe SnapshotLimits
a} :: GetSnapshotLimitsResponse)

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

instance Prelude.NFData GetSnapshotLimitsResponse