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

@ -29,19 +29,43 @@ type WriteApi interface {
* PostWrite Write data
* Writes data to a bucket.
To write data into InfluxDB, you need the following:
Use this endpoint to send data in [line protocol]({{% INFLUXDB_DOCS_URL %}}/reference/syntax/line-protocol/) format to InfluxDB.
- **organization name or ID** – _See [View organizations]({{% INFLUXDB_DOCS_URL %}}/organizations/view-orgs/#view-your-organization-id) for instructions on viewing your organization ID._
- **bucket** – _See [View buckets]({{% INFLUXDB_DOCS_URL %}}/organizations/buckets/view-buckets/) for
instructions on viewing your bucket ID._
- **API token** – _See [View tokens]({{% INFLUXDB_DOCS_URL %}}/security/tokens/view-tokens/)
for instructions on viewing your API token._
- **InfluxDB URL** – _See [InfluxDB URLs]({{% INFLUXDB_DOCS_URL %}}/reference/urls/)_.
- data in [line protocol]({{% INFLUXDB_DOCS_URL %}}/reference/syntax/line-protocol) format.
#### InfluxDB Cloud
InfluxDB Cloud enforces rate and size limits different from InfluxDB OSS. For details, see Responses.
- Takes the following steps when you send a write request:
1. Validates the request and queues the write.
2. If the write is queued, responds with an HTTP `204` status code.
3. Handles the write asynchronously and reaches eventual consistency.
An HTTP `2xx` status code acknowledges that the write or delete is queued.
To ensure that InfluxDB Cloud handles writes and deletes in the order you request them,
wait for a response before you send the next request.
Because writes are asynchronous, data might not yet be written
when you receive the response.
#### InfluxDB OSS
- Validates the request, handles the write synchronously,
and then responds with success or failure.
- If all points were written successfully, returns `204`,
otherwise returns the first line that failed.
#### 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
For more information and examples, see the following:
- [Write data with the InfluxDB API]({{% INFLUXDB_DOCS_URL %}}/write-data/developer-tools/api).
- [Optimize writes to InfluxDB]({{% INFLUXDB_DOCS_URL %}}/write-data/best-practices/optimize-writes/).
- [Troubleshoot issues writing data]({{% INFLUXDB_DOCS_URL %}}/write-data/troubleshoot/)
@ -174,19 +198,43 @@ func (r ApiPostWriteRequest) ExecuteWithHttpInfo() (*_nethttp.Response, error) {
* PostWrite Write data
* Writes data to a bucket.
To write data into InfluxDB, you need the following:
Use this endpoint to send data in [line protocol]({{% INFLUXDB_DOCS_URL %}}/reference/syntax/line-protocol/) format to InfluxDB.
- **organization name or ID** – _See [View organizations]({{% INFLUXDB_DOCS_URL %}}/organizations/view-orgs/#view-your-organization-id) for instructions on viewing your organization ID._
- **bucket** – _See [View buckets]({{% INFLUXDB_DOCS_URL %}}/organizations/buckets/view-buckets/) for
instructions on viewing your bucket ID._
- **API token** – _See [View tokens]({{% INFLUXDB_DOCS_URL %}}/security/tokens/view-tokens/)
for instructions on viewing your API token._
- **InfluxDB URL** – _See [InfluxDB URLs]({{% INFLUXDB_DOCS_URL %}}/reference/urls/)_.
- data in [line protocol]({{% INFLUXDB_DOCS_URL %}}/reference/syntax/line-protocol) format.
#### InfluxDB Cloud
InfluxDB Cloud enforces rate and size limits different from InfluxDB OSS. For details, see Responses.
- Takes the following steps when you send a write request:
1. Validates the request and queues the write.
2. If the write is queued, responds with an HTTP `204` status code.
3. Handles the write asynchronously and reaches eventual consistency.
An HTTP `2xx` status code acknowledges that the write or delete is queued.
To ensure that InfluxDB Cloud handles writes and deletes in the order you request them,
wait for a response before you send the next request.
Because writes are asynchronous, data might not yet be written
when you receive the response.
#### InfluxDB OSS
- Validates the request, handles the write synchronously,
and then responds with success or failure.
- If all points were written successfully, returns `204`,
otherwise returns the first line that failed.
#### 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
For more information and examples, see the following:
- [Write data with the InfluxDB API]({{% INFLUXDB_DOCS_URL %}}/write-data/developer-tools/api).
- [Optimize writes to InfluxDB]({{% INFLUXDB_DOCS_URL %}}/write-data/best-practices/optimize-writes/).
- [Troubleshoot issues writing data]({{% INFLUXDB_DOCS_URL %}}/write-data/troubleshoot/)
@ -228,7 +276,7 @@ func (a *WriteApiService) PostWriteExecuteWithHttpInfo(r ApiPostWriteRequest) (*
return nil, GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/write"
localVarPath := localBasePath + "/api/v2/write"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}