forked from raystack/compass
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: delete assets api #78
Open
luthfifahlevi
wants to merge
7
commits into
main
Choose a base branch
from
docs-delete-assets-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
76e7baa
docs: fix docs link in README.md
bb14a35
docs(assets): Add delete assets API docs
0940f1c
docs: update complex query that covered
5ab982a
docs: update delete assets api description regarding query validation
7a74aa6
feat: add case for MemberNode which handle nested query
aa6d4f0
fix: fix example query
0418df2
feat: add more example
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ Documentation of our Compass API with gRPC and gRPC-Gateway. | |
|
||
[More about Compass](https://goto.github.io/compass/) | ||
|
||
## default | ||
## Assets | ||
|
||
### /v1beta1/assets | ||
|
||
|
@@ -180,6 +180,51 @@ Delete a single asset with given ID | |
| 500 | Returned when theres is something wrong on the server side. | [Status](#status) | | ||
| default | An unexpected error response. | [Status](#status) | | ||
|
||
### /v1beta1/assets/delete-by-query | ||
##### Summary | ||
|
||
Delete assets by [query expression](https://expr-lang.org/). | ||
|
||
##### Description | ||
|
||
Delete all assets that match the given [query expression](https://expr-lang.org/). | ||
The query expr at least must consist `refreshed_at`, `type`, and `service` identifiers. | ||
`type` and `service` identifiers valid only if it's using equals (`==`) or `IN` operator, to prevent human error on deleting assets. | ||
For example of the correct query: | ||
``` | ||
refreshed_at <= "2023-12-12 23:59:59" && service in ["service-1", "service-2"] && type == "table" | ||
``` | ||
``` | ||
refreshed_at <= (now() - duration('24h') && service == "service-1" && (type == "table" || data.foo != "bar") | ||
``` | ||
|
||
The idea of query expr converter is convert `query_expr` to AST (Abstract Syntax Tree), then make it as SQL Query and Elasticsearch Query so can used as filter query on deletion process. | ||
Currently, the expr query **already support most of the frequently used cases, except** ChainNode, SliceNode, CallNode, ClosureNode, PointerNode, VariableDeclaratorNode, MapNode, and PairNode. | ||
For more contexts, please refer to [AST Node](https://github.com/expr-lang/expr/blob/master/ast/node.go) in expr-lang library and [Query Expr Converter](https://github.com/goto/compass/tree/main/pkg/query_expr) in Compass. | ||
Example of **unsupported query for now** due to not directly produce a value is | ||
``` | ||
service in filter(assets, .Service startsWith "T") | ||
``` | ||
|
||
Complex query covered only if it directly produces a value, like `bool_identifier == !(findLast([1, 2, 3, 4], # > 2) == 4)` will produce `bool_identifier == false`. | ||
However, **please do the best practice that try to simplify the query first** to makes readable and prevent unwanted things like errors or false positive result. Like example before, please write `false` instead of `!(findLast([1, 2, 3, 4], # > 2) == 4)`. You can use [expr-lang playground](https://expr-lang.org/playground) to simplify the query expr. | ||
|
||
|
||
##### Parameters | ||
|
||
| Name | Located in | Description | Required | Schema | | ||
|------------|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| ------ | | ||
| query_expr | body | query expression based on [expr-lang](https://expr-lang.org/) to filtering the assets that wants to be deleted. `refreshed_at`, `type`, and `service` identifiers must exist in the query. The `type` and `service` must using equals (`==`) or `IN` operator | Yes | string | | ||
| dry_run | body | if set to true, then deletion should not proceed and only return the affected rows. Else, will perform deletion in the background (default) | No | string | | ||
|
||
##### Responses | ||
|
||
| Code | Description | Schema | | ||
| ---- | ----------- |-----------------------------------------------| | ||
| 200 | A successful response. | [DeleteAssetsResponse](#deleteassetsresponse) | | ||
| 400 | Returned when the data that user input is wrong. | [Status](#status) | | ||
| 500 | Returned when theres is something wrong on the server side. | [Status](#status) | | ||
| default | An unexpected error response. | [Status](#status) | | ||
### /v1beta1/assets/{id}/stargazers | ||
|
||
#### GET | ||
|
@@ -1580,6 +1625,13 @@ Request to be sent to create a tag's template | |
| ---- | ---- | ----------- | -------- | | ||
| DeleteAssetResponse | object | | | | ||
|
||
#### DeleteAssetsResponse | ||
|
||
| Name | Type | Description | Required | | ||
|---------------|---------|-----------------------------------------------------|----------| | ||
| affected_rows | integer | the numbers of assets that match the given query | No | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to add column |
||
|
||
|
||
#### DeleteCommentResponse | ||
|
||
| Name | Type | Description | Required | | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we change the part saying:
into
also, need to put what is the default value to make it explicit. currently a bit confusing. an example: