{-# 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.DataBrew.ListSchedules
-- 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 DataBrew schedules that are defined.
--
-- This operation returns paginated results.
module Amazonka.DataBrew.ListSchedules
  ( -- * Creating a Request
    ListSchedules (..),
    newListSchedules,

    -- * Request Lenses
    listSchedules_jobName,
    listSchedules_maxResults,
    listSchedules_nextToken,

    -- * Destructuring the Response
    ListSchedulesResponse (..),
    newListSchedulesResponse,

    -- * Response Lenses
    listSchedulesResponse_nextToken,
    listSchedulesResponse_httpStatus,
    listSchedulesResponse_schedules,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataBrew.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListSchedules' smart constructor.
data ListSchedules = ListSchedules'
  { -- | The name of the job that these schedules apply to.
    ListSchedules -> Maybe Text
jobName :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return in this request.
    ListSchedules -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token returned by a previous call to retrieve the next set of
    -- results.
    ListSchedules -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListSchedules -> ListSchedules -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListSchedules -> ListSchedules -> Bool
$c/= :: ListSchedules -> ListSchedules -> Bool
== :: ListSchedules -> ListSchedules -> Bool
$c== :: ListSchedules -> ListSchedules -> Bool
Prelude.Eq, ReadPrec [ListSchedules]
ReadPrec ListSchedules
Int -> ReadS ListSchedules
ReadS [ListSchedules]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListSchedules]
$creadListPrec :: ReadPrec [ListSchedules]
readPrec :: ReadPrec ListSchedules
$creadPrec :: ReadPrec ListSchedules
readList :: ReadS [ListSchedules]
$creadList :: ReadS [ListSchedules]
readsPrec :: Int -> ReadS ListSchedules
$creadsPrec :: Int -> ReadS ListSchedules
Prelude.Read, Int -> ListSchedules -> ShowS
[ListSchedules] -> ShowS
ListSchedules -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListSchedules] -> ShowS
$cshowList :: [ListSchedules] -> ShowS
show :: ListSchedules -> String
$cshow :: ListSchedules -> String
showsPrec :: Int -> ListSchedules -> ShowS
$cshowsPrec :: Int -> ListSchedules -> ShowS
Prelude.Show, forall x. Rep ListSchedules x -> ListSchedules
forall x. ListSchedules -> Rep ListSchedules x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListSchedules x -> ListSchedules
$cfrom :: forall x. ListSchedules -> Rep ListSchedules x
Prelude.Generic)

-- |
-- Create a value of 'ListSchedules' 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:
--
-- 'jobName', 'listSchedules_jobName' - The name of the job that these schedules apply to.
--
-- 'maxResults', 'listSchedules_maxResults' - The maximum number of results to return in this request.
--
-- 'nextToken', 'listSchedules_nextToken' - The token returned by a previous call to retrieve the next set of
-- results.
newListSchedules ::
  ListSchedules
newListSchedules :: ListSchedules
newListSchedules =
  ListSchedules'
    { $sel:jobName:ListSchedules' :: Maybe Text
jobName = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListSchedules' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListSchedules' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the job that these schedules apply to.
listSchedules_jobName :: Lens.Lens' ListSchedules (Prelude.Maybe Prelude.Text)
listSchedules_jobName :: Lens' ListSchedules (Maybe Text)
listSchedules_jobName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSchedules' {Maybe Text
jobName :: Maybe Text
$sel:jobName:ListSchedules' :: ListSchedules -> Maybe Text
jobName} -> Maybe Text
jobName) (\s :: ListSchedules
s@ListSchedules' {} Maybe Text
a -> ListSchedules
s {$sel:jobName:ListSchedules' :: Maybe Text
jobName = Maybe Text
a} :: ListSchedules)

-- | The maximum number of results to return in this request.
listSchedules_maxResults :: Lens.Lens' ListSchedules (Prelude.Maybe Prelude.Natural)
listSchedules_maxResults :: Lens' ListSchedules (Maybe Natural)
listSchedules_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSchedules' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListSchedules' :: ListSchedules -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListSchedules
s@ListSchedules' {} Maybe Natural
a -> ListSchedules
s {$sel:maxResults:ListSchedules' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListSchedules)

-- | The token returned by a previous call to retrieve the next set of
-- results.
listSchedules_nextToken :: Lens.Lens' ListSchedules (Prelude.Maybe Prelude.Text)
listSchedules_nextToken :: Lens' ListSchedules (Maybe Text)
listSchedules_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSchedules' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListSchedules' :: ListSchedules -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListSchedules
s@ListSchedules' {} Maybe Text
a -> ListSchedules
s {$sel:nextToken:ListSchedules' :: Maybe Text
nextToken = Maybe Text
a} :: ListSchedules)

instance Core.AWSPager ListSchedules where
  page :: ListSchedules -> AWSResponse ListSchedules -> Maybe ListSchedules
page ListSchedules
rq AWSResponse ListSchedules
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListSchedules
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListSchedulesResponse (Maybe Text)
listSchedulesResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        (AWSResponse ListSchedules
rs forall s a. s -> Getting a s a -> a
Lens.^. Lens' ListSchedulesResponse [Schedule]
listSchedulesResponse_schedules) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListSchedules
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListSchedules (Maybe Text)
listSchedules_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListSchedules
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListSchedulesResponse (Maybe Text)
listSchedulesResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListSchedules where
  type
    AWSResponse ListSchedules =
      ListSchedulesResponse
  request :: (Service -> Service) -> ListSchedules -> Request ListSchedules
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 ListSchedules
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListSchedules)))
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 -> [Schedule] -> ListSchedulesResponse
ListSchedulesResponse'
            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
"Schedules" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

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

instance Prelude.NFData ListSchedules where
  rnf :: ListSchedules -> ()
rnf ListSchedules' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
jobName :: Maybe Text
$sel:nextToken:ListSchedules' :: ListSchedules -> Maybe Text
$sel:maxResults:ListSchedules' :: ListSchedules -> Maybe Natural
$sel:jobName:ListSchedules' :: ListSchedules -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
jobName
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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

instance Data.ToHeaders ListSchedules where
  toHeaders :: ListSchedules -> 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.ToPath ListSchedules where
  toPath :: ListSchedules -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/schedules"

instance Data.ToQuery ListSchedules where
  toQuery :: ListSchedules -> QueryString
toQuery ListSchedules' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
jobName :: Maybe Text
$sel:nextToken:ListSchedules' :: ListSchedules -> Maybe Text
$sel:maxResults:ListSchedules' :: ListSchedules -> Maybe Natural
$sel:jobName:ListSchedules' :: ListSchedules -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"jobName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
jobName,
        ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListSchedulesResponse' smart constructor.
data ListSchedulesResponse = ListSchedulesResponse'
  { -- | A token that you can use in a subsequent call to retrieve the next set
    -- of results.
    ListSchedulesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListSchedulesResponse -> Int
httpStatus :: Prelude.Int,
    -- | A list of schedules that are defined.
    ListSchedulesResponse -> [Schedule]
schedules :: [Schedule]
  }
  deriving (ListSchedulesResponse -> ListSchedulesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListSchedulesResponse -> ListSchedulesResponse -> Bool
$c/= :: ListSchedulesResponse -> ListSchedulesResponse -> Bool
== :: ListSchedulesResponse -> ListSchedulesResponse -> Bool
$c== :: ListSchedulesResponse -> ListSchedulesResponse -> Bool
Prelude.Eq, ReadPrec [ListSchedulesResponse]
ReadPrec ListSchedulesResponse
Int -> ReadS ListSchedulesResponse
ReadS [ListSchedulesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListSchedulesResponse]
$creadListPrec :: ReadPrec [ListSchedulesResponse]
readPrec :: ReadPrec ListSchedulesResponse
$creadPrec :: ReadPrec ListSchedulesResponse
readList :: ReadS [ListSchedulesResponse]
$creadList :: ReadS [ListSchedulesResponse]
readsPrec :: Int -> ReadS ListSchedulesResponse
$creadsPrec :: Int -> ReadS ListSchedulesResponse
Prelude.Read, Int -> ListSchedulesResponse -> ShowS
[ListSchedulesResponse] -> ShowS
ListSchedulesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListSchedulesResponse] -> ShowS
$cshowList :: [ListSchedulesResponse] -> ShowS
show :: ListSchedulesResponse -> String
$cshow :: ListSchedulesResponse -> String
showsPrec :: Int -> ListSchedulesResponse -> ShowS
$cshowsPrec :: Int -> ListSchedulesResponse -> ShowS
Prelude.Show, forall x. Rep ListSchedulesResponse x -> ListSchedulesResponse
forall x. ListSchedulesResponse -> Rep ListSchedulesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListSchedulesResponse x -> ListSchedulesResponse
$cfrom :: forall x. ListSchedulesResponse -> Rep ListSchedulesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListSchedulesResponse' 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', 'listSchedulesResponse_nextToken' - A token that you can use in a subsequent call to retrieve the next set
-- of results.
--
-- 'httpStatus', 'listSchedulesResponse_httpStatus' - The response's http status code.
--
-- 'schedules', 'listSchedulesResponse_schedules' - A list of schedules that are defined.
newListSchedulesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListSchedulesResponse
newListSchedulesResponse :: Int -> ListSchedulesResponse
newListSchedulesResponse Int
pHttpStatus_ =
  ListSchedulesResponse'
    { $sel:nextToken:ListSchedulesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListSchedulesResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:schedules:ListSchedulesResponse' :: [Schedule]
schedules = forall a. Monoid a => a
Prelude.mempty
    }

-- | A token that you can use in a subsequent call to retrieve the next set
-- of results.
listSchedulesResponse_nextToken :: Lens.Lens' ListSchedulesResponse (Prelude.Maybe Prelude.Text)
listSchedulesResponse_nextToken :: Lens' ListSchedulesResponse (Maybe Text)
listSchedulesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSchedulesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListSchedulesResponse' :: ListSchedulesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListSchedulesResponse
s@ListSchedulesResponse' {} Maybe Text
a -> ListSchedulesResponse
s {$sel:nextToken:ListSchedulesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListSchedulesResponse)

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

-- | A list of schedules that are defined.
listSchedulesResponse_schedules :: Lens.Lens' ListSchedulesResponse [Schedule]
listSchedulesResponse_schedules :: Lens' ListSchedulesResponse [Schedule]
listSchedulesResponse_schedules = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSchedulesResponse' {[Schedule]
schedules :: [Schedule]
$sel:schedules:ListSchedulesResponse' :: ListSchedulesResponse -> [Schedule]
schedules} -> [Schedule]
schedules) (\s :: ListSchedulesResponse
s@ListSchedulesResponse' {} [Schedule]
a -> ListSchedulesResponse
s {$sel:schedules:ListSchedulesResponse' :: [Schedule]
schedules = [Schedule]
a} :: ListSchedulesResponse) 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 ListSchedulesResponse where
  rnf :: ListSchedulesResponse -> ()
rnf ListSchedulesResponse' {Int
[Schedule]
Maybe Text
schedules :: [Schedule]
httpStatus :: Int
nextToken :: Maybe Text
$sel:schedules:ListSchedulesResponse' :: ListSchedulesResponse -> [Schedule]
$sel:httpStatus:ListSchedulesResponse' :: ListSchedulesResponse -> Int
$sel:nextToken:ListSchedulesResponse' :: ListSchedulesResponse -> 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 [Schedule]
schedules