{-# 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.ResilienceHub.ListAppVersions
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists the different versions for the Resilience Hub applications.
module Amazonka.ResilienceHub.ListAppVersions
  ( -- * Creating a Request
    ListAppVersions (..),
    newListAppVersions,

    -- * Request Lenses
    listAppVersions_maxResults,
    listAppVersions_nextToken,
    listAppVersions_appArn,

    -- * Destructuring the Response
    ListAppVersionsResponse (..),
    newListAppVersionsResponse,

    -- * Response Lenses
    listAppVersionsResponse_nextToken,
    listAppVersionsResponse_httpStatus,
    listAppVersionsResponse_appVersions,
  )
where

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 Amazonka.ResilienceHub.Types
import qualified Amazonka.Response as Response

-- | /See:/ 'newListAppVersions' smart constructor.
data ListAppVersions = ListAppVersions'
  { -- | The maximum number of results to include in the response. If more
    -- results exist than the specified @MaxResults@ value, a token is included
    -- in the response so that the remaining results can be retrieved.
    ListAppVersions -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | Null, or the token from a previous call to get the next set of results.
    ListAppVersions -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the application. The format for this
    -- ARN is: arn:@partition@:resiliencehub:@region@:@account@:app\/@app-id@.
    -- For more information about ARNs, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
    -- in the /AWS General Reference/.
    ListAppVersions -> Text
appArn :: Prelude.Text
  }
  deriving (ListAppVersions -> ListAppVersions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAppVersions -> ListAppVersions -> Bool
$c/= :: ListAppVersions -> ListAppVersions -> Bool
== :: ListAppVersions -> ListAppVersions -> Bool
$c== :: ListAppVersions -> ListAppVersions -> Bool
Prelude.Eq, ReadPrec [ListAppVersions]
ReadPrec ListAppVersions
Int -> ReadS ListAppVersions
ReadS [ListAppVersions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAppVersions]
$creadListPrec :: ReadPrec [ListAppVersions]
readPrec :: ReadPrec ListAppVersions
$creadPrec :: ReadPrec ListAppVersions
readList :: ReadS [ListAppVersions]
$creadList :: ReadS [ListAppVersions]
readsPrec :: Int -> ReadS ListAppVersions
$creadsPrec :: Int -> ReadS ListAppVersions
Prelude.Read, Int -> ListAppVersions -> ShowS
[ListAppVersions] -> ShowS
ListAppVersions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAppVersions] -> ShowS
$cshowList :: [ListAppVersions] -> ShowS
show :: ListAppVersions -> String
$cshow :: ListAppVersions -> String
showsPrec :: Int -> ListAppVersions -> ShowS
$cshowsPrec :: Int -> ListAppVersions -> ShowS
Prelude.Show, forall x. Rep ListAppVersions x -> ListAppVersions
forall x. ListAppVersions -> Rep ListAppVersions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAppVersions x -> ListAppVersions
$cfrom :: forall x. ListAppVersions -> Rep ListAppVersions x
Prelude.Generic)

-- |
-- Create a value of 'ListAppVersions' 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:
--
-- 'maxResults', 'listAppVersions_maxResults' - The maximum number of results to include in the response. If more
-- results exist than the specified @MaxResults@ value, a token is included
-- in the response so that the remaining results can be retrieved.
--
-- 'nextToken', 'listAppVersions_nextToken' - Null, or the token from a previous call to get the next set of results.
--
-- 'appArn', 'listAppVersions_appArn' - The Amazon Resource Name (ARN) of the application. The format for this
-- ARN is: arn:@partition@:resiliencehub:@region@:@account@:app\/@app-id@.
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the /AWS General Reference/.
newListAppVersions ::
  -- | 'appArn'
  Prelude.Text ->
  ListAppVersions
newListAppVersions :: Text -> ListAppVersions
newListAppVersions Text
pAppArn_ =
  ListAppVersions'
    { $sel:maxResults:ListAppVersions' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAppVersions' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:appArn:ListAppVersions' :: Text
appArn = Text
pAppArn_
    }

