{-# 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.WellArchitected.ListMilestones
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- List all milestones for an existing workload.
module Amazonka.WellArchitected.ListMilestones
  ( -- * Creating a Request
    ListMilestones (..),
    newListMilestones,

    -- * Request Lenses
    listMilestones_maxResults,
    listMilestones_nextToken,
    listMilestones_workloadId,

    -- * Destructuring the Response
    ListMilestonesResponse (..),
    newListMilestonesResponse,

    -- * Response Lenses
    listMilestonesResponse_milestoneSummaries,
    listMilestonesResponse_nextToken,
    listMilestonesResponse_workloadId,
    listMilestonesResponse_httpStatus,
  )
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 qualified Amazonka.Response as Response
import Amazonka.WellArchitected.Types

-- | Input to list all milestones for a workload.
--
-- /See:/ 'newListMilestones' smart constructor.
data ListMilestones = ListMilestones'
  { ListMilestones -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    ListMilestones -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    ListMilestones -> Text
workloadId :: Prelude.Text
  }
  deriving (ListMilestones -> ListMilestones -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListMilestones -> ListMilestones -> Bool
$c/= :: ListMilestones -> ListMilestones -> Bool
== :: ListMilestones -> ListMilestones -> Bool
$c== :: ListMilestones -> ListMilestones -> Bool
Prelude.Eq, ReadPrec [ListMilestones]
ReadPrec ListMilestones
Int -> ReadS ListMilestones
ReadS [ListMilestones]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListMilestones]
$creadListPrec :: ReadPrec [ListMilestones]
readPrec :: ReadPrec ListMilestones
$creadPrec :: ReadPrec ListMilestones
readList :: ReadS [ListMilestones]
$creadList :: ReadS [ListMilestones]
readsPrec :: Int -> ReadS ListMilestones
$creadsPrec :: Int -> ReadS ListMilestones
Prelude.Read, Int -> ListMilestones -> ShowS
[ListMilestones] -> ShowS
ListMilestones -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListMilestones] -> ShowS
$cshowList :: [ListMilestones] -> ShowS
show :: ListMilestones -> String
$cshow :: ListMilestones -> String
showsPrec :: Int -> ListMilestones -> ShowS
$cshowsPrec :: Int -> ListMilestones -> ShowS
Prelude.Show, forall x. Rep ListMilestones x -> ListMilestones
forall x. ListMilestones -> Rep ListMilestones x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListMilestones x -> ListMilestones
$cfrom :: forall x. ListMilestones -> Rep ListMilestones x
Prelude.Generic)

-- |
-- Create a value of 'ListMilestones' 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', 'listMilestones_maxResults' - Undocumented member.
--
-- 'nextToken', 'listMilestones_nextToken' - Undocumented member.
--
-- 'workloadId', 'listMilestones_workloadId' - Undocumented member.
newListMilestones ::
  -- | 'workloadId'
  Prelude.Text ->
  ListMilestones
newListMilestones :: Text -> ListMilestones
newListMilestones Text
pWorkloadId_ =
  ListMilestones'
    { $sel:maxResults:ListMilestones' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListMilestones' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:workloadId:ListMilestones' :: Text
workloadId = Text
pWorkloadId_
    }

-- | Undocumented member.
listMilestones_maxResults :: Lens.Lens' ListMilestones (Prelude.Maybe Prelude.Natural)
listMilestones_maxResults :: Lens' ListMilestones (Maybe Natural)
listMilestones_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMilestones' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListMilestones' :: ListMilestones -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListMilestones
s@ListMilestones' {} Maybe Natural
a -> ListMilestones
s {$sel:maxResults:ListMilestones' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListMilestones)

-- | Undocumented member.
listMilestones_nextToken :: Lens.Lens' ListMilestones (Prelude.Maybe Prelude.Text)
listMilestones_nextToken :: Lens' ListMilestones (Maybe Text)
listMilestones_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMilestones' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListMilestones' :: ListMilestones -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListMilestones
s@ListMilestones' {} Maybe Text
a -> ListMilestones
s {$sel:nextToken:ListMilestones' :: Maybe Text
nextToken = Maybe Text
a} :: ListMilestones)

-- | Undocumented member.
listMilestones_workloadId :: Lens.Lens' ListMilestones Prelude.Text
listMilestones_workloadId :: Lens' ListMilestones Text
listMilestones_workloadId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMilestones' {Text
workloadId :: Text
$sel:workloadId:ListMilestones' :: ListMilestones -> Text
workloadId} -> Text
workloadId) (\s :: ListMilestones
s@ListMilestones' {} Text
a -> ListMilestones
s {$sel:workloadId:ListMilestones' :: Text
workloadId = Text
a} :: ListMilestones)

