Skip to content

Commit

Permalink
[#5000] improvement(server): Move tag object API to object path (#5027)
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

Move tag related about metadata object API to object path

### Why are the changes needed?

Fix: #5000

### Does this PR introduce _any_ user-facing change?
Modified the document

### How was this patch tested?
Modified the UT.
  • Loading branch information
jerqi authored Sep 27, 2024
1 parent 46a6a20 commit 8c62fc5
Show file tree
Hide file tree
Showing 8 changed files with 976 additions and 217 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MetadataObjectTagOperations implements SupportsTags {
this.restClient = restClient;
this.tagRequestPath =
String.format(
"api/metalakes/%s/tags/%s/%s",
"api/metalakes/%s/objects/%s/%s/tags",
metalakeName,
metadataObject.type().name().toLowerCase(Locale.ROOT),
metadataObject.fullName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,11 @@ private void testListTags(SupportsTags supportsTags, MetadataObject metadataObje
String path =
"/api/metalakes/"
+ METALAKE_NAME
+ "/tags/"
+ "/objects/"
+ metadataObject.type().name().toLowerCase(Locale.ROOT)
+ "/"
+ metadataObject.fullName();
+ metadataObject.fullName()
+ "/tags";

String[] tags = new String[] {"tag1", "tag2"};
NameListResponse resp = new NameListResponse(tags);
Expand Down Expand Up @@ -383,10 +384,11 @@ private void testListTagsInfo(SupportsTags supportsTags, MetadataObject metadata
String path =
"/api/metalakes/"
+ METALAKE_NAME
+ "/tags/"
+ "/objects/"
+ metadataObject.type().name().toLowerCase(Locale.ROOT)
+ "/"
+ metadataObject.fullName();
+ metadataObject.fullName()
+ "/tags";

TagDTO tag1 =
TagDTO.builder()
Expand Down Expand Up @@ -435,11 +437,11 @@ private void testGetTag(SupportsTags supportsTags, MetadataObject metadataObject
String path =
"/api/metalakes/"
+ METALAKE_NAME
+ "/tags/"
+ "/objects/"
+ metadataObject.type().name().toLowerCase(Locale.ROOT)
+ "/"
+ metadataObject.fullName()
+ "/tag1";
+ "/tags/tag1";

TagDTO tag1 =
TagDTO.builder()
Expand Down Expand Up @@ -476,10 +478,11 @@ private void testAssociateTags(SupportsTags supportsTags, MetadataObject metadat
String path =
"/api/metalakes/"
+ METALAKE_NAME
+ "/tags/"
+ "/objects/"
+ metadataObject.type().name().toLowerCase(Locale.ROOT)
+ "/"
+ metadataObject.fullName();
+ metadataObject.fullName()
+ "/tags";

String[] tagsToAdd = new String[] {"tag1", "tag2"};
String[] tagsToRemove = new String[] {"tag3", "tag4"};
Expand Down
22 changes: 11 additions & 11 deletions docs/manage-tags-in-gravitino.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Gravitino allows you to associate and disassociate tags with metadata objects. C
You can associate and disassociate tags with a metadata object by providing the object type, object
name and tag names.

The request path for REST API is `/api/metalakes/{metalake}/tags/{metadataObjectType}/{metadataObjectName}`.
The request path for REST API is `/api/metalakes/{metalake}/objects/{metadataObjectType}/{metadataObjectName}/tags`.

<Tabs groupId='language' queryString>
<TabItem value="shell" label="Shell">
Expand All @@ -222,12 +222,12 @@ curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"tagsToAdd": ["tag1", "tag2"],
"tagsToRemove": ["tag3"]
}' http://localhost:8090/api/metalakes/test/tags/catalog/catalog1
}' http://localhost:8090/api/metalakes/test/objects/catalog/catalog1/tags

curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"tagsToAdd": ["tag1"]
}' http://localhost:8090/api/metalakes/test/tags/schema/catalog1.schema1
}' http://localhost:8090/api/metalakes/test/objects/schema/catalog1.schema1/tags
```

</TabItem>
Expand All @@ -252,23 +252,23 @@ You can list all the tags associated with a metadata object. The tags in Graviti
inheritable, so listing tags of a metadata object will also list the tags of its parent metadata
objects.

The request path for REST API is `/api/metalakes/{metalake}/tags/{metadataObjectType}/{metadataObjectName}`.
The request path for REST API is `/api/metalakes/{metalake}/objects/{metadataObjectType}/{metadataObjectName}/tags`.

<Tabs groupId='language' queryString>
<TabItem value="shell" label="Shell">

```shell
curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/test/tags/catalog/catalog1
http://localhost:8090/api/metalakes/test/objects/catalog/catalog1/tags

curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/test/tags/schema/catalog1.schema1
http://localhost:8090/api/metalakes/test/objects/schema/catalog1.schema1/tags

curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/test/tags/catalog/catalog1?details=true
http://localhost:8090/api/metalakes/test/objects/catalog/catalog1/tags?details=true

curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/test/tags/schema/catalog1.schema1?details=true
http://localhost:8090/api/metalakes/test/objects/schema/catalog1.schema1/tags?details=true
```

</TabItem>
Expand All @@ -291,17 +291,17 @@ Tag[] tagsInfo = schema1.supportsTags().listTagsInfo();

You can get an associated tag by its name for a metadata object.

The request path for REST API is `/api/metalakes/{metalake}/tags/{metadataObjectType}/{metadataObjectName}/{tagName}`.
The request path for REST API is `/api/metalakes/{metalake}/objects/{metadataObjectType}/{metadataObjectName}/tags/{tagName}`.

<Tabs groupId='language' queryString>
<TabItem value="shell" label="Shell">

```shell
curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/test/tags/catalog/catalog1/tag1
http://localhost:8090/api/metalakes/test/objects/catalog/catalog1/tags/tag1

curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/test/tags/schema/catalog1.schema1/tag1
http://localhost:8090/api/metalakes/test/objects/schema/catalog1.schema1/tags/tag1
```

</TabItem>
Expand Down
8 changes: 4 additions & 4 deletions docs/open-api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ paths:
/metalakes/{metalake}/tags/{tag}:
$ref: "./tags.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1tags~1%7Btag%7D"

/metalakes/{metalake}/tags/{metadataObjectType}/{metadataObjectFullName}:
$ref: "./tags.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1tags~1%7BmetadataObjectType%7D~1%7BmetadataObjectFullName%7D"
/metalakes/{metalake}/objects/{metadataObjectType}/{metadataObjectFullName}/tags:
$ref: "./tags.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1objects~1%7BmetadataObjectType%7D~1%7BmetadataObjectFullName%7D~1tags"

/metalakes/{metalake}/tags/{metadataObjectType}/{metadataObjectFullName}/{tag}:
$ref: "./tags.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1tags~1%7BmetadataObjectType%7D~1%7BmetadataObjectFullName%7D~1%7Btag%7D"
/metalakes/{metalake}/objects/{metadataObjectType}/{metadataObjectFullName}/tags/{tag}:
$ref: "./tags.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1objects~1%7BmetadataObjectType%7D~1%7BmetadataObjectFullName%7D~1tags~1%7Btag%7D"

/metalakes/{metalake}/tags/{tag}/objects:
$ref: "./tags.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1tags~1%7Btag%7D~1objects"
Expand Down
4 changes: 2 additions & 2 deletions docs/open-api/tags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ paths:
$ref: "./openapi.yaml#/components/responses/ServerErrorResponse"


/metalakes/{metalake}/tags/{metadataObjectType}/{metadataObjectFullName}:
/metalakes/{metalake}/objects/{metadataObjectType}/{metadataObjectFullName}/tags:
parameters:
- $ref: "./openapi.yaml#/components/parameters/metalake"
- $ref: "./openapi.yaml#/components/parameters/metadataObjectType"
Expand Down Expand Up @@ -245,7 +245,7 @@ paths:
$ref: "./openapi.yaml#/components/responses/ServerErrorResponse"


/metalakes/{metalake}/tags/{metadataObjectType}/{metadataObjectFullName}/{tag}:
/metalakes/{metalake}/objects/{metadataObjectType}/{metadataObjectFullName}/tags/{tag}:
parameters:
- $ref: "./openapi.yaml#/components/parameters/metalake"
- $ref: "./openapi.yaml#/components/parameters/metadataObjectType"
Expand Down
Loading

0 comments on commit 8c62fc5

Please sign in to comment.