From 33926930ccea96240f99130ca1935deb982aca71 Mon Sep 17 00:00:00 2001 From: Chris Durbin Date: Wed, 25 Sep 2024 14:02:50 -0400 Subject: [PATCH] HARMONY-1889: Replace averagingType with average to be consistent with our API parameters. --- services/harmony/app/markdown/apis.md | 4 +-- services/harmony/app/models/data-operation.ts | 2 +- services/harmony/app/models/services/index.ts | 4 +-- .../1.0.0/ogc-api-coverages-v1.0.0.yml | 8 +++--- .../ogc-api-edr/1.1.0/ogc-api-edr-v1.1.0.yml | 28 +++++++++---------- .../harmony/app/util/parameter-parsers.ts | 8 +++--- services/harmony/test/models/services.ts | 4 +-- .../harmony/test/parameters/averaging_type.ts | 24 ++++++++-------- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/services/harmony/app/markdown/apis.md b/services/harmony/app/markdown/apis.md index 66b998b72..cd3b48763 100644 --- a/services/harmony/app/markdown/apis.md +++ b/services/harmony/app/markdown/apis.md @@ -71,7 +71,7 @@ As such it accepts parameters in the URL path as well as query parameters. | ignoreErrors | if "true", continue processing a request to completion even if some items fail. If "false" immediately fail the request. Defaults to true | | destinationUrl | destination url specified by the client; currently only s3 link urls are supported (e.g. s3://my-bucket-name/mypath) and will result in the job being run asynchronously | | variable | the variable(s) to be used for variable subsetting. Multiple variables can be specified as a comma-separated list. This parameter is only used if the url `variable` path element is "parameter_vars" | -| averagingType | requests the data to be averaged over either time or area | +| average | requests the data to be averaged over either time or area | --- **Table {{tableCounter}}** - Harmony OGC Coverages API query parameters @@ -132,7 +132,7 @@ Currently only the `/position`, `/cube`, `/trajectory` and `/area` routes are su | subset | get a subset of the coverage by slicing or trimming along one axis. Harmony supports arbitrary dimension names for subsetting on numeric ranges for that dimension. | | height | number of rows to return in the output coverage | | width | number of columns to return in the output coverage | -| averagingType | requests the data to be averaged over either time or area | +| average | requests the data to be averaged over either time or area | --- **Table {{tableCounter}}** - Harmony extended parameters for all OGC EDR API routes diff --git a/services/harmony/app/models/data-operation.ts b/services/harmony/app/models/data-operation.ts index 9d62c1ae5..195a64160 100644 --- a/services/harmony/app/models/data-operation.ts +++ b/services/harmony/app/models/data-operation.ts @@ -310,7 +310,7 @@ export default class DataOperation { ignoreErrors?: boolean; - averagingType: string; + average: string; destinationUrl: string; diff --git a/services/harmony/app/models/services/index.ts b/services/harmony/app/models/services/index.ts index b1319f7be..562b9e4bd 100644 --- a/services/harmony/app/models/services/index.ts +++ b/services/harmony/app/models/services/index.ts @@ -454,7 +454,7 @@ function supportsDimensionSubsetting(configs: ServiceConfig[]): Service * @returns true if the provided operation requires time averaging and false otherwise */ function requiresTimeAveraging(operation: DataOperation): boolean { - return operation.averagingType === 'time'; + return operation.average === 'time'; } /** @@ -472,7 +472,7 @@ function supportsTimeAveraging(configs: ServiceConfig[]): ServiceConfig * @returns true if the provided operation requires area averaging and false otherwise */ function requiresAreaAveraging(operation: DataOperation): boolean { - return operation.averagingType === 'area'; + return operation.average === 'area'; } /** diff --git a/services/harmony/app/schemas/ogc-api-coverages/1.0.0/ogc-api-coverages-v1.0.0.yml b/services/harmony/app/schemas/ogc-api-coverages/1.0.0/ogc-api-coverages-v1.0.0.yml index 00cc4b06f..2795b2869 100644 --- a/services/harmony/app/schemas/ogc-api-coverages/1.0.0/ogc-api-coverages-v1.0.0.yml +++ b/services/harmony/app/schemas/ogc-api-coverages/1.0.0/ogc-api-coverages-v1.0.0.yml @@ -343,7 +343,7 @@ paths: - $ref: "#/components/parameters/grid" - $ref: "#/components/parameters/extend" - $ref: "#/components/parameters/variable" - - $ref: "#/components/parameters/averagingType" + - $ref: "#/components/parameters/average" responses: "200": description: A coverage's range set. @@ -385,7 +385,7 @@ paths: - $ref: "#/components/parameters/grid" - $ref: "#/components/parameters/extend" - $ref: "#/components/parameters/variable" - - $ref: "#/components/parameters/averagingType" + - $ref: "#/components/parameters/average" requestBody: content: multipart/form-data: @@ -986,8 +986,8 @@ components: items: type: string minLength: 1 - averagingType: - name: averagingType + average: + name: average in: query description: | requests the data to be averaged over time or area diff --git a/services/harmony/app/schemas/ogc-api-edr/1.1.0/ogc-api-edr-v1.1.0.yml b/services/harmony/app/schemas/ogc-api-edr/1.1.0/ogc-api-edr-v1.1.0.yml index c9fcb9c46..c6cf0c89b 100644 --- a/services/harmony/app/schemas/ogc-api-edr/1.1.0/ogc-api-edr-v1.1.0.yml +++ b/services/harmony/app/schemas/ogc-api-edr/1.1.0/ogc-api-edr-v1.1.0.yml @@ -172,7 +172,7 @@ paths: - $ref: "#/components/parameters/granuleName" - $ref: "#/components/parameters/grid" - $ref: "#/components/parameters/extend" - - $ref: "#/components/parameters/averagingType" + - $ref: "#/components/parameters/average" responses: "200": description: A collection's EDR. @@ -259,7 +259,7 @@ paths: type: string extend: type: string - averagingType: + average: type: string responses: "200": @@ -307,7 +307,7 @@ paths: - $ref: "#/components/parameters/granuleName" - $ref: "#/components/parameters/grid" - $ref: "#/components/parameters/extend" - - $ref: "#/components/parameters/averagingType" + - $ref: "#/components/parameters/average" responses: "200": description: A collection's EDR. @@ -400,7 +400,7 @@ paths: type: string extend: type: string - averagingType: + average: type: string responses: "200": @@ -448,7 +448,7 @@ paths: - $ref: "#/components/parameters/granuleName" - $ref: "#/components/parameters/grid" - $ref: "#/components/parameters/extend" - - $ref: "#/components/parameters/averagingType" + - $ref: "#/components/parameters/average" responses: "200": description: A collection's EDR. @@ -539,7 +539,7 @@ paths: type: string extend: type: string - averagingType: + average: type: string responses: "200": @@ -585,7 +585,7 @@ paths: - $ref: "#/components/parameters/granuleName" - $ref: "#/components/parameters/grid" - $ref: "#/components/parameters/extend" - - $ref: "#/components/parameters/averagingType" + - $ref: "#/components/parameters/average" responses: "200": description: A collection's EDR. @@ -671,7 +671,7 @@ paths: type: string extend: type: string - averagingType: + average: type: string responses: "200": @@ -717,7 +717,7 @@ paths: - $ref: "#/components/parameters/granuleName" - $ref: "#/components/parameters/grid" - $ref: "#/components/parameters/extend" - - $ref: "#/components/parameters/averagingType" + - $ref: "#/components/parameters/average" responses: "200": description: A collection's EDR. @@ -804,7 +804,7 @@ paths: type: string extend: type: string - averagingType: + average: type: string responses: "200": @@ -856,7 +856,7 @@ paths: - $ref: "#/components/parameters/granuleName" - $ref: "#/components/parameters/grid" - $ref: "#/components/parameters/extend" - - $ref: "#/components/parameters/averagingType" + - $ref: "#/components/parameters/average" responses: "200": description: A collection's EDR. @@ -959,7 +959,7 @@ paths: type: string extend: type: string - averagingType: + average: type: string responses: "200": @@ -1662,8 +1662,8 @@ components: required: false schema: type: string - averagingType: - name: averagingType + average: + name: average in: query description: | requests the data to be averaged over time or area diff --git a/services/harmony/app/util/parameter-parsers.ts b/services/harmony/app/util/parameter-parsers.ts index 181a2e477..b6aa0fa75 100644 --- a/services/harmony/app/util/parameter-parsers.ts +++ b/services/harmony/app/util/parameter-parsers.ts @@ -212,11 +212,11 @@ export function handleWidth( export function handleAveragingType( operation: DataOperation, query: Record): void { - if (query.averagingtype) { - const value = query.averagingtype.toLowerCase(); + if (query.average) { + const value = query.average.toLowerCase(); if (value !== 'time' && value !== 'area') { - throw new RequestValidationError('query parameter "averagingType" must be either "time" or "area"'); + throw new RequestValidationError('query parameter "average" must be either "time" or "area"'); } - operation.averagingType = value; + operation.average = value; } } diff --git a/services/harmony/test/models/services.ts b/services/harmony/test/models/services.ts index c6f084a4e..da6de6f76 100644 --- a/services/harmony/test/models/services.ts +++ b/services/harmony/test/models/services.ts @@ -201,7 +201,7 @@ describe('services.chooseServiceConfig and services.buildService', function () { describe('and the request needs area averaging', function () { beforeEach(function () { - this.operation.averagingType = 'area'; + this.operation.average = 'area'; }); it('chooses the service that supports area averaging', function () { @@ -212,7 +212,7 @@ describe('services.chooseServiceConfig and services.buildService', function () { describe('and the request needs time averaging', function () { beforeEach(function () { - this.operation.averagingType = 'time'; + this.operation.average = 'time'; }); it('chooses the service that supports time averaging', function () { diff --git a/services/harmony/test/parameters/averaging_type.ts b/services/harmony/test/parameters/averaging_type.ts index 7d0ca004d..6a2e7fe4a 100644 --- a/services/harmony/test/parameters/averaging_type.ts +++ b/services/harmony/test/parameters/averaging_type.ts @@ -14,7 +14,7 @@ import { partialApply } from '../helpers/util'; const collection = 'C1233800302-EEDTEST'; const edrVersion = '1.1.0'; -// We want to test the averagingType parameter on each of the following APIs, so we'll +// We want to test the average parameter on each of the following APIs, so we'll // run the same tests against each in a loop const endpointFunctions = [{ label: 'OGC Coverages', @@ -39,12 +39,12 @@ const endpointFunctions = [{ }]; for (const { label, endpointFn, extraArgs } of endpointFunctions) { - describe(`averagingType for ${label} API`, function () { + describe(`average for ${label} API`, function () { hookServersStartStop(); - describe('when making a request with averagingType time', function () { + describe('when making a request with average time', function () { const averagingTimeQuery = { - averagingType: 'time', + average: 'time', }; describe('for a collection that can support it', function () { @@ -57,7 +57,7 @@ for (const { label, endpointFn, extraArgs } of endpointFunctions) { }); xit('specifies to perform time averaging in the operation', async function () { - expect(this.service.operation.averagingType).to.equal('time'); + expect(this.service.operation.average).to.equal('time'); }); }); @@ -77,9 +77,9 @@ for (const { label, endpointFn, extraArgs } of endpointFunctions) { }); }); - describe('when making a request with averagingType area', function () { + describe('when making a request with average area', function () { const averagingAreaQuery = { - averagingType: 'area', + average: 'area', }; describe('for a collection that can support it', function () { @@ -92,7 +92,7 @@ for (const { label, endpointFn, extraArgs } of endpointFunctions) { }); xit('specifies to perform area averaging in the operation', async function () { - expect(this.service.operation.averagingType).to.equal('area'); + expect(this.service.operation.average).to.equal('area'); }); }); @@ -112,9 +112,9 @@ for (const { label, endpointFn, extraArgs } of endpointFunctions) { }); }); - describe('when making a request with an invalid averagingType', function () { + describe('when making a request with an invalid average', function () { const badAveragingQuery = { - averagingType: 'no not that', + average: 'no not that', }; endpointFn({ query: { ...badAveragingQuery, ...extraArgs } }); @@ -122,10 +122,10 @@ for (const { label, endpointFn, extraArgs } of endpointFunctions) { expect(this.res.status).to.equal(400); }); - it('returns a message indicating that the averagingType value is invalid', async function () { + it('returns a message indicating that the average value is invalid', async function () { const errorMessage = { 'code': 'harmony.RequestValidationError', - 'description': 'Error: query parameter "averagingType" must be either "time" or "area"', + 'description': 'Error: query parameter "average" must be either "time" or "area"', }; expect(this.res.body).to.eql(errorMessage); });