-
Notifications
You must be signed in to change notification settings - Fork 91
Add API Spec for Geospatial plugin #893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Changes AnalysisCommit SHA: 858cb84 API ChangesSummary
ReportThe full API changes report is available at: https://github.com/opensearch-project/opensearch-api-specification/actions/runs/15056800388/artifacts/3135519884 API Coverage
|
Spec Test Coverage Analysis
|
Signed-off-by: Weijia Zhao <[email protected]>
post: | ||
operationId: geospatial.geojson_upload_post.0 | ||
x-operation-group: geospatial.geojson_upload_post | ||
x-version-added: '2.11' | ||
description: |- | ||
Use an OpenSearch query to upload `GeoJSON`, operation will fail if index exists. | ||
- When type is `geo_point`, only Point geometry is allowed | ||
- When type is `geo_shape`, all geometry types are allowed (Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, GeometryCollection, Envelope). | ||
requestBody: | ||
$ref: '#/components/requestBodies/geospatial.geojson_upload_post' | ||
responses: | ||
'200': | ||
$ref: '#/components/responses/geospatial.geojson_upload_post@200' | ||
'400': | ||
$ref: '#/components/responses/geospatial.geojson_upload_post@400' | ||
put: | ||
operationId: geospatial.geojson_upload_put.0 | ||
x-operation-group: geospatial.geojson_upload_put | ||
x-version-added: '2.11' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As these appear to be functionally identical, I'd give these the same operation group to allow generated clients to collapse them into one operation. Also so that the grouping reads more like the action being performed I'd potentially rearrange the naming to geospatial.upload_geojson
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to do that initially, but it violates lint:spec. Here's what it complains:
Validating /Users/zweijia/IdeaProjects/opensearch-api-specification/spec ...
[ERROR] Errors found:
{
file: 'namespaces/geospatial.yaml',
location: 'Operation Group: geospatial.geojson_upload',
message: "2 'geospatial.geojson_upload' operations must have identical description property."
}
{
file: 'namespaces/geospatial.yaml',
location: 'Operation Group: geospatial.geojson_upload',
message: "2 'geospatial.geojson_upload' operations must have an identical set of responses."
}
[ERROR]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I just noticed the operation will fail if index exists.
vs regardless if index exists.
, that does mean they shouldn't actually be the same operation. Naming will be tricky to communicate that difference.
spec/namespaces/geospatial.yaml
Outdated
/_plugins/geospatial/ip2geo/datasource: | ||
get: | ||
operationId: geospatial.ip_to_geo_get_all_datasource.0 | ||
x-operation-group: geospatial.ip_to_geo_get_all_datasource | ||
x-version-added: '2.11' | ||
description: Get information about all IP2Geo data sources. | ||
externalDocs: | ||
url: 'https://docs.opensearch.org/docs/latest/ingest-pipelines/processors/ip2geo/' | ||
responses: | ||
'200': | ||
$ref: '#/components/responses/geospatial.ip_to_geo_get_all_datasource@200' | ||
|
||
/_plugins/geospatial/ip2geo/datasource/{datasource_name}: | ||
get: | ||
operationId: geospatial.ip_to_geo_get_datasource.0 | ||
x-operation-group: geospatial.ip_to_geo_get_datasource | ||
x-version-added: '2.11' | ||
description: Get information for a specific IP2Geo data source. | ||
externalDocs: | ||
url: 'https://docs.opensearch.org/docs/latest/ingest-pipelines/processors/ip2geo/#sending-a-get-request' | ||
parameters: | ||
- $ref: '#/components/parameters/geospatial.ip_to_geo_get_datasource::path.datasource_name' | ||
responses: | ||
'200': | ||
$ref: '#/components/responses/geospatial.ip_to_geo_get_datasource@200' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As these have identical response structures, the pattern used elsewhere in the spec is to give these the same operation group, and allow generated clients to make overloads and pick the path based on whether a datasource name was provided.
Again also preferring the action as the start of the name, in this case I'd prefer geospatial.get_ip_to_geo_datasource
.
I'd also be fine with these using get_ip2geo_datasource
for conciseness and matching the naming of the data format, however the regex here currently disallows digits, I think it'd be reasonable to allow digits as long as it isn't the first character of either part of the group. Thoughts @dblock @nhtruong ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As these have identical response structures, the pattern used elsewhere in the spec is to give these the same operation group, and allow generated clients to make overloads and pick the path based on whether a datasource name was provided.
Although these have the same response structure, the request is different. For the first one, it doesn't require to pass in a {datasource_name} parameter , while the second one requires. Also the description is different as well. If we move to a same group, it will violate the lint rule again.
Again also preferring the action as the start of the name, in this case I'd prefer geospatial.get_ip_to_geo_datasource.
Will do
I'd also be fine with these using get_ip2geo_datasource for conciseness and matching the naming of the data format, however the regex here currently disallows digits, I think it'd be reasonable to allow digits as long as it isn't the first character of either part of the group. Thoughts @dblock @nhtruong ?
Yeah, I was using ip2geo_datasource first, and it violate the regex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As these have identical response structures, the pattern used elsewhere in the spec is to give these the same operation group, and allow generated clients to make overloads and pick the path based on whether a datasource name was provided.
Although these have the same response structure, the request is different. For the first one, it doesn't require to pass in a {datasource_name} parameter , while the second one requires. Also the description is different as well. If we move to a same group, it will violate the lint rule again.
Based on the code https://github.com/opensearch-project/geospatial/blob/main/src/main/java/org/opensearch/geospatial/ip2geo/action/RestGetDatasourceHandler.java they're not really separate actions, as the {datasource_name}
can also be a comma delimited array, so it's just "Get one or more IP2Geo data sources, defaulting to returning all if no names specified".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, then I can merge these two actions into one
Signed-off-by: Weijia Zhao <[email protected]>
spec/namespaces/geospatial.yaml
Outdated
in: path | ||
required: true | ||
schema: | ||
type: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this can be a comma delimited array, this should be:
type: string | |
$ref: '../schemas/_common.yaml#/components/schemas/StringOrStringArray' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally all the {datasource_name}
path params can just be {name}
Signed-off-by: Weijia Zhao <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would update the operation group regex to:
const GROUP_REGEX = /^([a-z]+[a-z_]*[a-z]+\.)?([a-z]+[a-z0-9_]*[a-z0-9]+)$/
And rename all the ip_to_geo
s to ip2geo
'200': | ||
$ref: '#/components/responses/geospatial.get_upload_stats@200' | ||
|
||
/_plugins/geospatial/ip2geo/datasource/{name}: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still need the non {name}
path variant, just giving them the same operation-group, description and response $ref
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Signed-off-by: Weijia Zhao <[email protected]>
@@ -11,7 +11,7 @@ import { type OperationSpec, type ValidationError } from 'types' | |||
import _ from 'lodash' | |||
import ValidatorBase from './base/ValidatorBase' | |||
|
|||
const GROUP_REGEX = /^([a-z]+[a-z_]*[a-z]+\.)?([a-z]+[a-z_]*[a-z]+)$/ | |||
const GROUP_REGEX = /^([a-z]+[a-z_]*[a-z]+\.)?([a-z]+[a-z0-9_]*[a-z0-9]+)$/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this regex appears in error messages which are tested verbatim, so will need updating:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Signed-off-by: Weijia Zhao <[email protected]>
Description
This PR adds API Spec for geospatial plugin
Tests
Issues Resolved
Closes #238
Closes opensearch-project/geospatial#658
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.