From e792fff6db1bede18bf36871a7119bb8bfde3fb9 Mon Sep 17 00:00:00 2001 From: Honah J Date: Sun, 12 Jan 2025 22:00:53 -0800 Subject: [PATCH 01/17] Add policy management APIs spec --- spec/rest-catalog-open-api.yaml | 389 ++++++++++++++++++++++++++++++++ 1 file changed, 389 insertions(+) diff --git a/spec/rest-catalog-open-api.yaml b/spec/rest-catalog-open-api.yaml index cfcd4987d..13a001c65 100644 --- a/spec/rest-catalog-open-api.yaml +++ b/spec/rest-catalog-open-api.yaml @@ -1595,6 +1595,239 @@ paths: $ref: '#/components/responses/ServiceUnavailableResponse' 5XX: $ref: '#/components/responses/ServerErrorResponse' + + /v1/{prefix}/policies: + parameters: + - $ref: '#/components/parameters/prefix' + + post: + tags: + - Catalog API + summary: 'Create a policy' + operationId: createPolicy + description: + Create a Policy + + # TODO: add description of policy + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreatePolicyRequest' + responses: + 200: + $ref: '#/components/responses/CreatePolicyResponse' + 400: + $ref: '#/components/responses/BadRequestErrorResponse' + 401: + $ref: '#/components/responses/UnauthorizedResponse' + 403: + $ref: '#/components/responses/ForbiddenResponse' + 419: + $ref: '#/components/responses/AuthenticationTimeoutResponse' + 503: + $ref: '#/components/responses/ServiceUnavailableResponse' + 5XX: + $ref: '#/components/responses/ServerErrorResponse' + + /v1/{prefix}/policies/{policy}: + parameters: + - $ref: '#/components/parameters/prefix' + - $ref: '#/components/parameters/policy' + + get: + tags: + - Catalog API + summary: 'Get a policy' + operationId: getPolicy + description: + Get a policy from the catalog + + responses: + 200: + $ref: '#/components/responses/LoadPolicyResponse' + 400: + $ref: '#/components/responses/BadRequestErrorResponse' + 401: + $ref: '#/components/responses/UnauthorizedResponse' + 403: + $ref: '#/components/responses/ForbiddenResponse' + 404: + description: + Not Found - NoSuchPolicyException, policy to get does not exist + content: + application/json: + schema: + $ref: '#/components/schemas/IcebergErrorResponse' + examples: + PolicyToGetDoesNotExist: + $ref: '#/components/examples/NoSuchPolicyError' + 419: + $ref: '#/components/responses/AuthenticationTimeoutResponse' + 503: + $ref: '#/components/responses/ServiceUnavailableResponse' + 5XX: + $ref: '#/components/responses/ServerErrorResponse' + + post: + tags: + - Catalog API + summary: Update a policy + operationId: updatePolicy + description: + Update a policy + + The owner_id, policy_id, and policy_type cannot be updated + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdatePolicyRequest' + + responses: + 200: + $ref: '#/components/responses/UpdatePolicyResponse' + 400: + $ref: '#/components/responses/BadRequestErrorResponse' + 401: + $ref: '#/components/responses/UnauthorizedResponse' + 403: + $ref: '#/components/responses/ForbiddenResponse' + 404: + description: + Not Found - NoSuchPolicyException, policy to get does not exist + content: + application/json: + schema: + $ref: '#/components/schemas/IcebergErrorResponse' + examples: + PolicyToUpdateDoesNotExist: + $ref: '#/components/examples/NoSuchPolicyError' + 419: + $ref: '#/components/responses/AuthenticationTimeoutResponse' + 503: + $ref: '#/components/responses/ServiceUnavailableResponse' + 5XX: + $ref: '#/components/responses/ServerErrorResponse' + + delete: + tags: + - Catalog API + summary: Delete a policy from the catalog + operationId: deletePolicy + description: Remove a policy from the catalog + responses: + 204: + description: Success, no content + 400: + $ref: '#/components/responses/BadRequestErrorResponse' + 401: + $ref: '#/components/responses/UnauthorizedResponse' + 403: + $ref: '#/components/responses/ForbiddenResponse' + 404: + description: + Not Found - NoSuchPolicyException, policy to get does not exist + content: + application/json: + schema: + $ref: '#/components/schemas/IcebergErrorResponse' + examples: + PolicyToDeleteDoesNotExist: + $ref: '#/components/examples/NoSuchPolicyError' + 419: + $ref: '#/components/responses/AuthenticationTimeoutResponse' + 503: + $ref: '#/components/responses/ServiceUnavailableResponse' + 5XX: + $ref: '#/components/responses/ServerErrorResponse' + + /v1/{prefix}/policies/{policy}/mappings/{entity-id}: + parameters: + - $ref: '#/components/parameters/prefix' + - $ref: '#/components/parameters/policy' + - $ref: '#/components/parameters/entity-id' + + post: + tags: + - Catalog API + summary: Create a mapping between a policy and a resource entity + operationId: setPolicy + description: Create a mapping between a policy and a resource entity + requestBody: + required: false + content: + application/json: + schema: + $ref: '#/components/schemas/SetPolicyRequest' + + responses: + 204: + description: Success, no content + 400: + $ref: '#/components/responses/BadRequestErrorResponse' + 401: + $ref: '#/components/responses/UnauthorizedResponse' + 403: + $ref: '#/components/responses/ForbiddenResponse' + 404: + description: + Not Found - NoSuchPolicyException, policy to get does not exist + content: + application/json: + schema: + $ref: '#/components/schemas/IcebergErrorResponse' + examples: + PolicyToSetDoesNotExist: + $ref: '#/components/examples/NoSuchPolicyError' + EntityToSetDoesNotExist: + $ref: '#/components/examples/NoSuchEntityError' + 419: + $ref: '#/components/responses/AuthenticationTimeoutResponse' + 503: + $ref: '#/components/responses/ServiceUnavailableResponse' + 5XX: + $ref: '#/components/responses/ServerErrorResponse' + + delete: + tags: + - Catalog API + summary: Remove a mapping between a policy and an entity + operationId: unsetPolicy + description: Remove a mapping between a policy and an entity + responses: + 204: + description: Success, no content + 400: + $ref: '#/components/responses/BadRequestErrorResponse' + 401: + $ref: '#/components/responses/UnauthorizedResponse' + 403: + $ref: '#/components/responses/ForbiddenResponse' + 404: + description: + Not Found - NoSuchPolicyException, policy to get does not exist + content: + application/json: + schema: + $ref: '#/components/schemas/IcebergErrorResponse' + examples: + PolicyToUnsetDoesNotExist: + $ref: '#/components/examples/NoSuchPolicyError' + EntityToUnsetDoesNotExist: + $ref: '#/components/examples/NoSuchEntityError' + MappingToUnsetDoesNotExist: + $ref: '#/components/examples/NoSuchMappingError' + 419: + $ref: '#/components/responses/AuthenticationTimeoutResponse' + 503: + $ref: '#/components/responses/ServiceUnavailableResponse' + 5XX: + $ref: '#/components/responses/ServerErrorResponse' + + components: @@ -1688,6 +1921,24 @@ components: type: integer minimum: 1 + policy: + name: policy + in: path + description: id of a policy + required: true + schema: + type: string + example: 'b792559c-c4c2-45aa-bff0-831eba3c2126' + + entity-id: + name: entityId + in: path + description: id of an entity in Polaris + required: true + schema: + type: string + example: '7e7230c8-bcc3-49ea-87f3-e943ddd48e73' + ############################## # Application Schema Objects # ############################## @@ -3977,6 +4228,90 @@ components: items: type: integer description: "List of equality field IDs" + + Policy: + type: object + required: + - policy-id + - policy-type + - policy-type-schema-version + - name + - content + - version + properties: + policy-id: + type: string + policy-type: + type: string + policy-type-schema-version: + type: integer + name: + type: string + description: + type: string + content: + $ref: '#/components/schemas/PolicyContent' + version: + type: integer + created-at-ms: + type: integer + format: int64 + updated-at-ms: + type: integer + format: int64 + + PolicyContent: + anyOf: + - type: object + - type: string + + CreatePolicyRequest: + type: object + required: + - name + - type + - description + - content + properties: + name: + type: string + type: + type: string + description: + type: string + content: + $ref: '#/components/schemas/PolicyContent' + subjects: + type: array + uniqueItems: true + items: + type: string # subject id + + LoadPolicyResult: + type: object + properties: + policy: + $ref: '#/components/schemas/Policy' + + UpdatePolicyRequest: + type: object + properties: + name: + type: string + description: + type: string + content: + $ref: '#/components/schemas/PolicyContent' + + SetPolicyRequest: + type: object + properties: + parameters: + type: object + additionalProperties: + type: string + + ############################# # Reusable Response Objects # @@ -4225,6 +4560,30 @@ components: schema: $ref: '#/components/schemas/LoadCredentialsResponse' + CreatePolicyResponse: + description: Policy object result after creating a policy + content: + application/json: + schema: + $ref: '#/components/schemas/LoadPolicyResult' + + LoadPolicyResponse: + description: Policy object result when getting a policy + content: + application/json: + schema: + $ref: '#/components/schemas/LoadPolicyResult' + + UpdatePolicyResponse: + description: + Response used when a policy is successfully updated + + The updated policy JSON is returned in the policy field + content: + application/json: + schema: + $ref: '#/components/schemas/LoadPolicyResult' + ####################################### # Common examples of different values # ####################################### @@ -4373,6 +4732,36 @@ components: "code": 409 } } + + NoSuchPolicyError: + summary: The requested policy does not exist + value: { + "error": { + "message": "The given policy does not exist", + "type": "NoSuchPolicyException", + "code": 404 + } + } + + NoSuchEntityError: + summary: The requested entity does not exist + value: { + "error": { + "message": "The given entity does not exist", + "type": "NoSuchEntityException", + "code": 404 + } + } + + NoSuchMappingError: + summary: The requested mapping between policy and entity does not exist + value: { + "error": { + "message": "The given mapping between policy and entity does not exist", + "type": "NoSuchMappingException", + "code": 404 + } + } securitySchemes: OAuth2: From 35df43b833714dc932b8cb3a425ca4ebe84b639c Mon Sep 17 00:00:00 2001 From: Honah J Date: Mon, 13 Jan 2025 10:35:14 -0800 Subject: [PATCH 02/17] update errors and fix format issues --- spec/rest-catalog-open-api.yaml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/spec/rest-catalog-open-api.yaml b/spec/rest-catalog-open-api.yaml index 13a001c65..70f58746d 100644 --- a/spec/rest-catalog-open-api.yaml +++ b/spec/rest-catalog-open-api.yaml @@ -1744,7 +1744,7 @@ paths: 5XX: $ref: '#/components/responses/ServerErrorResponse' - /v1/{prefix}/policies/{policy}/mappings/{entity-id}: + /v1/{prefix}/policies/{policy}/mappings/{entityId}: parameters: - $ref: '#/components/parameters/prefix' - $ref: '#/components/parameters/policy' @@ -1774,7 +1774,7 @@ paths: $ref: '#/components/responses/ForbiddenResponse' 404: description: - Not Found - NoSuchPolicyException, policy to get does not exist + Not Found - NoSuchPolicyException, NoSuchEntityException content: application/json: schema: @@ -1784,6 +1784,15 @@ paths: $ref: '#/components/examples/NoSuchPolicyError' EntityToSetDoesNotExist: $ref: '#/components/examples/NoSuchEntityError' + 409: + description: Conflict - The mapping already exists + content: + application/json: + schema: + $ref: '#/components/schemas/IcebergErrorResponse' + examples: + MappingAlreadyExistsError: + $ref: '#/components/examples/MappingAlreadyExistsError' 419: $ref: '#/components/responses/AuthenticationTimeoutResponse' 503: @@ -1808,7 +1817,7 @@ paths: $ref: '#/components/responses/ForbiddenResponse' 404: description: - Not Found - NoSuchPolicyException, policy to get does not exist + Not Found - NoSuchPolicyException, NoSuchEntityException, NoSuchMappingException content: application/json: schema: @@ -4763,6 +4772,16 @@ components: } } + MappingAlreadyExistsError: + summary: The mapping between the given policy and entity already exists + value: { + "error": { + "message": "The mapping between the given policy and entity does not exist", + "type": "MappingAlreadyExistsError", + "code": 409 + } + } + securitySchemes: OAuth2: type: oauth2 From 9e3d9939b070d9069c7e6d0959cdb3c40b27a730 Mon Sep 17 00:00:00 2001 From: Honah J Date: Tue, 14 Jan 2025 14:37:51 -0800 Subject: [PATCH 03/17] Update spec based on discussion --- spec/rest-catalog-open-api.yaml | 84 +++++++++++++++++++++++++++------ 1 file changed, 69 insertions(+), 15 deletions(-) diff --git a/spec/rest-catalog-open-api.yaml b/spec/rest-catalog-open-api.yaml index 70f58746d..7ebf15362 100644 --- a/spec/rest-catalog-open-api.yaml +++ b/spec/rest-catalog-open-api.yaml @@ -1670,7 +1670,7 @@ paths: 5XX: $ref: '#/components/responses/ServerErrorResponse' - post: + put: tags: - Catalog API summary: Update a policy @@ -1744,11 +1744,10 @@ paths: 5XX: $ref: '#/components/responses/ServerErrorResponse' - /v1/{prefix}/policies/{policy}/mappings/{entityId}: + /v1/{prefix}/policies/{policy}/mappings: parameters: - $ref: '#/components/parameters/prefix' - $ref: '#/components/parameters/policy' - - $ref: '#/components/parameters/entity-id' post: tags: @@ -1757,7 +1756,7 @@ paths: operationId: setPolicy description: Create a mapping between a policy and a resource entity requestBody: - required: false + required: true content: application/json: schema: @@ -1806,6 +1805,13 @@ paths: summary: Remove a mapping between a policy and an entity operationId: unsetPolicy description: Remove a mapping between a policy and an entity + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UnsetPolicyRequest' + responses: 204: description: Success, no content @@ -1933,11 +1939,11 @@ components: policy: name: policy in: path - description: id of a policy + description: a policy name required: true schema: type: string - example: 'b792559c-c4c2-45aa-bff0-831eba3c2126' + example: 'compaction-policy' entity-id: name: entityId @@ -4241,19 +4247,19 @@ components: Policy: type: object required: + - owner_id - policy-id - policy-type - - policy-type-schema-version - name - content - version properties: + owner-id: + type: string policy-id: type: string policy-type: type: string - policy-type-schema-version: - type: integer name: type: string description: @@ -4279,7 +4285,6 @@ components: required: - name - type - - description - content properties: name: @@ -4290,11 +4295,6 @@ components: type: string content: $ref: '#/components/schemas/PolicyContent' - subjects: - type: array - uniqueItems: true - items: - type: string # subject id LoadPolicyResult: type: object @@ -4314,12 +4314,66 @@ components: SetPolicyRequest: type: object + required: + - entity properties: + entity: + $ref: '#/components/schemas/EntityIdentifier' parameters: type: object additionalProperties: type: string + UnsetPolicyRequest: + type: object + required: + - entity + properties: + entity: + $ref: '#/components/schemas/EntityIdentifier' + + CatalogIdentifier: + type: object + required: + - catalog + properties: + catalog: + type: string + + NamespaceIdentifier: + type: object + required: + - catalog + - namespace + properties: + catalog: + type: string + nullable: false + namespace: + $ref: '#/components/schemas/Namespace' + + TableLikeIdentifier: + type: object + required: + - catalog + - namespace + - name + properties: + catalog: + type: string + nullable: false + namespace: + $ref: '#/components/schemas/Namespace' + name: + type: string + nullable: false + + EntityIdentifier: + oneOf: + - $ref: '#/components/schemas/CatalogIdentifier' + - $ref: '#/components/schemas/NamespaceIdentifier' + - $ref: '#/components/schemas/TableLikeIdentifier' + ############################# From d7526ac2331f045ebebe881baec9e5afa36659e3 Mon Sep 17 00:00:00 2001 From: Honah J Date: Wed, 15 Jan 2025 21:16:14 -0800 Subject: [PATCH 04/17] update rest spec and generate models --- api/iceberg-service/build.gradle.kts | 14 + .../types/policy/CatalogIdentifier.java | 121 ++++++++ .../types/policy/CreatePolicyRequest.java | 175 +++++++++++ .../types/policy/EntityIdentifier.java | 136 ++++++++ .../types/policy/LoadPolicyResult.java | 103 ++++++ .../types/policy/NamespaceIdentifier.java | 146 +++++++++ .../polaris/service/types/policy/Policy.java | 293 ++++++++++++++++++ .../service/types/policy/PolicyContent.java | 80 +++++ .../types/policy/SetPolicyRequest.java | 138 +++++++++ .../types/policy/TableLikeIdentifier.java | 167 ++++++++++ .../types/policy/UnsetPolicyRequest.java | 113 +++++++ .../types/policy/UpdatePolicyRequest.java | 139 +++++++++ spec/rest-catalog-open-api.yaml | 89 +++--- 13 files changed, 1677 insertions(+), 37 deletions(-) create mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CatalogIdentifier.java create mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CreatePolicyRequest.java create mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/EntityIdentifier.java create mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/LoadPolicyResult.java create mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/NamespaceIdentifier.java create mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/Policy.java create mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/PolicyContent.java create mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/SetPolicyRequest.java create mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/TableLikeIdentifier.java create mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UnsetPolicyRequest.java create mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UpdatePolicyRequest.java diff --git a/api/iceberg-service/build.gradle.kts b/api/iceberg-service/build.gradle.kts index a0e4768bb..e638862eb 100644 --- a/api/iceberg-service/build.gradle.kts +++ b/api/iceberg-service/build.gradle.kts @@ -49,6 +49,7 @@ openApiGenerate { generatorName = "jaxrs-resteasy" outputDir = "$projectDir/build/generated" apiPackage = "org.apache.polaris.service.catalog.api" + modelPackage = "org.apache.polaris.services.types" ignoreFileOverride = "$rootDir/.openapi-generator-ignore" removeOperationIdPrefix = true templateDir = "$rootDir/server-templates" @@ -101,6 +102,19 @@ openApiGenerate { "NotificationRequest" to "org.apache.polaris.service.types.NotificationRequest", "TableUpdateNotification" to "org.apache.polaris.service.types.TableUpdateNotification", "NotificationType" to "org.apache.polaris.service.types.NotificationType", + + // Policy managements + "Policy" to "org.apache.polaris.service.types.policy.Policy", + "PolicyContent" to "org.apache.polaris.service.types.policy.PolicyContent", + "CreatePolicyRequest" to "org.apache.polaris.service.types.policy.CreatePolicyRequest", + "LoadPolicyResult" to "org.apache.polaris.service.types.policy.LoadPolicyResult", + "UpdatePolicyRequest" to "org.apache.polaris.service.types.policy.UpdatePolicyRequest", + "SetPolicyRequest" to "org.apache.polaris.service.types.policy.SetPolicyRequest", + "UnsetPolicyRequest" to "org.apache.polaris.service.types.policy.UnsetPolicyRequest", + "CatalogIdentifier" to "org.apache.iceberg.service.types.policy.CatalogIdentifier", + "NamespaceIdentifier" to "org.apache.iceberg.service.types.policy.NamespaceIdentifier", + "TableLikeIdentifier" to "org.apache.iceberg.service.types.policy.TableLikeIdentifier", + "EntityIdentifier" to "org.apache.iceberg.service.types.policy.EntityIdentifier", ) } diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CatalogIdentifier.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CatalogIdentifier.java new file mode 100644 index 000000000..2cc5e7d2e --- /dev/null +++ b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CatalogIdentifier.java @@ -0,0 +1,121 @@ +/* + * 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. + */ +package org.apache.polaris.service.types.policy; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.constraints.*; +import java.util.Objects; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", + date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", + comments = "Generator version: 7.10.0") +public class CatalogIdentifier extends EntityIdentifier { + + @NotNull private final String catalog; + + /** */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(value = "catalog", required = true) + public String getCatalog() { + return catalog; + } + + @JsonCreator + public CatalogIdentifier( + @JsonProperty(value = "catalog", required = true) String catalog, + @JsonProperty(value = "type", required = true) TypeEnum type) { + super(type); + this.catalog = catalog; + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(String catalog, TypeEnum type) { + return new Builder(catalog, type); + } + + public static final class Builder { + private String catalog; + private TypeEnum type; + + private Builder() {} + + private Builder(String catalog, TypeEnum type) { + this.catalog = catalog; + this.type = type; + } + + public Builder setCatalog(String catalog) { + this.catalog = catalog; + return this; + } + + public Builder setType(TypeEnum type) { + this.type = type; + return this; + } + + public CatalogIdentifier build() { + CatalogIdentifier inst = new CatalogIdentifier(catalog, type); + return inst; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CatalogIdentifier catalogIdentifier = (CatalogIdentifier) o; + return super.equals(o) && Objects.equals(this.catalog, catalogIdentifier.catalog); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), catalog); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CatalogIdentifier {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" catalog: ").append(toIndentedString(catalog)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CreatePolicyRequest.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CreatePolicyRequest.java new file mode 100644 index 000000000..0f766785b --- /dev/null +++ b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CreatePolicyRequest.java @@ -0,0 +1,175 @@ +/* + * 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. + */ +package org.apache.polaris.service.types.policy; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.constraints.*; +import java.util.Objects; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", + date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", + comments = "Generator version: 7.10.0") +public class CreatePolicyRequest { + + @NotNull private final String name; + @NotNull private final String type; + private final String description; + @NotNull private final Object content; + + /** */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(value = "name", required = true) + public String getName() { + return name; + } + + /** */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(value = "type", required = true) + public String getType() { + return type; + } + + /** */ + @ApiModelProperty(value = "") + @JsonProperty(value = "description") + public String getDescription() { + return description; + } + + /** */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(value = "content", required = true) + public Object getContent() { + return content; + } + + @JsonCreator + public CreatePolicyRequest( + @JsonProperty(value = "name", required = true) String name, + @JsonProperty(value = "type", required = true) String type, + @JsonProperty(value = "description") String description, + @JsonProperty(value = "content", required = true) Object content) { + this.name = name; + this.type = type; + this.description = description; + this.content = Objects.requireNonNullElse(content, null); + } + + public CreatePolicyRequest(String name, String type, Object content) { + this.name = name; + this.type = type; + this.description = null; + this.content = Objects.requireNonNullElse(content, null); + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(String name, String type, Object content) { + return new Builder(name, type, content); + } + + public static final class Builder { + private String name; + private String type; + private String description; + private Object content; + + private Builder() {} + + private Builder(String name, String type, Object content) { + this.name = name; + this.type = type; + this.content = Objects.requireNonNullElse(content, null); + } + + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setType(String type) { + this.type = type; + return this; + } + + public Builder setDescription(String description) { + this.description = description; + return this; + } + + public Builder setContent(Object content) { + this.content = content; + return this; + } + + public CreatePolicyRequest build() { + CreatePolicyRequest inst = new CreatePolicyRequest(name, type, description, content); + return inst; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreatePolicyRequest createPolicyRequest = (CreatePolicyRequest) o; + return Objects.equals(this.name, createPolicyRequest.name) + && Objects.equals(this.type, createPolicyRequest.type) + && Objects.equals(this.description, createPolicyRequest.description) + && Objects.equals(this.content, createPolicyRequest.content); + } + + @Override + public int hashCode() { + return Objects.hash(name, type, description, content); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreatePolicyRequest {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/EntityIdentifier.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/EntityIdentifier.java new file mode 100644 index 000000000..ca0b2e662 --- /dev/null +++ b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/EntityIdentifier.java @@ -0,0 +1,136 @@ +/* + * 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. + */ +package org.apache.polaris.service.types.policy; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.constraints.*; +import java.util.Objects; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", + date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", + comments = "Generator version: 7.10.0") +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "type", + visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = CatalogIdentifier.class, name = "catalog"), + @JsonSubTypes.Type(value = NamespaceIdentifier.class, name = "namespace"), + @JsonSubTypes.Type(value = TableLikeIdentifier.class, name = "table-like"), +}) +public class EntityIdentifier { + + /** Gets or Sets type */ + public enum TypeEnum { + CATALOG("catalog"), + + NAMESPACE("namespace"), + + TABLE_LIKE("table-like"); + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + } + + @NotNull private final TypeEnum type; + + /** */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(value = "type", required = true) + public TypeEnum getType() { + return type; + } + + @JsonCreator + public EntityIdentifier(@JsonProperty(value = "type", required = true) TypeEnum type) { + this.type = type; + } + + public static final class Builder { + private TypeEnum type; + + private Builder() {} + + private Builder(TypeEnum type) { + this.type = type; + } + + public Builder setType(TypeEnum type) { + this.type = type; + return this; + } + + public EntityIdentifier build() { + EntityIdentifier inst = new EntityIdentifier(type); + return inst; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EntityIdentifier entityIdentifier = (EntityIdentifier) o; + return Objects.equals(this.type, entityIdentifier.type); + } + + @Override + public int hashCode() { + return Objects.hash(type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EntityIdentifier {\n"); + + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/LoadPolicyResult.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/LoadPolicyResult.java new file mode 100644 index 000000000..89cc74c14 --- /dev/null +++ b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/LoadPolicyResult.java @@ -0,0 +1,103 @@ +/* + * 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. + */ +package org.apache.polaris.service.types.policy; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.Valid; +import java.util.Objects; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", + date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", + comments = "Generator version: 7.10.0") +public class LoadPolicyResult { + + @Valid private final Policy policy; + + /** */ + @ApiModelProperty(value = "") + @JsonProperty(value = "policy") + public Policy getPolicy() { + return policy; + } + + @JsonCreator + public LoadPolicyResult(@JsonProperty(value = "policy") Policy policy) { + this.policy = policy; + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private Policy policy; + + private Builder() {} + + public Builder setPolicy(Policy policy) { + this.policy = policy; + return this; + } + + public LoadPolicyResult build() { + LoadPolicyResult inst = new LoadPolicyResult(policy); + return inst; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LoadPolicyResult loadPolicyResult = (LoadPolicyResult) o; + return Objects.equals(this.policy, loadPolicyResult.policy); + } + + @Override + public int hashCode() { + return Objects.hash(policy); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LoadPolicyResult {\n"); + + sb.append(" policy: ").append(toIndentedString(policy)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/NamespaceIdentifier.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/NamespaceIdentifier.java new file mode 100644 index 000000000..a126fa08e --- /dev/null +++ b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/NamespaceIdentifier.java @@ -0,0 +1,146 @@ +/* + * 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. + */ +package org.apache.polaris.service.types.policy; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.constraints.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", + date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", + comments = "Generator version: 7.10.0") +public class NamespaceIdentifier extends EntityIdentifier { + + @NotNull private final String catalog; + @NotNull private final List namespace; + + /** */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(value = "catalog", required = true) + public String getCatalog() { + return catalog; + } + + /** Reference to one or more levels of a namespace */ + @ApiModelProperty( + example = "[\"accounting\",\"tax\"]", + required = true, + value = "Reference to one or more levels of a namespace") + @JsonProperty(value = "namespace", required = true) + public List getNamespace() { + return namespace; + } + + @JsonCreator + public NamespaceIdentifier( + @JsonProperty(value = "catalog", required = true) String catalog, + @JsonProperty(value = "namespace", required = true) List namespace, + @JsonProperty(value = "type", required = true) TypeEnum type) { + super(type); + this.catalog = catalog; + this.namespace = Objects.requireNonNullElse(namespace, new ArrayList<>()); + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(String catalog, List namespace, TypeEnum type) { + return new Builder(catalog, namespace, type); + } + + public static final class Builder { + private String catalog; + private List namespace; + private TypeEnum type; + + private Builder() {} + + private Builder(String catalog, List namespace, TypeEnum type) { + this.catalog = catalog; + this.namespace = Objects.requireNonNullElse(namespace, new ArrayList<>()); + this.type = type; + } + + public Builder setCatalog(String catalog) { + this.catalog = catalog; + return this; + } + + public Builder setNamespace(List namespace) { + this.namespace = namespace; + return this; + } + + public Builder setType(TypeEnum type) { + this.type = type; + return this; + } + + public NamespaceIdentifier build() { + NamespaceIdentifier inst = new NamespaceIdentifier(catalog, namespace, type); + return inst; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NamespaceIdentifier namespaceIdentifier = (NamespaceIdentifier) o; + return super.equals(o) + && Objects.equals(this.catalog, namespaceIdentifier.catalog) + && Objects.equals(this.namespace, namespaceIdentifier.namespace); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), catalog, super.hashCode(), namespace); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NamespaceIdentifier {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" catalog: ").append(toIndentedString(catalog)).append("\n"); + sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/Policy.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/Policy.java new file mode 100644 index 000000000..1a9225549 --- /dev/null +++ b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/Policy.java @@ -0,0 +1,293 @@ +/* + * 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. + */ +package org.apache.polaris.service.types.policy; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.constraints.*; +import java.util.Objects; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", + date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", + comments = "Generator version: 7.10.0") +public class Policy { + + private final String ownerId; + @NotNull private final String policyId; + @NotNull private final String policyType; + @NotNull private final String name; + private final String description; + @NotNull private final Object content; + @NotNull private final Integer version; + private final Long createdAtMs; + private final Long updatedAtMs; + + /** */ + @ApiModelProperty(value = "") + @JsonProperty(value = "owner-id") + public String getOwnerId() { + return ownerId; + } + + /** */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(value = "policy-id", required = true) + public String getPolicyId() { + return policyId; + } + + /** */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(value = "policy-type", required = true) + public String getPolicyType() { + return policyType; + } + + /** */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(value = "name", required = true) + public String getName() { + return name; + } + + /** */ + @ApiModelProperty(value = "") + @JsonProperty(value = "description") + public String getDescription() { + return description; + } + + /** */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(value = "content", required = true) + public Object getContent() { + return content; + } + + /** */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(value = "version", required = true) + public Integer getVersion() { + return version; + } + + /** */ + @ApiModelProperty(value = "") + @JsonProperty(value = "created-at-ms") + public Long getCreatedAtMs() { + return createdAtMs; + } + + /** */ + @ApiModelProperty(value = "") + @JsonProperty(value = "updated-at-ms") + public Long getUpdatedAtMs() { + return updatedAtMs; + } + + @JsonCreator + public Policy( + @JsonProperty(value = "owner-id") String ownerId, + @JsonProperty(value = "policy-id", required = true) String policyId, + @JsonProperty(value = "policy-type", required = true) String policyType, + @JsonProperty(value = "name", required = true) String name, + @JsonProperty(value = "description") String description, + @JsonProperty(value = "content", required = true) Object content, + @JsonProperty(value = "version", required = true) Integer version, + @JsonProperty(value = "created-at-ms") Long createdAtMs, + @JsonProperty(value = "updated-at-ms") Long updatedAtMs) { + this.ownerId = ownerId; + this.policyId = policyId; + this.policyType = policyType; + this.name = name; + this.description = description; + this.content = Objects.requireNonNullElse(content, null); + this.version = version; + this.createdAtMs = createdAtMs; + this.updatedAtMs = updatedAtMs; + } + + public Policy(String policyId, String policyType, String name, Object content, Integer version) { + this.ownerId = null; + this.policyId = policyId; + this.policyType = policyType; + this.name = name; + this.description = null; + this.content = Objects.requireNonNullElse(content, null); + this.version = version; + this.createdAtMs = null; + this.updatedAtMs = null; + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder( + String policyId, String policyType, String name, Object content, Integer version) { + return new Builder(policyId, policyType, name, content, version); + } + + public static final class Builder { + private String ownerId; + private String policyId; + private String policyType; + private String name; + private String description; + private Object content; + private Integer version; + private Long createdAtMs; + private Long updatedAtMs; + + private Builder() {} + + private Builder( + String policyId, String policyType, String name, Object content, Integer version) { + this.policyId = policyId; + this.policyType = policyType; + this.name = name; + this.content = Objects.requireNonNullElse(content, null); + this.version = version; + } + + public Builder setOwnerId(String ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder setPolicyId(String policyId) { + this.policyId = policyId; + return this; + } + + public Builder setPolicyType(String policyType) { + this.policyType = policyType; + return this; + } + + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setDescription(String description) { + this.description = description; + return this; + } + + public Builder setContent(Object content) { + this.content = content; + return this; + } + + public Builder setVersion(Integer version) { + this.version = version; + return this; + } + + public Builder setCreatedAtMs(Long createdAtMs) { + this.createdAtMs = createdAtMs; + return this; + } + + public Builder setUpdatedAtMs(Long updatedAtMs) { + this.updatedAtMs = updatedAtMs; + return this; + } + + public Policy build() { + Policy inst = + new Policy( + ownerId, + policyId, + policyType, + name, + description, + content, + version, + createdAtMs, + updatedAtMs); + return inst; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Policy policy = (Policy) o; + return Objects.equals(this.ownerId, policy.ownerId) + && Objects.equals(this.policyId, policy.policyId) + && Objects.equals(this.policyType, policy.policyType) + && Objects.equals(this.name, policy.name) + && Objects.equals(this.description, policy.description) + && Objects.equals(this.content, policy.content) + && Objects.equals(this.version, policy.version) + && Objects.equals(this.createdAtMs, policy.createdAtMs) + && Objects.equals(this.updatedAtMs, policy.updatedAtMs); + } + + @Override + public int hashCode() { + return Objects.hash( + ownerId, + policyId, + policyType, + name, + description, + content, + version, + createdAtMs, + updatedAtMs); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Policy {\n"); + + sb.append(" ownerId: ").append(toIndentedString(ownerId)).append("\n"); + sb.append(" policyId: ").append(toIndentedString(policyId)).append("\n"); + sb.append(" policyType: ").append(toIndentedString(policyType)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" createdAtMs: ").append(toIndentedString(createdAtMs)).append("\n"); + sb.append(" updatedAtMs: ").append(toIndentedString(updatedAtMs)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/PolicyContent.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/PolicyContent.java new file mode 100644 index 000000000..81e51fb21 --- /dev/null +++ b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/PolicyContent.java @@ -0,0 +1,80 @@ +/* + * 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. + */ +package org.apache.polaris.service.types.policy; + +import com.fasterxml.jackson.annotation.JsonCreator; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", + date = "2025-01-14T19:27:03.909488-08:00[America/Los_Angeles]", + comments = "Generator version: 7.10.0") +public class PolicyContent { + + @JsonCreator + public PolicyContent() {} + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private Builder() {} + + public PolicyContent build() { + PolicyContent inst = new PolicyContent(); + return inst; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PolicyContent policyContent = (PolicyContent) o; + return true; + } + + @Override + public int hashCode() { + return 1; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PolicyContent {\n"); + + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/SetPolicyRequest.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/SetPolicyRequest.java new file mode 100644 index 000000000..187b9ce6d --- /dev/null +++ b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/SetPolicyRequest.java @@ -0,0 +1,138 @@ +/* + * 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. + */ +package org.apache.polaris.service.types.policy; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", + date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", + comments = "Generator version: 7.10.0") +public class SetPolicyRequest { + + @NotNull @Valid private final EntityIdentifier entity; + private final Map parameters; + + /** */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(value = "entity", required = true) + public EntityIdentifier getEntity() { + return entity; + } + + /** */ + @ApiModelProperty(value = "") + @JsonProperty(value = "parameters") + public Map getParameters() { + return parameters; + } + + @JsonCreator + public SetPolicyRequest( + @JsonProperty(value = "entity", required = true) EntityIdentifier entity, + @JsonProperty(value = "parameters") Map parameters) { + this.entity = entity; + this.parameters = Objects.requireNonNullElse(parameters, new HashMap<>()); + } + + public SetPolicyRequest(EntityIdentifier entity) { + this.entity = entity; + this.parameters = new HashMap<>(); + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(EntityIdentifier entity) { + return new Builder(entity); + } + + public static final class Builder { + private EntityIdentifier entity; + private Map parameters; + + private Builder() {} + + private Builder(EntityIdentifier entity) { + this.entity = entity; + } + + public Builder setEntity(EntityIdentifier entity) { + this.entity = entity; + return this; + } + + public Builder setParameters(Map parameters) { + this.parameters = parameters; + return this; + } + + public SetPolicyRequest build() { + SetPolicyRequest inst = new SetPolicyRequest(entity, parameters); + return inst; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetPolicyRequest setPolicyRequest = (SetPolicyRequest) o; + return Objects.equals(this.entity, setPolicyRequest.entity) + && Objects.equals(this.parameters, setPolicyRequest.parameters); + } + + @Override + public int hashCode() { + return Objects.hash(entity, parameters); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SetPolicyRequest {\n"); + + sb.append(" entity: ").append(toIndentedString(entity)).append("\n"); + sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/TableLikeIdentifier.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/TableLikeIdentifier.java new file mode 100644 index 000000000..c7d82ed07 --- /dev/null +++ b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/TableLikeIdentifier.java @@ -0,0 +1,167 @@ +/* + * 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. + */ +package org.apache.polaris.service.types.policy; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.constraints.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", + date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", + comments = "Generator version: 7.10.0") +public class TableLikeIdentifier extends EntityIdentifier { + + @NotNull private final String catalog; + @NotNull private final List namespace; + @NotNull private final String name; + + /** */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(value = "catalog", required = true) + public String getCatalog() { + return catalog; + } + + /** Reference to one or more levels of a namespace */ + @ApiModelProperty( + example = "[\"accounting\",\"tax\"]", + required = true, + value = "Reference to one or more levels of a namespace") + @JsonProperty(value = "namespace", required = true) + public List getNamespace() { + return namespace; + } + + /** */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(value = "name", required = true) + public String getName() { + return name; + } + + @JsonCreator + public TableLikeIdentifier( + @JsonProperty(value = "catalog", required = true) String catalog, + @JsonProperty(value = "namespace", required = true) List namespace, + @JsonProperty(value = "name", required = true) String name, + @JsonProperty(value = "type", required = true) TypeEnum type) { + super(type); + this.catalog = catalog; + this.namespace = Objects.requireNonNullElse(namespace, new ArrayList<>()); + this.name = name; + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder( + String catalog, List namespace, String name, TypeEnum type) { + return new Builder(catalog, namespace, name, type); + } + + public static final class Builder { + private String catalog; + private List namespace; + private String name; + private TypeEnum type; + + private Builder() {} + + private Builder(String catalog, List namespace, String name, TypeEnum type) { + this.catalog = catalog; + this.namespace = Objects.requireNonNullElse(namespace, new ArrayList<>()); + this.name = name; + this.type = type; + } + + public Builder setCatalog(String catalog) { + this.catalog = catalog; + return this; + } + + public Builder setNamespace(List namespace) { + this.namespace = namespace; + return this; + } + + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setType(TypeEnum type) { + this.type = type; + return this; + } + + public TableLikeIdentifier build() { + TableLikeIdentifier inst = new TableLikeIdentifier(catalog, namespace, name, type); + return inst; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TableLikeIdentifier tableLikeIdentifier = (TableLikeIdentifier) o; + return super.equals(o) + && Objects.equals(this.catalog, tableLikeIdentifier.catalog) + && Objects.equals(this.namespace, tableLikeIdentifier.namespace) + && Objects.equals(this.name, tableLikeIdentifier.name); + } + + @Override + public int hashCode() { + return Objects.hash( + super.hashCode(), catalog, super.hashCode(), namespace, super.hashCode(), name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TableLikeIdentifier {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" catalog: ").append(toIndentedString(catalog)).append("\n"); + sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UnsetPolicyRequest.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UnsetPolicyRequest.java new file mode 100644 index 000000000..ae0829bcf --- /dev/null +++ b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UnsetPolicyRequest.java @@ -0,0 +1,113 @@ +/* + * 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. + */ +package org.apache.polaris.service.types.policy; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import java.util.Objects; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", + date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", + comments = "Generator version: 7.10.0") +public class UnsetPolicyRequest { + + @NotNull @Valid private final EntityIdentifier entity; + + /** */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(value = "entity", required = true) + public EntityIdentifier getEntity() { + return entity; + } + + @JsonCreator + public UnsetPolicyRequest( + @JsonProperty(value = "entity", required = true) EntityIdentifier entity) { + this.entity = entity; + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(EntityIdentifier entity) { + return new Builder(entity); + } + + public static final class Builder { + private EntityIdentifier entity; + + private Builder() {} + + private Builder(EntityIdentifier entity) { + this.entity = entity; + } + + public Builder setEntity(EntityIdentifier entity) { + this.entity = entity; + return this; + } + + public UnsetPolicyRequest build() { + UnsetPolicyRequest inst = new UnsetPolicyRequest(entity); + return inst; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UnsetPolicyRequest unsetPolicyRequest = (UnsetPolicyRequest) o; + return Objects.equals(this.entity, unsetPolicyRequest.entity); + } + + @Override + public int hashCode() { + return Objects.hash(entity); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UnsetPolicyRequest {\n"); + + sb.append(" entity: ").append(toIndentedString(entity)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UpdatePolicyRequest.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UpdatePolicyRequest.java new file mode 100644 index 000000000..5d393db77 --- /dev/null +++ b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UpdatePolicyRequest.java @@ -0,0 +1,139 @@ +/* + * 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. + */ +package org.apache.polaris.service.types.policy; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import java.util.Objects; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", + date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", + comments = "Generator version: 7.10.0") +public class UpdatePolicyRequest { + + private final String name; + private final String description; + private final Object content; + + /** */ + @ApiModelProperty(value = "") + @JsonProperty(value = "name") + public String getName() { + return name; + } + + /** */ + @ApiModelProperty(value = "") + @JsonProperty(value = "description") + public String getDescription() { + return description; + } + + /** */ + @ApiModelProperty(value = "") + @JsonProperty(value = "content") + public Object getContent() { + return content; + } + + @JsonCreator + public UpdatePolicyRequest( + @JsonProperty(value = "name") String name, + @JsonProperty(value = "description") String description, + @JsonProperty(value = "content") Object content) { + this.name = name; + this.description = description; + this.content = Objects.requireNonNullElse(content, null); + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private String name; + private String description; + private Object content; + + private Builder() {} + + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setDescription(String description) { + this.description = description; + return this; + } + + public Builder setContent(Object content) { + this.content = content; + return this; + } + + public UpdatePolicyRequest build() { + UpdatePolicyRequest inst = new UpdatePolicyRequest(name, description, content); + return inst; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdatePolicyRequest updatePolicyRequest = (UpdatePolicyRequest) o; + return Objects.equals(this.name, updatePolicyRequest.name) + && Objects.equals(this.description, updatePolicyRequest.description) + && Objects.equals(this.content, updatePolicyRequest.content); + } + + @Override + public int hashCode() { + return Objects.hash(name, description, content); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdatePolicyRequest {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/spec/rest-catalog-open-api.yaml b/spec/rest-catalog-open-api.yaml index 7ebf15362..a250af1f8 100644 --- a/spec/rest-catalog-open-api.yaml +++ b/spec/rest-catalog-open-api.yaml @@ -4275,10 +4275,7 @@ components: type: integer format: int64 - PolicyContent: - anyOf: - - type: object - - type: string + PolicyContent: {} CreatePolicyRequest: type: object @@ -4333,46 +4330,64 @@ components: $ref: '#/components/schemas/EntityIdentifier' CatalogIdentifier: - type: object - required: - - catalog - properties: - catalog: - type: string + allOf: + - $ref: '#/components/schemas/EntityIdentifier' + - type: object + required: + - catalog + properties: + catalog: + type: string NamespaceIdentifier: - type: object - required: - - catalog - - namespace - properties: - catalog: - type: string - nullable: false - namespace: - $ref: '#/components/schemas/Namespace' + allOf: + - $ref: '#/components/schemas/EntityIdentifier' + - type: object + required: + - catalog + - namespace + properties: + catalog: + type: string + nullable: false + namespace: + $ref: '#/components/schemas/Namespace' TableLikeIdentifier: + allOf: + - $ref: '#/components/schemas/EntityIdentifier' + - type: object + required: + - catalog + - namespace + - name + properties: + catalog: + type: string + nullable: false + namespace: + $ref: '#/components/schemas/Namespace' + name: + type: string + nullable: false + + EntityIdentifier: type: object - required: - - catalog - - namespace - - name + discriminator: + propertyName: type + mapping: + catalog: '#/components/schemas/CatalogIdentifier' + namespace: '#/components/schemas/NamespaceIdentifier' + table-like: '#/components/schemas/TableLikeIdentifier' properties: - catalog: - type: string - nullable: false - namespace: - $ref: '#/components/schemas/Namespace' - name: + type: type: string - nullable: false - - EntityIdentifier: - oneOf: - - $ref: '#/components/schemas/CatalogIdentifier' - - $ref: '#/components/schemas/NamespaceIdentifier' - - $ref: '#/components/schemas/TableLikeIdentifier' + enum: + - catalog + - namespace + - table-like + required: + - type From 7162da643d40f8fe9cef65f89bcd6f8d4ba2c180 Mon Sep 17 00:00:00 2001 From: Honah J Date: Wed, 15 Jan 2025 21:51:53 -0800 Subject: [PATCH 05/17] add implementation example --- .../catalog/IcebergCatalogAdapter.java | 41 +++++++++++++ .../catalog/PolarisCatalogHandlerWrapper.java | 57 +++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java b/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java index b0d291400..04b117ba2 100644 --- a/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java +++ b/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java @@ -68,6 +68,10 @@ import org.apache.polaris.service.types.CommitTableRequest; import org.apache.polaris.service.types.CommitViewRequest; import org.apache.polaris.service.types.NotificationRequest; +import org.apache.polaris.service.types.policy.CreatePolicyRequest; +import org.apache.polaris.service.types.policy.SetPolicyRequest; +import org.apache.polaris.service.types.policy.UnsetPolicyRequest; +import org.apache.polaris.service.types.policy.UpdatePolicyRequest; /** * {@link IcebergRestCatalogApiService} implementation that delegates operations to {@link @@ -515,6 +519,43 @@ public Response sendNotification( return Response.status(Response.Status.NO_CONTENT).build(); } + @Override + public Response createPolicy( + String prefix, CreatePolicyRequest createPolicyRequest, RealmContext realmContext, SecurityContext securityContext + ) { + + return Response.ok(newHandlerWrapper(realmContext, securityContext, prefix).createPolicy(createPolicyRequest)).build(); + } + + @Override + public Response getPolicy(String prefix,String policy,RealmContext realmContext,SecurityContext securityContext) + { + return Response.ok(newHandlerWrapper(realmContext, securityContext, prefix).getPolicy(policy)).build(); + } + + @Override + public Response updatePolicy (String prefix, String policy, UpdatePolicyRequest updatePolicyRequest, RealmContext realmContext, SecurityContext securityContext) { + return Response.ok(newHandlerWrapper(realmContext, securityContext, prefix).updatePolicy(policy, updatePolicyRequest)).build(); + } + + @Override + public Response deletePolicy(String prefix,String policy,RealmContext realmContext,SecurityContext securityContext) { + newHandlerWrapper(realmContext, securityContext, prefix).deletePolicy(policy); + return Response.status(Response.Status.NO_CONTENT).build(); + } + + @Override + public Response setPolicy(String prefix, String policy, SetPolicyRequest setPolicyRequest, RealmContext realmContext, SecurityContext securityContext) { + newHandlerWrapper(realmContext, securityContext, prefix).setPolicy(policy, setPolicyRequest); + return Response.status(Response.Status.NO_CONTENT).build(); + } + + @Override + public Response unsetPolicy(String prefix, String policy, UnsetPolicyRequest unsetPolicyRequest, RealmContext realmContext, SecurityContext securityContext) { + newHandlerWrapper(realmContext, securityContext, prefix).unsetPolicy(policy, unsetPolicyRequest); + return Response.status(Response.Status.NO_CONTENT).build(); + } + /** From IcebergRestConfigurationApiService. */ @Override public Response getConfig( diff --git a/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java b/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java index 823cb0db6..d67cf1f15 100644 --- a/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java +++ b/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java @@ -92,6 +92,7 @@ import org.apache.polaris.core.storage.PolarisStorageActions; import org.apache.polaris.service.context.CallContextCatalogFactory; import org.apache.polaris.service.types.NotificationRequest; +import org.apache.polaris.service.types.policy.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -1181,4 +1182,60 @@ public void renameView(RenameTableRequest request) { } doCatalogOperation(() -> CatalogHandlers.renameView(viewCatalog, request)); } + + public LoadPolicyResult createPolicy(CreatePolicyRequest request) { + Policy examplePolicy = Policy.builder().setPolicyId("example-policy-id") + .setOwnerId("owner-id") + .setPolicyType(request.getType()) + .setName(request.getName()) + .setDescription(request.getDescription()) + .setContent(request.getContent()) + .setVersion(0) + .setCreatedAtMs(System.currentTimeMillis()) + .setUpdatedAtMs(System.currentTimeMillis()) + .build(); + return LoadPolicyResult.builder().setPolicy(examplePolicy).build(); + } + + public LoadPolicyResult getPolicy(String policy) { + Policy examplePolicy = Policy.builder().setPolicyId("example-policy-id") + .setOwnerId("owner-id") + .setPolicyType("example-policy-type") + .setName("example-policy-name") + .setDescription("example-description") + .setContent("example-content") + .setVersion(0) + .setCreatedAtMs(System.currentTimeMillis()) + .setUpdatedAtMs(System.currentTimeMillis()) + .build(); + + return LoadPolicyResult.builder().setPolicy(examplePolicy).build(); + } + + public LoadPolicyResult updatePolicy(String policy, UpdatePolicyRequest request) { + Policy examplePolicy = Policy.builder().setPolicyId("example-policy-id") + .setOwnerId("owner-id") + .setPolicyType("example-policy-type") + .setName(policy) + .setDescription(request.getDescription()) + .setContent(request.getContent()) + .setVersion(0) + .setCreatedAtMs(System.currentTimeMillis()) + .setUpdatedAtMs(System.currentTimeMillis()) + .build(); + + return LoadPolicyResult.builder().setPolicy(examplePolicy).build(); + } + + public void deletePolicy(String policy) { + return; + } + + public void setPolicy(String policy, SetPolicyRequest setPolicyRequest) { + return; + } + + public void unsetPolicy(String policy, UnsetPolicyRequest unsetPolicyRequest) { + return; + } } From 35f2c110f73f6df3f46ce6d44b1a0a233ea939fc Mon Sep 17 00:00:00 2001 From: Honah J Date: Wed, 15 Jan 2025 22:02:55 -0800 Subject: [PATCH 06/17] update to new branch --- .../catalog/IcebergCatalogAdapter.java | 78 ++++++++++++++----- .../catalog/PolarisCatalogHandlerWrapper.java | 12 ++- 2 files changed, 68 insertions(+), 22 deletions(-) diff --git a/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java b/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java index bd2c95146..390425a8d 100644 --- a/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java +++ b/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java @@ -73,12 +73,12 @@ import org.apache.polaris.service.types.CommitTableRequest; import org.apache.polaris.service.types.CommitViewRequest; import org.apache.polaris.service.types.NotificationRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.apache.polaris.service.types.policy.CreatePolicyRequest; import org.apache.polaris.service.types.policy.SetPolicyRequest; import org.apache.polaris.service.types.policy.UnsetPolicyRequest; import org.apache.polaris.service.types.policy.UpdatePolicyRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * {@link IcebergRestCatalogApiService} implementation that delegates operations to {@link @@ -608,39 +608,79 @@ public Response sendNotification( @Override public Response createPolicy( - String prefix, CreatePolicyRequest createPolicyRequest, RealmContext realmContext, SecurityContext securityContext - ) { + String prefix, + CreatePolicyRequest createPolicyRequest, + RealmId realmId, + SecurityContext securityContext) { - return Response.ok(newHandlerWrapper(realmContext, securityContext, prefix).createPolicy(createPolicyRequest)).build(); + return withCatalog( + securityContext, + prefix, + catalog -> Response.ok(catalog.createPolicy(createPolicyRequest)).build()); } @Override - public Response getPolicy(String prefix,String policy,RealmContext realmContext,SecurityContext securityContext) - { - return Response.ok(newHandlerWrapper(realmContext, securityContext, prefix).getPolicy(policy)).build(); + public Response getPolicy( + String prefix, String policy, RealmId realmId, SecurityContext securityContext) { + return withCatalog( + securityContext, prefix, catalog -> Response.ok(catalog.getPolicy(policy)).build()); } @Override - public Response updatePolicy (String prefix, String policy, UpdatePolicyRequest updatePolicyRequest, RealmContext realmContext, SecurityContext securityContext) { - return Response.ok(newHandlerWrapper(realmContext, securityContext, prefix).updatePolicy(policy, updatePolicyRequest)).build(); + public Response updatePolicy( + String prefix, + String policy, + UpdatePolicyRequest updatePolicyRequest, + RealmId realmId, + SecurityContext securityContext) { + return withCatalog( + securityContext, + prefix, + catalog -> Response.ok(catalog.updatePolicy(policy, updatePolicyRequest)).build()); } @Override - public Response deletePolicy(String prefix,String policy,RealmContext realmContext,SecurityContext securityContext) { - newHandlerWrapper(realmContext, securityContext, prefix).deletePolicy(policy); - return Response.status(Response.Status.NO_CONTENT).build(); + public Response deletePolicy( + String prefix, String policy, RealmId realmId, SecurityContext securityContext) { + return withCatalog( + securityContext, + prefix, + catalog -> { + catalog.deletePolicy(policy); + return Response.status(Response.Status.NO_CONTENT).build(); + }); } @Override - public Response setPolicy(String prefix, String policy, SetPolicyRequest setPolicyRequest, RealmContext realmContext, SecurityContext securityContext) { - newHandlerWrapper(realmContext, securityContext, prefix).setPolicy(policy, setPolicyRequest); - return Response.status(Response.Status.NO_CONTENT).build(); + public Response setPolicy( + String prefix, + String policy, + SetPolicyRequest setPolicyRequest, + RealmId realmId, + SecurityContext securityContext) { + return withCatalog( + securityContext, + prefix, + catalog -> { + catalog.setPolicy(policy, setPolicyRequest); + return Response.status(Response.Status.NO_CONTENT).build(); + }); } @Override - public Response unsetPolicy(String prefix, String policy, UnsetPolicyRequest unsetPolicyRequest, RealmContext realmContext, SecurityContext securityContext) { - newHandlerWrapper(realmContext, securityContext, prefix).unsetPolicy(policy, unsetPolicyRequest); - return Response.status(Response.Status.NO_CONTENT).build(); + public Response unsetPolicy( + String prefix, + String policy, + UnsetPolicyRequest unsetPolicyRequest, + RealmId realmId, + SecurityContext securityContext) { + return withCatalog( + securityContext, + prefix, + catalog -> { + catalog.unsetPolicy(policy, unsetPolicyRequest); + return Response.status(Response.Status.NO_CONTENT).build(); + }); } /** From IcebergRestConfigurationApiService. */ diff --git a/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java b/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java index 2122767a9..0ff6244ca 100644 --- a/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java +++ b/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java @@ -1197,7 +1197,9 @@ public void renameView(RenameTableRequest request) { } public LoadPolicyResult createPolicy(CreatePolicyRequest request) { - Policy examplePolicy = Policy.builder().setPolicyId("example-policy-id") + Policy examplePolicy = + Policy.builder() + .setPolicyId("example-policy-id") .setOwnerId("owner-id") .setPolicyType(request.getType()) .setName(request.getName()) @@ -1211,7 +1213,9 @@ public LoadPolicyResult createPolicy(CreatePolicyRequest request) { } public LoadPolicyResult getPolicy(String policy) { - Policy examplePolicy = Policy.builder().setPolicyId("example-policy-id") + Policy examplePolicy = + Policy.builder() + .setPolicyId("example-policy-id") .setOwnerId("owner-id") .setPolicyType("example-policy-type") .setName("example-policy-name") @@ -1226,7 +1230,9 @@ public LoadPolicyResult getPolicy(String policy) { } public LoadPolicyResult updatePolicy(String policy, UpdatePolicyRequest request) { - Policy examplePolicy = Policy.builder().setPolicyId("example-policy-id") + Policy examplePolicy = + Policy.builder() + .setPolicyId("example-policy-id") .setOwnerId("owner-id") .setPolicyType("example-policy-type") .setName(policy) From 608f521837f4a25f3e3f2862daae44110760e5dc Mon Sep 17 00:00:00 2001 From: Honah J Date: Fri, 17 Jan 2025 15:33:46 -0800 Subject: [PATCH 07/17] update rest spec --- .../types/policy/UpdatePolicyRequest.java | 29 ++----- .../catalog/IcebergCatalogAdapter.java | 81 ------------------- .../catalog/PolarisCatalogHandlerWrapper.java | 62 -------------- spec/rest-catalog-open-api.yaml | 34 +++++--- 4 files changed, 26 insertions(+), 180 deletions(-) diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UpdatePolicyRequest.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UpdatePolicyRequest.java index 5d393db77..83f7c1f20 100644 --- a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UpdatePolicyRequest.java +++ b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UpdatePolicyRequest.java @@ -25,21 +25,13 @@ @jakarta.annotation.Generated( value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", - date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", + date = "2025-01-17T15:18:16.353234-08:00[America/Los_Angeles]", comments = "Generator version: 7.10.0") public class UpdatePolicyRequest { - private final String name; private final String description; private final Object content; - /** */ - @ApiModelProperty(value = "") - @JsonProperty(value = "name") - public String getName() { - return name; - } - /** */ @ApiModelProperty(value = "") @JsonProperty(value = "description") @@ -56,10 +48,7 @@ public Object getContent() { @JsonCreator public UpdatePolicyRequest( - @JsonProperty(value = "name") String name, - @JsonProperty(value = "description") String description, - @JsonProperty(value = "content") Object content) { - this.name = name; + @JsonProperty("description") String description, @JsonProperty("content") Object content) { this.description = description; this.content = Objects.requireNonNullElse(content, null); } @@ -69,17 +58,11 @@ public static Builder builder() { } public static final class Builder { - private String name; private String description; private Object content; private Builder() {} - public Builder setName(String name) { - this.name = name; - return this; - } - public Builder setDescription(String description) { this.description = description; return this; @@ -91,7 +74,7 @@ public Builder setContent(Object content) { } public UpdatePolicyRequest build() { - UpdatePolicyRequest inst = new UpdatePolicyRequest(name, description, content); + UpdatePolicyRequest inst = new UpdatePolicyRequest(description, content); return inst; } } @@ -105,14 +88,13 @@ public boolean equals(Object o) { return false; } UpdatePolicyRequest updatePolicyRequest = (UpdatePolicyRequest) o; - return Objects.equals(this.name, updatePolicyRequest.name) - && Objects.equals(this.description, updatePolicyRequest.description) + return Objects.equals(this.description, updatePolicyRequest.description) && Objects.equals(this.content, updatePolicyRequest.content); } @Override public int hashCode() { - return Objects.hash(name, description, content); + return Objects.hash(description, content); } @Override @@ -120,7 +102,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class UpdatePolicyRequest {\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); sb.append(" content: ").append(toIndentedString(content)).append("\n"); sb.append("}"); diff --git a/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java b/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java index 390425a8d..a123019cd 100644 --- a/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java +++ b/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java @@ -73,10 +73,6 @@ import org.apache.polaris.service.types.CommitTableRequest; import org.apache.polaris.service.types.CommitViewRequest; import org.apache.polaris.service.types.NotificationRequest; -import org.apache.polaris.service.types.policy.CreatePolicyRequest; -import org.apache.polaris.service.types.policy.SetPolicyRequest; -import org.apache.polaris.service.types.policy.UnsetPolicyRequest; -import org.apache.polaris.service.types.policy.UpdatePolicyRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -606,83 +602,6 @@ public Response sendNotification( }); } - @Override - public Response createPolicy( - String prefix, - CreatePolicyRequest createPolicyRequest, - RealmId realmId, - SecurityContext securityContext) { - - return withCatalog( - securityContext, - prefix, - catalog -> Response.ok(catalog.createPolicy(createPolicyRequest)).build()); - } - - @Override - public Response getPolicy( - String prefix, String policy, RealmId realmId, SecurityContext securityContext) { - return withCatalog( - securityContext, prefix, catalog -> Response.ok(catalog.getPolicy(policy)).build()); - } - - @Override - public Response updatePolicy( - String prefix, - String policy, - UpdatePolicyRequest updatePolicyRequest, - RealmId realmId, - SecurityContext securityContext) { - return withCatalog( - securityContext, - prefix, - catalog -> Response.ok(catalog.updatePolicy(policy, updatePolicyRequest)).build()); - } - - @Override - public Response deletePolicy( - String prefix, String policy, RealmId realmId, SecurityContext securityContext) { - return withCatalog( - securityContext, - prefix, - catalog -> { - catalog.deletePolicy(policy); - return Response.status(Response.Status.NO_CONTENT).build(); - }); - } - - @Override - public Response setPolicy( - String prefix, - String policy, - SetPolicyRequest setPolicyRequest, - RealmId realmId, - SecurityContext securityContext) { - return withCatalog( - securityContext, - prefix, - catalog -> { - catalog.setPolicy(policy, setPolicyRequest); - return Response.status(Response.Status.NO_CONTENT).build(); - }); - } - - @Override - public Response unsetPolicy( - String prefix, - String policy, - UnsetPolicyRequest unsetPolicyRequest, - RealmId realmId, - SecurityContext securityContext) { - return withCatalog( - securityContext, - prefix, - catalog -> { - catalog.unsetPolicy(policy, unsetPolicyRequest); - return Response.status(Response.Status.NO_CONTENT).build(); - }); - } - /** From IcebergRestConfigurationApiService. */ @Override public Response getConfig(String warehouse, RealmId realmId, SecurityContext securityContext) { diff --git a/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java b/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java index 0ff6244ca..123f7322f 100644 --- a/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java +++ b/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java @@ -1195,66 +1195,4 @@ public void renameView(RenameTableRequest request) { } CatalogHandlers.renameView(viewCatalog, request); } - - public LoadPolicyResult createPolicy(CreatePolicyRequest request) { - Policy examplePolicy = - Policy.builder() - .setPolicyId("example-policy-id") - .setOwnerId("owner-id") - .setPolicyType(request.getType()) - .setName(request.getName()) - .setDescription(request.getDescription()) - .setContent(request.getContent()) - .setVersion(0) - .setCreatedAtMs(System.currentTimeMillis()) - .setUpdatedAtMs(System.currentTimeMillis()) - .build(); - return LoadPolicyResult.builder().setPolicy(examplePolicy).build(); - } - - public LoadPolicyResult getPolicy(String policy) { - Policy examplePolicy = - Policy.builder() - .setPolicyId("example-policy-id") - .setOwnerId("owner-id") - .setPolicyType("example-policy-type") - .setName("example-policy-name") - .setDescription("example-description") - .setContent("example-content") - .setVersion(0) - .setCreatedAtMs(System.currentTimeMillis()) - .setUpdatedAtMs(System.currentTimeMillis()) - .build(); - - return LoadPolicyResult.builder().setPolicy(examplePolicy).build(); - } - - public LoadPolicyResult updatePolicy(String policy, UpdatePolicyRequest request) { - Policy examplePolicy = - Policy.builder() - .setPolicyId("example-policy-id") - .setOwnerId("owner-id") - .setPolicyType("example-policy-type") - .setName(policy) - .setDescription(request.getDescription()) - .setContent(request.getContent()) - .setVersion(0) - .setCreatedAtMs(System.currentTimeMillis()) - .setUpdatedAtMs(System.currentTimeMillis()) - .build(); - - return LoadPolicyResult.builder().setPolicy(examplePolicy).build(); - } - - public void deletePolicy(String policy) { - return; - } - - public void setPolicy(String policy, SetPolicyRequest setPolicyRequest) { - return; - } - - public void unsetPolicy(String policy, UnsetPolicyRequest unsetPolicyRequest) { - return; - } } diff --git a/spec/rest-catalog-open-api.yaml b/spec/rest-catalog-open-api.yaml index a250af1f8..f0ed02dbc 100644 --- a/spec/rest-catalog-open-api.yaml +++ b/spec/rest-catalog-open-api.yaml @@ -1596,19 +1596,20 @@ paths: 5XX: $ref: '#/components/responses/ServerErrorResponse' - /v1/{prefix}/policies: + /v1/{prefix}/namespaces/{namespaces}/policies: parameters: - $ref: '#/components/parameters/prefix' + - $ref: '#/components/parameters/namespace' post: tags: - Catalog API - summary: 'Create a policy' + summary: 'Create a policy in the given namespace' operationId: createPolicy description: - Create a Policy + Create a policy - # TODO: add description of policy + Policy's type will be fixed after creation requestBody: required: true content: @@ -1631,9 +1632,10 @@ paths: 5XX: $ref: '#/components/responses/ServerErrorResponse' - /v1/{prefix}/policies/{policy}: + /v1/{prefix}/namespaces/{namespaces}/policies/{policy}: parameters: - $ref: '#/components/parameters/prefix' + - $ref: '#/components/parameters/namespace' - $ref: '#/components/parameters/policy' get: @@ -1643,7 +1645,8 @@ paths: operationId: getPolicy description: Get a policy from the catalog - + + The response contains the policy's metadata and content responses: 200: $ref: '#/components/responses/LoadPolicyResponse' @@ -1678,7 +1681,7 @@ paths: description: Update a policy - The owner_id, policy_id, and policy_type cannot be updated + Only policy's description and content can be updated requestBody: required: true content: @@ -1744,9 +1747,10 @@ paths: 5XX: $ref: '#/components/responses/ServerErrorResponse' - /v1/{prefix}/policies/{policy}/mappings: + /v1/{prefix}/namespaces/{namespaces}/policies/{policy}/mappings: parameters: - $ref: '#/components/parameters/prefix' + - $ref: '#/components/parameters/namespace' - $ref: '#/components/parameters/policy' post: @@ -1754,7 +1758,10 @@ paths: - Catalog API summary: Create a mapping between a policy and a resource entity operationId: setPolicy - description: Create a mapping between a policy and a resource entity + description: + Create a mapping between a policy and a resource entity + + A resource entity can be a catalog, namespace, or any table-like entity requestBody: required: true content: @@ -1802,9 +1809,12 @@ paths: delete: tags: - Catalog API - summary: Remove a mapping between a policy and an entity + summary: Remove a mapping between a policy and a resource entity operationId: unsetPolicy - description: Remove a mapping between a policy and an entity + description: + Remove a mapping between a policy and a resource entity + + A resource entity can be a catalog, namespace, or any table-like entity requestBody: required: true content: @@ -4302,8 +4312,6 @@ components: UpdatePolicyRequest: type: object properties: - name: - type: string description: type: string content: From 7993dc073a48e1ff257950135303f92d25d1c58f Mon Sep 17 00:00:00 2001 From: Honah J Date: Fri, 17 Jan 2025 15:34:47 -0800 Subject: [PATCH 08/17] fix import in PolarisCatalogHandlerWrapper --- .../polaris/service/catalog/PolarisCatalogHandlerWrapper.java | 1 - 1 file changed, 1 deletion(-) diff --git a/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java b/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java index 123f7322f..ea014f2cc 100644 --- a/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java +++ b/service/common/src/main/java/org/apache/polaris/service/catalog/PolarisCatalogHandlerWrapper.java @@ -99,7 +99,6 @@ import org.apache.polaris.service.catalog.io.FileIOFactory; import org.apache.polaris.service.task.TaskExecutor; import org.apache.polaris.service.types.NotificationRequest; -import org.apache.polaris.service.types.policy.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; From b87a4dea3e5ffaebdbd59adef021e4e82683ebe5 Mon Sep 17 00:00:00 2001 From: Honah J Date: Tue, 21 Jan 2025 17:03:20 -0800 Subject: [PATCH 09/17] clean up --- spec/rest-catalog-open-api.yaml | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/spec/rest-catalog-open-api.yaml b/spec/rest-catalog-open-api.yaml index f0ed02dbc..60dc98484 100644 --- a/spec/rest-catalog-open-api.yaml +++ b/spec/rest-catalog-open-api.yaml @@ -1607,9 +1607,7 @@ paths: summary: 'Create a policy in the given namespace' operationId: createPolicy description: - Create a policy - - Policy's type will be fixed after creation + Create a policy in the given namespace requestBody: required: true content: @@ -1646,6 +1644,7 @@ paths: description: Get a policy from the catalog + The response contains the policy's metadata and content responses: 200: @@ -1680,8 +1679,6 @@ paths: operationId: updatePolicy description: Update a policy - - Only policy's description and content can be updated requestBody: required: true content: @@ -1953,16 +1950,7 @@ components: required: true schema: type: string - example: 'compaction-policy' - - entity-id: - name: entityId - in: path - description: id of an entity in Polaris - required: true - schema: - type: string - example: '7e7230c8-bcc3-49ea-87f3-e943ddd48e73' + example: 'compaction' ############################## # Application Schema Objects # From b8a195942867a9a3b65f4712c020e42a125b8e77 Mon Sep 17 00:00:00 2001 From: Honah J Date: Tue, 21 Jan 2025 17:05:21 -0800 Subject: [PATCH 10/17] remove unnecessary change --- api/iceberg-service/build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/api/iceberg-service/build.gradle.kts b/api/iceberg-service/build.gradle.kts index dd6a55f1d..3a10a66d0 100644 --- a/api/iceberg-service/build.gradle.kts +++ b/api/iceberg-service/build.gradle.kts @@ -52,7 +52,6 @@ openApiGenerate { generatorName = "jaxrs-resteasy" outputDir = "$projectDir/build/generated" apiPackage = "org.apache.polaris.service.catalog.api" - modelPackage = "org.apache.polaris.services.types" ignoreFileOverride = "$rootDir/.openapi-generator-ignore" removeOperationIdPrefix = true templateDir = "$rootDir/server-templates" From 97c3803cf9f342bcf047e8c301b6b16be04d25a2 Mon Sep 17 00:00:00 2001 From: Honah J Date: Wed, 22 Jan 2025 17:18:19 -0800 Subject: [PATCH 11/17] PoC --- api/iceberg-service/build.gradle.kts | 2 +- spec/new-catalog-open-api.yaml | 137 +++++++++++++++++++++++++++ spec/rest-catalog-open-api.yaml | 6 +- 3 files changed, 141 insertions(+), 4 deletions(-) create mode 100644 spec/new-catalog-open-api.yaml diff --git a/api/iceberg-service/build.gradle.kts b/api/iceberg-service/build.gradle.kts index 3a10a66d0..7e9b6d29c 100644 --- a/api/iceberg-service/build.gradle.kts +++ b/api/iceberg-service/build.gradle.kts @@ -48,7 +48,7 @@ dependencies { } openApiGenerate { - inputSpec = "$rootDir/spec/rest-catalog-open-api.yaml" + inputSpec = "$rootDir/spec/new-catalog-open-api.yaml" generatorName = "jaxrs-resteasy" outputDir = "$projectDir/build/generated" apiPackage = "org.apache.polaris.service.catalog.api" diff --git a/spec/new-catalog-open-api.yaml b/spec/new-catalog-open-api.yaml new file mode 100644 index 000000000..d17621795 --- /dev/null +++ b/spec/new-catalog-open-api.yaml @@ -0,0 +1,137 @@ +# +# 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. +# + +--- +openapi: 3.0.3 +info: + title: Apache Iceberg REST Catalog API + license: + name: Apache 2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + version: 0.0.1 + description: + Defines the specification for the first version of the REST Catalog API. + Implementations should ideally support both Iceberg table specs v1 and v2, with priority given to v2. +servers: + - url: "{scheme}://{host}/{basePath}" + description: Server URL when the port can be inferred from the scheme + variables: + scheme: + description: The scheme of the URI, either http or https. + default: https + host: + description: The host address for the specified server + default: localhost + basePath: + description: Optional prefix to be appended to all routes + default: "" + - url: "{scheme}://{host}:{port}/{basePath}" + description: Generic base server URL, with all parts configurable + variables: + scheme: + description: The scheme of the URI, either http or https. + default: https + host: + description: The host address for the specified server + default: localhost + port: + description: The port used when addressing the host + default: "443" + basePath: + description: Optional prefix to be appended to all routes + default: "" +# All routes are currently configured using an Authorization header. +security: + - OAuth2: [catalog] + - BearerAuth: [] + +paths: + /v1/{prefix}/namespaces: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces' + /v1/{prefix}/namespaces/{namespace}: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}' + /v1/{prefix}/namespaces/{namespace}/policies: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1policies' + /v1/{prefix}/namespaces/{namespace}/policies/{policy}: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1policies~1{policy}' + /v1/{prefix}/namespaces/{namespace}/properties: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1properties' + /v1/{prefix}/namespaces/{namespace}/register: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1register' + /v1/{prefix}/namespaces/{namespace}/tables: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1tables' + /v1/{prefix}/namespaces/{namespace}/tables/{table}: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1tables~1{table}' + /v1/{prefix}/namespaces/{namespace}/tables/{table}/credentials: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1tables~1{table}~1credentials' + /v1/{prefix}/namespaces/{namespace}/tables/{table}/metrics: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1tables~1{table}~1metrics' + /v1/{prefix}/namespaces/{namespace}/tables/{table}/notifications: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1tables~1{table}~1notifications' + /v1/{prefix}/namespaces/{namespace}/views: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1views' + /v1/{prefix}/namespaces/{namespace}/views/{view}: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1views~1{view}' + /v1/{prefix}/tables/rename: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1tables~1rename' + /v1/{prefix}/transactions/commit: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1transactions~1commit' + /v1/{prefix}/views/rename: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1views~1rename' + /v1/config: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1config' + /v1/oauth/tokens: + $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1oauth~1tokens' + +# components: +# examples: +# $ref: './rest-catalog-open-api.yaml#/components/examples' +# schemas: +# $ref: './rest-catalog-open-api.yaml#/components/schemas' +# responses: +# $ref: './rest-catalog-open-api.yaml#/components/responses' +# parameters: +# $ref: './rest-catalog-open-api.yaml#/components/parameters' +# securitySchemes: +# $ref: './rest-catalog-open-api.yaml#/components/securitySchemes' + + +components: + securitySchemes: + OAuth2: + type: oauth2 + description: + This scheme is used for OAuth2 authorization. + + + For unauthorized requests, services should return an appropriate 401 or + 403 response. Implementations must not return altered success (200) + responses when a request is unauthenticated or unauthorized. + + If a separate authorization server is used, substitute the tokenUrl with + the full token path of the external authorization server, and use the + resulting token to access the resources defined in the spec. + flows: + clientCredentials: + tokenUrl: /v1/oauth/tokens + scopes: + catalog: Allows interacting with the Config and Catalog APIs + BearerAuth: + type: http + scheme: bearer diff --git a/spec/rest-catalog-open-api.yaml b/spec/rest-catalog-open-api.yaml index 60dc98484..a211671f5 100644 --- a/spec/rest-catalog-open-api.yaml +++ b/spec/rest-catalog-open-api.yaml @@ -1596,7 +1596,7 @@ paths: 5XX: $ref: '#/components/responses/ServerErrorResponse' - /v1/{prefix}/namespaces/{namespaces}/policies: + /v1/{prefix}/namespaces/{namespace}/policies: parameters: - $ref: '#/components/parameters/prefix' - $ref: '#/components/parameters/namespace' @@ -1630,7 +1630,7 @@ paths: 5XX: $ref: '#/components/responses/ServerErrorResponse' - /v1/{prefix}/namespaces/{namespaces}/policies/{policy}: + /v1/{prefix}/namespaces/{namespace}/policies/{policy}: parameters: - $ref: '#/components/parameters/prefix' - $ref: '#/components/parameters/namespace' @@ -1744,7 +1744,7 @@ paths: 5XX: $ref: '#/components/responses/ServerErrorResponse' - /v1/{prefix}/namespaces/{namespaces}/policies/{policy}/mappings: + /v1/{prefix}/namespaces/{namespace}/policies/{policy}/mappings: parameters: - $ref: '#/components/parameters/prefix' - $ref: '#/components/parameters/namespace' From d65742d7604bc0c994a2c440ea80909e302dc7cc Mon Sep 17 00:00:00 2001 From: Honah J Date: Wed, 22 Jan 2025 17:57:12 -0800 Subject: [PATCH 12/17] separate policy management api out --- api/iceberg-service/build.gradle.kts | 2 +- ...api.yaml => polaris-catalog-open-api.yaml} | 22 +- spec/rest-catalog-open-api.yaml | 475 +----------------- 3 files changed, 9 insertions(+), 490 deletions(-) rename spec/{new-catalog-open-api.yaml => polaris-catalog-open-api.yaml} (89%) diff --git a/api/iceberg-service/build.gradle.kts b/api/iceberg-service/build.gradle.kts index 7e9b6d29c..484a125a2 100644 --- a/api/iceberg-service/build.gradle.kts +++ b/api/iceberg-service/build.gradle.kts @@ -48,7 +48,7 @@ dependencies { } openApiGenerate { - inputSpec = "$rootDir/spec/new-catalog-open-api.yaml" + inputSpec = "$rootDir/spec/polaris-catalog-open-api.yaml" generatorName = "jaxrs-resteasy" outputDir = "$projectDir/build/generated" apiPackage = "org.apache.polaris.service.catalog.api" diff --git a/spec/new-catalog-open-api.yaml b/spec/polaris-catalog-open-api.yaml similarity index 89% rename from spec/new-catalog-open-api.yaml rename to spec/polaris-catalog-open-api.yaml index d17621795..b062c7116 100644 --- a/spec/new-catalog-open-api.yaml +++ b/spec/polaris-catalog-open-api.yaml @@ -66,10 +66,6 @@ paths: $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces' /v1/{prefix}/namespaces/{namespace}: $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}' - /v1/{prefix}/namespaces/{namespace}/policies: - $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1policies' - /v1/{prefix}/namespaces/{namespace}/policies/{policy}: - $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1policies~1{policy}' /v1/{prefix}/namespaces/{namespace}/properties: $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1properties' /v1/{prefix}/namespaces/{namespace}/register: @@ -99,17 +95,13 @@ paths: /v1/oauth/tokens: $ref: './rest-catalog-open-api.yaml#/paths/~1v1~1oauth~1tokens' -# components: -# examples: -# $ref: './rest-catalog-open-api.yaml#/components/examples' -# schemas: -# $ref: './rest-catalog-open-api.yaml#/components/schemas' -# responses: -# $ref: './rest-catalog-open-api.yaml#/components/responses' -# parameters: -# $ref: './rest-catalog-open-api.yaml#/components/parameters' -# securitySchemes: -# $ref: './rest-catalog-open-api.yaml#/components/securitySchemes' + # policy management apis + /v1/{prefix}/namespaces/{namespace}/policies: + $ref: './polaris-api/policy-management-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1policies' + /v1/{prefix}/namespaces/{namespace}/policies/{policy}: + $ref: './polaris-api/policy-management-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1policies~1{policy}' + /v1/{prefix}/namespaces/{namespace}/policies/{policy}/mappings: + $ref: './polaris-api/policy-management-api.yaml#/paths/~1v1~1{prefix}~1namespaces~1{namespace}~1policies~1{policy}~1mappings' components: diff --git a/spec/rest-catalog-open-api.yaml b/spec/rest-catalog-open-api.yaml index a211671f5..a4db287c4 100644 --- a/spec/rest-catalog-open-api.yaml +++ b/spec/rest-catalog-open-api.yaml @@ -1595,261 +1595,6 @@ paths: $ref: '#/components/responses/ServiceUnavailableResponse' 5XX: $ref: '#/components/responses/ServerErrorResponse' - - /v1/{prefix}/namespaces/{namespace}/policies: - parameters: - - $ref: '#/components/parameters/prefix' - - $ref: '#/components/parameters/namespace' - - post: - tags: - - Catalog API - summary: 'Create a policy in the given namespace' - operationId: createPolicy - description: - Create a policy in the given namespace - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CreatePolicyRequest' - responses: - 200: - $ref: '#/components/responses/CreatePolicyResponse' - 400: - $ref: '#/components/responses/BadRequestErrorResponse' - 401: - $ref: '#/components/responses/UnauthorizedResponse' - 403: - $ref: '#/components/responses/ForbiddenResponse' - 419: - $ref: '#/components/responses/AuthenticationTimeoutResponse' - 503: - $ref: '#/components/responses/ServiceUnavailableResponse' - 5XX: - $ref: '#/components/responses/ServerErrorResponse' - - /v1/{prefix}/namespaces/{namespace}/policies/{policy}: - parameters: - - $ref: '#/components/parameters/prefix' - - $ref: '#/components/parameters/namespace' - - $ref: '#/components/parameters/policy' - - get: - tags: - - Catalog API - summary: 'Get a policy' - operationId: getPolicy - description: - Get a policy from the catalog - - - The response contains the policy's metadata and content - responses: - 200: - $ref: '#/components/responses/LoadPolicyResponse' - 400: - $ref: '#/components/responses/BadRequestErrorResponse' - 401: - $ref: '#/components/responses/UnauthorizedResponse' - 403: - $ref: '#/components/responses/ForbiddenResponse' - 404: - description: - Not Found - NoSuchPolicyException, policy to get does not exist - content: - application/json: - schema: - $ref: '#/components/schemas/IcebergErrorResponse' - examples: - PolicyToGetDoesNotExist: - $ref: '#/components/examples/NoSuchPolicyError' - 419: - $ref: '#/components/responses/AuthenticationTimeoutResponse' - 503: - $ref: '#/components/responses/ServiceUnavailableResponse' - 5XX: - $ref: '#/components/responses/ServerErrorResponse' - - put: - tags: - - Catalog API - summary: Update a policy - operationId: updatePolicy - description: - Update a policy - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/UpdatePolicyRequest' - - responses: - 200: - $ref: '#/components/responses/UpdatePolicyResponse' - 400: - $ref: '#/components/responses/BadRequestErrorResponse' - 401: - $ref: '#/components/responses/UnauthorizedResponse' - 403: - $ref: '#/components/responses/ForbiddenResponse' - 404: - description: - Not Found - NoSuchPolicyException, policy to get does not exist - content: - application/json: - schema: - $ref: '#/components/schemas/IcebergErrorResponse' - examples: - PolicyToUpdateDoesNotExist: - $ref: '#/components/examples/NoSuchPolicyError' - 419: - $ref: '#/components/responses/AuthenticationTimeoutResponse' - 503: - $ref: '#/components/responses/ServiceUnavailableResponse' - 5XX: - $ref: '#/components/responses/ServerErrorResponse' - - delete: - tags: - - Catalog API - summary: Delete a policy from the catalog - operationId: deletePolicy - description: Remove a policy from the catalog - responses: - 204: - description: Success, no content - 400: - $ref: '#/components/responses/BadRequestErrorResponse' - 401: - $ref: '#/components/responses/UnauthorizedResponse' - 403: - $ref: '#/components/responses/ForbiddenResponse' - 404: - description: - Not Found - NoSuchPolicyException, policy to get does not exist - content: - application/json: - schema: - $ref: '#/components/schemas/IcebergErrorResponse' - examples: - PolicyToDeleteDoesNotExist: - $ref: '#/components/examples/NoSuchPolicyError' - 419: - $ref: '#/components/responses/AuthenticationTimeoutResponse' - 503: - $ref: '#/components/responses/ServiceUnavailableResponse' - 5XX: - $ref: '#/components/responses/ServerErrorResponse' - - /v1/{prefix}/namespaces/{namespace}/policies/{policy}/mappings: - parameters: - - $ref: '#/components/parameters/prefix' - - $ref: '#/components/parameters/namespace' - - $ref: '#/components/parameters/policy' - - post: - tags: - - Catalog API - summary: Create a mapping between a policy and a resource entity - operationId: setPolicy - description: - Create a mapping between a policy and a resource entity - - A resource entity can be a catalog, namespace, or any table-like entity - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/SetPolicyRequest' - - responses: - 204: - description: Success, no content - 400: - $ref: '#/components/responses/BadRequestErrorResponse' - 401: - $ref: '#/components/responses/UnauthorizedResponse' - 403: - $ref: '#/components/responses/ForbiddenResponse' - 404: - description: - Not Found - NoSuchPolicyException, NoSuchEntityException - content: - application/json: - schema: - $ref: '#/components/schemas/IcebergErrorResponse' - examples: - PolicyToSetDoesNotExist: - $ref: '#/components/examples/NoSuchPolicyError' - EntityToSetDoesNotExist: - $ref: '#/components/examples/NoSuchEntityError' - 409: - description: Conflict - The mapping already exists - content: - application/json: - schema: - $ref: '#/components/schemas/IcebergErrorResponse' - examples: - MappingAlreadyExistsError: - $ref: '#/components/examples/MappingAlreadyExistsError' - 419: - $ref: '#/components/responses/AuthenticationTimeoutResponse' - 503: - $ref: '#/components/responses/ServiceUnavailableResponse' - 5XX: - $ref: '#/components/responses/ServerErrorResponse' - - delete: - tags: - - Catalog API - summary: Remove a mapping between a policy and a resource entity - operationId: unsetPolicy - description: - Remove a mapping between a policy and a resource entity - - A resource entity can be a catalog, namespace, or any table-like entity - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/UnsetPolicyRequest' - - responses: - 204: - description: Success, no content - 400: - $ref: '#/components/responses/BadRequestErrorResponse' - 401: - $ref: '#/components/responses/UnauthorizedResponse' - 403: - $ref: '#/components/responses/ForbiddenResponse' - 404: - description: - Not Found - NoSuchPolicyException, NoSuchEntityException, NoSuchMappingException - content: - application/json: - schema: - $ref: '#/components/schemas/IcebergErrorResponse' - examples: - PolicyToUnsetDoesNotExist: - $ref: '#/components/examples/NoSuchPolicyError' - EntityToUnsetDoesNotExist: - $ref: '#/components/examples/NoSuchEntityError' - MappingToUnsetDoesNotExist: - $ref: '#/components/examples/NoSuchMappingError' - 419: - $ref: '#/components/responses/AuthenticationTimeoutResponse' - 503: - $ref: '#/components/responses/ServiceUnavailableResponse' - 5XX: - $ref: '#/components/responses/ServerErrorResponse' - - components: @@ -1943,15 +1688,6 @@ components: type: integer minimum: 1 - policy: - name: policy - in: path - description: a policy name - required: true - schema: - type: string - example: 'compaction' - ############################## # Application Schema Objects # ############################## @@ -4241,151 +3977,6 @@ components: items: type: integer description: "List of equality field IDs" - - Policy: - type: object - required: - - owner_id - - policy-id - - policy-type - - name - - content - - version - properties: - owner-id: - type: string - policy-id: - type: string - policy-type: - type: string - name: - type: string - description: - type: string - content: - $ref: '#/components/schemas/PolicyContent' - version: - type: integer - created-at-ms: - type: integer - format: int64 - updated-at-ms: - type: integer - format: int64 - - PolicyContent: {} - - CreatePolicyRequest: - type: object - required: - - name - - type - - content - properties: - name: - type: string - type: - type: string - description: - type: string - content: - $ref: '#/components/schemas/PolicyContent' - - LoadPolicyResult: - type: object - properties: - policy: - $ref: '#/components/schemas/Policy' - - UpdatePolicyRequest: - type: object - properties: - description: - type: string - content: - $ref: '#/components/schemas/PolicyContent' - - SetPolicyRequest: - type: object - required: - - entity - properties: - entity: - $ref: '#/components/schemas/EntityIdentifier' - parameters: - type: object - additionalProperties: - type: string - - UnsetPolicyRequest: - type: object - required: - - entity - properties: - entity: - $ref: '#/components/schemas/EntityIdentifier' - - CatalogIdentifier: - allOf: - - $ref: '#/components/schemas/EntityIdentifier' - - type: object - required: - - catalog - properties: - catalog: - type: string - - NamespaceIdentifier: - allOf: - - $ref: '#/components/schemas/EntityIdentifier' - - type: object - required: - - catalog - - namespace - properties: - catalog: - type: string - nullable: false - namespace: - $ref: '#/components/schemas/Namespace' - - TableLikeIdentifier: - allOf: - - $ref: '#/components/schemas/EntityIdentifier' - - type: object - required: - - catalog - - namespace - - name - properties: - catalog: - type: string - nullable: false - namespace: - $ref: '#/components/schemas/Namespace' - name: - type: string - nullable: false - - EntityIdentifier: - type: object - discriminator: - propertyName: type - mapping: - catalog: '#/components/schemas/CatalogIdentifier' - namespace: '#/components/schemas/NamespaceIdentifier' - table-like: '#/components/schemas/TableLikeIdentifier' - properties: - type: - type: string - enum: - - catalog - - namespace - - table-like - required: - - type - - ############################# # Reusable Response Objects # @@ -4634,30 +4225,6 @@ components: schema: $ref: '#/components/schemas/LoadCredentialsResponse' - CreatePolicyResponse: - description: Policy object result after creating a policy - content: - application/json: - schema: - $ref: '#/components/schemas/LoadPolicyResult' - - LoadPolicyResponse: - description: Policy object result when getting a policy - content: - application/json: - schema: - $ref: '#/components/schemas/LoadPolicyResult' - - UpdatePolicyResponse: - description: - Response used when a policy is successfully updated - - The updated policy JSON is returned in the policy field - content: - application/json: - schema: - $ref: '#/components/schemas/LoadPolicyResult' - ####################################### # Common examples of different values # ####################################### @@ -4806,46 +4373,6 @@ components: "code": 409 } } - - NoSuchPolicyError: - summary: The requested policy does not exist - value: { - "error": { - "message": "The given policy does not exist", - "type": "NoSuchPolicyException", - "code": 404 - } - } - - NoSuchEntityError: - summary: The requested entity does not exist - value: { - "error": { - "message": "The given entity does not exist", - "type": "NoSuchEntityException", - "code": 404 - } - } - - NoSuchMappingError: - summary: The requested mapping between policy and entity does not exist - value: { - "error": { - "message": "The given mapping between policy and entity does not exist", - "type": "NoSuchMappingException", - "code": 404 - } - } - - MappingAlreadyExistsError: - summary: The mapping between the given policy and entity already exists - value: { - "error": { - "message": "The mapping between the given policy and entity does not exist", - "type": "MappingAlreadyExistsError", - "code": 409 - } - } securitySchemes: OAuth2: @@ -4868,4 +4395,4 @@ components: catalog: Allows interacting with the Config and Catalog APIs BearerAuth: type: http - scheme: bearer + scheme: bearer \ No newline at end of file From eda146bcb077b983c9e805e92ad36073a5d64910 Mon Sep 17 00:00:00 2001 From: Honah J Date: Wed, 22 Jan 2025 17:59:11 -0800 Subject: [PATCH 13/17] add blank line --- spec/rest-catalog-open-api.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/rest-catalog-open-api.yaml b/spec/rest-catalog-open-api.yaml index a4db287c4..cfcd4987d 100644 --- a/spec/rest-catalog-open-api.yaml +++ b/spec/rest-catalog-open-api.yaml @@ -4395,4 +4395,4 @@ components: catalog: Allows interacting with the Config and Catalog APIs BearerAuth: type: http - scheme: bearer \ No newline at end of file + scheme: bearer From bad36cf2c366810a6430c25ae73cfbc480ffa6c5 Mon Sep 17 00:00:00 2001 From: Honah J Date: Wed, 22 Jan 2025 18:06:03 -0800 Subject: [PATCH 14/17] add missing file --- spec/polaris-api/policy-management-api.yaml | 508 ++++++++++++++++++++ 1 file changed, 508 insertions(+) create mode 100644 spec/polaris-api/policy-management-api.yaml diff --git a/spec/polaris-api/policy-management-api.yaml b/spec/polaris-api/policy-management-api.yaml new file mode 100644 index 000000000..4a950b7b4 --- /dev/null +++ b/spec/polaris-api/policy-management-api.yaml @@ -0,0 +1,508 @@ +paths: + /v1/{prefix}/namespaces/{namespace}/policies: + parameters: + - $ref: '#/components/parameters/prefix' + - $ref: '#/components/parameters/namespace' + + post: + tags: + - Catalog API + summary: 'Create a policy in the given namespace' + operationId: createPolicy + description: + Create a policy in the given namespace + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreatePolicyRequest' + responses: + 200: + $ref: '#/components/responses/CreatePolicyResponse' + 400: + $ref: '#/components/responses/BadRequestErrorResponse' + 401: + $ref: '#/components/responses/UnauthorizedResponse' + 403: + $ref: '#/components/responses/ForbiddenResponse' + 419: + $ref: '#/components/responses/AuthenticationTimeoutResponse' + 503: + $ref: '#/components/responses/ServiceUnavailableResponse' + 5XX: + $ref: '#/components/responses/ServerErrorResponse' + + /v1/{prefix}/namespaces/{namespace}/policies/{policy}: + parameters: + - $ref: '#/components/parameters/prefix' + - $ref: '#/components/parameters/namespace' + - $ref: '#/components/parameters/policy' + + get: + tags: + - Catalog API + summary: 'Get a policy' + operationId: getPolicy + description: + Get a policy from the catalog + + + The response contains the policy's metadata and content + responses: + 200: + $ref: '#/components/responses/LoadPolicyResponse' + 400: + $ref: '#/components/responses/BadRequestErrorResponse' + 401: + $ref: '#/components/responses/UnauthorizedResponse' + 403: + $ref: '#/components/responses/ForbiddenResponse' + 404: + description: + Not Found - NoSuchPolicyException, policy to get does not exist + content: + application/json: + schema: + $ref: '#/components/schemas/IcebergErrorResponse' + examples: + PolicyToGetDoesNotExist: + $ref: '#/components/examples/NoSuchPolicyError' + 419: + $ref: '#/components/responses/AuthenticationTimeoutResponse' + 503: + $ref: '#/components/responses/ServiceUnavailableResponse' + 5XX: + $ref: '#/components/responses/ServerErrorResponse' + + put: + tags: + - Catalog API + summary: Update a policy + operationId: updatePolicy + description: + Update a policy + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdatePolicyRequest' + + responses: + 200: + $ref: '#/components/responses/UpdatePolicyResponse' + 400: + $ref: '#/components/responses/BadRequestErrorResponse' + 401: + $ref: '#/components/responses/UnauthorizedResponse' + 403: + $ref: '#/components/responses/ForbiddenResponse' + 404: + description: + Not Found - NoSuchPolicyException, policy to get does not exist + content: + application/json: + schema: + $ref: '#/components/schemas/IcebergErrorResponse' + examples: + PolicyToUpdateDoesNotExist: + $ref: '#/components/examples/NoSuchPolicyError' + 419: + $ref: '#/components/responses/AuthenticationTimeoutResponse' + 503: + $ref: '#/components/responses/ServiceUnavailableResponse' + 5XX: + $ref: '#/components/responses/ServerErrorResponse' + + delete: + tags: + - Catalog API + summary: Delete a policy from the catalog + operationId: deletePolicy + description: Remove a policy from the catalog + responses: + 204: + description: Success, no content + 400: + $ref: '#/components/responses/BadRequestErrorResponse' + 401: + $ref: '#/components/responses/UnauthorizedResponse' + 403: + $ref: '#/components/responses/ForbiddenResponse' + 404: + description: + Not Found - NoSuchPolicyException, policy to get does not exist + content: + application/json: + schema: + $ref: '#/components/schemas/IcebergErrorResponse' + examples: + PolicyToDeleteDoesNotExist: + $ref: '#/components/examples/NoSuchPolicyError' + 419: + $ref: '#/components/responses/AuthenticationTimeoutResponse' + 503: + $ref: '#/components/responses/ServiceUnavailableResponse' + 5XX: + $ref: '#/components/responses/ServerErrorResponse' + + /v1/{prefix}/namespaces/{namespace}/policies/{policy}/mappings: + parameters: + - $ref: '#/components/parameters/prefix' + - $ref: '#/components/parameters/namespace' + - $ref: '#/components/parameters/policy' + + post: + tags: + - Catalog API + summary: Create a mapping between a policy and a resource entity + operationId: setPolicy + description: + Create a mapping between a policy and a resource entity + + A resource entity can be a catalog, namespace, or any table-like entity + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/SetPolicyRequest' + + responses: + 204: + description: Success, no content + 400: + $ref: '#/components/responses/BadRequestErrorResponse' + 401: + $ref: '#/components/responses/UnauthorizedResponse' + 403: + $ref: '#/components/responses/ForbiddenResponse' + 404: + description: + Not Found - NoSuchPolicyException, NoSuchEntityException + content: + application/json: + schema: + $ref: '#/components/schemas/IcebergErrorResponse' + examples: + PolicyToSetDoesNotExist: + $ref: '#/components/examples/NoSuchPolicyError' + EntityToSetDoesNotExist: + $ref: '#/components/examples/NoSuchEntityError' + 409: + description: Conflict - The mapping already exists + content: + application/json: + schema: + $ref: '#/components/schemas/IcebergErrorResponse' + examples: + MappingAlreadyExistsError: + $ref: '#/components/examples/MappingAlreadyExistsError' + 419: + $ref: '#/components/responses/AuthenticationTimeoutResponse' + 503: + $ref: '#/components/responses/ServiceUnavailableResponse' + 5XX: + $ref: '#/components/responses/ServerErrorResponse' + + delete: + tags: + - Catalog API + summary: Remove a mapping between a policy and a resource entity + operationId: unsetPolicy + description: + Remove a mapping between a policy and a resource entity + + A resource entity can be a catalog, namespace, or any table-like entity + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UnsetPolicyRequest' + + responses: + 204: + description: Success, no content + 400: + $ref: '#/components/responses/BadRequestErrorResponse' + 401: + $ref: '#/components/responses/UnauthorizedResponse' + 403: + $ref: '#/components/responses/ForbiddenResponse' + 404: + description: + Not Found - NoSuchPolicyException, NoSuchEntityException, NoSuchMappingException + content: + application/json: + schema: + $ref: '#/components/schemas/IcebergErrorResponse' + examples: + PolicyToUnsetDoesNotExist: + $ref: '#/components/examples/NoSuchPolicyError' + EntityToUnsetDoesNotExist: + $ref: '#/components/examples/NoSuchEntityError' + MappingToUnsetDoesNotExist: + $ref: '#/components/examples/NoSuchMappingError' + 419: + $ref: '#/components/responses/AuthenticationTimeoutResponse' + 503: + $ref: '#/components/responses/ServiceUnavailableResponse' + 5XX: + $ref: '#/components/responses/ServerErrorResponse' + + +components: + parameters: + namespace: + $ref: '../rest-catalog-open-api.yaml#/components/parameters/namespace' + + prefix: + $ref: '../rest-catalog-open-api.yaml#/components/parameters/prefix' + + policy: + name: policy + in: path + description: a policy name + required: true + schema: + type: string + example: 'compaction' + + schemas: + Namespace: + $ref: '../rest-catalog-open-api.yaml#/components/schemas/Namespace' + + IcebergErrorResponse: + $ref: '../rest-catalog-open-api.yaml#/components/schemas/IcebergErrorResponse' + + Policy: + type: object + required: + - owner_id + - policy-id + - policy-type + - name + - content + - version + properties: + owner-id: + type: string + policy-id: + type: string + policy-type: + type: string + name: + type: string + description: + type: string + content: + $ref: '#/components/schemas/PolicyContent' + version: + type: integer + created-at-ms: + type: integer + format: int64 + updated-at-ms: + type: integer + format: int64 + + PolicyContent: {} + + CreatePolicyRequest: + type: object + required: + - name + - type + - content + properties: + name: + type: string + type: + type: string + description: + type: string + content: + $ref: '#/components/schemas/PolicyContent' + + LoadPolicyResult: + type: object + properties: + policy: + $ref: '#/components/schemas/Policy' + + UpdatePolicyRequest: + type: object + properties: + description: + type: string + content: + $ref: '#/components/schemas/PolicyContent' + + SetPolicyRequest: + type: object + required: + - entity + properties: + entity: + $ref: '#/components/schemas/EntityIdentifier' + parameters: + type: object + additionalProperties: + type: string + + UnsetPolicyRequest: + type: object + required: + - entity + properties: + entity: + $ref: '#/components/schemas/EntityIdentifier' + + CatalogIdentifier: + allOf: + - $ref: '#/components/schemas/EntityIdentifier' + - type: object + required: + - catalog + properties: + catalog: + type: string + + NamespaceIdentifier: + allOf: + - $ref: '#/components/schemas/EntityIdentifier' + - type: object + required: + - catalog + - namespace + properties: + catalog: + type: string + nullable: false + namespace: + $ref: '#/components/schemas/Namespace' + + TableLikeIdentifier: + allOf: + - $ref: '#/components/schemas/EntityIdentifier' + - type: object + required: + - catalog + - namespace + - name + properties: + catalog: + type: string + nullable: false + namespace: + $ref: '#/components/schemas/Namespace' + name: + type: string + nullable: false + + EntityIdentifier: + type: object + discriminator: + propertyName: type + mapping: + catalog: '#/components/schemas/CatalogIdentifier' + namespace: '#/components/schemas/NamespaceIdentifier' + table-like: '#/components/schemas/TableLikeIdentifier' + properties: + type: + type: string + enum: + - catalog + - namespace + - table-like + required: + - type + + responses: + BadRequestErrorResponse: + $ref: '../rest-catalog-open-api.yaml#/components/responses/BadRequestErrorResponse' + + UnauthorizedResponse: + $ref: '../rest-catalog-open-api.yaml#/components/responses/UnauthorizedResponse' + + ForbiddenResponse: + $ref: '../rest-catalog-open-api.yaml#/components/responses/ForbiddenResponse' + + AuthenticationTimeoutResponse: + $ref: '../rest-catalog-open-api.yaml#/components/responses/AuthenticationTimeoutResponse' + + ServiceUnavailableResponse: + $ref: '../rest-catalog-open-api.yaml#/components/responses/ServiceUnavailableResponse' + + ServerErrorResponse: + $ref: '../rest-catalog-open-api.yaml#/components/responses/ServerErrorResponse' + + IcebergErrorResponse: + $ref: '../rest-catalog-open-api.yaml#/components/responses/IcebergErrorResponse' + + CreatePolicyResponse: + description: Policy object result after creating a policy + content: + application/json: + schema: + $ref: '#/components/schemas/LoadPolicyResult' + + LoadPolicyResponse: + description: Policy object result when getting a policy + content: + application/json: + schema: + $ref: '#/components/schemas/LoadPolicyResult' + + UpdatePolicyResponse: + description: + Response used when a policy is successfully updated + + The updated policy JSON is returned in the policy field + content: + application/json: + schema: + $ref: '#/components/schemas/LoadPolicyResult' + + examples: + NoSuchPolicyError: + summary: The requested policy does not exist + value: { + "error": { + "message": "The given policy does not exist", + "type": "NoSuchPolicyException", + "code": 404 + } + } + + NoSuchEntityError: + summary: The requested entity does not exist + value: { + "error": { + "message": "The given entity does not exist", + "type": "NoSuchEntityException", + "code": 404 + } + } + + NoSuchMappingError: + summary: The requested mapping between policy and entity does not exist + value: { + "error": { + "message": "The given mapping between policy and entity does not exist", + "type": "NoSuchMappingException", + "code": 404 + } + } + + MappingAlreadyExistsError: + summary: The mapping between the given policy and entity already exists + value: { + "error": { + "message": "The mapping between the given policy and entity does not exist", + "type": "MappingAlreadyExistsError", + "code": 409 + } + } From c86a4c4f3d4001d671ddcf8bbcc09e5e103614d9 Mon Sep 17 00:00:00 2001 From: Honah J Date: Wed, 22 Jan 2025 19:43:51 -0800 Subject: [PATCH 15/17] add license header --- spec/polaris-api/policy-management-api.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/polaris-api/policy-management-api.yaml b/spec/polaris-api/policy-management-api.yaml index 4a950b7b4..539a3e7c4 100644 --- a/spec/polaris-api/policy-management-api.yaml +++ b/spec/polaris-api/policy-management-api.yaml @@ -1,3 +1,23 @@ +# +# 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. +# + +--- paths: /v1/{prefix}/namespaces/{namespace}/policies: parameters: From 50def9415a61593d9f02c4017dbd5f43e0c960cd Mon Sep 17 00:00:00 2001 From: Honah J Date: Wed, 22 Jan 2025 20:48:44 -0800 Subject: [PATCH 16/17] make models auto-generated --- api/iceberg-service/build.gradle.kts | 38 ++- .../types/policy/CatalogIdentifier.java | 121 -------- .../types/policy/CreatePolicyRequest.java | 175 ----------- .../types/policy/EntityIdentifier.java | 136 -------- .../types/policy/LoadPolicyResult.java | 103 ------ .../types/policy/NamespaceIdentifier.java | 146 --------- .../polaris/service/types/policy/Policy.java | 293 ------------------ .../service/types/policy/PolicyContent.java | 80 ----- .../types/policy/SetPolicyRequest.java | 138 --------- .../types/policy/TableLikeIdentifier.java | 167 ---------- .../types/policy/UnsetPolicyRequest.java | 113 ------- .../types/policy/UpdatePolicyRequest.java | 120 ------- 12 files changed, 24 insertions(+), 1606 deletions(-) delete mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CatalogIdentifier.java delete mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CreatePolicyRequest.java delete mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/EntityIdentifier.java delete mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/LoadPolicyResult.java delete mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/NamespaceIdentifier.java delete mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/Policy.java delete mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/PolicyContent.java delete mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/SetPolicyRequest.java delete mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/TableLikeIdentifier.java delete mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UnsetPolicyRequest.java delete mode 100644 api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UpdatePolicyRequest.java diff --git a/api/iceberg-service/build.gradle.kts b/api/iceberg-service/build.gradle.kts index 484a125a2..acb175c0f 100644 --- a/api/iceberg-service/build.gradle.kts +++ b/api/iceberg-service/build.gradle.kts @@ -47,16 +47,36 @@ dependencies { implementation("com.fasterxml.jackson.core:jackson-databind") } +val policyManagementModels = + listOf( + "CatalogIdentifier", + "CreatePolicyRequest", + "EntityIdentifier", + "LoadPolicyResult", + "CreatePolicyResponse", + "LoadPolicyResponse", + "UpdatePolicyResponse", + "NamespaceIdentifier", + "Policy", + "PolicyContent", + "SetPolicyRequest", + "TableLikeIdentifier", + "UnsetPolicyRequest", + "UpdatePolicyRequest", + ) + .joinToString(",") + openApiGenerate { inputSpec = "$rootDir/spec/polaris-catalog-open-api.yaml" generatorName = "jaxrs-resteasy" outputDir = "$projectDir/build/generated" apiPackage = "org.apache.polaris.service.catalog.api" + modelPackage = "org.apache.polaris.service.types" ignoreFileOverride = "$rootDir/.openapi-generator-ignore" removeOperationIdPrefix = true templateDir = "$rootDir/server-templates" globalProperties.put("apis", "") - globalProperties.put("models", "false") + globalProperties.put("models", policyManagementModels) globalProperties.put("apiDocs", "false") globalProperties.put("modelTests", "false") configOptions.put("resourceName", "catalog") @@ -64,6 +84,9 @@ openApiGenerate { configOptions.put("useBeanValidation", "false") configOptions.put("sourceFolder", "src/main/java") configOptions.put("useJakartaEe", "true") + configOptions.put("generateBuilders", "true") + configOptions.put("generateConstructorWithAllArgs", "true") + configOptions.put("openApiNullable", "false") openapiNormalizer.put("REFACTOR_ALLOF_WITH_PROPERTIES_ONLY", "true") additionalProperties.put("apiNamePrefix", "IcebergRest") additionalProperties.put("apiNameSuffix", "") @@ -104,19 +127,6 @@ openApiGenerate { "NotificationRequest" to "org.apache.polaris.service.types.NotificationRequest", "TableUpdateNotification" to "org.apache.polaris.service.types.TableUpdateNotification", "NotificationType" to "org.apache.polaris.service.types.NotificationType", - - // Policy managements - "Policy" to "org.apache.polaris.service.types.policy.Policy", - "PolicyContent" to "org.apache.polaris.service.types.policy.PolicyContent", - "CreatePolicyRequest" to "org.apache.polaris.service.types.policy.CreatePolicyRequest", - "LoadPolicyResult" to "org.apache.polaris.service.types.policy.LoadPolicyResult", - "UpdatePolicyRequest" to "org.apache.polaris.service.types.policy.UpdatePolicyRequest", - "SetPolicyRequest" to "org.apache.polaris.service.types.policy.SetPolicyRequest", - "UnsetPolicyRequest" to "org.apache.polaris.service.types.policy.UnsetPolicyRequest", - "CatalogIdentifier" to "org.apache.iceberg.service.types.policy.CatalogIdentifier", - "NamespaceIdentifier" to "org.apache.iceberg.service.types.policy.NamespaceIdentifier", - "TableLikeIdentifier" to "org.apache.iceberg.service.types.policy.TableLikeIdentifier", - "EntityIdentifier" to "org.apache.iceberg.service.types.policy.EntityIdentifier", ) } diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CatalogIdentifier.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CatalogIdentifier.java deleted file mode 100644 index 2cc5e7d2e..000000000 --- a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CatalogIdentifier.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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. - */ -package org.apache.polaris.service.types.policy; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; -import jakarta.validation.constraints.*; -import java.util.Objects; - -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", - date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", - comments = "Generator version: 7.10.0") -public class CatalogIdentifier extends EntityIdentifier { - - @NotNull private final String catalog; - - /** */ - @ApiModelProperty(required = true, value = "") - @JsonProperty(value = "catalog", required = true) - public String getCatalog() { - return catalog; - } - - @JsonCreator - public CatalogIdentifier( - @JsonProperty(value = "catalog", required = true) String catalog, - @JsonProperty(value = "type", required = true) TypeEnum type) { - super(type); - this.catalog = catalog; - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(String catalog, TypeEnum type) { - return new Builder(catalog, type); - } - - public static final class Builder { - private String catalog; - private TypeEnum type; - - private Builder() {} - - private Builder(String catalog, TypeEnum type) { - this.catalog = catalog; - this.type = type; - } - - public Builder setCatalog(String catalog) { - this.catalog = catalog; - return this; - } - - public Builder setType(TypeEnum type) { - this.type = type; - return this; - } - - public CatalogIdentifier build() { - CatalogIdentifier inst = new CatalogIdentifier(catalog, type); - return inst; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CatalogIdentifier catalogIdentifier = (CatalogIdentifier) o; - return super.equals(o) && Objects.equals(this.catalog, catalogIdentifier.catalog); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), catalog); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class CatalogIdentifier {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" catalog: ").append(toIndentedString(catalog)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CreatePolicyRequest.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CreatePolicyRequest.java deleted file mode 100644 index 0f766785b..000000000 --- a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/CreatePolicyRequest.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * 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. - */ -package org.apache.polaris.service.types.policy; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; -import jakarta.validation.constraints.*; -import java.util.Objects; - -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", - date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", - comments = "Generator version: 7.10.0") -public class CreatePolicyRequest { - - @NotNull private final String name; - @NotNull private final String type; - private final String description; - @NotNull private final Object content; - - /** */ - @ApiModelProperty(required = true, value = "") - @JsonProperty(value = "name", required = true) - public String getName() { - return name; - } - - /** */ - @ApiModelProperty(required = true, value = "") - @JsonProperty(value = "type", required = true) - public String getType() { - return type; - } - - /** */ - @ApiModelProperty(value = "") - @JsonProperty(value = "description") - public String getDescription() { - return description; - } - - /** */ - @ApiModelProperty(required = true, value = "") - @JsonProperty(value = "content", required = true) - public Object getContent() { - return content; - } - - @JsonCreator - public CreatePolicyRequest( - @JsonProperty(value = "name", required = true) String name, - @JsonProperty(value = "type", required = true) String type, - @JsonProperty(value = "description") String description, - @JsonProperty(value = "content", required = true) Object content) { - this.name = name; - this.type = type; - this.description = description; - this.content = Objects.requireNonNullElse(content, null); - } - - public CreatePolicyRequest(String name, String type, Object content) { - this.name = name; - this.type = type; - this.description = null; - this.content = Objects.requireNonNullElse(content, null); - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(String name, String type, Object content) { - return new Builder(name, type, content); - } - - public static final class Builder { - private String name; - private String type; - private String description; - private Object content; - - private Builder() {} - - private Builder(String name, String type, Object content) { - this.name = name; - this.type = type; - this.content = Objects.requireNonNullElse(content, null); - } - - public Builder setName(String name) { - this.name = name; - return this; - } - - public Builder setType(String type) { - this.type = type; - return this; - } - - public Builder setDescription(String description) { - this.description = description; - return this; - } - - public Builder setContent(Object content) { - this.content = content; - return this; - } - - public CreatePolicyRequest build() { - CreatePolicyRequest inst = new CreatePolicyRequest(name, type, description, content); - return inst; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CreatePolicyRequest createPolicyRequest = (CreatePolicyRequest) o; - return Objects.equals(this.name, createPolicyRequest.name) - && Objects.equals(this.type, createPolicyRequest.type) - && Objects.equals(this.description, createPolicyRequest.description) - && Objects.equals(this.content, createPolicyRequest.content); - } - - @Override - public int hashCode() { - return Objects.hash(name, type, description, content); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class CreatePolicyRequest {\n"); - - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" description: ").append(toIndentedString(description)).append("\n"); - sb.append(" content: ").append(toIndentedString(content)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/EntityIdentifier.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/EntityIdentifier.java deleted file mode 100644 index ca0b2e662..000000000 --- a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/EntityIdentifier.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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. - */ -package org.apache.polaris.service.types.policy; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModelProperty; -import jakarta.validation.constraints.*; -import java.util.Objects; - -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", - date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", - comments = "Generator version: 7.10.0") -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.PROPERTY, - property = "type", - visible = true) -@JsonSubTypes({ - @JsonSubTypes.Type(value = CatalogIdentifier.class, name = "catalog"), - @JsonSubTypes.Type(value = NamespaceIdentifier.class, name = "namespace"), - @JsonSubTypes.Type(value = TableLikeIdentifier.class, name = "table-like"), -}) -public class EntityIdentifier { - - /** Gets or Sets type */ - public enum TypeEnum { - CATALOG("catalog"), - - NAMESPACE("namespace"), - - TABLE_LIKE("table-like"); - private String value; - - TypeEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - } - - @NotNull private final TypeEnum type; - - /** */ - @ApiModelProperty(required = true, value = "") - @JsonProperty(value = "type", required = true) - public TypeEnum getType() { - return type; - } - - @JsonCreator - public EntityIdentifier(@JsonProperty(value = "type", required = true) TypeEnum type) { - this.type = type; - } - - public static final class Builder { - private TypeEnum type; - - private Builder() {} - - private Builder(TypeEnum type) { - this.type = type; - } - - public Builder setType(TypeEnum type) { - this.type = type; - return this; - } - - public EntityIdentifier build() { - EntityIdentifier inst = new EntityIdentifier(type); - return inst; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - EntityIdentifier entityIdentifier = (EntityIdentifier) o; - return Objects.equals(this.type, entityIdentifier.type); - } - - @Override - public int hashCode() { - return Objects.hash(type); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class EntityIdentifier {\n"); - - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/LoadPolicyResult.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/LoadPolicyResult.java deleted file mode 100644 index 89cc74c14..000000000 --- a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/LoadPolicyResult.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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. - */ -package org.apache.polaris.service.types.policy; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; -import jakarta.validation.Valid; -import java.util.Objects; - -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", - date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", - comments = "Generator version: 7.10.0") -public class LoadPolicyResult { - - @Valid private final Policy policy; - - /** */ - @ApiModelProperty(value = "") - @JsonProperty(value = "policy") - public Policy getPolicy() { - return policy; - } - - @JsonCreator - public LoadPolicyResult(@JsonProperty(value = "policy") Policy policy) { - this.policy = policy; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private Policy policy; - - private Builder() {} - - public Builder setPolicy(Policy policy) { - this.policy = policy; - return this; - } - - public LoadPolicyResult build() { - LoadPolicyResult inst = new LoadPolicyResult(policy); - return inst; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - LoadPolicyResult loadPolicyResult = (LoadPolicyResult) o; - return Objects.equals(this.policy, loadPolicyResult.policy); - } - - @Override - public int hashCode() { - return Objects.hash(policy); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class LoadPolicyResult {\n"); - - sb.append(" policy: ").append(toIndentedString(policy)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/NamespaceIdentifier.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/NamespaceIdentifier.java deleted file mode 100644 index a126fa08e..000000000 --- a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/NamespaceIdentifier.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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. - */ -package org.apache.polaris.service.types.policy; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; -import jakarta.validation.constraints.*; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", - date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", - comments = "Generator version: 7.10.0") -public class NamespaceIdentifier extends EntityIdentifier { - - @NotNull private final String catalog; - @NotNull private final List namespace; - - /** */ - @ApiModelProperty(required = true, value = "") - @JsonProperty(value = "catalog", required = true) - public String getCatalog() { - return catalog; - } - - /** Reference to one or more levels of a namespace */ - @ApiModelProperty( - example = "[\"accounting\",\"tax\"]", - required = true, - value = "Reference to one or more levels of a namespace") - @JsonProperty(value = "namespace", required = true) - public List getNamespace() { - return namespace; - } - - @JsonCreator - public NamespaceIdentifier( - @JsonProperty(value = "catalog", required = true) String catalog, - @JsonProperty(value = "namespace", required = true) List namespace, - @JsonProperty(value = "type", required = true) TypeEnum type) { - super(type); - this.catalog = catalog; - this.namespace = Objects.requireNonNullElse(namespace, new ArrayList<>()); - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(String catalog, List namespace, TypeEnum type) { - return new Builder(catalog, namespace, type); - } - - public static final class Builder { - private String catalog; - private List namespace; - private TypeEnum type; - - private Builder() {} - - private Builder(String catalog, List namespace, TypeEnum type) { - this.catalog = catalog; - this.namespace = Objects.requireNonNullElse(namespace, new ArrayList<>()); - this.type = type; - } - - public Builder setCatalog(String catalog) { - this.catalog = catalog; - return this; - } - - public Builder setNamespace(List namespace) { - this.namespace = namespace; - return this; - } - - public Builder setType(TypeEnum type) { - this.type = type; - return this; - } - - public NamespaceIdentifier build() { - NamespaceIdentifier inst = new NamespaceIdentifier(catalog, namespace, type); - return inst; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - NamespaceIdentifier namespaceIdentifier = (NamespaceIdentifier) o; - return super.equals(o) - && Objects.equals(this.catalog, namespaceIdentifier.catalog) - && Objects.equals(this.namespace, namespaceIdentifier.namespace); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), catalog, super.hashCode(), namespace); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class NamespaceIdentifier {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" catalog: ").append(toIndentedString(catalog)).append("\n"); - sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/Policy.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/Policy.java deleted file mode 100644 index 1a9225549..000000000 --- a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/Policy.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * 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. - */ -package org.apache.polaris.service.types.policy; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; -import jakarta.validation.constraints.*; -import java.util.Objects; - -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", - date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", - comments = "Generator version: 7.10.0") -public class Policy { - - private final String ownerId; - @NotNull private final String policyId; - @NotNull private final String policyType; - @NotNull private final String name; - private final String description; - @NotNull private final Object content; - @NotNull private final Integer version; - private final Long createdAtMs; - private final Long updatedAtMs; - - /** */ - @ApiModelProperty(value = "") - @JsonProperty(value = "owner-id") - public String getOwnerId() { - return ownerId; - } - - /** */ - @ApiModelProperty(required = true, value = "") - @JsonProperty(value = "policy-id", required = true) - public String getPolicyId() { - return policyId; - } - - /** */ - @ApiModelProperty(required = true, value = "") - @JsonProperty(value = "policy-type", required = true) - public String getPolicyType() { - return policyType; - } - - /** */ - @ApiModelProperty(required = true, value = "") - @JsonProperty(value = "name", required = true) - public String getName() { - return name; - } - - /** */ - @ApiModelProperty(value = "") - @JsonProperty(value = "description") - public String getDescription() { - return description; - } - - /** */ - @ApiModelProperty(required = true, value = "") - @JsonProperty(value = "content", required = true) - public Object getContent() { - return content; - } - - /** */ - @ApiModelProperty(required = true, value = "") - @JsonProperty(value = "version", required = true) - public Integer getVersion() { - return version; - } - - /** */ - @ApiModelProperty(value = "") - @JsonProperty(value = "created-at-ms") - public Long getCreatedAtMs() { - return createdAtMs; - } - - /** */ - @ApiModelProperty(value = "") - @JsonProperty(value = "updated-at-ms") - public Long getUpdatedAtMs() { - return updatedAtMs; - } - - @JsonCreator - public Policy( - @JsonProperty(value = "owner-id") String ownerId, - @JsonProperty(value = "policy-id", required = true) String policyId, - @JsonProperty(value = "policy-type", required = true) String policyType, - @JsonProperty(value = "name", required = true) String name, - @JsonProperty(value = "description") String description, - @JsonProperty(value = "content", required = true) Object content, - @JsonProperty(value = "version", required = true) Integer version, - @JsonProperty(value = "created-at-ms") Long createdAtMs, - @JsonProperty(value = "updated-at-ms") Long updatedAtMs) { - this.ownerId = ownerId; - this.policyId = policyId; - this.policyType = policyType; - this.name = name; - this.description = description; - this.content = Objects.requireNonNullElse(content, null); - this.version = version; - this.createdAtMs = createdAtMs; - this.updatedAtMs = updatedAtMs; - } - - public Policy(String policyId, String policyType, String name, Object content, Integer version) { - this.ownerId = null; - this.policyId = policyId; - this.policyType = policyType; - this.name = name; - this.description = null; - this.content = Objects.requireNonNullElse(content, null); - this.version = version; - this.createdAtMs = null; - this.updatedAtMs = null; - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder( - String policyId, String policyType, String name, Object content, Integer version) { - return new Builder(policyId, policyType, name, content, version); - } - - public static final class Builder { - private String ownerId; - private String policyId; - private String policyType; - private String name; - private String description; - private Object content; - private Integer version; - private Long createdAtMs; - private Long updatedAtMs; - - private Builder() {} - - private Builder( - String policyId, String policyType, String name, Object content, Integer version) { - this.policyId = policyId; - this.policyType = policyType; - this.name = name; - this.content = Objects.requireNonNullElse(content, null); - this.version = version; - } - - public Builder setOwnerId(String ownerId) { - this.ownerId = ownerId; - return this; - } - - public Builder setPolicyId(String policyId) { - this.policyId = policyId; - return this; - } - - public Builder setPolicyType(String policyType) { - this.policyType = policyType; - return this; - } - - public Builder setName(String name) { - this.name = name; - return this; - } - - public Builder setDescription(String description) { - this.description = description; - return this; - } - - public Builder setContent(Object content) { - this.content = content; - return this; - } - - public Builder setVersion(Integer version) { - this.version = version; - return this; - } - - public Builder setCreatedAtMs(Long createdAtMs) { - this.createdAtMs = createdAtMs; - return this; - } - - public Builder setUpdatedAtMs(Long updatedAtMs) { - this.updatedAtMs = updatedAtMs; - return this; - } - - public Policy build() { - Policy inst = - new Policy( - ownerId, - policyId, - policyType, - name, - description, - content, - version, - createdAtMs, - updatedAtMs); - return inst; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Policy policy = (Policy) o; - return Objects.equals(this.ownerId, policy.ownerId) - && Objects.equals(this.policyId, policy.policyId) - && Objects.equals(this.policyType, policy.policyType) - && Objects.equals(this.name, policy.name) - && Objects.equals(this.description, policy.description) - && Objects.equals(this.content, policy.content) - && Objects.equals(this.version, policy.version) - && Objects.equals(this.createdAtMs, policy.createdAtMs) - && Objects.equals(this.updatedAtMs, policy.updatedAtMs); - } - - @Override - public int hashCode() { - return Objects.hash( - ownerId, - policyId, - policyType, - name, - description, - content, - version, - createdAtMs, - updatedAtMs); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Policy {\n"); - - sb.append(" ownerId: ").append(toIndentedString(ownerId)).append("\n"); - sb.append(" policyId: ").append(toIndentedString(policyId)).append("\n"); - sb.append(" policyType: ").append(toIndentedString(policyType)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" description: ").append(toIndentedString(description)).append("\n"); - sb.append(" content: ").append(toIndentedString(content)).append("\n"); - sb.append(" version: ").append(toIndentedString(version)).append("\n"); - sb.append(" createdAtMs: ").append(toIndentedString(createdAtMs)).append("\n"); - sb.append(" updatedAtMs: ").append(toIndentedString(updatedAtMs)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/PolicyContent.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/PolicyContent.java deleted file mode 100644 index 81e51fb21..000000000 --- a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/PolicyContent.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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. - */ -package org.apache.polaris.service.types.policy; - -import com.fasterxml.jackson.annotation.JsonCreator; - -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", - date = "2025-01-14T19:27:03.909488-08:00[America/Los_Angeles]", - comments = "Generator version: 7.10.0") -public class PolicyContent { - - @JsonCreator - public PolicyContent() {} - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private Builder() {} - - public PolicyContent build() { - PolicyContent inst = new PolicyContent(); - return inst; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PolicyContent policyContent = (PolicyContent) o; - return true; - } - - @Override - public int hashCode() { - return 1; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PolicyContent {\n"); - - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/SetPolicyRequest.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/SetPolicyRequest.java deleted file mode 100644 index 187b9ce6d..000000000 --- a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/SetPolicyRequest.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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. - */ -package org.apache.polaris.service.types.policy; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; -import jakarta.validation.Valid; -import jakarta.validation.constraints.*; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", - date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", - comments = "Generator version: 7.10.0") -public class SetPolicyRequest { - - @NotNull @Valid private final EntityIdentifier entity; - private final Map parameters; - - /** */ - @ApiModelProperty(required = true, value = "") - @JsonProperty(value = "entity", required = true) - public EntityIdentifier getEntity() { - return entity; - } - - /** */ - @ApiModelProperty(value = "") - @JsonProperty(value = "parameters") - public Map getParameters() { - return parameters; - } - - @JsonCreator - public SetPolicyRequest( - @JsonProperty(value = "entity", required = true) EntityIdentifier entity, - @JsonProperty(value = "parameters") Map parameters) { - this.entity = entity; - this.parameters = Objects.requireNonNullElse(parameters, new HashMap<>()); - } - - public SetPolicyRequest(EntityIdentifier entity) { - this.entity = entity; - this.parameters = new HashMap<>(); - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(EntityIdentifier entity) { - return new Builder(entity); - } - - public static final class Builder { - private EntityIdentifier entity; - private Map parameters; - - private Builder() {} - - private Builder(EntityIdentifier entity) { - this.entity = entity; - } - - public Builder setEntity(EntityIdentifier entity) { - this.entity = entity; - return this; - } - - public Builder setParameters(Map parameters) { - this.parameters = parameters; - return this; - } - - public SetPolicyRequest build() { - SetPolicyRequest inst = new SetPolicyRequest(entity, parameters); - return inst; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SetPolicyRequest setPolicyRequest = (SetPolicyRequest) o; - return Objects.equals(this.entity, setPolicyRequest.entity) - && Objects.equals(this.parameters, setPolicyRequest.parameters); - } - - @Override - public int hashCode() { - return Objects.hash(entity, parameters); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SetPolicyRequest {\n"); - - sb.append(" entity: ").append(toIndentedString(entity)).append("\n"); - sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/TableLikeIdentifier.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/TableLikeIdentifier.java deleted file mode 100644 index c7d82ed07..000000000 --- a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/TableLikeIdentifier.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * 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. - */ -package org.apache.polaris.service.types.policy; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; -import jakarta.validation.constraints.*; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", - date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", - comments = "Generator version: 7.10.0") -public class TableLikeIdentifier extends EntityIdentifier { - - @NotNull private final String catalog; - @NotNull private final List namespace; - @NotNull private final String name; - - /** */ - @ApiModelProperty(required = true, value = "") - @JsonProperty(value = "catalog", required = true) - public String getCatalog() { - return catalog; - } - - /** Reference to one or more levels of a namespace */ - @ApiModelProperty( - example = "[\"accounting\",\"tax\"]", - required = true, - value = "Reference to one or more levels of a namespace") - @JsonProperty(value = "namespace", required = true) - public List getNamespace() { - return namespace; - } - - /** */ - @ApiModelProperty(required = true, value = "") - @JsonProperty(value = "name", required = true) - public String getName() { - return name; - } - - @JsonCreator - public TableLikeIdentifier( - @JsonProperty(value = "catalog", required = true) String catalog, - @JsonProperty(value = "namespace", required = true) List namespace, - @JsonProperty(value = "name", required = true) String name, - @JsonProperty(value = "type", required = true) TypeEnum type) { - super(type); - this.catalog = catalog; - this.namespace = Objects.requireNonNullElse(namespace, new ArrayList<>()); - this.name = name; - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder( - String catalog, List namespace, String name, TypeEnum type) { - return new Builder(catalog, namespace, name, type); - } - - public static final class Builder { - private String catalog; - private List namespace; - private String name; - private TypeEnum type; - - private Builder() {} - - private Builder(String catalog, List namespace, String name, TypeEnum type) { - this.catalog = catalog; - this.namespace = Objects.requireNonNullElse(namespace, new ArrayList<>()); - this.name = name; - this.type = type; - } - - public Builder setCatalog(String catalog) { - this.catalog = catalog; - return this; - } - - public Builder setNamespace(List namespace) { - this.namespace = namespace; - return this; - } - - public Builder setName(String name) { - this.name = name; - return this; - } - - public Builder setType(TypeEnum type) { - this.type = type; - return this; - } - - public TableLikeIdentifier build() { - TableLikeIdentifier inst = new TableLikeIdentifier(catalog, namespace, name, type); - return inst; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TableLikeIdentifier tableLikeIdentifier = (TableLikeIdentifier) o; - return super.equals(o) - && Objects.equals(this.catalog, tableLikeIdentifier.catalog) - && Objects.equals(this.namespace, tableLikeIdentifier.namespace) - && Objects.equals(this.name, tableLikeIdentifier.name); - } - - @Override - public int hashCode() { - return Objects.hash( - super.hashCode(), catalog, super.hashCode(), namespace, super.hashCode(), name); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TableLikeIdentifier {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" catalog: ").append(toIndentedString(catalog)).append("\n"); - sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UnsetPolicyRequest.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UnsetPolicyRequest.java deleted file mode 100644 index ae0829bcf..000000000 --- a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UnsetPolicyRequest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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. - */ -package org.apache.polaris.service.types.policy; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; -import jakarta.validation.Valid; -import jakarta.validation.constraints.*; -import java.util.Objects; - -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", - date = "2025-01-15T21:05:26.610355-08:00[America/Los_Angeles]", - comments = "Generator version: 7.10.0") -public class UnsetPolicyRequest { - - @NotNull @Valid private final EntityIdentifier entity; - - /** */ - @ApiModelProperty(required = true, value = "") - @JsonProperty(value = "entity", required = true) - public EntityIdentifier getEntity() { - return entity; - } - - @JsonCreator - public UnsetPolicyRequest( - @JsonProperty(value = "entity", required = true) EntityIdentifier entity) { - this.entity = entity; - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(EntityIdentifier entity) { - return new Builder(entity); - } - - public static final class Builder { - private EntityIdentifier entity; - - private Builder() {} - - private Builder(EntityIdentifier entity) { - this.entity = entity; - } - - public Builder setEntity(EntityIdentifier entity) { - this.entity = entity; - return this; - } - - public UnsetPolicyRequest build() { - UnsetPolicyRequest inst = new UnsetPolicyRequest(entity); - return inst; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - UnsetPolicyRequest unsetPolicyRequest = (UnsetPolicyRequest) o; - return Objects.equals(this.entity, unsetPolicyRequest.entity); - } - - @Override - public int hashCode() { - return Objects.hash(entity); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class UnsetPolicyRequest {\n"); - - sb.append(" entity: ").append(toIndentedString(entity)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UpdatePolicyRequest.java b/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UpdatePolicyRequest.java deleted file mode 100644 index 83f7c1f20..000000000 --- a/api/iceberg-service/src/main/java/org/apache/polaris/service/types/policy/UpdatePolicyRequest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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. - */ -package org.apache.polaris.service.types.policy; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; -import java.util.Objects; - -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", - date = "2025-01-17T15:18:16.353234-08:00[America/Los_Angeles]", - comments = "Generator version: 7.10.0") -public class UpdatePolicyRequest { - - private final String description; - private final Object content; - - /** */ - @ApiModelProperty(value = "") - @JsonProperty(value = "description") - public String getDescription() { - return description; - } - - /** */ - @ApiModelProperty(value = "") - @JsonProperty(value = "content") - public Object getContent() { - return content; - } - - @JsonCreator - public UpdatePolicyRequest( - @JsonProperty("description") String description, @JsonProperty("content") Object content) { - this.description = description; - this.content = Objects.requireNonNullElse(content, null); - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private String description; - private Object content; - - private Builder() {} - - public Builder setDescription(String description) { - this.description = description; - return this; - } - - public Builder setContent(Object content) { - this.content = content; - return this; - } - - public UpdatePolicyRequest build() { - UpdatePolicyRequest inst = new UpdatePolicyRequest(description, content); - return inst; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - UpdatePolicyRequest updatePolicyRequest = (UpdatePolicyRequest) o; - return Objects.equals(this.description, updatePolicyRequest.description) - && Objects.equals(this.content, updatePolicyRequest.content); - } - - @Override - public int hashCode() { - return Objects.hash(description, content); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class UpdatePolicyRequest {\n"); - - sb.append(" description: ").append(toIndentedString(description)).append("\n"); - sb.append(" content: ").append(toIndentedString(content)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} From ba05af56f31816aec0448fe65b5459bd1d0056f7 Mon Sep 17 00:00:00 2001 From: Honah J Date: Wed, 22 Jan 2025 20:53:55 -0800 Subject: [PATCH 17/17] remove unnecessary models --- api/iceberg-service/build.gradle.kts | 3 --- 1 file changed, 3 deletions(-) diff --git a/api/iceberg-service/build.gradle.kts b/api/iceberg-service/build.gradle.kts index acb175c0f..d8a75d064 100644 --- a/api/iceberg-service/build.gradle.kts +++ b/api/iceberg-service/build.gradle.kts @@ -53,9 +53,6 @@ val policyManagementModels = "CreatePolicyRequest", "EntityIdentifier", "LoadPolicyResult", - "CreatePolicyResponse", - "LoadPolicyResponse", - "UpdatePolicyResponse", "NamespaceIdentifier", "Policy", "PolicyContent",