feat: add back the InfluxQL REPL (#386)

* add v1-compatible query path and refactor other paths to de-duplicate "/query"

* add initial influxQL repl

* add ping endpoint to schema

* improve prompt UX, implement some commands

* fix json column type in schema and improve completion

* feat: add table formatter and move to forked go-prompt

* improve formatting and add table pagination

* implement more REPL commands, including insert and history

* implement "INSERT INTO"

* move repl command to "v1 repl"

* refactor and improve documentation

* clean up v1_repl cmd

* update to latest openapi, use some openapi paths instead of overrides

* remove additional files that were moved to openapi

* compute historyFilePath at REPL start

* clean up REPL use command logic flow

* clean up comments for TODOs now in issues

* move gopher (chonky boi)

* remove autocompletion for separate PR

* run go mod tidy

* add rfc3339 precision option

* allow left and right column scrolling to display whole table

* add error to JSON query response

* add tags and partial to JSON response series schema

* fix csv formatting and add column formatting

* remove table format for separate PR

* fix getDatabases

* move from write to legacy write endpoint for INSERT

* remove history vestiges

* allow multiple spaces in INSERT commands

* add precision comment

* remove auth for separate PR

* separate parseInsert and add unit test

* add additional test case and improve error messages

* fix missing errors import

* print rfc3339 precision

* add rfc3339 to help output
This commit is contained in:
Andrew Lee
2022-06-10 08:54:07 -06:00
committed by GitHub
parent 51ca97ee29
commit fc529745a5
44 changed files with 2959 additions and 305 deletions

View File

@ -26,10 +26,45 @@ var (
type DeleteApi interface {
/*
* PostDelete Delete data
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiPostDeleteRequest
*/
* PostDelete Delete data
* Deletes data from a bucket.
Use this endpoint to delete points from a bucket in a specified time range.
#### InfluxDB Cloud
- Does the following when you send a delete request:
1. Validates the request and queues the delete.
2. Returns _success_ if queued; _error_ otherwise.
3. Handles the delete asynchronously.
#### InfluxDB OSS
- Validates the request, handles the delete synchronously,
and then responds with success or failure.
#### Required permissions
- `write-buckets` or `write-bucket BUCKET_ID`.
`BUCKET_ID` is the ID of the destination bucket.
#### Rate limits (with InfluxDB Cloud)
`write` rate limits apply.
For more information, see [limits and adjustable quotas](https://docs.influxdata.com/influxdb/cloud/account-management/limits/).
#### Related guides
- [Delete data]({{% INFLUXDB_DOCS_URL %}}/write-data/delete-data/).
- Learn how to use [delete predicate syntax]({{% INFLUXDB_DOCS_URL %}}/reference/syntax/delete-predicate/).
- Learn how InfluxDB handles [deleted tags](https://docs.influxdata.com/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagkeys/)
and [deleted fields](https://docs.influxdata.com/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementfieldkeys/).
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiPostDeleteRequest
*/
PostDelete(ctx _context.Context) ApiPostDeleteRequest
/*
@ -117,9 +152,44 @@ func (r ApiPostDeleteRequest) ExecuteWithHttpInfo() (*_nethttp.Response, error)
/*
* PostDelete Delete data
* Deletes data from a bucket.
Use this endpoint to delete points from a bucket in a specified time range.
#### InfluxDB Cloud
- Does the following when you send a delete request:
1. Validates the request and queues the delete.
2. Returns _success_ if queued; _error_ otherwise.
3. Handles the delete asynchronously.
#### InfluxDB OSS
- Validates the request, handles the delete synchronously,
and then responds with success or failure.
#### Required permissions
- `write-buckets` or `write-bucket BUCKET_ID`.
`BUCKET_ID` is the ID of the destination bucket.
#### Rate limits (with InfluxDB Cloud)
`write` rate limits apply.
For more information, see [limits and adjustable quotas](https://docs.influxdata.com/influxdb/cloud/account-management/limits/).
#### Related guides
- [Delete data]({{% INFLUXDB_DOCS_URL %}}/write-data/delete-data/).
- Learn how to use [delete predicate syntax]({{% INFLUXDB_DOCS_URL %}}/reference/syntax/delete-predicate/).
- Learn how InfluxDB handles [deleted tags](https://docs.influxdata.com/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementtagkeys/)
and [deleted fields](https://docs.influxdata.com/flux/v0.x/stdlib/influxdata/influxdb/schema/measurementfieldkeys/).
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiPostDeleteRequest
*/
*/
func (a *DeleteApiService) PostDelete(ctx _context.Context) ApiPostDeleteRequest {
return ApiPostDeleteRequest{
ApiService: a,
@ -154,7 +224,7 @@ func (a *DeleteApiService) PostDeleteExecuteWithHttpInfo(r ApiPostDeleteRequest)
return nil, GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/delete"
localVarPath := localBasePath + "/api/v2/delete"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
@ -237,28 +307,6 @@ func (a *DeleteApiService) PostDeleteExecuteWithHttpInfo(r ApiPostDeleteRequest)
newErr.model = &v
return localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 403 {
var v Error
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
return localVarHTTPResponse, newErr
}
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
newErr.model = &v
return localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 404 {
var v Error
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error())
return localVarHTTPResponse, newErr
}
v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage()))
newErr.model = &v
return localVarHTTPResponse, newErr
}
var v Error
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {