samredai commented on code in PR #4858: URL: https://github.com/apache/iceberg/pull/4858#discussion_r881813525
########## .github/workflows/openapi-ci.yml: ########## @@ -0,0 +1,51 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name: "OpenAPI CI" +on: + push: + branches: + - 'master' + - '0.**' + tags: + - 'apache-iceberg-**' + pull_request: + paths: + - '.github/workflows/openapi-ci.yml' + - 'openapi/**' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + openapi: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + - working-directory: ./python + run: | + make generate-openapi + if ! git diff --exit-code src/iceberg/openapi/rest_catalog.py; then Review Comment: Awesome! ########## .github/workflows/openapi-ci.yml: ########## @@ -0,0 +1,51 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name: "OpenAPI CI" +on: + push: + branches: + - 'master' + - '0.**' + tags: + - 'apache-iceberg-**' + pull_request: + paths: + - '.github/workflows/openapi-ci.yml' + - 'openapi/**' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + openapi: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + - working-directory: ./python Review Comment: Is a name here helpful? Maybe something like `name: "Validate that python OpenAPI code is in sync"` ########## python/src/iceberg/openapi/rest_catalog.py: ########## @@ -0,0 +1,503 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# generated by datamodel-codegen: +# filename: rest-catalog-open-api.yaml + +from __future__ import annotations + +from enum import Enum +from typing import Any, Dict, List, Literal, Optional, Union + +from pydantic import BaseModel, Extra, Field + + +class ErrorModel(BaseModel): + """ + JSON error payload returned in a response with further details on the error + """ + + message: str = Field(..., description='Human-readable error message') + type: str = Field( + ..., + description='Internal type definition of the error', + example='NoSuchNamespaceException', + ) + code: int = Field( + ..., description='HTTP response code', example=404, ge=400, le=600 + ) + stack: Optional[List[str]] = None + + +class CatalogConfig(BaseModel): + """ + Server-provided configuration for the catalog. + """ + + overrides: Dict[str, Any] = Field( + ..., + description='Properties that should be used to override client configuration; applied after defaults and client configuration.', + ) + defaults: Dict[str, Any] = Field( + ..., + description='Properties that should be used as default configuration; applied before client configuration.', + ) + + +class Updates(BaseModel): + pass + + +class UpdateNamespacePropertiesRequest(BaseModel): + removals: Optional[List[str]] = Field( + None, example=['department', 'access_group'], unique_items=True + ) + updates: Optional[Union[List[str], Updates]] = Field( + None, example={'owner': 'Hank Bendickson'}, unique_items=True + ) + + +class Namespace(BaseModel): + """ + Reference to one or more levels of a namespace + """ + + __root__: List[str] = Field( + ..., + description='Reference to one or more levels of a namespace', + example=['accounting', 'tax'], + ) + + +class TableIdentifier(BaseModel): + namespace: Namespace + name: str + + +class PrimitiveType(BaseModel): + __root__: str = Field(..., example=['long', 'string', 'fixed[16]', 'decimal(10,2)']) + + +class Transform(BaseModel): + __root__: str = Field( + ..., + example=[ + 'identity', + 'year', + 'month', + 'day', + 'hour', + 'bucket[256]', + 'truncate[16]', + ], + ) + + +class PartitionField(BaseModel): + field_id: Optional[int] = Field(None, alias='field-id') Review Comment: I know python doesn't leave us the option here to use `field-id` as the name, but does `alias` here mean we'd allow either `field-id` _or_ `field_id` in a response? Are there any implications to not strictly requiring `field-id`? cc: @kbendick -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