-- | The maximum number of results to include in the response. If more
-- results exist than the specified @MaxResults@ value, a token is included
-- in the response so that the remaining results can be retrieved.
listAppVersions_maxResults :: Lens.Lens' ListAppVersions (Prelude.Maybe Prelude.Natural)
listAppVersions_maxResults :: Lens' ListAppVersions (Maybe Natural)
listAppVersions_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAppVersions' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListAppVersions' :: ListAppVersions -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListAppVersions
s@ListAppVersions' {} Maybe Natural
a -> ListAppVersions
s {$sel:maxResults:ListAppVersions' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListAppVersions)

-- | Null, or the token from a previous call to get the next set of results.
listAppVersions_nextToken :: Lens.Lens' ListAppVersions (Prelude.Maybe Prelude.Text)
listAppVersions_nextToken :: Lens' ListAppVersions (Maybe Text)
listAppVersions_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAppVersions' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAppVersions' :: ListAppVersions -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAppVersions
s@ListAppVersions' {} Maybe Text
a -> ListAppVersions
s {$sel:nextToken:ListAppVersions' :: Maybe Text
nextToken = Maybe Text
a} :: ListAppVersions)

-- | The Amazon Resource Name (ARN) of the application. The format for this
-- ARN is: arn:@partition@:resiliencehub:@region@:@account@:app\/@app-id@.
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the /AWS General Reference/.
listAppVersions_appArn :: Lens.Lens' ListAppVersions Prelude.Text
listAppVersions_appArn :: Lens' ListAppVersions Text
listAppVersions_appArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAppVersions' {Text
appArn :: Text
$sel:appArn:ListAppVersions' :: ListAppVersions -> Text
appArn} -> Text
appArn) (\s :: ListAppVersions
s@ListAppVersions' {} Text
a -> ListAppVersions
s {$sel:appArn:ListAppVersions' :: Text
appArn = Text
a} :: ListAppVersions)

instance Core.AWSRequest ListAppVersions where
  type
    AWSResponse ListAppVersions =
      ListAppVersionsResponse
  request :: (Service -> Service) -> ListAppVersions -> Request ListAppVersions
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListAppVersions
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListAppVersions)))
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 Text -> Int -> [AppVersionSummary] -> ListAppVersionsResponse
ListAppVersionsResponse'
            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
"nextToken")
            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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"appVersions" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListAppVersions where
  hashWithSalt :: Int -> ListAppVersions -> Int
hashWithSalt Int
_salt ListAppVersions' {Maybe Natural
Maybe Text
Text
appArn :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:appArn:ListAppVersions' :: ListAppVersions -> Text
$sel:nextToken:ListAppVersions' :: ListAppVersions -> Maybe Text
$sel:maxResults:ListAppVersions' :: ListAppVersions -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
appArn

instance Prelude.NFData ListAppVersions where
  rnf :: ListAppVersions -> ()
rnf ListAppVersions' {Maybe Natural
Maybe Text
Text
appArn :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:appArn:ListAppVersions' :: ListAppVersions -> Text
$sel:nextToken:ListAppVersions' :: ListAppVersions -> Maybe Text
$sel:maxResults:ListAppVersions' :: ListAppVersions -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
appArn

instance Data.ToHeaders ListAppVersions where
  toHeaders :: ListAppVersions -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON ListAppVersions where
  toJSON :: ListAppVersions -> Value
toJSON ListAppVersions' {Maybe Natural
Maybe Text
Text
appArn :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:appArn:ListAppVersions' :: ListAppVersions -> Text
$sel:nextToken:ListAppVersions' :: ListAppVersions -> Maybe Text
$sel:maxResults:ListAppVersions' :: ListAppVersions -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"maxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            (Key
"nextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            forall a. a -> Maybe a
Prelude.Just (Key
"appArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
appArn)
          ]
      )

instance Data.ToPath ListAppVersions where
  toPath :: ListAppVersions -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/list-app-versions"

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

-- | /See:/ 'newListAppVersionsResponse' smart constructor.
data ListAppVersionsResponse = ListAppVersionsResponse'
  { -- | The token for the next set of results, or null if there are no more
    -- results.
    ListAppVersionsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListAppVersionsResponse -> Int
httpStatus :: Prelude.Int,
    -- | The version of the application.
    ListAppVersionsResponse -> [AppVersionSummary]
appVersions :: [AppVersionSummary]
  }
  deriving (ListAppVersionsResponse -> ListAppVersionsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAppVersionsResponse -> ListAppVersionsResponse -> Bool
$c/= :: ListAppVersionsResponse -> ListAppVersionsResponse -> Bool
== :: ListAppVersionsResponse -> ListAppVersionsResponse -> Bool
$c== :: ListAppVersionsResponse -> ListAppVersionsResponse -> Bool
Prelude.Eq, ReadPrec [ListAppVersionsResponse]
ReadPrec ListAppVersionsResponse
Int -> ReadS ListAppVersionsResponse
ReadS [ListAppVersionsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAppVersionsResponse]
$creadListPrec :: ReadPrec [ListAppVersionsResponse]
readPrec :: ReadPrec ListAppVersionsResponse
$creadPrec :: ReadPrec ListAppVersionsResponse
readList :: ReadS [ListAppVersionsResponse]
$creadList :: ReadS [ListAppVersionsResponse]
readsPrec :: Int -> ReadS ListAppVersionsResponse
$creadsPrec :: Int -> ReadS ListAppVersionsResponse
Prelude.Read, Int -> ListAppVersionsResponse -> ShowS
[ListAppVersionsResponse] -> ShowS
ListAppVersionsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAppVersionsResponse] -> ShowS
$cshowList :: [ListAppVersionsResponse] -> ShowS
show :: ListAppVersionsResponse -> String
$cshow :: ListAppVersionsResponse -> String
showsPrec :: Int -> ListAppVersionsResponse -> ShowS
$cshowsPrec :: Int -> ListAppVersionsResponse -> ShowS
Prelude.Show, forall x. Rep ListAppVersionsResponse x -> ListAppVersionsResponse
forall x. ListAppVersionsResponse -> Rep ListAppVersionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAppVersionsResponse x -> ListAppVersionsResponse
$cfrom :: forall x. ListAppVersionsResponse -> Rep ListAppVersionsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAppVersionsResponse' 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:
--
-- 'nextToken', 'listAppVersionsResponse_nextToken' - The token for the next set of results, or null if there are no more
-- results.
--
-- 'httpStatus', 'listAppVersionsResponse_httpStatus' - The response's http status code.
--
-- 'appVersions', 'listAppVersionsResponse_appVersions' - The version of the application.
newListAppVersionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAppVersionsResponse
newListAppVersionsResponse :: Int -> ListAppVersionsResponse
newListAppVersionsResponse Int
pHttpStatus_ =
  ListAppVersionsResponse'
    { $sel:nextToken:ListAppVersionsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAppVersionsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:appVersions:ListAppVersionsResponse' :: [AppVersionSummary]
appVersions = forall a. Monoid a => a
Prelude.mempty
    }

-- | The token for the next set of results, or null if there are no more
-- results.
listAppVersionsResponse_nextToken :: Lens.Lens' ListAppVersionsResponse (Prelude.Maybe Prelude.Text)
listAppVersionsResponse_nextToken :: Lens' ListAppVersionsResponse (Maybe Text)
listAppVersionsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAppVersionsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAppVersionsResponse' :: ListAppVersionsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAppVersionsResponse
s@ListAppVersionsResponse' {} Maybe Text
a -> ListAppVersionsResponse
s {$sel:nextToken:ListAppVersionsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAppVersionsResponse)

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

-- | The version of the application.
listAppVersionsResponse_appVersions :: Lens.Lens' ListAppVersionsResponse [AppVersionSummary]
listAppVersionsResponse_appVersions :: Lens' ListAppVersionsResponse [AppVersionSummary]
listAppVersionsResponse_appVersions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAppVersionsResponse' {[AppVersionSummary]
appVersions :: [AppVersionSummary]
$sel:appVersions:ListAppVersionsResponse' :: ListAppVersionsResponse -> [AppVersionSummary]
appVersions} -> [AppVersionSummary]
appVersions) (\s :: ListAppVersionsResponse
s@ListAppVersionsResponse' {} [AppVersionSummary]
a -> ListAppVersionsResponse
s {$sel:appVersions:ListAppVersionsResponse' :: [AppVersionSummary]
appVersions = [AppVersionSummary]
a} :: ListAppVersionsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListAppVersionsResponse where
  rnf :: ListAppVersionsResponse -> ()
rnf ListAppVersionsResponse' {Int
[AppVersionSummary]
Maybe Text
appVersions :: [AppVersionSummary]
httpStatus :: Int
nextToken :: Maybe Text
$sel:appVersions:ListAppVersionsResponse' :: ListAppVersionsResponse -> [AppVersionSummary]
$sel:httpStatus:ListAppVersionsResponse' :: ListAppVersionsResponse -> Int
$sel:nextToken:ListAppVersionsResponse' :: ListAppVersionsResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [AppVersionSummary]
appVersions