{-# 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.APIGateway.GetStages
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets information about one or more Stage resources.
module Amazonka.APIGateway.GetStages
  ( -- * Creating a Request
    GetStages (..),
    newGetStages,

    -- * Request Lenses
    getStages_deploymentId,
    getStages_restApiId,

    -- * Destructuring the Response
    GetStagesResponse (..),
    newGetStagesResponse,

    -- * Response Lenses
    getStagesResponse_item,
    getStagesResponse_httpStatus,
  )
where

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

-- | Requests API Gateway to get information about one or more Stage
-- resources.
--
-- /See:/ 'newGetStages' smart constructor.
data GetStages = GetStages'
  { -- | The stages\' deployment identifiers.
    GetStages -> Maybe Text
deploymentId :: Prelude.Maybe Prelude.Text,
    -- | The string identifier of the associated RestApi.
    GetStages -> Text
restApiId :: Prelude.Text
  }
  deriving (GetStages -> GetStages -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetStages -> GetStages -> Bool
$c/= :: GetStages -> GetStages -> Bool
== :: GetStages -> GetStages -> Bool
$c== :: GetStages -> GetStages -> Bool
Prelude.Eq, ReadPrec [GetStages]
ReadPrec GetStages
Int -> ReadS GetStages
ReadS [GetStages]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetStages]
$creadListPrec :: ReadPrec [GetStages]
readPrec :: ReadPrec GetStages
$creadPrec :: ReadPrec GetStages
readList :: ReadS [GetStages]
$creadList :: ReadS [GetStages]
readsPrec :: Int -> ReadS GetStages
$creadsPrec :: Int -> ReadS GetStages
Prelude.Read, Int -> GetStages -> ShowS
[GetStages] -> ShowS
GetStages -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetStages] -> ShowS
$cshowList :: [GetStages] -> ShowS
show :: GetStages -> String
$cshow :: GetStages -> String
showsPrec :: Int -> GetStages -> ShowS
$cshowsPrec :: Int -> GetStages -> ShowS
Prelude.Show, forall x. Rep GetStages x -> GetStages
forall x. GetStages -> Rep GetStages x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetStages x -> GetStages
$cfrom :: forall x. GetStages -> Rep GetStages x
Prelude.Generic)

-- |
-- Create a value of 'GetStages' 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:
--
-- 'deploymentId', 'getStages_deploymentId' - The stages\' deployment identifiers.
--
-- 'restApiId', 'getStages_restApiId' - The string identifier of the associated RestApi.
newGetStages ::
  -- | 'restApiId'
  Prelude.Text ->
  GetStages
newGetStages :: Text -> GetStages
newGetStages Text
pRestApiId_ =
  GetStages'
    { $sel:deploymentId:GetStages' :: Maybe Text
deploymentId = forall a. Maybe a
Prelude.Nothing,
      $sel:restApiId:GetStages' :: Text
restApiId = Text
pRestApiId_
    }

-- | The stages\' deployment identifiers.
getStages_deploymentId :: Lens.Lens' GetStages (Prelude.Maybe Prelude.Text)
getStages_deploymentId :: Lens' GetStages (Maybe Text)
getStages_deploymentId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStages' {Maybe Text
deploymentId :: Maybe Text
$sel:deploymentId:GetStages' :: GetStages -> Maybe Text
deploymentId} -> Maybe Text
deploymentId) (\s :: GetStages
s@GetStages' {} Maybe Text
a -> GetStages
s {$sel:deploymentId:GetStages' :: Maybe Text
deploymentId = Maybe Text
a} :: GetStages)

-- | The string identifier of the associated RestApi.
getStages_restApiId :: Lens.Lens' GetStages Prelude.Text
getStages_restApiId :: Lens' GetStages Text
getStages_restApiId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStages' {Text
restApiId :: Text
$sel:restApiId:GetStages' :: GetStages -> Text
restApiId} -> Text
restApiId) (\s :: GetStages
s@GetStages' {} Text
a -> GetStages
s {$sel:restApiId:GetStages' :: Text
restApiId = Text
a} :: GetStages)

instance Core.AWSRequest GetStages where
  type AWSResponse GetStages = GetStagesResponse
  request :: (Service -> Service) -> GetStages -> Request GetStages
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetStages
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetStages)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Stage] -> Int -> GetStagesResponse
GetStagesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"item" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 GetStages where
  hashWithSalt :: Int -> GetStages -> Int
hashWithSalt Int
_salt GetStages' {Maybe Text
Text
restApiId :: Text
deploymentId :: Maybe Text
$sel:restApiId:GetStages' :: GetStages -> Text
$sel:deploymentId:GetStages' :: GetStages -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
deploymentId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
restApiId

instance Prelude.NFData GetStages where
  rnf :: GetStages -> ()
rnf GetStages' {Maybe Text
Text
restApiId :: Text
deploymentId :: Maybe Text
$sel:restApiId:GetStages' :: GetStages -> Text
$sel:deploymentId:GetStages' :: GetStages -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
deploymentId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
restApiId

