diff --git a/Makefile b/Makefile index 006273cac4..cc9e238ee0 100644 --- a/Makefile +++ b/Makefile @@ -154,7 +154,7 @@ run: chronogiraffe ./bin/$(GOOS)/influxd --developer-mode=true generate-typescript-client: - cat http/cur_swagger.yml | yq read -j - > openapi.json + cat http/cur_swagger.yml | go run ./internal/yaml2json > openapi.json openapi-generator generate -g typescript-axios -o ui/src/api -i openapi.json rm openapi.json diff --git a/go.mod b/go.mod index a7a1333d2e..04b1402e95 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/fatih/color v1.7.0 // indirect github.com/fatih/structs v1.1.0 // indirect github.com/getkin/kin-openapi v0.1.0 - github.com/ghodss/yaml v1.0.0 // indirect + github.com/ghodss/yaml v1.0.0 github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd // indirect github.com/glycerine/goconvey v0.0.0-20180728074245-46e3a41ad493 // indirect github.com/go-ldap/ldap v2.5.1+incompatible // indirect diff --git a/internal/yaml2json/main.go b/internal/yaml2json/main.go new file mode 100644 index 0000000000..6f346ac236 --- /dev/null +++ b/internal/yaml2json/main.go @@ -0,0 +1,26 @@ +package main + +import ( + "io/ioutil" + "log" + "os" + + yaml "github.com/ghodss/yaml" +) + +// yaml2json reads yaml data from stdin and outputs json to stdout. +// There are no arguments or flags. +func main() { + in, err := ioutil.ReadAll(os.Stdin) + if err != nil { + log.Fatal(err) + } + out, err := yaml.YAMLToJSON(in) + if err != nil { + log.Fatal(err) + } + _, err = os.Stdout.Write(out) + if err != nil { + log.Fatal(err) + } +} diff --git a/ui/src/api/api.ts b/ui/src/api/api.ts index 08ce6df349..b6c31be93b 100644 --- a/ui/src/api/api.ts +++ b/ui/src/api/api.ts @@ -69,6 +69,52 @@ export class RequiredError extends Error { } } +/** + * + * @export + * @interface AnalyzeQueryResponse + */ +export interface AnalyzeQueryResponse { + /** + * + * @type {Array} + * @memberof AnalyzeQueryResponse + */ + errors?: Array; +} + +/** + * + * @export + * @interface AnalyzeQueryResponseErrors + */ +export interface AnalyzeQueryResponseErrors { + /** + * + * @type {number} + * @memberof AnalyzeQueryResponseErrors + */ + character?: number; + /** + * + * @type {number} + * @memberof AnalyzeQueryResponseErrors + */ + column?: number; + /** + * + * @type {number} + * @memberof AnalyzeQueryResponseErrors + */ + line?: number; + /** + * + * @type {string} + * @memberof AnalyzeQueryResponseErrors + */ + message?: string; +} + /** * * @export @@ -450,14 +496,6 @@ export interface CellUpdate { name?: string; } -/** - * - * @export - * @interface Cells - */ -export interface Cells extends Array { -} - /** * * @export @@ -550,10 +588,10 @@ export interface CreateCell { export interface Dashboard { /** * - * @type {Cells} + * @type {Array} * @memberof Dashboard */ - cells?: Cells; + cells?: Array; /** * user-facing description of the dashboard * @type {string} @@ -9273,6 +9311,48 @@ export class OrganizationsApi extends BaseAPI { */ export const QueryApiAxiosParamCreator = function (configuration?: Configuration) { return { + /** + * + * @summary analyze an influxql or flux query + * @param {'application/json'} [contentType] + * @param {string} [authorization] the authorization header should be in the format of `Token <key>` + * @param {Query} [query] flux or influxql query to analyze + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + queryAnalyzePost(contentType?: 'application/json', authorization?: string, query?: Query, options: any = {}): RequestArgs { + const localVarPath = `/query/analyze`; + const localVarUrlObj = url.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + if (contentType !== undefined && contentType !== null) { + localVarHeaderParameter['Content-Type'] = String(contentType); + } + + if (authorization !== undefined && authorization !== null) { + localVarHeaderParameter['Authorization'] = String(authorization); + } + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); + // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); + const needsSerialization = ("Query" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; + localVarRequestOptions.data = needsSerialization ? JSON.stringify(query || {}) : (query || ""); + + return { + url: url.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * analyzes flux query and generates a query specification. * @param {'application/json'} [contentType] @@ -9565,6 +9645,22 @@ export const QueryApiAxiosParamCreator = function (configuration?: Configuration */ export const QueryApiFp = function(configuration?: Configuration) { return { + /** + * + * @summary analyze an influxql or flux query + * @param {'application/json'} [contentType] + * @param {string} [authorization] the authorization header should be in the format of `Token <key>` + * @param {Query} [query] flux or influxql query to analyze + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + queryAnalyzePost(contentType?: 'application/json', authorization?: string, query?: Query, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { + const localVarAxiosArgs = QueryApiAxiosParamCreator(configuration).queryAnalyzePost(contentType, authorization, query, options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = Object.assign(localVarAxiosArgs.options, {url: basePath + localVarAxiosArgs.url}) + return axios.request(axiosRequestArgs); + }; + }, /** * analyzes flux query and generates a query specification. * @param {'application/json'} [contentType] @@ -9678,6 +9774,18 @@ export const QueryApiFp = function(configuration?: Configuration) { */ export const QueryApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { return { + /** + * + * @summary analyze an influxql or flux query + * @param {'application/json'} [contentType] + * @param {string} [authorization] the authorization header should be in the format of `Token <key>` + * @param {Query} [query] flux or influxql query to analyze + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + queryAnalyzePost(contentType?: 'application/json', authorization?: string, query?: Query, options?: any) { + return QueryApiFp(configuration).queryAnalyzePost(contentType, authorization, query, options)(axios, basePath); + }, /** * analyzes flux query and generates a query specification. * @param {'application/json'} [contentType] @@ -9764,6 +9872,20 @@ export const QueryApiFactory = function (configuration?: Configuration, basePath * @extends {BaseAPI} */ export class QueryApi extends BaseAPI { + /** + * + * @summary analyze an influxql or flux query + * @param {'application/json'} [contentType] + * @param {string} [authorization] the authorization header should be in the format of `Token <key>` + * @param {Query} [query] flux or influxql query to analyze + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof QueryApi + */ + public queryAnalyzePost(contentType?: 'application/json', authorization?: string, query?: Query, options?: any) { + return QueryApiFp(this.configuration).queryAnalyzePost(contentType, authorization, query, options)(this.axios, this.basePath); + } + /** * analyzes flux query and generates a query specification. * @param {'application/json'} [contentType]