• kylin 使用RESTful API 请求


          目前根据Kylin的官方文档介绍,Kylin的认证是basic authentication,加密算法是Base64,在POST的header进行用户认证
    我使用的用户和密码是(格式:username:password) :ADMIN:KYLIN 使用Base64编码后结果为QURNSU46S1lMSU4=
    1、在Linux环境下
         curl -c cookiefile.txt -X POST -H "Authorization: Basic QURNSU46S1lMSU4="-H 'Content-Type: application/json'http://10.8.217.66:7070/kylin/api/user/authentication

         在执行的目录下会生成cookiefile.txt 文件,内容是:

     

    返回结果:

    {
        "userDetails":{
            "password":null,
            "username":"ADMIN",
            "authorities":[
                {
                    "authority":"ROLE_ADMIN"
                },
                {
                    "authority":"ROLE_ANALYST"
                },
                {
                    "authority":"ROLE_MODELER"
                }
            ],
            "accountNonExpired":true,
            "accountNonLocked":true,
            "credentialsNonExpired":true,
            "enabled":true
        }
    }

     如果登录成功,JSESSIONID将被保存到cookie文件中; 在随后的http请求中,附加cookiefile.txt 文件就可以了,不需要每次都认证,

     相当于在浏览器下访问后,留下的cookis信息。  如:

    curl -b cookiefile.txt -X PUT -H 'Content-Type: application/json' -d '{"startTime":'1423526400000', "endTime":'1423526400', "buildType":"BUILD"}' http://<host>:<port>/kylin/api/cubes/your_cube/build
    您可以在命令中提供用户名/密码选项“用户”; 请注意,这在shell历史中有密码泄露的风险
    curl -X PUT --user ADMIN:KYLIN -H "Content-Type: application/json;charset=utf-8" -d '{ "startTime": 820454400000, "endTime": 821318400000, "buildType": "BUILD"}' http://<host>:<port>/kylin/api/cubes/kylin_sales/build

    查询项目下的表数据

    curl -X POST -H "Authorization: Basic QURNSU46S1lMSU4=" -H "Content-Type: application/json" -d '{ "sql":"select count(*) from TEST_KYLIN_FACT", "project":"learn_kylin" }'http://<host>:<port>/kylin//api/query

    你可能觉得这个方式不好,写这么多,没有关系,你也可以通过代码实现,使用JDBC访问方式。如果仅仅为了看数据,也可以使用PostMan来看数据。

    2、POSTMAN 方式查看或者请求

    首先必须知道你用什么用户名和密码去访问Kylin,所以Header信息必须要带。

       Authorization:Basic QURNSU46S1lMSU4=
       Content-Type: application/json;charset=UTF-8

    
    
    

    1、查看Cube信息
    get:http://10.8.217.66:7070/kylin/api/cubes?cubeName=kylin_sales_cube&limit=15&offset=0

    2、列出当前项目的表和列

    3、SQL 查询语句请求
    post:http://10.8.217.66:7070/kylin/api/query

    {
    "sql":"select * from KYLIN_SALES",
    "offset":0,
    "limit":50000,
    "acceptPartial":false,
    "project":"learn_kylin"
    }

    4、列出所以Cubes信息
    get:http://10.8.217.66:7070//kylin/api/cubes

    5、GET http://10.8.217.66:7070/kylin/api/cubes/kylin_sales_cube
    6、GET http://10.8.217.66:7070/kylin//api/cube_desc/{cubeName}


    参考详见:
    http://kylin.apache.org/docs20/howto/howto_use_restapi.html#build-cube
    http://kylin.apache.org/docs20/howto/howto_build_cube_with_restapi.html




  • 相关阅读:
    wireshark和tcpdump抓包TCP乱序和重传怎么办?PCAP TCP排序工具分享
    途游斗地主加密协议分析及破解
    linux下unzip解压报错“symlink error: File name too long”怎么办?提供解决方案。
    GPS NMEA-0183协议常用报文数据格式
    微信出现“已停止访问该网页”或“关于潜在的违法或违规内容”怎么办?如何获取被屏蔽的网页的网址?...
    m3u8视频格式分析
    精确哈克,以贪婪为基础的欺诈式引流法
    某米浏览器黑名单文件破解
    HTTP.sys远程执行代码漏洞
    SNMP协议利用
  • 原文地址:https://www.cnblogs.com/mistor/p/6724902.html
Copyright © 2020-2023  润新知