instance Data.ToHeaders GetStages where
  toHeaders :: GetStages -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Accept"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/json" :: Prelude.ByteString)
          ]
      )

instance Data.ToPath GetStages where
  toPath :: GetStages -> ByteString
toPath GetStages' {Maybe Text
Text
restApiId :: Text
deploymentId :: Maybe Text
$sel:restApiId:GetStages' :: GetStages -> Text
$sel:deploymentId:GetStages' :: GetStages -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/restapis/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
restApiId, ByteString
"/stages"]

instance Data.ToQuery GetStages where
  toQuery :: GetStages -> QueryString
toQuery GetStages' {Maybe Text
Text
restApiId :: Text
deploymentId :: Maybe Text
$sel:restApiId:GetStages' :: GetStages -> Text
$sel:deploymentId:GetStages' :: GetStages -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"deploymentId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
deploymentId]

-- | A list of Stage resources that are associated with the ApiKey resource.
--
-- /See:/ 'newGetStagesResponse' smart constructor.
data GetStagesResponse = GetStagesResponse'
  { -- | The current page of elements from this collection.
    GetStagesResponse -> Maybe [Stage]
item :: Prelude.Maybe [Stage],
    -- | The response's http status code.
    GetStagesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetStagesResponse -> GetStagesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetStagesResponse -> GetStagesResponse -> Bool
$c/= :: GetStagesResponse -> GetStagesResponse -> Bool
== :: GetStagesResponse -> GetStagesResponse -> Bool
$c== :: GetStagesResponse -> GetStagesResponse -> Bool
Prelude.Eq, ReadPrec [GetStagesResponse]
ReadPrec GetStagesResponse
Int -> ReadS GetStagesResponse
ReadS [GetStagesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetStagesResponse]
$creadListPrec :: ReadPrec [GetStagesResponse]
readPrec :: ReadPrec GetStagesResponse
$creadPrec :: ReadPrec GetStagesResponse
readList :: ReadS [GetStagesResponse]
$creadList :: ReadS [GetStagesResponse]
readsPrec :: Int -> ReadS GetStagesResponse
$creadsPrec :: Int -> ReadS GetStagesResponse
Prelude.Read, Int -> GetStagesResponse -> ShowS
[GetStagesResponse] -> ShowS
GetStagesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetStagesResponse] -> ShowS
$cshowList :: [GetStagesResponse] -> ShowS
show :: GetStagesResponse -> String
$cshow :: GetStagesResponse -> String
showsPrec :: Int -> GetStagesResponse -> ShowS
$cshowsPrec :: Int -> GetStagesResponse -> ShowS
Prelude.Show, forall x. Rep GetStagesResponse x -> GetStagesResponse
forall x. GetStagesResponse -> Rep GetStagesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetStagesResponse x -> GetStagesResponse
$cfrom :: forall x. GetStagesResponse -> Rep GetStagesResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetStagesResponse' 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:
--
-- 'item', 'getStagesResponse_item' - The current page of elements from this collection.
--
-- 'httpStatus', 'getStagesResponse_httpStatus' - The response's http status code.
newGetStagesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetStagesResponse
newGetStagesResponse :: Int -> GetStagesResponse
newGetStagesResponse Int
pHttpStatus_ =
  GetStagesResponse'
    { $sel:item:GetStagesResponse' :: Maybe [Stage]
item = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetStagesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The current page of elements from this collection.
getStagesResponse_item :: Lens.Lens' GetStagesResponse (Prelude.Maybe [Stage])
getStagesResponse_item :: Lens' GetStagesResponse (Maybe [Stage])
getStagesResponse_item = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStagesResponse' {Maybe [Stage]
item :: Maybe [Stage]
$sel:item:GetStagesResponse' :: GetStagesResponse -> Maybe [Stage]
item} -> Maybe [Stage]
item) (\s :: GetStagesResponse
s@GetStagesResponse' {} Maybe [Stage]
a -> GetStagesResponse
s {$sel:item:GetStagesResponse' :: Maybe [Stage]
item = Maybe [Stage]
a} :: GetStagesResponse) 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.
getStagesResponse_httpStatus :: Lens.Lens' GetStagesResponse Prelude.Int
getStagesResponse_httpStatus :: Lens' GetStagesResponse Int
getStagesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStagesResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetStagesResponse' :: GetStagesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetStagesResponse
s@GetStagesResponse' {} Int
a -> GetStagesResponse
s {$sel:httpStatus:GetStagesResponse' :: Int
httpStatus = Int
a} :: GetStagesResponse)

instance Prelude.NFData GetStagesResponse where
  rnf :: GetStagesResponse -> ()
rnf GetStagesResponse' {Int
Maybe [Stage]
httpStatus :: Int
item :: Maybe [Stage]
$sel:httpStatus:GetStagesResponse' :: GetStagesResponse -> Int
$sel:item:GetStagesResponse' :: GetStagesResponse -> Maybe [Stage]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Stage]
item
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus