Skip to content

Commit

Permalink
update rest spec
Browse files Browse the repository at this point in the history
  • Loading branch information
HonahX committed Jan 17, 2025
1 parent 35f2c11 commit 608f521
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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);
}
Expand All @@ -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;
Expand All @@ -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;
}
}
Expand All @@ -105,22 +88,20 @@ 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
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("}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
34 changes: 21 additions & 13 deletions spec/rest-catalog-open-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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'
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -1744,17 +1747,21 @@ 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:
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
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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -4302,8 +4312,6 @@ components:
UpdatePolicyRequest:
type: object
properties:
name:
type: string
description:
type: string
content:
Expand Down

0 comments on commit 608f521

Please sign in to comment.