blob: 4f303308075329d7abc002a8809a1206c679fd95 [file] [log] [blame]
(window.webpackJsonp=window.webpackJsonp||[]).push([[43],{110:function(e,n,t){"use strict";t.r(n),t.d(n,"frontMatter",(function(){return c})),t.d(n,"metadata",(function(){return s})),t.d(n,"toc",(function(){return b})),t.d(n,"default",(function(){return l}));var o=t(3),a=t(7),r=(t(0),t(144)),c={title:"Notebook REST API"},s={unversionedId:"api/notebook",id:"api/notebook",isDocsHomePage:!1,title:"Notebook REST API",description:"\x3c!--",source:"@site/docs/api/notebook.md",slug:"/api/notebook",permalink:"/docs/api/notebook",editUrl:"https://github.com/apache/submarine/edit/master/website/docs/api/notebook.md",version:"current",sidebar:"api",previous:{title:"Experiment Template REST API",permalink:"/docs/api/experiment-template"}},b=[{value:"Create a notebook instance",id:"create-a-notebook-instance",children:[]},{value:"List notebook instances which belong to user",id:"list-notebook-instances-which-belong-to-user",children:[]},{value:"Get the notebook instance",id:"get-the-notebook-instance",children:[]},{value:"Delete the notebook instance",id:"delete-the-notebook-instance",children:[]}],i={toc:b};function l(e){var n=e.components,t=Object(a.a)(e,["components"]);return Object(r.b)("wrapper",Object(o.a)({},i,t,{components:n,mdxType:"MDXLayout"}),Object(r.b)("blockquote",null,Object(r.b)("p",{parentName:"blockquote"},"Note: The Notebook API is in the alpha stage which is subjected to incompatible changes in future releases.")),Object(r.b)("h2",{id:"create-a-notebook-instance"},"Create a notebook instance"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"POST /api/v1/notebook")),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"Example Request")),Object(r.b)("pre",null,Object(r.b)("code",{parentName:"pre",className:"language-sh"},'curl -X POST -H "Content-Type: application/json" -d \'\n{\n "meta": {\n "name": "test-nb",\n "namespace": "default",\n "ownerId": "e9ca23d68d884d4ebb19d07889727dae"\n },\n "environment": {\n "name": "notebook-env"\n },\n "spec": {\n "envVars": {\n "TEST_ENV": "test"\n },\n "resources": "cpu=1,memory=1.0Gi"\n }\n}\n\' http://127.0.0.1:32080/api/v1/notebook\n')),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"Example Response:")),Object(r.b)("pre",null,Object(r.b)("code",{parentName:"pre",className:"language-json"},'{\n "status":"OK",\n "code":200,\n "success":true,\n "message":"Create a notebook instance",\n "result":{\n "notebookId":"notebook_1597931805405_0001",\n "name":"test-nb",\n "uid":"5a94c01d-6a92-4222-bc66-c610c277546d",\n "url":"/notebook/default/test-nb/",\n "status":"creating",\n "reason":"The notebook instance is creating",\n "createdTime":"2020-08-20T21:58:27.000+08:00",\n "deletedTime":null,\n "spec":{\n "meta":{\n "name":"test-nb",\n "namespace":"default",\n "ownerId":"e9ca23d68d884d4ebb19d07889727dae"\n },\n "environment":{\n "name":"notebook-env",\n "dockerImage":"apache/submarine:jupyter-notebook-0.5.0",\n "kernelSpec":{\n "name": "team_default_python_3.7",\n "channels": [\n "defaults"\n ],\n "dependencies": [\n ""\n ]\n },\n "description":null,\n "image":null\n },\n "spec":{\n "envVars":{\n "TEST_ENV":"test"\n },\n "resources":"cpu=1,memory=1.0Gi"\n }\n }\n },\n "attributes":{}\n}\n')),Object(r.b)("h2",{id:"list-notebook-instances-which-belong-to-user"},"List notebook instances which belong to user"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"GET /api/v1/notebook")),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"Example Request:")),Object(r.b)("pre",null,Object(r.b)("code",{parentName:"pre",className:"language-sh"},"curl -X GET http://127.0.0.1:32080/api/v1/notebook?id={user_id}\n")),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"Example Response:")),Object(r.b)("pre",null,Object(r.b)("code",{parentName:"pre",className:"language-json"},'{\n "status":"OK",\n "code":200,\n "success":true,\n "message":"List all notebook instances",\n "result":[\n {\n "notebookId":"notebook_1597931805405_0001",\n "name":"test-nb",\n "uid":"5a94c01d-6a92-4222-bc66-c610c277546d",\n "url":"/notebook/default/test-nb/",\n "status": "running",\n "reason": "The notebook instance is running",\n "createdTime":"2020-08-20T21:58:27.000+08:00",\n "deletedTime":null,\n "spec":{\n "meta":{\n "name":"test-nb",\n "namespace":"default",\n "ownerId":"e9ca23d68d884d4ebb19d07889727dae"\n },\n "environment":{\n "name":"notebook-env",\n "dockerImage":"apache/submarine:jupyter-notebook-0.5.0",\n "kernelSpec":{\n "name": "team_default_python_3.7",\n "channels": [\n "defaults"\n ],\n "dependencies": [\n ""\n ]\n },\n "description":null,\n "image":null\n },\n "spec":{\n "envVars":{\n "TEST_ENV":"test"\n },\n "resources":"cpu=1,memory=1.0Gi"\n }\n }\n }\n ],\n "attributes":{}\n}\n')),Object(r.b)("h2",{id:"get-the-notebook-instance"},"Get the notebook instance"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"GET /api/v1/notebook/{id}")),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"Example Request:")),Object(r.b)("pre",null,Object(r.b)("code",{parentName:"pre",className:"language-sh"},"curl -X GET http://127.0.0.1:32080/api/v1/notebook/{id}\n")),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"Example Response:")),Object(r.b)("pre",null,Object(r.b)("code",{parentName:"pre",className:"language-json"},'{\n "status":"OK",\n "code":200,\n "success":true,\n "message":"Get the notebook instance",\n "result":{\n "notebookId":"notebook_1597931805405_0001",\n "name":"test-nb",\n "uid":"5a94c01d-6a92-4222-bc66-c610c277546d",\n "url":"/notebook/default/test-nb/",\n "status":"running",\n "reason":"The notebook instance is running",\n "createdTime":"2020-08-20T21:58:27.000+08:00",\n "deletedTime":null,\n "spec":{\n "meta":{\n "name":"test-nb",\n "namespace":"default",\n "ownerId":"e9ca23d68d884d4ebb19d07889727dae"\n },\n "environment":{\n "name":"notebook-env",\n "dockerImage":"apache/submarine:jupyter-notebook-0.5.0",\n "kernelSpec":{\n "name": "team_default_python_3.7",\n "channels": [\n "defaults"\n ],\n "dependencies": [\n ""\n ]\n },\n "description":null,\n "image":null\n },\n "spec":{\n "envVars":{\n "TEST_ENV":"test"\n },\n "resources":"cpu=1,memory=1.0Gi"\n }\n }\n },\n "attributes":{}\n}\n')),Object(r.b)("h2",{id:"delete-the-notebook-instance"},"Delete the notebook instance"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"DELETE /api/v1/notebook/{id}")),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"Example Request:")),Object(r.b)("pre",null,Object(r.b)("code",{parentName:"pre",className:"language-sh"},"curl -X DELETE http://127.0.0.1:32080/api/v1/notebook/{id}\n")),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"Example Response:")),Object(r.b)("pre",null,Object(r.b)("code",{parentName:"pre",className:"language-json"},'{\n "status": "OK",\n "code": 200,\n "success": true,\n "message": "Delete the notebook instance",\n "result": {\n "notebookId": "notebook_1597931805405_0001",\n "name": "test-nb",\n "uid": "5a94c01d-6a92-4222-bc66-c610c277546d",\n "url": "/notebook/default/test-nb/",\n "status": "terminating",\n "reason": "The notebook instance is terminating",\n "createdTime": "2020-08-22T14:03:19.000+08:00",\n "deletedTime": "2020-08-22T14:46:28+0800",\n "spec": {\n "meta": {\n "name": "test-nb",\n "namespace": "default",\n "ownerId":"e9ca23d68d884d4ebb19d07889727dae"\n },\n "environment": {\n "name": "notebook-env",\n "dockerImage": "apache/submarine:jupyter-notebook-0.5.0",\n "kernelSpec": {\n "name": "team_default_python_3.7",\n "channels": [\n "defaults"\n ],\n "dependencies": [\n ""\n ]\n },\n "description": null,\n "image": null\n },\n "spec": {\n "envVars": {\n "TEST_ENV": "test"\n },\n "resources": "cpu=1,memory=1.0Gi"\n }\n }\n },\n "attributes": {}\n}\n')))}l.isMDXComponent=!0},144:function(e,n,t){"use strict";t.d(n,"a",(function(){return p})),t.d(n,"b",(function(){return m}));var o=t(0),a=t.n(o);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function s(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?c(Object(t),!0).forEach((function(n){r(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function b(e,n){if(null==e)return{};var t,o,a=function(e,n){if(null==e)return{};var t,o,a={},r=Object.keys(e);for(o=0;o<r.length;o++)t=r[o],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)t=r[o],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}var i=a.a.createContext({}),l=function(e){var n=a.a.useContext(i),t=n;return e&&(t="function"==typeof e?e(n):s(s({},n),e)),t},p=function(e){var n=l(e.components);return a.a.createElement(i.Provider,{value:n},e.children)},u={inlineCode:"code",wrapper:function(e){var n=e.children;return a.a.createElement(a.a.Fragment,{},n)}},d=a.a.forwardRef((function(e,n){var t=e.components,o=e.mdxType,r=e.originalType,c=e.parentName,i=b(e,["components","mdxType","originalType","parentName"]),p=l(t),d=o,m=p["".concat(c,".").concat(d)]||p[d]||u[d]||r;return t?a.a.createElement(m,s(s({ref:n},i),{},{components:t})):a.a.createElement(m,s({ref:n},i))}));function m(e,n){var t=arguments,o=n&&n.mdxType;if("string"==typeof e||o){var r=t.length,c=new Array(r);c[0]=d;var s={};for(var b in n)hasOwnProperty.call(n,b)&&(s[b]=n[b]);s.originalType=e,s.mdxType="string"==typeof e?e:o,c[1]=s;for(var i=2;i<r;i++)c[i]=t[i];return a.a.createElement.apply(null,c)}return a.a.createElement.apply(null,t)}d.displayName="MDXCreateElement"}}]);