数据应用程序接口

datadots-api的Python项目详细描述


#用于python的datadots api

[![PYPI](https://img.shields.io/PYPI/v/nine.svg)](https://pypi.org/project/datadots-api/)



**状态:您当前看到的是WIP,请勿在生产中使用!**

这是用于python的datadots api,允许您针对任何dotmesh集群访问和操作点。注意,只支持Python3。

-[安装](安装)
-[使用](使用)
-[创建点](创建点)
-[在命名空间中创建点](创建点在命名空间中)
-[按名称查找点](查找点在命名空间中)
-[提交到分支,show log](commit-to-a-branch-and-show-the-log)
-[基于最新主控形状创建新分支](基于最新主控形状创建新分支)
-[端到端示例](端到端示例)
-[测试]

这是唯一支持的版本。
然后执行:

``bash
$pip3 install datadots api==0.1.4
````

=dotmesh client(cluster_url=cluster_url,username=user,api_key=api_key)
dot=dmclient.createdot(dotname="test")
`````

``python
api_key=api_key)
dot=dmclient.createdot(dot name="test",ns="mynamespace")
`````

```python
api_key=api_key)
打印(d.getdot(dotname="test")
````

``python
api_key=api_key)
dot=dmclient.createdot(dotname="test")
branch=dot.getbranch("master")
branch.commit("just a test commit")
print(branch.log())
``````

=dotmeshclient(cluster_url=cluster_url,username=user,api_key=api_key)
dot=dmclient.createdot(dotname="test")
branch=dot.getbranch("master")
branch.commit("带有一些额外元数据的提交",{"fruit":"apples","color":"red"})
打印(branch.log())
```

``python
```python
;基于最新的主节点创建新的分支。客户端导入dotmesh client
d=dotmeshclient(cluster=cluster=url,username=user,api_key=api_key)
dot=dmclient.createdot(dotname="test")
branch=dot.getbranch("master")
branch.commit("just a test commit")
mybranch=branch.createbranch("mybranch","master")
my branch.commit("我的分支中的第一个提交")
print(mybranch.log())
`````

````````````br/>通过运行以下[示例](example.py):

`` bash
$dotmesh_apikey=$(cat~/.dotmesh/config jq-r.remotes.local.apikey)
$dotmesh_apikey=$dotmesh_apikey python3 example.py
==创建点:
-->;{"jsonrpc":"2.0","method":"dotmeshrpc.create","params":{"namespace":"admin","name":"test"},"id":1}
<;--{"jsonrpc":"2.0","result":true,"id":1}(200 ok)
--gt;{"jsonrpc":"2.0","method":"dotmeshrpc.lookup","params":{"namespace":"admin","name":"test","branch":"}",id:2}
<;--"jsonrpc":"2.0","result":"32965cef-4310-4291-6f36-c86106655d10","id":2}(200正常)

id=32965cef-4310-4291-6f36-c86106655d10,name=test

==获取主分支:
-->;{"jsonrpc":"2.0","method":"dotmeshrpc.lookup","params":"namespace":"admin","name":"test","branch":"}",id":3}
<;--{"jsonrpc":"2.0","result":"32965cef-4310-4291-6f36-c86106655d10","id":3}(200 ok)



==执行一些提交并显示日志:
-->;{"jsonrpc":"2.0","method":"dotmeshrpc.commit","params":"namespace":"admin","name":"test","branch":","message":"只是一个测试提交"},"id":4}
<;{"jsonrpc":"2.0","result":true,"id":4}(200 ok)
--gt;{"jsonrpc":"2.0","method":"dotmeshrpc.commit","params":{"namespace":"admin","name":"test","branch":,"message":"和另一个提交,谁会想到"},"id":5}
<;{"jsonrpc":"2.0","result":true,"id":5}(200 ok)
-->;{"jsonrpc":"2.0","method":"dotmeshrpc.commits","params":{"namespace":"admin","name":"test","branch":"}",id:6}
<;{"jsonrpc":"2.0","result":[{"id":"1007db99-11cb-4bd7-747e-1d121bb9b11a","metadata":{"author":"admin","message":"只是一个测试提交","timestamp":"1521214312285694689"},{"id":"67bb6184-430b-46d7-4337-b858ee85eb1c","metadata":{"author":"admin","message":"和另一个提交,谁会想到呢","timestamp":"1521214312418429042"},"id":6}(200 ok)



<1521214312285694689:只是一个测试提交
<1521214312418429042:和另一个提交,谁会想到

==创建新分支,提交并显示日志:
-->;{"jsonrpc":"2.0","method":"dotmeshrpc.commits","params":{"namespace":"admin","name":"test","branch":"}",id:7}
<;{"jsonrpc":"2.0","result":[{"id":"1007db99-11cb-4bd7-747e-1d121bb9b11a","metadata":{"author":"admin","message":"just a test commit","timestamp":"1521214312285694689"},"id":"67bb6184-430b-46d7-4337-b858ee85eb1c,"metadata":{"author":"admin","message":"还有另一个commit,谁会想到","timestamp":"1521214312418429042"}),"id":7}(200 ok)
--gt;{"jsonrpc":"2.0","method":"dotmeshrpc.branch","params":{"namespace":"admin","name":"test","sourcebranch":"master","newbranchname":"mybranch","sourcecommitid":"67bb6184-430b-46d7-4337-b858ee85eb1c"},"id":8}
<;{"jsonrpc":"2.0","result":true,"id":8}(200 ok)
-->;{"jsonrpc":"2.0","method":"dotmeshrpc.commit","params":{"namespace":"admin","name":"test","branch":"mybranch","message":"我的分支中的第一次提交"},"id":9}
<;{"jsonrpc":"2.0","result":true,"id":9}(200 ok)
--gt;{"jsonrpc":"2.0","method":"dotmeshrpc.commits","params":{"namespace":"admin","name":"test","branch":"mybranch"},"id":10}
<;{"jsonrpc":"2.0","result":[{"id":"565b04ab-abae-476a-75bd-203bce2a56b2","metadata":{"author":"admin","message":"我的分支中的第一次提交","timestamp":"1521214312967840418"}],"id":10}(200 ok)



1521214312967840418:我的分支中的第一个提交
````

请注意,上面示例的默认行为是保留点,也就是说,如果执行'dm dot show test',则应该看到带有提交的'master'分支和'my branch'。如果你想自动清理,按如下方式执行:`python3 example.py cleanup`:

``bash
$dm list
current remote:local(使用'dm remote-v'列出,使用'dm remote switch'切换)


dot branch server containers size commits dirty
*test master 995e5c821c38e7f51.00 kib 1-

$dm dot show test
点管理/测试:
主分支ID:7f4a4d67-5bc7-47aa-7829-31d5a02f70f
点大小:1.00 kib(全部干净)
分支:
*master
mybranch

$dm checkout mybranch&;dm log
commit 565b04ab-abae-476a-75bd-203bce2a56b2
作者:admin
日期:1521214312967840418


我的分支中的第一次提交
`````

测试

它假设您已经安装了[http](https://httpie.org/)(或者您也可以使用'curl')并且Docker正在运行(注意:在v18.03上测试):

``` bash
$dm cluster init
$dotmesh_clusterurl=http://localhost:6969/rpc
$dotmesh_apikey=$(cat~/.dotmesh/config jq-r.remotes.local.apikey)
$http-a admin:$dotmesh_apikey post$dotmesh_clusterurl<;test/ping.json
http/1.1200 ok
内容长度:57
内容类型:application/json;charset=utf-8
日期:周五,2018年3月16日07:06:44 GMT
x-content-type-options:nosniff

{
"id":612948461166146000,
"jsonrpc":"2.0",
"结果":真
}
```

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
在java中将字符串转换为音频输入   java如何使用Spring Boot RestTemplate解组json列表   计算机上C++ OpenCV项目转换为OpenCV Android的java步骤   Java Spring Telegraf数据表不工作   openurlconnection与connect之间的java差异?   java Solr字段搜索、通配符和转义字符   java如何使用DLFolderLocalServiceUtil类的getFolders()方法?   尝试用Java编写文件   java连续双缓冲解决方案不起作用   两个数组的Java乘积   java Jackson,如何正确编写自定义反序列化程序   java将布尔标志按一定顺序排列以获得更好的性能是否有意义   java Vaadin无缓冲网格无法关闭   java在MySQL中以同一用户身份同时从不同客户端登录安全吗?   java如何使用安卓asynchttp库   java无法在Android中使用AlarmManager停止服务   java在Hibernate的XML配置文件中指定默认值   Spring启动应用程序中的java内存SQLITE不工作   Java代码无法写入文本文件,