instance Core.AWSRequest ListMilestones where
  type
    AWSResponse ListMilestones =
      ListMilestonesResponse
  request :: (Service -> Service) -> ListMilestones -> Request ListMilestones
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 ListMilestones
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListMilestones)))
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 [MilestoneSummary]
-> Maybe Text -> Maybe Text -> Int -> ListMilestonesResponse
ListMilestonesResponse'
            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
"MilestoneSummaries"
                            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.<*> (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.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"WorkloadId")
            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 ListMilestones where
  hashWithSalt :: Int -> ListMilestones -> Int
hashWithSalt Int
_salt ListMilestones' {Maybe Natural
Maybe Text
Text
workloadId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:workloadId:ListMilestones' :: ListMilestones -> Text
$sel:nextToken:ListMilestones' :: ListMilestones -> Maybe Text
$sel:maxResults:ListMilestones' :: ListMilestones -> 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
workloadId

instance Prelude.NFData ListMilestones where
  rnf :: ListMilestones -> ()
rnf ListMilestones' {Maybe Natural
Maybe Text
Text
workloadId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:workloadId:ListMilestones' :: ListMilestones -> Text
$sel:nextToken:ListMilestones' :: ListMilestones -> Maybe Text
$sel:maxResults:ListMilestones' :: ListMilestones -> 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
workloadId

instance Data.ToHeaders ListMilestones where
  toHeaders :: ListMilestones -> 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 ListMilestones where
  toJSON :: ListMilestones -> Value
toJSON ListMilestones' {Maybe Natural
Maybe Text
Text
workloadId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:workloadId:ListMilestones' :: ListMilestones -> Text
$sel:nextToken:ListMilestones' :: ListMilestones -> Maybe Text
$sel:maxResults:ListMilestones' :: ListMilestones -> 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
          ]
      )

instance Data.ToPath ListMilestones where
  toPath :: ListMilestones -> ByteString
toPath ListMilestones' {Maybe Natural
Maybe Text
Text
workloadId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:workloadId:ListMilestones' :: ListMilestones -> Text
$sel:nextToken:ListMilestones' :: ListMilestones -> Maybe Text
$sel:maxResults:ListMilestones' :: ListMilestones -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/workloads/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
workloadId,
        ByteString
"/milestonesSummaries"
      ]

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

-- | Output of a list milestones call.
--
-- /See:/ 'newListMilestonesResponse' smart constructor.
data ListMilestonesResponse = ListMilestonesResponse'
  { ListMilestonesResponse -> Maybe [MilestoneSummary]
milestoneSummaries :: Prelude.Maybe [MilestoneSummary],
    ListMilestonesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    ListMilestonesResponse -> Maybe Text
workloadId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListMilestonesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListMilestonesResponse -> ListMilestonesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListMilestonesResponse -> ListMilestonesResponse -> Bool
$c/= :: ListMilestonesResponse -> ListMilestonesResponse -> Bool
== :: ListMilestonesResponse -> ListMilestonesResponse -> Bool
$c== :: ListMilestonesResponse -> ListMilestonesResponse -> Bool
Prelude.Eq, ReadPrec [ListMilestonesResponse]
ReadPrec ListMilestonesResponse
Int -> ReadS ListMilestonesResponse
ReadS [ListMilestonesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListMilestonesResponse]
$creadListPrec :: ReadPrec [ListMilestonesResponse]
readPrec :: ReadPrec ListMilestonesResponse
$creadPrec :: ReadPrec ListMilestonesResponse
readList :: ReadS [ListMilestonesResponse]
$creadList :: ReadS [ListMilestonesResponse]
readsPrec :: Int -> ReadS ListMilestonesResponse
$creadsPrec :: Int -> ReadS ListMilestonesResponse
Prelude.Read, Int -> ListMilestonesResponse -> ShowS
[ListMilestonesResponse] -> ShowS
ListMilestonesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListMilestonesResponse] -> ShowS
$cshowList :: [ListMilestonesResponse] -> ShowS
show :: ListMilestonesResponse -> String
$cshow :: ListMilestonesResponse -> String
showsPrec :: Int -> ListMilestonesResponse -> ShowS
$cshowsPrec :: Int -> ListMilestonesResponse -> ShowS
Prelude.Show, forall x. Rep ListMilestonesResponse x -> ListMilestonesResponse
forall x. ListMilestonesResponse -> Rep ListMilestonesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListMilestonesResponse x -> ListMilestonesResponse
$cfrom :: forall x. ListMilestonesResponse -> Rep ListMilestonesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListMilestonesResponse' 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:
--
-- 'milestoneSummaries', 'listMilestonesResponse_milestoneSummaries' - Undocumented member.
--
-- 'nextToken', 'listMilestonesResponse_nextToken' - Undocumented member.
--
-- 'workloadId', 'listMilestonesResponse_workloadId' - Undocumented member.
--
-- 'httpStatus', 'listMilestonesResponse_httpStatus' - The response's http status code.
newListMilestonesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListMilestonesResponse
newListMilestonesResponse :: Int -> ListMilestonesResponse
newListMilestonesResponse Int
pHttpStatus_ =
  ListMilestonesResponse'
    { $sel:milestoneSummaries:ListMilestonesResponse' :: Maybe [MilestoneSummary]
milestoneSummaries =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListMilestonesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:workloadId:ListMilestonesResponse' :: Maybe Text
workloadId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListMilestonesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
listMilestonesResponse_milestoneSummaries :: Lens.Lens' ListMilestonesResponse (Prelude.Maybe [MilestoneSummary])
listMilestonesResponse_milestoneSummaries :: Lens' ListMilestonesResponse (Maybe [MilestoneSummary])
listMilestonesResponse_milestoneSummaries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMilestonesResponse' {Maybe [MilestoneSummary]
milestoneSummaries :: Maybe [MilestoneSummary]
$sel:milestoneSummaries:ListMilestonesResponse' :: ListMilestonesResponse -> Maybe [MilestoneSummary]
milestoneSummaries} -> Maybe [MilestoneSummary]
milestoneSummaries) (\s :: ListMilestonesResponse
s@ListMilestonesResponse' {} Maybe [MilestoneSummary]
a -> ListMilestonesResponse
s {$sel:milestoneSummaries:ListMilestonesResponse' :: Maybe [MilestoneSummary]
milestoneSummaries = Maybe [MilestoneSummary]
a} :: ListMilestonesResponse) 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

-- | Undocumented member.
listMilestonesResponse_nextToken :: Lens.Lens' ListMilestonesResponse (Prelude.Maybe Prelude.Text)
listMilestonesResponse_nextToken :: Lens' ListMilestonesResponse (Maybe Text)
listMilestonesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMilestonesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListMilestonesResponse' :: ListMilestonesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListMilestonesResponse
s@ListMilestonesResponse' {} Maybe Text
a -> ListMilestonesResponse
s {$sel:nextToken:ListMilestonesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListMilestonesResponse)

-- | Undocumented member.
listMilestonesResponse_workloadId :: Lens.Lens' ListMilestonesResponse (Prelude.Maybe Prelude.Text)
listMilestonesResponse_workloadId :: Lens' ListMilestonesResponse (Maybe Text)
listMilestonesResponse_workloadId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMilestonesResponse' {Maybe Text
workloadId :: Maybe Text
$sel:workloadId:ListMilestonesResponse' :: ListMilestonesResponse -> Maybe Text
workloadId} -> Maybe Text
workloadId) (\s :: ListMilestonesResponse
s@ListMilestonesResponse' {} Maybe Text
a -> ListMilestonesResponse
s {$sel:workloadId:ListMilestonesResponse' :: Maybe Text
workloadId = Maybe Text
a} :: ListMilestonesResponse)

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

instance Prelude.NFData ListMilestonesResponse where
  rnf :: ListMilestonesResponse -> ()
rnf ListMilestonesResponse' {Int
Maybe [MilestoneSummary]
Maybe Text
httpStatus :: Int
workloadId :: Maybe Text
nextToken :: Maybe Text
milestoneSummaries :: Maybe [MilestoneSummary]
$sel:httpStatus:ListMilestonesResponse' :: ListMilestonesResponse -> Int
$sel:workloadId:ListMilestonesResponse' :: ListMilestonesResponse -> Maybe Text
$sel:nextToken:ListMilestonesResponse' :: ListMilestonesResponse -> Maybe Text
$sel:milestoneSummaries:ListMilestonesResponse' :: ListMilestonesResponse -> Maybe [MilestoneSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [MilestoneSummary]
milestoneSummaries
      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 Maybe Text
workloadId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus