{-# 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.Snowball.ListJobs -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Returns an array of @JobListEntry@ objects of the specified length. Each -- @JobListEntry@ object contains a job\'s state, a job\'s ID, and a value -- that indicates whether the job is a job part, in the case of export -- jobs. Calling this API action in one of the US regions will return jobs -- from the list of all jobs associated with this account in all US -- regions. -- -- This operation returns paginated results. module Amazonka.Snowball.ListJobs ( -- * Creating a Request ListJobs (..), newListJobs, -- * Request Lenses listJobs_maxResults, listJobs_nextToken, -- * Destructuring the Response ListJobsResponse (..), newListJobsResponse, -- * Response Lenses listJobsResponse_jobListEntries, listJobsResponse_nextToken, listJobsResponse_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.Snowball.Types -- | /See:/ 'newListJobs' smart constructor. data ListJobs = ListJobs' { -- | The number of @JobListEntry@ objects to return. maxResults :: Prelude.Maybe Prelude.Natural, -- | HTTP requests are stateless. To identify what object comes \"next\" in -- the list of @JobListEntry@ objects, you have the option of specifying -- @NextToken@ as the starting point for your returned list. nextToken :: Prelude.Maybe Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListJobs' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'maxResults', 'listJobs_maxResults' - The number of @JobListEntry@ objects to return. -- -- 'nextToken', 'listJobs_nextToken' - HTTP requests are stateless. To identify what object comes \"next\" in -- the list of @JobListEntry@ objects, you have the option of specifying -- @NextToken@ as the starting point for your returned list. newListJobs :: ListJobs newListJobs = ListJobs' { maxResults = Prelude.Nothing, nextToken = Prelude.Nothing } -- | The number of @JobListEntry@ objects to return. listJobs_maxResults :: Lens.Lens' ListJobs (Prelude.Maybe Prelude.Natural) listJobs_maxResults = Lens.lens (\ListJobs' {maxResults} -> maxResults) (\s@ListJobs' {} a -> s {maxResults = a} :: ListJobs) -- | HTTP requests are stateless. To identify what object comes \"next\" in -- the list of @JobListEntry@ objects, you have the option of specifying -- @NextToken@ as the starting point for your returned list. listJobs_nextToken :: Lens.Lens' ListJobs (Prelude.Maybe Prelude.Text) listJobs_nextToken = Lens.lens (\ListJobs' {nextToken} -> nextToken) (\s@ListJobs' {} a -> s {nextToken = a} :: ListJobs) instance Core.AWSPager ListJobs where page rq rs | Core.stop ( rs Lens.^? listJobsResponse_nextToken Prelude.. Lens._Just ) = Prelude.Nothing | Core.stop ( rs Lens.^? listJobsResponse_jobListEntries Prelude.. Lens._Just ) = Prelude.Nothing | Prelude.otherwise = Prelude.Just Prelude.$ rq Prelude.& listJobs_nextToken Lens..~ rs Lens.^? listJobsResponse_nextToken Prelude.. Lens._Just instance Core.AWSRequest ListJobs where type AWSResponse ListJobs = ListJobsResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> ListJobsResponse' Prelude.<$> (x Data..?> "JobListEntries" Core..!@ Prelude.mempty) Prelude.<*> (x Data..?> "NextToken") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable ListJobs where hashWithSalt _salt ListJobs' {..} = _salt `Prelude.hashWithSalt` maxResults `Prelude.hashWithSalt` nextToken instance Prelude.NFData ListJobs where rnf ListJobs' {..} = Prelude.rnf maxResults `Prelude.seq` Prelude.rnf nextToken instance Data.ToHeaders ListJobs where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ( "AWSIESnowballJobManagementService.ListJobs" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON ListJobs where toJSON ListJobs' {..} = Data.object ( Prelude.catMaybes [ ("MaxResults" Data..=) Prelude.<$> maxResults, ("NextToken" Data..=) Prelude.<$> nextToken ] ) instance Data.ToPath ListJobs where toPath = Prelude.const "/" instance Data.ToQuery ListJobs where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newListJobsResponse' smart constructor. data ListJobsResponse = ListJobsResponse' { -- | Each @JobListEntry@ object contains a job\'s state, a job\'s ID, and a -- value that indicates whether the job is a job part, in the case of -- export jobs. jobListEntries :: Prelude.Maybe [JobListEntry], -- | HTTP requests are stateless. If you use this automatically generated -- @NextToken@ value in your next @ListJobs@ call, your returned -- @JobListEntry@ objects will start from this point in the array. nextToken :: Prelude.Maybe Prelude.Text, -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListJobsResponse' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'jobListEntries', 'listJobsResponse_jobListEntries' - Each @JobListEntry@ object contains a job\'s state, a job\'s ID, and a -- value that indicates whether the job is a job part, in the case of -- export jobs. -- -- 'nextToken', 'listJobsResponse_nextToken' - HTTP requests are stateless. If you use this automatically generated -- @NextToken@ value in your next @ListJobs@ call, your returned -- @JobListEntry@ objects will start from this point in the array. -- -- 'httpStatus', 'listJobsResponse_httpStatus' - The response's http status code. newListJobsResponse :: -- | 'httpStatus' Prelude.Int -> ListJobsResponse newListJobsResponse pHttpStatus_ = ListJobsResponse' { jobListEntries = Prelude.Nothing, nextToken = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | Each @JobListEntry@ object contains a job\'s state, a job\'s ID, and a -- value that indicates whether the job is a job part, in the case of -- export jobs. listJobsResponse_jobListEntries :: Lens.Lens' ListJobsResponse (Prelude.Maybe [JobListEntry]) listJobsResponse_jobListEntries = Lens.lens (\ListJobsResponse' {jobListEntries} -> jobListEntries) (\s@ListJobsResponse' {} a -> s {jobListEntries = a} :: ListJobsResponse) Prelude.. Lens.mapping Lens.coerced -- | HTTP requests are stateless. If you use this automatically generated -- @NextToken@ value in your next @ListJobs@ call, your returned -- @JobListEntry@ objects will start from this point in the array. listJobsResponse_nextToken :: Lens.Lens' ListJobsResponse (Prelude.Maybe Prelude.Text) listJobsResponse_nextToken = Lens.lens (\ListJobsResponse' {nextToken} -> nextToken) (\s@ListJobsResponse' {} a -> s {nextToken = a} :: ListJobsResponse) -- | The response's http status code. listJobsResponse_httpStatus :: Lens.Lens' ListJobsResponse Prelude.Int listJobsResponse_httpStatus = Lens.lens (\ListJobsResponse' {httpStatus} -> httpStatus) (\s@ListJobsResponse' {} a -> s {httpStatus = a} :: ListJobsResponse) instance Prelude.NFData ListJobsResponse where rnf ListJobsResponse' {..} = Prelude.rnf jobListEntries `Prelude.seq` Prelude.rnf nextToken `Prelude.seq` Prelude.rnf httpStatus