Skip to content

Commit a5d56e3

Browse files
authored
Merge pull request #65 from Open-EO/pagination
Support for pagination #64
2 parents f22f9a1 + 7665b60 commit a5d56e3

File tree

7 files changed

+623
-193
lines changed

7 files changed

+623
-193
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- New function `getMissingBackends` for `Logs`
1313
- New property `federation:backends` added to the array returned by `validateProcess`
14+
- New functions in `Connection` for paginating through lists:
15+
- `paginateProcesses`
16+
- `paginateCollections`
17+
- `paginateJobs`
18+
- `paginateFiles`
19+
- `paginateUserProcesses`
20+
- `paginateServices`
21+
- The client may add a self link to the links in responses
22+
23+
### Changed
24+
25+
- The `listCollectionItems` function in `Connection` was completely rewritten.
1426

1527
## [2.6.0] - 2024-07-11
1628

openeo.d.ts

Lines changed: 97 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,12 +2020,25 @@ declare module OpenEO {
20202020
* List all collections available on the back-end.
20212021
*
20222022
* The collections returned always comply to the latest STAC version (currently 1.0.0).
2023+
* This function adds a self link to the response if not present.
20232024
*
20242025
* @async
20252026
* @returns {Promise<Collections>} A response compatible to the API specification.
20262027
* @throws {Error}
20272028
*/
20282029
listCollections(): Promise<Collections>;
2030+
/**
2031+
* Paginate through the collections available on the back-end.
2032+
*
2033+
* The collections returned always complies to the latest STAC version (currently 1.0.0).
2034+
* This function adds a self link to the response if not present.
2035+
*
2036+
* @async
2037+
* @param {?number} [limit=50] - The number of collections per request/page as integer. If `null`, requests all collections.
2038+
* @yields {Promise<Collections>} A response compatible to the API specification.
2039+
* @throws {Error}
2040+
*/
2041+
paginateCollections(limit?: number | null): AsyncGenerator<any, void, unknown>;
20292042
/**
20302043
* Get further information about a single collection.
20312044
*
@@ -2039,12 +2052,11 @@ declare module OpenEO {
20392052
describeCollection(collectionId: string): Promise<Collection>;
20402053
/**
20412054
* Loads items for a specific image collection.
2055+
*
20422056
* May not be available for all collections.
20432057
*
20442058
* The items returned always comply to the latest STAC version (currently 1.0.0).
20452059
*
2046-
* This is an experimental API and is subject to change.
2047-
*
20482060
* @async
20492061
* @param {string} collectionId - Collection ID to request items for.
20502062
* @param {?Array.<number>} [spatialExtent=null] - Limits the items to the given bounding box in WGS84:
@@ -2076,20 +2088,40 @@ declare module OpenEO {
20762088
*/
20772089
protected normalizeNamespace(namespace: string | null): string | null;
20782090
/**
2079-
* List processes available on the back-end.
2091+
* List all processes available on the back-end.
20802092
*
20812093
* Requests pre-defined processes by default.
20822094
* Set the namespace parameter to request processes from a specific namespace.
20832095
*
20842096
* Note: The list of namespaces can be retrieved by calling `listProcesses` without a namespace given.
20852097
* The namespaces are then listed in the property `namespaces`.
20862098
*
2099+
* This function adds a self link to the response if not present.
2100+
*
20872101
* @async
20882102
* @param {?string} [namespace=null] - Namespace of the processes (default to `null`, i.e. pre-defined processes). EXPERIMENTAL!
20892103
* @returns {Promise<Processes>} - A response compatible to the API specification.
20902104
* @throws {Error}
20912105
*/
20922106
listProcesses(namespace?: string | null): Promise<Processes>;
2107+
/**
2108+
* Paginate through the processes available on the back-end.
2109+
*
2110+
* Requests pre-defined processes by default.
2111+
* Set the namespace parameter to request processes from a specific namespace.
2112+
*
2113+
* Note: The list of namespaces can be retrieved by calling `listProcesses` without a namespace given.
2114+
* The namespaces are then listed in the property `namespaces`.
2115+
*
2116+
* This function adds a self link to the response if not present.
2117+
*
2118+
* @async
2119+
* @param {?string} [namespace=null] - Namespace of the processes (default to `null`, i.e. pre-defined processes). EXPERIMENTAL!
2120+
* @param {?number} [limit=50] - The number of processes per request/page as integer. If `null`, requests all processes.
2121+
* @yields {Promise<Processes>} - A response compatible to the API specification.
2122+
* @throws {Error}
2123+
*/
2124+
paginateProcesses(namespace?: string | null, limit?: number | null): AsyncGenerator<any, void, unknown>;
20932125
/**
20942126
* Get information about a single process.
20952127
*
@@ -2239,13 +2271,22 @@ declare module OpenEO {
22392271
*/
22402272
describeAccount(): Promise<UserAccount>;
22412273
/**
2242-
* Lists all files from the user workspace.
2274+
* List all files from the user workspace.
22432275
*
22442276
* @async
22452277
* @returns {Promise<ResponseArray.<UserFile>>} A list of files.
22462278
* @throws {Error}
22472279
*/
22482280
listFiles(): Promise<ResponseArray<UserFile>>;
2281+
/**
2282+
* Paginate through the files from the user workspace.
2283+
*
2284+
* @async
2285+
* @param {?number} [limit=50] - The number of files per request/page as integer. If `null`, requests all files.
2286+
* @yields {Promise<ResponseArray.<UserFile>>} A list of files.
2287+
* @throws {Error}
2288+
*/
2289+
paginateFiles(limit?: number | null): AsyncGenerator<any, void, unknown>;
22492290
/**
22502291
* A callback that is executed on upload progress updates.
22512292
*
@@ -2299,14 +2340,24 @@ declare module OpenEO {
22992340
*/
23002341
validateProcess(process: Process): Promise<ValidationResult>;
23012342
/**
2302-
* Lists all user-defined processes of the authenticated user.
2343+
* List all user-defined processes of the authenticated user.
23032344
*
23042345
* @async
23052346
* @param {Array.<UserProcess>} [oldProcesses=[]] - A list of existing user-defined processes to update.
23062347
* @returns {Promise<ResponseArray.<UserProcess>>} A list of user-defined processes.
23072348
* @throws {Error}
23082349
*/
23092350
listUserProcesses(oldProcesses?: Array<UserProcess>): Promise<ResponseArray<UserProcess>>;
2351+
/**
2352+
* Paginates through the user-defined processes of the authenticated user.
2353+
*
2354+
* @async
2355+
* @param {?number} [limit=50] - The number of processes per request/page as integer. If `null`, requests all processes.
2356+
* @param {Array.<UserProcess>} [oldProcesses=[]] - A list of existing user-defined processes to update.
2357+
* @yields {Promise<ResponseArray.<UserProcess>>} A list of user-defined processes.
2358+
* @throws {Error}
2359+
*/
2360+
paginateUserProcesses(limit?: number | null, oldProcesses?: Array<UserProcess>): AsyncGenerator<any, void, unknown>;
23102361
/**
23112362
* Creates a new stored user-defined process at the back-end.
23122363
*
@@ -2359,14 +2410,24 @@ declare module OpenEO {
23592410
*/
23602411
downloadResult(process: Process, targetPath: string, plan?: string | null, budget?: number | null, abortController?: AbortController | null): Promise<void>;
23612412
/**
2362-
* Lists all batch jobs of the authenticated user.
2413+
* List all batch jobs of the authenticated user.
23632414
*
23642415
* @async
23652416
* @param {Array.<Job>} [oldJobs=[]] - A list of existing jobs to update.
23662417
* @returns {Promise<ResponseArray.<Job>>} A list of jobs.
23672418
* @throws {Error}
23682419
*/
23692420
listJobs(oldJobs?: Array<Job>): Promise<ResponseArray<Job>>;
2421+
/**
2422+
* Paginate through the batch jobs of the authenticated user.
2423+
*
2424+
* @async
2425+
* @param {?number} [limit=50] - The number of jobs per request/page as integer. If `null`, requests all jobs.
2426+
* @param {Array.<Job>} [oldJobs=[]] - A list of existing jobs to update.
2427+
* @yields {Promise<ResponseArray.<Job>>} A list of jobs.
2428+
* @throws {Error}
2429+
*/
2430+
paginateJobs(limit?: number | null, oldJobs?: Array<Job>): AsyncGenerator<any, void, unknown>;
23702431
/**
23712432
* Creates a new batch job at the back-end.
23722433
*
@@ -2391,14 +2452,24 @@ declare module OpenEO {
23912452
*/
23922453
getJob(id: string): Promise<Job>;
23932454
/**
2394-
* Lists all secondary web services of the authenticated user.
2455+
* List all secondary web services of the authenticated user.
23952456
*
23962457
* @async
23972458
* @param {Array.<Service>} [oldServices=[]] - A list of existing services to update.
23982459
* @returns {Promise<ResponseArray.<Job>>} A list of services.
23992460
* @throws {Error}
24002461
*/
24012462
listServices(oldServices?: Array<Service>): Promise<ResponseArray<Job>>;
2463+
/**
2464+
* Paginate through the secondary web services of the authenticated user.
2465+
*
2466+
* @async
2467+
* @param {?number} [limit=50] - The number of services per request/page as integer. If `null` (default), requests all services.
2468+
* @param {Array.<Service>} [oldServices=[]] - A list of existing services to update.
2469+
* @yields {Promise<ResponseArray.<Job>>} A list of services.
2470+
* @throws {Error}
2471+
*/
2472+
paginateServices(limit?: number | null, oldServices?: Array<Service>): AsyncGenerator<any, void, unknown>;
24022473
/**
24032474
* Creates a new secondary web service at the back-end.
24042475
*
@@ -2433,9 +2504,10 @@ declare module OpenEO {
24332504
* @protected
24342505
* @param {Array.<*>} arr
24352506
* @param {object.<string, *>} response
2507+
* @param {string} selfUrl
24362508
* @returns {ResponseArray}
24372509
*/
2438-
protected _toResponseArray(arr: Array<any>, response: object<string, any>): ResponseArray;
2510+
protected _toResponseArray(arr: Array<any>, response: object<string, any>, selfUrl: string): ResponseArray;
24392511
/**
24402512
* Get the a link with the given rel type.
24412513
*
@@ -2446,6 +2518,22 @@ declare module OpenEO {
24462518
* @throws {Error}
24472519
*/
24482520
protected _getLinkHref(links: Array<Link>, rel: string | Array<string>): string | null;
2521+
/**
2522+
* Get the URL of the next page from a response.
2523+
*
2524+
* @protected
2525+
* @param {AxiosResponse} response
2526+
* @returns {string | null}
2527+
*/
2528+
protected _getNextLink(response: AxiosResponse): string | null;
2529+
/**
2530+
* Add a self link to the response if not present.
2531+
*
2532+
* @param {object} data - The body of the response as an object.
2533+
* @param {string} selfUrl - The URL of the current request.
2534+
* @returns {object} The modified object.
2535+
*/
2536+
_addSelfLink(data: object, selfUrl: string): object;
24492537
/**
24502538
* Makes all links in the list absolute.
24512539
*
@@ -2909,7 +2997,7 @@ declare module OpenEO {
29092997
/**
29102998
* An array, but enriched with additional details from an openEO API response.
29112999
*
2912-
* Adds two properties: `links` and `federation:missing`.
3000+
* Adds three properties: `url`, `links` and `federation:missing`.
29133001
*/
29143002
export type ResponseArray = any;
29153003
export type ServiceType = object<string, any>;

0 commit comments

Comments
 (0)