简体   繁体   English

ArangoDB:通过API创建新的Foxx服务

[英]ArangoDB: Create a new Foxx service via API

A core requirement of my application is the ability to automatically deploy ArangoDB with all collections, graphs, data, and APIs. 我的应用程序的核心要求是能够自动部署具有所有集合,图形,数据和API的ArangoDB。 The HTTP API and the various wrappers have been sufficient for this so far, but I haven't been able to find an API for deploying Foxx services. 到目前为止,HTTP API和各种包装程序已经足够了,但是我还没有找到用于部署Foxx服务的API。 Is there any way to create and deploy a Foxx service via RESTful API or through one of the wrappers? 是否可以通过RESTful API或通过其中一个包装器创建和部署Foxx服务? So far, the only way I know to create a Foxx service is through the web interface. 到目前为止,我知道创建Foxx服务的唯一方法是通过Web界面。

I found this question which leads me to believe it's possible, but I don't know how to specify the Git location of the Foxx service. 我发现这个问题使我相信这是可能的,但是我不知道如何指定Foxx服务的Git位置。 Could you provide instructions for creating a Foxx service without the web UI and list the possible parameters? 您能否提供在没有Web UI的情况下创建Foxx服务的说明,并列出可能的参数?

To install a Foxx service via the REST API, you can use the endpoint HTTP PUT /_admin/foxx/install . 要通过REST API安装Foxx服务,可以使用端点HTTP PUT /_admin/foxx/install

It will require a JSON body to be sent, with attributes named mount and appInfo . 它将需要发送带有名为mountappInfo属性的JSON正文。 mount needs to contain the mountpoint (needs to start with a forward slash). mount需要包含mount点(需要以正斜杠开头)。 appInfo is the application to be mounted. appInfo是要挂载的应用程序。 It can contain the filename as previously returned by the server from the call to /_api/upload , eg 它可以包含服务器先前从/_api/upload调用返回的文件名,例如

{ 
    "appInfo" : "uploads/tmp-30573-2010894858", 
    "mount" : "/my-mount-point" 
}

install from remote URL 从远程URL安装

You can also install a Foxx service from a zip file available via HTTP(S) from an external server. 您也可以从外部服务器通过HTTP(S)获得的zip文件中安装Foxx服务。 You can include the username and password for HTTP Basic Auth as necessary: 您可以根据需要添加HTTP Basic Auth的用户名和密码:

{ 
    "appInfo" : "https://user:password@example.com/my-service.zip", 
    "mount" : "/my-mount-point" 
}

install from GitHub 从GitHub安装

You can also install a Foxx service from a GitHub repository, if the repository is public accessible, eg 如果该存储库是可公共访问的,那么您还可以从GitHub存储库安装Foxx服务。

{ 
    "appInfo" : "git:arangodb-foxx/demo-hello-foxx:master", 
    "mount" : "/my-mount-point" 
}

Behind the scenes, ArangoDB will translate the request into a regular URL for the zip bundle GitHub provides. 在后台,ArangoDB会将请求转换为GitHub提供的zip捆绑包的常规URL。

install from local file system 从本地文件系统安装

You can also install a Foxx service from a zip file or directory on the local filesystem: 您还可以从本地文件系统上的zip文件或目录中安装Foxx服务:

{ 
    "appInfo" : "/path/to/foxx-service.zip", 
    "mount" : "/my-mount-point" 
}

This also works with directory, but ArangoDB will create a temporary zip file for you in this case. 这也适用于目录,但是在这种情况下,ArangoDB将为您创建一个临时zip文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM