This is an automated email from the ASF dual-hosted git repository. hxd pushed a commit to branch openapi in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit b59e3212d1359fd74229eb36c143f9771b387345 Author: xiangdong huang <[email protected]> AuthorDate: Tue Jan 12 00:02:13 2021 +0800 add openapi for test --- openapi/pom.xml | 125 +++++++ openapi/src/main/openapi3/iotdb-rest.yaml | 531 ++++++++++++++++++++++++++++++ pom.xml | 1 + 3 files changed, 657 insertions(+) diff --git a/openapi/pom.xml b/openapi/pom.xml new file mode 100644 index 0000000..e395a4a --- /dev/null +++ b/openapi/pom.xml @@ -0,0 +1,125 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>iotdb-parent</artifactId> + <groupId>org.apache.iotdb</groupId> + <version>0.12.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <packaging>pom</packaging> + + <artifactId>openapi</artifactId> + <properties> + <swagger-codegen-maven-plugin-version>3.0.24</swagger-codegen-maven-plugin-version> + <resteasy-version>3.1.3.Final</resteasy-version> + <swagger-core-version>2.0.0</swagger-core-version> + </properties> + + + <build> + <plugins> + <plugin> + <groupId>io.swagger.codegen.v3</groupId> + <artifactId>swagger-codegen-maven-plugin</artifactId> + <version>${swagger-codegen-maven-plugin-version}</version> + <executions> + <execution> + <goals> + <goal>generate</goal> + </goals> + <configuration> + <!-- use `java -jar swagger-codegen-cli-3.0.24.jar config-help -l java` + to see configuration options--> + <inputSpec>${project.basedir}/src/main/openapi3/iotdb-rest.yaml</inputSpec> + <language>java</language> + <output>${project.build.directory}/generated-sources/java</output> + <apiPackage>org.apache.iotdb.openapi.gen.handler</apiPackage> + <modelPackage>org.apache.iotdb.openapi.gen.model</modelPackage> + <invokerPackage>org.apache.iotdb.openapi.gen.invoker</invokerPackage> + <addCompileSourceRoot>false</addCompileSourceRoot> + <configOptions> + <licenseName>Apache License 2.0</licenseName> + <groupId>org.apache.iotdb</groupId> + <artifactId>iotdb-rest-service</artifactId> + <artifactVersion>${project.version}</artifactVersion> + <serverPort>5667</serverPort> + <dateLibrary>java8</dateLibrary> + <useGzipFeature>true</useGzipFeature> +<!-- <library>resteasy</library>--> + </configOptions> + </configuration> + </execution> + </executions> + </plugin> + + </plugins> + </build> + + <!-- + <dependencies> + <dependency> + <groupId>io.swagger.core.v3</groupId> + <artifactId>swagger-annotations</artifactId> + <version>${swagger-core-version}</version> + </dependency> + <dependency> + <groupId>org.jboss.resteasy</groupId> + <artifactId>resteasy-client</artifactId> + <version>${resteasy-version}</version> + </dependency> + <dependency> + <groupId>org.jboss.resteasy</groupId> + <artifactId>resteasy-multipart-provider</artifactId> + <version>${resteasy-version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + <version>${jackson.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>${jackson.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>${jackson.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.datatype</groupId> + <artifactId>jackson-datatype-jsr310</artifactId> + <version>${jackson.version}</version> + </dependency> + <dependency> + <groupId>org.jboss.resteasy</groupId> + <artifactId>resteasy-jackson-provider</artifactId> + <version>3.1.3.Final</version> + </dependency> + <dependency> + <groupId>com.github.joschi.jackson</groupId> + <artifactId>jackson-datatype-threetenbp</artifactId> + <version>${jackson.version}</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>${junit.version}</version> + <scope>test</scope> + </dependency> + </dependencies> +--> + <profiles> + <profile> + <id>java-rest</id> + <modules> + <module>target/generated-sources/java</module> + </modules> + </profile> + + </profiles> + +</project> \ No newline at end of file diff --git a/openapi/src/main/openapi3/iotdb-rest.yaml b/openapi/src/main/openapi3/iotdb-rest.yaml new file mode 100644 index 0000000..8b8831b --- /dev/null +++ b/openapi/src/main/openapi3/iotdb-rest.yaml @@ -0,0 +1,531 @@ +--- +openapi: 3.0.0 +info: + title: iotdb-rest + description: IoTDB Rest API for Grafana, Prometheus, etc.. + license: + name: Apache 2.0 + version: 1.0.0 +servers: +- url: https://virtserver.swaggerhub.com/jixuan1989/iotdb/1.0.0 + description: SwaggerHub API Auto Mocking +- url: http://localhost:5667 + description: api +security: +- basic: [] +paths: + /v1/grafana/query/frame: + post: + summary: Serve for queries from Grafana + description: Auto Downsampling data query for Grafana + operationId: post-v1-grafana-data + parameters: [] + requestBody: + description: Group By Fill Plan + content: + application/json: + schema: + $ref: '#/components/schemas/GroupByFillPlan' + examples: + example-1: + value: + interval: 0 + stime: 0 + etime: 0 + fills: + - dtype: string + fun: string + paths: + - - string + responses: + "200": + description: return data in wide table format + content: + application/json: + schema: + $ref: '#/components/schemas/GrafanaDataFrame' + examples: {} + "401": + description: Example response + content: + application/json: + schema: + type: string + description: "reason: \nnot login\nno permission" + examples: + example-1: + value: passowrd is incorrect; + /v1/grafana/query/json: + post: + summary: Serve for queries from Grafana with simpleJson plugin + description: Auto Downsampling data query for Grafana with SimpleJson Plugin + operationId: post-v1-grafana-data-simplejson + parameters: [] + requestBody: + description: Group By Fill Plan + content: + application/json: + schema: + $ref: '#/components/schemas/GroupByFillPlan' + examples: {} + responses: + "200": + description: Return data in narrow table format + content: + application/json: + schema: + $ref: '#/components/schemas/GrafanaJson' + examples: + example-1: + value: + - target: root.sg.d1.s1 + datapoints: + - 1.2 + - 16100110034 + - 1.3 + - 16100110035 + - target: root.sg.d1.s2 + datapoints: + - 1.2 + - 16100110034 + - 1.3 + - 16100110035 + "401": + description: Example response + content: + application/json: + schema: + type: string + description: "reason: \nnot login\nno permission" + examples: + example-1: + value: passowrd is incorrect; + /v1/prometheus/write: + post: + summary: Serve for writing data by Prometheus + operationId: post-v1-prometheus-receive + parameters: + - name: User-Agent + in: header + description: Prometheus/2.24.0 + required: false + style: simple + explode: false + schema: + type: string + example: Prometheus/2.24.0 + - name: X-Prometheus-Remote-Write-Version + in: header + description: 0.1.0 + required: false + style: simple + explode: false + schema: + type: string + example: 0.1.0 + requestBody: + description: | + Prompb.WriteRequest that encoding by Protobuf (3.12.3) and compressed by Snappy. Once uncompressed and dencoding. + content: + application/x-protobuf: + schema: + type: object + properties: {} + examples: + example-1: + value: + Timeseries: + - - Labels: + - Name: tagkey + Value: tagvalue + - Name: tagkey2 + Value: tagValue2 + - Samples: + - value1: + Timestamp: 16100105235 + Value: 0.1 + - - Labels: + - Name: tagkey + Value: tagvalue + - value2: + Name: tagkey2 + Value: tagValue2 + - Samples: + - value1: + Timestamp: 16100105235 + Value: 0.1 + responses: + "200": + description: OK for failed + content: + application/json: + schema: + $ref: '#/components/schemas/inline_response_200' + examples: + example-1: + value: + code: string + message: string + "401": + description: Example response + content: + application/json: + schema: + type: string + description: "reason: \nnot login\nno permission" + examples: + example-1: + value: passowrd is incorrect; + /v1/prometheus/query: + post: + summary: Serve for queries from Prometheus + description: Serve reading data by Prometheus + operationId: post-v1-prometheus-query + parameters: + - name: User-Agent + in: header + description: e.g., Prometheus/2.24.0 + required: false + style: simple + explode: false + schema: + type: string + - name: X-Prometheus-Remote-Read-version + in: header + description: e.g., 0.1.0 + required: false + style: simple + explode: false + schema: + type: string + requestBody: + description: | + Prompb.ReadRequest that encoding by Protobuf (3.12.3) and compressed by Snappy. Once uncompressed and dencoding. + content: + application/x-protobuf: + schema: + type: object + examples: + example-1: + value: + Queries: + - StartTimestampMs: 1610210292064 + EndTimestampMs: 1610210292064 + Matchers: + - Type: LabelMatcher_EQ + Name: __name__ + Value: value on the operator right side, e.g., root.sg.d1.s1 + Hints: + StepMs: 0 + Func: "" + StartMs: 161021029264 + EndMs: 161021029264 + Grouping: [] + By: false + RangeMs: 0 + responses: + "200": + description: | + Prompb.QueryResult that encoding by Protobuf (3.12.3) and compressed by Snappy. Once uncompressed and dencoding, the data looks like (the same with WriteRequest). + content: + application/x-protobuf: + schema: + type: object + examples: + example-1: + value: + Timeseries: + - - Labels: + - Name: tagkey + Value: tagvalue + - Name: tagkey2 + Value: tagValue2 + - Samples: + - value1: + Timestamp: 16100105235 + Value: 0.1 + - - Labels: + - Name: tagkey + Value: tagvalue + - value2: + Name: tagkey2 + Value: tagValue2 + - Samples: + - value1: + Timestamp: 16100105235 + Value: 0.1 + /v1/grafana/node: + post: + summary: Serve for getting time series name level by level by Grafana + description: Get Children nodes that the node has + operationId: post-v1-grafana-node + requestBody: + content: + application/json: + schema: + type: array + description: node name (e.g., "root.a.b.c") + items: + type: string + examples: + example-1: + value: + - root + - sg + - d1 + responses: + "200": + description: Return Node collection for a given parent node. + content: + application/json: + schema: + $ref: '#/components/schemas/inline_response_200_1' + examples: + example-1: + value: + leaf: + - string + internal: + - string + "401": + description: Example response + content: + application/json: + schema: + type: string + description: "reason: \nnot login\nno permission" + examples: + example-1: + value: passowrd is incorrect; +components: + schemas: + GroupByFillPlan: + title: GroupByTimeFillPlan + type: object + properties: + interval: + type: number + description: group by + stime: + type: number + etime: + type: number + fills: + type: array + items: + $ref: '#/components/schemas/GroupByFillPlan_fills' + paths: + type: array + items: + type: array + items: + type: string + description: Group By Time Plan in IoTDB + x-examples: + example-1: + interval: 0 + stime: 0 + etime: 0 + fills: + - dtype: string + fun: string + paths: + - - string + GrafanaDataFrame: + minItems: 1 + uniqueItems: true + type: array + items: + $ref: '#/components/schemas/GrafanaDataFrame_inner' + x-examples: + example-1: + - name: test + fields: + - name: Time + type: FieldType.time + values: + - 1610111000 + - 1610111100 + - 1610112000 + - name: root.sg.d1.s1 + type: FieldType.number + values: + - 1 + - 2 + - 3 + - name: root.sg.d1.s2 + type: FieldType.number + values: + - 1 + - null + - 3 + - name: root.sg.d1.s3 + type: FieldType.boolean + values: + - 0 + - 0 + - 1 + GrafanaJson: + title: GrafanaJson + type: array + items: + $ref: '#/components/schemas/GrafanaJson_inner' + x-examples: + example-1: + - target: root.sg.d1.s1 + datapoints: + - - 1.2 + - 16100110034 + - - 1.3 + - 16100110035 + - target: root.sg.d1.s2 + datapoints: + - - 1.2 + - 16100110034 + - - 1.3 + - 16100110035 + inline_response_200: + type: object + properties: + code: + type: string + message: + type: string + inline_response_200_1: + type: object + properties: + leaf: + type: array + description: All children nodes that are leaves + items: + type: string + internal: + type: array + description: All internal nodes + items: + type: string + GroupByFillPlan_fills: + type: object + properties: + dtype: + type: string + fun: + type: string + GrafanaDataFrame_inner: + required: + - fields + type: object + properties: + name: + minLength: 1 + type: string + description: prefix of series path + fields: + minItems: 1 + uniqueItems: true + type: array + items: + required: + - name + - type + type: object + properties: + name: + minLength: 1 + type: string + description: Time, or series name + type: + minLength: 1 + type: string + description: FieldType.time or FieldType.number + values: + type: array + description: points (time column or value column) + items: {} + GrafanaJson_inner: + type: object + properties: + target: + type: string + description: time series name + datapoints: + type: array + description: value(null if no value), timestamp + items: + type: number + responses: + Unauthorized401: + description: Example response + content: + application/json: + schema: + type: string + description: "reason: \nnot login\nno permission" + examples: + example-1: + value: passowrd is incorrect; + GrafanaDataFrame200: + description: return data in wide table format + content: + application/json: + schema: + $ref: '#/components/schemas/GrafanaDataFrame' + examples: {} + GrafanaSimpleJson200: + description: Return data in narrow table format + content: + application/json: + schema: + $ref: '#/components/schemas/GrafanaJson' + examples: + example-1: + value: + - target: root.sg.d1.s1 + datapoints: + - 1.2 + - 16100110034 + - 1.3 + - 16100110035 + - target: root.sg.d1.s2 + datapoints: + - 1.2 + - 16100110034 + - 1.3 + - 16100110035 + ChinldNodes200: + description: Return Node collection for a given parent node. + content: + application/json: + schema: + $ref: '#/components/schemas/inline_response_200_1' + examples: + example-1: + value: + leaf: + - string + internal: + - string + GeneralResult200: + description: Example response + content: + application/json: + schema: + type: object + properties: + status: + type: integer + type: + type: integer + ? "" + : oneOf: + - $ref: '#/components/schemas/GrafanaJson' + - $ref: '#/components/schemas/GrafanaDataFrame' + - type: object + securitySchemes: + basic: + type: http + scheme: basic + APIKey: + type: apiKey + name: API Key + in: header diff --git a/pom.xml b/pom.xml index 9a8c06c..f053b2c 100644 --- a/pom.xml +++ b/pom.xml @@ -100,6 +100,7 @@ <module>cross-tests</module> <module>zeppelin-interpreter</module> <module>client-py</module> + <module>openapi</module> </modules> <!-- Properties Management --> <properties>
