50.md 8.2 KB
Newer Older
W
mkdocs  
wizardforcel 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
# 解释器 API

原文链接 : [http://zeppelin.apache.org/docs/0.7.2/rest-api/rest-interpreter.html](http://zeppelin.apache.org/docs/0.7.2/rest-api/rest-interpreter.html)

译文链接 : [http://www.apache.wiki/pages/viewpage.action?pageId=10030697](http://www.apache.wiki/pages/viewpage.action?pageId=10030697)

贡献者 : [小瑶](/display/~chenyao) [ApacheCN](/display/~apachecn) [Apache中文网](/display/~apachechina)

## Overview ( 概述 )

**Apache Zeppelin** 提供了几个 **REST API** ,用于交互和远程激活 **zeppelin** 功能。所有 **REST API** 都可以从以下端点。请注意,**Apache Zeppelin REST API** 接收或返回 **JSON** 对象,建议您安装 **JSON** 查看器如 **[JSONView](https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc) **

如果您使用 **Apache Zeppelin** 并发现需要一个额外的 **REST API** ,请 [提出问题或向我们发送电子邮件](http://zeppelin.apache.org/community.html)

## 解释器REST API列表

这里介绍了 **registered interpreters** , **settings** ( 设置 ) 和 **interpreters group** 的作用。

### 注册解释器人员名单

| 描述 | 该 GET 方法返回服务器上可用的 all the registered interpreters ( 所有已注册的解释器 ) 。 |
| URL | http://[zeppelin-server]:[zeppelin-port]/api/interpreter |
| 成功代码 | 200 |
| 失败代码 | 500 |
| JSON 响应示例 | 

```
{
  "status": "OK",
  "message": "",
  "body": {
    "md.md": {
      "name": "md",
      "group": "md",
      "className": "org.apache.zeppelin.markdown.Markdown",
      "properties": {},
      "path": "/zeppelin/interpreter/md"
    },
    "spark.spark": {
      "name": "spark",
      "group": "spark",
      "className": "org.apache.zeppelin.spark.SparkInterpreter",
      "properties": {
        "spark.executor.memory": {
          "defaultValue": "1g",
          "description": "Executor memory per worker instance. ex) 512m, 32g"
        },
        "spark.cores.max": {
          "defaultValue": "",
          "description": "Total number of cores to use. Empty value uses all available core."
        },
      },
      "path": "/zeppelin/interpreter/spark"
    },
    "spark.sql": {
      "name": "sql",
      "group": "spark",
      "className": "org.apache.zeppelin.spark.SparkSqlInterpreter",
      "properties": {
        "zeppelin.spark.maxResult": {
          "defaultValue": "1000",
          "description": "Max number of Spark SQL result to display."
        }
      },
      "path": "/zeppelin/interpreter/spark"
    }
  }
}
```

 |

### 注册解释器设定清单

| 描述 | 该 GET 方法返回服务器上注册的所有解释器设置。 |
| URL | http://[zeppelin-server]:[zeppelin-port]/api/interpreter/setting |
| 成功代码 | 200 |
| 失败代码 | 500 |
| JSON 响应示例 | 

```
{
  "status": "OK",
  "message": "",
  "body": [
    {
      "id": "2AYUGP2D5",
      "name": "md",
      "group": "md",
      "properties": {
        "empty": ""
      },
      "interpreterGroup": [
        {
          "class": "org.apache.zeppelin.markdown.Markdown",
          "name": "md"
        }
      ],
      "dependencies": []
    },

    {
      "id": "2AY6GV7Q3",
      "name": "spark",
      "group": "spark",
      "properties": {
        "spark.cores.max": "",
        "spark.executor.memory": "1g",
      },
      "interpreterGroup": [
        {
          "class": "org.apache.zeppelin.spark.SparkInterpreter",
          "name": "spark"
        },
        {
          "class": "org.apache.zeppelin.spark.SparkSqlInterpreter",
          "name": "sql"
        }
      ],
      "dependencies": [
        {
          "groupArtifactVersion": "com.databricks:spark-csv_2.10:1.3.0"
        }
      ]
    }
  ]
}
```

 |

### 通过设置 ID 获取注册的解释器设置

| 描述 | 该 GET 方法在服务器上返回已注册的解释器设置 |
| URL | http://[zeppelin-server]:[zeppelin-port]/api/interpreter/setting/[setting ID] |
| 成功代码 | 200 |
| 失败代码 | 400 如果这样的解释器设置 id 不存在500 任何其他错误 |
| JSON 响应示例 | 

```
{
  "status": "OK",
  "message": "",
  "body": {
    "id": "2AYW25ANY",
    "name": "Markdown setting name",
    "group": "md",
    "properties": {
      "propname": "propvalue"
    },
    "interpreterGroup": [
      {
        "class": "org.apache.zeppelin.markdown.Markdown",
        "name": "md"
      }
    ],
    "dependencies": [
      {
        "groupArtifactVersion": "groupId:artifactId:version",
        "exclusions": [
          "groupId:artifactId"
        ]
      }
    ]
  }
}
```

 |

### 创建一个新的解释器设置 

| 描述 | 此 POST 方法使用注册的解释器将新的解释器设置添加到服务器。 |
| URL | http://[zeppelin-server]:[zeppelin-port]/api/interpreter/setting |
| 成功代码 | 201 |
| 失败代码 | 400 如果输入 JSON 为空500 则为其他任何错误 |
| 示例 JSON 输入 | 

```
{
  "name": "Markdown setting name",
  "group": "md",
  "properties": {
    "propname": "propvalue"
  },
  "interpreterGroup": [
    {
      "class": "org.apache.zeppelin.markdown.Markdown",
      "name": "md"
    }
  ],
  "dependencies": [
    {
      "groupArtifactVersion": "groupId:artifactId:version",
      "exclusions": [
        "groupId:artifactId"
      ]
    }
  ]
}
```

 |
| 示例 JSON 响应 | 

```
{
  "status": "CREATED",
  "message": "",
  "body": {
    "id": "2AYW25ANY",
    "name": "Markdown setting name",
    "group": "md",
    "properties": {
      "propname": "propvalue"
    },
    "interpreterGroup": [
      {
        "class": "org.apache.zeppelin.markdown.Markdown",
        "name": "md"
      }
    ],
    "dependencies": [
      {
        "groupArtifactVersion": "groupId:artifactId:version",
        "exclusions": [
          "groupId:artifactId"
        ]
      }
    ]
  }
}
```

 |

### 更新解释器设置

| 描述 | 此 PUT 方法使用新属性更新解释器设置 |
| URL | http://[zeppelin-server]:[zeppelin-port]/api/interpreter/setting/[interpreter ID] |
| 成功代码 | 200 |
| 失败代码 | 500 |
| 示例 JSON 输入 | 

```
{
  "name": "Markdown setting name",
  "group": "md",
  "properties": {
    "propname": "Otherpropvalue"
  },
  "interpreterGroup": [
    {
      "class": "org.apache.zeppelin.markdown.Markdown",
      "name": "md"
    }
  ],
  "dependencies": [
    {
      "groupArtifactVersion": "groupId:artifactId:version",
      "exclusions": [
        "groupId:artifactId"
      ]
    }
  ]
}
```

 |
| 示例 JSON 响应 | 

```
{
  "status": "OK",
  "message": "",
  "body": {
    "id": "2AYW25ANY",
    "name": "Markdown setting name",
    "group": "md",
    "properties": {
      "propname": "Otherpropvalue"
    },
    "interpreterGroup": [
      {
        "class": "org.apache.zeppelin.markdown.Markdown",
        "name": "md"
      }
    ],
    "dependencies": [
      {
        "groupArtifactVersion": "groupId:artifactId:version",
        "exclusions": [
          "groupId:artifactId"
        ]
      }
    ]
  }
}
```

 |

### 删除解释器设置

| 描述 | 此 DELETE 方法删除给定的解释器设置 |
| URL | http://[zeppelin-server]:[zeppelin-port]/api/interpreter/setting/[interpreter ID] |
| 成功代码 | 200 |
| 失败代码 | 500 |
| 示例 JSON 响应 | {"status":"OK"} |

### 重新启动解释器

| 描述 | 此 PUT 方法重新启动给定的解释器标识。 |
| URL | http://[zeppelin-server]:[zeppelin-port]/api/interpreter/setting/restart/[interpreter ID] |
| 成功代码 | 200 |
| 失败代码 | 500 |
| JSON 输入示例(可选) | 

```
{ 
  “noteId”:“2AVQJVC8N” 
}
```

 |
| 示例 JSON 响应 | {"status":"OK"} |

### 添加用于依赖关系解析的新存储库

| 描述 | 此 POST 方法添加新的存储库。 |
| URL | http://[zeppelin-server]:[zeppelin-port]/api/interpreter/repository |
| 成功代码 | 201 |
| 失败代码 | 500 |
| 示例 JSON 输入 | 

```
{
  "id": "securecentral",
  "url": "https://repo1.maven.org/maven2",
  "snapshot": false
}
```

 |
| 示例 JSON 响应 | {"status":"OK"} |

### 删除依赖关系解析的存储库

| 描述 | 此 DELETE 方法删除具有给定 ID 的存储库。 |
| URL | http://[zeppelin-server]:[zeppelin-port]/api/interpreter/repository/[repository ID] |
| 成功代码 | 200 |
| 失败代码 | 500 |