Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Kylin Restful API

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

How to use Kylin Restful API, in view of this problem, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Description: the Restful API Response section on the official website is very detailed, but the Request part is very simple, and some examples are not illustrated. The author was very confused at the beginning of the restful interface development, and of course we are more concerned about how to send a request to access Kylin, so that the Response we get is meaningful. This article focuses on examples of how to use Restful API to access Kylin (the structure is consistent with the official website).

1. Query | Authentication

Official website: there are examples.

API description: for authentication.

The author was a little dizzy at the beginning, and didn't understand the meaning of its permission verification for a while. Here is a brief explanation:

On the first visit:

Curl-c / path/to/cookiefile.txt-X POST\

-H "Authorization: Basic XXXXXXXXX"\

-H 'Content-Type: application/json'\

Http://:/kylin/api/user/authentication

On the second visit:

Curl-b / path/to/cookiefile.txt-X PUT\

-H 'Content-Type: application/json'\

-d'{"startTime": '1423526400000,\

"endTime": '1423526400,\

BuildType: "BUILD"}'\

Http://:/kylin/api/cubes/your_cube/build

This is a bit like kerberos authentication: first generate a keytab file for each user, and then users can log in through this keytab file, of course, the principle is not the same. The first time to access Kylin, to carry out authentication operation, through the Authorization header, pass in a base64 encoded value, usually the "user name: password" is encoded and passed in, and then generate a cookie file to save locally, that is, cookiefile.txt. When you log in the second time, you no longer need to authenticate, you can access the Kylin by specifying the cookie file (you can also access the Kylin by specifying the Authorization header, of course).

The Authorization value can be obtained from the following code:

Byte [] key = ("ADMIN:KYLIN") .getBytes

Encoding = new sun.misc.BASE64Encoder () .encode (key)

You can get: encoding = "QURNSU46S1lMSU4="

Then access it through-H "Authorization: Basic QURNSU46S1lMSU4="

2. Query | Query

Official website: there are examples.

API description: execute all query statements.

3. Query | List queryable tables

API description: lists the tables that can be queried under the specified project

API gives an example:

Curl-X GET-H "Content-Type: application/json"\

-H "Authorization: Basic QURNSU46S1lMSU4="\

Http://:/kylin/api/tables_and_columns?project=projectName

4. CUBE | List cubes

API description: lists cube information that meets the criteria

API gives an example:

a. List all cube information (limit=15) for all projects

Curl-vi-X GET\

-H "Authorization: Basic QURNSU46S1lMSU4="\

-H "Content-Type: application/json"\

Http://:/kylin/api/cubes?limit=15&offset=0

b. List the cube information of cubeName=xxxx under all projects

Curl-vi-X GET\

-H "Authorization: Basic QURNSU46S1lMSU4="\

-H "Content-Type: application/json"\

Http://:/kylin/api/cubes?cubeName=xxxx&limit=15&offset=0

Note: cubeName parameters must be written before limit and offset, otherwise they will become invalid.

c. List all the cube information under the specified project

Curl-vi-X GET\

-H "Authorization: Basic QURNSU46S1lMSU4="\

-H "Content-Type: application/json"\

Http://:/kylin/api/cubes?projectName=xxxx&limit=15&offset=0

Note: projectName parameters must be written before limit and offset, otherwise they will become invalid.

D.cubeName and projectName are optional, which is the first and which is effective

Curl-vi-X GET\

-H "Authorization: Basic QURNSU46S1lMSU4="\

-H "Content-Type: application/json"\

Http://:/kylin/api/cubes?cubeName=xxxx&\

ProjectName=xxxx&limit=15&offset=0

5. CUBE | Get Cube

API description: get the specified cube information

API gives an example:

Curl-vi-b / home/cookiefile.txt-X GET\

-H "Content-Type: application/json"\

Http://:/kylin/api/cubes?cubeName=xxxx

6. CUBE | Get cube descriptor

API description: gets the description information of the specified cube

API gives an example:

Curl-vi-b / home/cookiefile.txt-X GET\

-H "Content-Type: application/json"\

Http://:/kylin/api/cube_desc/{cubeName}

7. CUBE | Get data model

API description: get the information of the specified model

API gives an example:

Curl-vi-b / home/cookiefile.txt-X GET\

-H "Content-Type: application/json"\

Http://:/kylin/api/model/{modelName}

8. CUBE | Build cube

API description: build cube

API gives an example: there is a case on the official website

Note: both PUT / kylin/api/cubes/ {cubeName} / build and PUT / kylin/api/cubes/ {cubeName} / rebuild tests are available.

9. CUBE | Enable Cube

API description: make the built cube unavailable

API gives an example:

Curl-X PUT\

-H "Authorization: Basic QURNSU46S1lMSU4="\

-H 'Content-Type: application/json'\

Http://:/kylin/api/cubes/{cubeName}/enable

10. CUBE | Disable Cube

API description: restore unavailable cube is available

API gives an example:

Curl-X PUT\

-H "Authorization: Basic QURNSU46S1lMSU4="\

-H 'Content-Type: application/json'\

Http://:/kylin/api/cubes/{cubeName}/disable

11. CUBE | Purge Cube

API description: clear all cube data

API gives an example:

Curl-X PUT\

-H "Authorization: Basic QURNSU46S1lMSU4="\

-H 'Content-Type: application/json'\

Http://:/kylin/api/cubes/{cubeName}/purge

Note: before purge, you must first disable,purge and then delete the metadata, and the table has not been deleted.

twelve。 Delete useless segment

API description: it is not available on the official website. It took a long time for Google to find it. This API can be used when an error build a cube.

API gives an example:

Curl-vi-b / home/cookiefile.txt\

-XDELETE-H "Content-Type: application/json"\

This is the answer to the question on how to use Kylin Restful API. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report