Browse Source

arangoApi 新增模块

erlArango_v1
SisMaker 5 years ago
parent
commit
52de658bab
15 changed files with 1981 additions and 90 deletions
  1. +7
    -1
      README.md
  2. +3
    -0
      include/agHttpCli.hrl
  3. +0
    -3
      include/erlArango.hrl
  4. +327
    -0
      src/arangoApi/agAdminMonitor.erl
  5. +83
    -11
      src/arangoApi/agCluster.erl
  6. +41
    -0
      src/arangoApi/agEndPoints.erl
  7. +407
    -0
      src/arangoApi/agFoxxServices.erl
  8. +108
    -0
      src/arangoApi/agHotBackup.erl
  9. +234
    -0
      src/arangoApi/agMiscFun.erl
  10. +0
    -73
      src/arangoApi/agOtherFunc.erl
  11. +446
    -0
      src/arangoApi/agReplication.erl
  12. +89
    -0
      src/arangoApi/agTasks.erl
  13. +234
    -0
      src/arangoApi/agUserMgr.erl
  14. +1
    -0
      src/erlArango_sup.erl
  15. +1
    -2
      src/httpCli/agAgencyPoolMgrIns.erl

+ 7
- 1
README.md View File

@ -11,6 +11,9 @@
等待接收数据返回,当前改驱动封装的API均使用同步操作,如果需要异步操作可自行修改。单进程操作时仅支持同步操作。
单进程模式下相对连接池模式可以减少一次数据在进程间的复制,对于大量数据的操作,可以考虑在数据管理进程单独建立数据库连接,而不用连接池。
4. 连接池模式和非连接池模式API接口保证了同一性,不用区别对待, 易于理解和连接池模式和非连接池模式相互转换修改。
## 暂不支持批处理请求
https://www.arangodb.com/docs/stable/http/batch-request.html
## 编译
rebar get-deps; rebar compile or rebar3 compile
@ -29,5 +32,8 @@
application:ensure_all_started(erlArango). %%启动app
agHttpCli:startPool(poolName, [], []). %%初始连接池
然后就可以使用poolName作为第一个参数调用各种API了
agMgrDb:curDbInfo(poolName).
agMgrDb:curDbInfo(poolName).
## TODO
将注释转为edoc格式

+ 3
- 0
include/agHttpCli.hrl View File

@ -1,3 +1,6 @@
%% agency
-define(agAgencyPoolMgr, agAgencyPoolMgr).
%% beam cache
-define(agBeamPool, agBeamPool).
-define(agBeamAgency, agBeamAgency).

+ 0
- 3
include/erlArango.hrl View File

@ -1,6 +1,3 @@
%% agency
-define(agAgencyPoolMgr, agAgencyPoolMgr).
-define(Get, <<"GET">>).
-define(Put, <<"PUT">>).
-define(Post, <<"POST">>).

+ 327
- 0
src/arangoApi/agAdminMonitor.erl View File

@ -0,0 +1,327 @@
-module(agAdminMonitor).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html
%
% GET /_admin/log
%
% upto必须为
% 0
% 1
% 2
% 3
% debug 4 info
% upto和level是互斥的
% start使lid值start
% size
% offset
% search中指定的文本的日志条目
% sortsort为ascsort为desc asc
% JSON对象
% HTTP 200
% lid@LIT {lid}
% level
% timestamp1970-01-01
% text
% topic
% totalAmount
% 400up或level指定了无效值
% 500
getAdminLog(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/log">>, [], undefined).
getAdminLog(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_admin/log", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
% GET /_admin/log/level
% JSON对象
%
% 200
% 500
getAdminLogLevel(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/log/level">>, [], undefined).
%
% PUT /_admin/log/level
% JSON对象是必需的
% agency
% agencycomm
% authentication
%
% cache
% cluster
% collector
%
%
% config
% datafiles
%
%
% general
% graphs
%
%
% mmap
%
% pregel
%
%
%
% rocksdb
% ssl
% startup
%
% syscall
% 线
% trx
% v8
% views
% ldap
% audit-authentication
% audit-authorization
% audit-database
% audit-collection
% audit-view
% audit-document
% audit-service
% JSON对象
% JSON对象
% json来设置所有功能的日志级别
%
% -ArangoDB将关闭
% -
% -
% -
% -
% ---使
%
% 200
% 400JSON时返回
% 405使HTTP方法时返回
% 500
modifyAdminLogLevel(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_admin/log/level">>, [], BodyStr).
%
% GET /_admin/statistics
% _admin / statistics-description返回的描述分组在一起的 访userTimeuserTime的值存储在同名属性中
% count为单位的总计 counts为单位的分发列表
% RocksDB存储引擎DBServer在事务提交到群集范围之前完成使
% HTTP 200
% errorfalse
% codeHTTP状态码-200
% time
% errorMessage
% enabledtrue
%
% minorPageFaultspagefaults
% majorPageFaultspagefaults
% userTime使CPU时间
% systemTime使CPU时间
% numberOfThreads线
% residentSizeRSS
% residentSizePercentRSS
% virtualSizeVSS
% client使
% sum
% count
% counts
% connectionTime
% totalTime
% requestTime
% queueTime
% ioTimeIO时间
% bytesSent
% bytesReceived
% httpConnectionshttp连接数
% http
% requestsTotalhttp请求总数
% requestsAsynchttp请求的总数
% RequestsGet使GET动词的请求数
% requestHead使HEAD动词的请求数
% requestPost使POST动词的请求数
% requestsPut使PUT动词的请求数
% requestsPatch使PATCH动词的请求数
% requestsDelete使DELETE动词的请求数
% requestsOptions使OPTIONS动词的请求数
% requestOther使
%
%
% physicalMemory
% Transactions
%
%
%
% middleCommits
% v8ContextV8 JavaScript上下文的统计信息
% V8上下文的数量
% busyV8上下文的数量
% dirty使使
% free使V8上下文的数量
% max--javascript.v8-contexts配置生成的V8上下文总数
% V8内存/使/10
% contextIdID
% tMax10
% countOfTimes10
% heapMax10
% heapMin10
% 线线V8或jemalloc的线程和系统线程
% scheduler-threads线
% 线
% 线
getAdminStatistics(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/statistics">>, [], undefined).
%
%
% GET /_admin/statistics-description
% / _admin / statistics返回的统计信息的描述
%
% group
% name
% description
%
% group
%
% name
% description
%
% cuts
%
% HTTP 200
%
% group
% name
% description
%
% group
%
% name
% description
%
% cuts
%
% codeHTTP状态码
% false
getAdminStatisticsDesc(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/statistics-description">>, [], undefined).
%
% GET /_admin/metrics
% Prometheus格式返回实例的当前指标Prometheus收集
% 使arangodb_或rocksdb_字符串发布
% API添加到Prometheus配置文件中进行收集
%
% 200
% 404使--server.export-metrics-api false API API
getAdminMetrics(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/metrics">>, [], undefined).
%
%
%
% GET /_admin/server/mode
% json响应将包含一个mode值为readonly或的字段default1004ERROR_READ_ONLY11ERROR_FORBIDDEN
% API
%
% 200API将返回HTTP 200
getAdminServerMode(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/server/mode">>, [], undefined).
% ID
% ID
% GET /_admin/server/id
% ID
%
% 200
% 500
getAdminServerId(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/server/id">>, [], undefined).
%
% GET /_admin/server/role
% role属性中返回
% SINGLE
%
% PRIMARYDBServer
% 使
%
% UNDEFINEDUNDEFINED
% HTTP 200
%
% codeHTTP状态码200
% errorNum
% [ SINGLEPRIMARYSECONDARYAGENTUNDEFINED ]
getAdminServerRole(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/server/role">>, [], undefined).
%
% GET /_admin/server/availability
%
% API使
%
% 200API将返回HTTP 200
% 503HTTP 503
getAdminServerAvailability(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/server/availability">>, [], undefined).
% DBserver
%
% GET /_admin/clusterStatistics
%
% DBserverDBserver的统计信息
%
% 200
% 400ID
% 403
getAdminClusterStatistics(PoolNameOrSocket, DBserver) ->
Path = <<"/_admin/clusterStatistics?DBserver=", (agMiscUtils:toBinary(DBserver))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
% Permalink
%
% GET /_admin/cluster/health
% JSON对象codeerrorerrorNumerrorMessage字段适当
% ClusterIdUUID字符串
% Health
% <nodeID>Health将由节点ID键入
% Endpoint
% Role"AGENT""COORDINATOR""DBSERVER"
% CanBeDeleted
% Version使ArangoDB的版本字符串
% Engine使
% Statusdbservers节点运行状况"GOOD""BAD"15"FAILED"
%
%
% SyncStatusStatus"UNKNOWN""UNDEFINED""STARTUP""STOPPING""STOPPED""SERVING""SHUTDOWN"
% LastAckedTimeISO 8601
% ShortName"Coordinator0001"
% TimestampISO 8601
% Host
%
% AdvertisedEndpointIP地址或负载平衡器
%
% LeaderID
% Leadingtruefalse
% LastAckedTimeacked以秒为单位
%
% 200
getAdminClusterHealth(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/cluster/health">>, [], undefined).
%
% POST /_admin/routing/reload
%
%
% 200
reloadAdminRouting(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/routing/reload">>, [], undefined).

+ 83
- 11
src/arangoApi/agCluster.erl View File

@ -5,25 +5,97 @@
%% doc_address:https://www.arangodb.com/docs/stable/http/cluster.html
%% GET /_admin/server/id
serverId(PoolNameOrSocket) ->
% HTTP接口
% ArangoDB群集的REST API
%
% ID
%
%
%
%
%
% ID
% ID
% GET /_admin/server/id
% ID
%
% 200
% 500
getServerId(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/server/id">>, [], undefined).
%% GET /_admin/server/role
serverRole(PoolNameOrSocket) ->
%
%GET /_admin/server/role
%role属性中返回
%SINGLE
%
%PRIMARYDBServer
%使
%
%UNDEFINEDUNDEFINED
%HTTP 200
%
%codeHTTP状态码200
%errorNum
%[ SINGLEPRIMARYSECONDARYAGENTUNDEFINED ]
getServerRole(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/server/role">>, [], undefined).
%% GET /_admin/clusterStatistics
clusterStatistics(PoolNameOrSocket) ->
% DBserver查询统计
%
% GET /_admin/clusterStatistics
%
% DBserverDBserver的统计信息
%
% 200
% 400ID
% 403
getClusterStatistics(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/clusterStatistics">>, [], undefined).
%% GET /_admin/cluster/health
clusterHealth(PoolNameOrSocket) ->
%
%
% GET /_admin/cluster/health
% JSON对象codeerrorerrorNumerrorMessage字段适当
% ClusterIdUUID字符串
% Health
% <nodeID>Health将由节点ID键入
% Endpoint
% Role"AGENT""COORDINATOR""DBSERVER"
% CanBeDeleted
% Version使ArangoDB的版本字符串
% Engine使
% Statusdbservers节点运行状况"GOOD""BAD"15"FAILED"
%
%
% SyncStatusStatus"UNKNOWN""UNDEFINED""STARTUP""STOPPING""STOPPED""SERVING""SHUTDOWN"
% LastAckedTimeISO 8601
% ShortName"Coordinator0001"
% TimestampISO 8601
% Host
%
% AdvertisedEndpointIP地址或负载平衡器
%
% LeaderID
% Leadingtruefalse
% LastAckedTimeacked以秒为单位
% 200
getClusterHealth(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/cluster/health">>, [], undefined).
%% PUT /_admin/cluster/maintenance
clusterMaintenance(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_admin/cluster/maintenance">>, [], undefined).
%
%
% PUT /_admin/cluster/maintenance
% API60
% "on""off"
%
% 200
% 400
% 501
% 504
setClusterMaintenance(PoolNameOrSocket, OnOrOff) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_admin/cluster/maintenance">>, [], OnOrOff).

+ 41
- 0
src/arangoApi/agEndPoints.erl View File

@ -0,0 +1,41 @@
-module(agEndPoints).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/endpoints.html
% HTTP接口
% API /_api/endpoint已弃用/_api/cluster/endpoints可以找到所有当前的Coordinator端点
%
% ArangoDB服务器可以在多个端点上侦听传入的请求
%
% 使 --server.endpointArangoDB的配置文件或命令行中指定端点ArangoDB的默认终结点是tcp//127.0.0.18529 tcp// localhost8529
%
% _system访访
%
% API调用返回有关所有协调器终结点的信息
% GET /_api/cluster/endpoints
% endpoints的对象endpointerror属性设置为 true
% HTTP 200
% errortrue
% codeHTTP状态码-200
%
% tcp://[::1]:8530
% 501
getClusterEndpoints(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/cluster/endpoints">>, [], undefined, true).
%
% API调用返回所有端点
% GET /_api/endpoint
% 使3.4.0
%
% JSON对象的JSON数组 entrypoint
% 使
%
% 200
% 400
% 405使HTTP方法HTTP 405

+ 407
- 0
src/arangoApi/agFoxxServices.erl View File

@ -0,0 +1,407 @@
-module(agFoxxServices).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/foxx.html
% Foxx HTTP API
% Foxx服务
%
% Foxx及其JavaScript API的更多信息Foxx章节
% Foxx服务管理
% Foxx服务的ArangoDB HTTP接口的简介
%
%
% GET /_api/foxx
%
% excludeSystem
%
%
% mount
% developmenttrue
% legacy2.8true
%
%
% name
% versionsemver兼容的版本字符串
%
% 200
getFoxxList(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/foxx">>, [], undefined).
getFoxxList(PoolNameOrSocket, ExcludeSystem) ->
case ExcludeSystem of
true ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/foxx?excludeSystem=true">>, [], undefined);
_ ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/foxx?excludeSystem=false">>, [], undefined)
end.
%
% GET /_api/foxx/service
%
% mount
%
%
% mount
% path
% developmenttrue
% legacy2.8true
% manifestJSON清单
%
% name
% versionsemver兼容的版本字符串
%
% 200
% 400
getFoxxService(PoolNameOrSocket, Mount) ->
Path = <<"/_api/foxx/service?mount=", (agMiscUtils:toBinary(Mount))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
%
% POST /_api/foxx
%
% mount
% true为启用开发模式
% false不运行服务的安装脚本
% legacytrue以2.8
%
%
% application/zipzip捆绑包
% application/javascriptJavaScript文件
% application/jsonJSON
% multipart/form-data
%
% configurationJSON对象
% JSON对象
% sourceURL或绝对路径
% 使zip捆绑包或独立JavaScript文件的文件字段
% 使JavaScript文件时HTTP端点main与在服务清单字段中定义的相同
% URL访URLsource是文件系统路径URL都应解析为zip包JavaScript文件或
% 使
%
% 201
installFoxx(PoolNameOrSocket, MapData, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx", QueryBinary/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr).
%
% DELETE /_api/foxx/service
%
% mount
% false不运行服务的拆卸脚本
%
%
%
% 204
uninstallFoxx(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/service", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined).
%
% PUT /_api/foxx/service
%
% mount
% false不运行旧服务的拆卸脚本
% false不运行新服务的安装脚本
% legacytrue以2.8 Legacy兼容模式安装新服务
% true强制安装服务使
%
%
%
% application/zipzip捆绑包
% application/javascriptJavaScript文件
% application/jsonJSON
% multipart/form-data
%
% configurationJSON对象
% JSON对象
% sourceURL或绝对路径
% 使zip捆绑包或独立JavaScript文件的文件字段
% 使JavaScript文件时HTTP端点main与在服务清单字段中定义的相同
% URL访URLsource是文件系统路径URL都应解析为zip包JavaScript文件或
% 使
%
% 200
replaceFoxx(PoolNameOrSocket, MapData, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/service", QueryBinary/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr).
%
% PATCH /_api/foxx/service
%
% mount
% true运行旧服务的拆卸脚本
% false不运行新服务的安装脚本
% legacytrue以2.8 Legacy兼容模式安装新服务
% true强制安装服务使
% 使
%
%
% application/zipzip捆绑包
% application/javascriptJavaScript文件
% application/jsonJSON
% multipart/form-data
%
% configurationJSON对象
% JSON对象
% sourceURL或绝对路径
% 使zip捆绑包或独立JavaScript文件的文件字段
% 使JavaScript文件时HTTP端点main与在服务清单字段中定义的相同
% URL访URLsource是文件系统路径URL都应解析为zip包JavaScript文件或
% 使
%
% 200
upgradeFoxx(PoolNameOrSocket, MapData, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/service", QueryBinary/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, [], BodyStr).
% Foxx服务配置/
% Foxx服务配置和依赖关系的ArangoDB HTTP接口的简介
%
%
% GET /_api/foxx/configuration
%
% mount
%
%
%
% 200
getFoxxConfig(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/configuration", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
% PATCH /_api/foxx/configuration
%
% mount
% json
% JSON对象映射配置选项名称为其新值
%
%
%
% 200
updateFoxxConfig(PoolNameOrSocket, MapData, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/configuration", QueryBinary/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, [], BodyStr).
%
% PUT /_api/foxx/configuration
%
% mount
% json
% JSON对象映射配置选项名称为其新值
%
%
%
% 200
replaceFoxxConfig(PoolNameOrSocket, MapData, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/configuration", QueryBinary/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr).
%
% GET /_api/foxx/dependencies
%
% mount
%
%
%
% 200
getFoxxDependencies(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/dependencies", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
% PATCH /_api/foxx/dependencies
%
% mount
% json
% JSON对象
%
%
%
% 200
updateFoxxDependencies(PoolNameOrSocket, MapData, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/dependencies", QueryBinary/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, [], BodyStr).
%
% PUT /_api/foxx/dependencies
%
% mount
% json
% JSON对象
%
%
%
% 200
replaceFoxxDependencies(PoolNameOrSocket, MapData, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/dependencies", QueryBinary/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr).
% Foxx服务杂项
%
%
% GET /_api/foxx/scripts
%
% mount
%
%
%
% 200
getFoxxScripts(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/scripts", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
% POST /_api/foxx/scripts/{name}
%
%
%
% mount
% json
% JSON值
%
%
%
% 200
runFoxxScripts(PoolNameOrSocket, ScriptName, MapData, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/scripts/", ScriptName/binary, QueryBinary/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr).
%
% POST /_api/foxx/tests
%
% mount
% 使
% 使Accept标头无关
% filter
%
%
%
% suite
%
% xunitXUnit / JUnit兼容的结构
% tapTAP兼容流
%
% 使application/x-ldjson将导致响应主体被格式化为以换行符分隔的JSON流
% 使text/plain或时text/*TAP报告
% 使xunit报告程序时application/xml或text/xml将导致响应正文被格式化为XML而不是JSONML
% prettyprinted JSON
%
% 200
runFoxxTest(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/tests", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], undefined).
%
% POST /_api/foxx/development
%
% mount
%
%
% ArangoDB时
%
% 200
%
%
enableFoxxDevelopment(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/development", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], undefined).
%
% DELETE /_api/foxx/development
%
% mount
%
% ArangoDB时
%
% 200
disableFoxxDevelopment(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/development", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined).
%
% GET /_api/foxx/readme
%
% mount
% README或README.md文件的内容
%
% 200
% 204
getFoxxReadme(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/readme", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
% GET /_api/foxx/swagger
%
% mount
% Swagger API描述
% API的与OpenAPI 2.0JSON描述
%
% 200
getFoxxSwagger(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/swagger", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
% POST /_api/foxx/download
%
% mount
% zip捆绑包
%
% ArangoDB实例上安装的服务的版本
%
% 200
% 400
downloadFoxxBundle(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/download", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], undefined).
%
% POST /_api/foxx/commit
%
% replace使
%
%
%
% 204
commitFoxxState(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/foxx/commit", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], undefined).

+ 108
- 0
src/arangoApi/agHotBackup.erl View File

@ -0,0 +1,108 @@
-module(agHotBackup).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/hot-backup.html
% HTTP接口进行热备份和还原
% v3.5.1
% ArangoDB HTTP接口的简介
%
%
% ArangoDB服务的即时一致快照
% UUIDAPI在这些标识符上运行
% API专用于处理POST操作
% 使API
%
% POST /_admin/backup/create
% JSON对象是必需的
% label使<timestamp>_<label>ID的此部分创建默认的UUID
% timeout120
% allowInconsistenttrue并且在给定的超时时间内无法获取全局事务锁定falseHTTP 408
% forcetrue并且在给定的超时时间内无法获取全局事务锁定JavaScript事务 timeout几秒钟使force请求超时将增加一倍使false allowInconsistent并force设置为true
% 使
%
% 201201
% 400使HTTP方法调用了create命令POSTHTTP 400
% 408HTTP 408
newBackup(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/backup/create">>, [], BodyStr).
%
% POST /_admin/backup/restore
% JSON对象是必需的
% idID
% 使ID及时从快照恢复一致的备份ArangoDB服务上
%
% 200
% 400使HTTP方法调用了restore命令POSTHTTP 400
restoreBackup(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/backup/restore">>, [], BodyStr).
%
% POST /_admin/backup/delete
% JSON对象是必需的
% id
% id
%
% 200200
% 400使HTTP方法调用delete命令POSTHTTP 400
% 404id找不到与该标识符相对应的备份
delBackup(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/backup/delete">>, [], BodyStr).
%
% POST /_admin/backup/list
% JSON对象是必需的
% idattribute的对象id为字符串ID的备份
%
%
% 200200
% 400使list命令 HTTP 400
% 404id给出了ID或ID列表ID作为备份的标识符HTTP 404 NOT FOUND
% 405使HTTP方法调用了list命令POSTHTTP 405 METHOD NOT ALLOWED
getBackupList(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/backup/list">>, [], undefined).
%
% POST /_admin/backup/upload
% JSON对象是必需的
% iduploadId
% remoteRepositoryURLuploadId属性URL进行了规范化和验证URL前缀必须作为键存在于以下配置对象中线1 ...//
% configuploadId arangobackup程序说明config
% uploadIdID
% aborttrue如果正在运行的上载操作应中止body参数是uploadId
%
%
% 200200
% 202202
% 400使HTTP方法调用了上载命令POSTHTTP 400
% 401HTTP 400
% 404id uploadId
uploadBackup(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/backup/upload">>, [], BodyStr).
%
% POST /_admin/backup/download
% JSON对象是必需的
% iddownloadId
% remoteRepositoryURLdownloadId属性URL进行了规范化和验证URL前缀必须作为键存在于以下配置对象中线1 ...//
% configdownloadId arangobackup程序说明config
% downloadIdID
% aborttrue如果正在运行的下载操作应中止body参数是downloadId
%
%
% 200200
% 202202
% 400使HTTP方法调用了download命令POSTHTTP 400
% 401HTTP 401
% 404id downloadId
downloadBackup(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/backup/download">>, [], BodyStr).

+ 234
- 0
src/arangoApi/agMiscFun.erl View File

@ -0,0 +1,234 @@
-module(agMiscFun).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
%% doc_address:https://www.arangodb.com/docs/stable/http/miscellaneous-functions.html
%
% GET /_api/version
%
% detailstruedetails属性ArangoDB版本而异
% JSON对象
% HTTP 200
% arango
% version major major和minor将是数字sub
% detailsJSON对象details查询参数设置为true时
% CPU体系结构64
% arm false-ARM cpu上运行
% asanasan地址清理器打开的情况下进行编译
% asm-crc32CRC函数吗
% =>
% boost-versionboost版本
% build-date
% build-repositorygit-ID
% 使
% cplusplusC ++
% debug false
%
% false
% fd-client-event-handler使fd-setlinux上进行
% fd-setsizefd setsize对于文件描述符的最大数目有效
% full-version-string
% icu-versionICU
% jemalloc 使jemalloctrue
% maintenanceer-mode false
% openssl-versionopenssl版本
% os- linuxwindows或darwin
% epoll TODO
% rockdb-versionrocksdb版本
% server-versionArangoDB发行版本
% sizeof int
% sizeof void * void指针的字节数
% sse42SSE 4.2CPU
% unaligned-access访
% v8版本V8 JavaScript引擎版本
% vpack-version使velocypack实现的版本
% zlib-versionzlib的版本
% -[ ]
% hostID
getSrvVersion(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/version">>, [], undefined).
getSrvVersion(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/version", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
% GET /_api/engine
% 使JSON对象
% HTTP 200
% mmfiles或rocksdb
getSrvEngine(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/engine">>, [], undefined).
% WAL同步到磁盘
% PUT /_admin/wal/flush
%
% waitForSync
% waitForCollectortrue可能会阻塞很长时间
%
%
% 200
% 405使HTTP方法时返回
flushWal(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_admin/wal/flush">>, [], undefined).
%
%
% GET /_admin/wal/properties
% JSON对象
% allowOversizeEntries
% logfileSize
% HistoricLogfiles
% reserveLogfilesArangoDB在后台分配的最大保留日志文件数
% syncInterval
% valveWait
% acceleratorWhenPending 0
%
% 200
% 405使HTTP方法时返回
getWalProperties(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/wal/properties">>, [], undefined).
%
%
% PUT /_admin/wal/properties
% JSON对象
% allowOversizeEntries
% logfileSize
% HistoricLogfiles
% reserveLogfilesArangoDB在后台分配的最大保留日志文件数
% valveWait
% acceleratorWhenPending 0
%
%
% 200
% 405使HTTP方法时返回
setWalProperties(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_admin/wal/properties">>, BodyStr, undefined).
%
%
% GET /_admin/wal/transactions
% JSON对象
% runningTransactions
% minLastCollectedIDnull
% minLastSealedIDnull
%
% 200
% 405使HTTP方法时返回
getTransactions(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/wal/transactions">>, [], undefined).
%
%
% GET /_admin/time
% time的对象Unix时间戳为单位
% HTTP 200
% errorfalse
% codeHTTP状态码
% timeUnix时间戳记为单位
getDbTime(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/time">>, [], undefined).
%
% POST /_admin/echo
%
%
%
% HTTP 200 Echo成功返回
%
%
% database
% urlURL
% ['http''https''velocystream']
%
% address
% port
% client
% IP地址
% porttcp连接的客户端端口
% idid
%
% prefix
% headersHTTP标头的列表
% requestTypePOST使HTTP-Verb/...
% requestBodyPOST正文的字符串化版本
%
% cookiescookie列表
%
% rawSuffix
% path
% rawRequestBody
echo(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/echo">>, [], undefined).
%
% GET /_admin/database/target-version
%
%
% 200
getTargetVersion(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/database/target-version">>, [], undefined).
%
% DELETE /_admin/shutdown
%
%
% 200OK都将返回
shutDown(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, <<"/_admin/shutdown">>, [], undefined).
%
% POST /_admin/execute
%
%
% javascript代码作为不带参数的函数主体执行return语句 application / json返回returnAsJSON设置为 trueJSON对象JSON.stringify生成的字符串
% 使option启动服务器时API端点才会存在--javascript.allow-admin-execute true
% falseAPI端点
%
% 200application / json类型的主体returnAsJSON的不同json对象或纯字符串
% 403ArangoDB不在集群模式下运行
% 404ArangoDB404
execute(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/execute">>, [], BodyStr).
%
% GET /_admin/status
%
% 使
%
% arango
%
% version
%
% hostServerState
% serverInfo.role
% serverInfo.writeOpsEnabledtrue
% serverInfo.maintenancetrue
% agency.endpoints
%
% serverInfo.persistedIdide CRDN-e427b441-5087-4a9a-9983-2fb1682f3e2a
%
% serverInfo.state
% serverInfo.addresstcp// [:: 1]8530
% serverInfo.serverId CRDN-e427b441-5087-4a9a-9983-2fb1682f3e2a
%
% coordinator.foxxmasterfoxx主服务器的服务器ID
% coordinator.isFoxxmasterfoxx主服务器true
%
% agent.idID
% agent.leaderIdID
% agentLeading true
% agent.endpoint
% agent.term
%
% 200
getDbStatus(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/status">>, [], undefined).

+ 0
- 73
src/arangoApi/agOtherFunc.erl View File

@ -1,73 +0,0 @@
-module(agOtherFunc).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
%% doc_address:https://www.arangodb.com/docs/stable/http/miscellaneous-functions.html
%% server版本
%% GET /_api/version
serverInfo(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/version">>, [], undefined).
%% server版本详细信息
%% GET /_api/version?details=true
serverDetails(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/version?details=true">>, [], undefined).
%% 使
%% GET /_api/engine
engine(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/engine">>, [], undefined).
%%
%% PUT /_admin/wal/flush
logFlush(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_admin/wal/flush">>, [], undefined).
%%
%% GET /_admin/wal/properties
walConfig(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/wal/properties">>, [], undefined).
%%
%% PUT /_admin/wal/properties
setWalConfig(PoolNameOrSocket, LogFileSize, AllowOversizeEntries) ->
BodyStr = jiffy:encode(#{<<"logfileSize">> => LogFileSize, <<"allowOversizeEntries">> => AllowOversizeEntries}),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_admin/wal/properties">>, BodyStr, undefined).
%%
%% GET /_admin/wal/transactions
transactions(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/wal/transactions">>, [], undefined).
%%
%% GET /_admin/time
ostime(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/time">>, [], undefined).
%% 西
%% POST /_admin/echo
echo(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/echo">>, [], undefined).
%%
%% GET /_admin/database/target-version
dbVersion(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/database/target-version">>, [], undefined).
%% DELETE /_admin/shutdown
shutDown(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, <<"/_admin/shutdown">>, [], undefined).
%%
%% POST /_admin/execute
execute(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/execute">>, [], undefined).
%%
%% GET /_admin/status
status(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/status">>, [], undefined).

+ 446
- 0
src/arangoApi/agReplication.erl View File

@ -187,3 +187,449 @@ getRepClusterInventory(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/replication/clusterInventory", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
%
% GET /_api/replication/logger-state
%
% JSON对象
% stateJSON对象
% running
% lastLogTick
% totalEvents
% time
% serverJSON对象
% version
% serverIdID
% clientJSON对象返回
% syncerIdID
% serverIdID
% lastServedTicklogger-follow API
% timelogger-follow API的日期和时间
%
% 200
% 405使HTTP方法时返回
% 500
getRepLoggerState(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/logger-state">>, [], undefined).
%
%
% GET /_api/replication/logger-follow
% 使3.4.0
%
% from
%
% chunkSize
% includeSystemtrue
% 使
% from值
% 使from查询参数时使from from值的日志条目from的日志条目将被排除使from值
% 使使to参数
% CHUNKSIZE查询参数可用于控制结果的大小CHUNKSIZE值也仅是被兑现chunkSize值太低可能导致服务器无法仅将一个日志条目放入结果中并将其返回chunkSize值 chunkSizechunkSize
% chunkSize使
% Content-Type是application / x-arango-dumpJSON对象
% tick
% type
%
% cidID
% tidID
%
% revID
% data
%
% HTTP标头
% x-arango-replication-active使
% x-arango-replication-lastincluded0from的值
% x-arango-replication-lasttick
% x-arango-replication-checkmorelogger-follow
%
%
%
% 200
% 204
% 400from或to值无效
% 405使HTTP方法时返回
% 500500
% 501
% 使3.4.0
%
% GET /_api/replication/logger-first-tick
%
% firstTick的JSON对象
%
%
% 200
% 405使HTTP方法时返回
% 500500
% 501
getRepLoggerFirstTick(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/logger-first-tick">>, [], undefined).
%
% GET /_api/replication/logger-tick-ranges
% WAL日志文件的刻度值的当前可用范围
% JSON数组
% datafile
% status
% tickMin
% tickMax
%
% 200
% 405使HTTP方法时返回
% 500
% 501
getRepLoggerTickRanges(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/logger-tick-ranges">>, [], undefined).
%
% applier命令允许远程启动ArangoDB数据库复制应用程序的状态和配置
%
% GET /_api/replication/applier-config
%
% truefalse
%
% JSON对象
% tcp//192.168.173.138529
% database _system
% username使ArangoDB用户名
% password使
% maxConnectRetries
% connectTimeout
% requestTimeout
% chunkSize使
% autoStart
% adaptivePolling使
% includeSystem
% autoResync
% autoResyncRetries0autoResync
% initialSyncMaxWaitTime使autoResync设置为true时0
% connectionRetryWaitTime0
% idleMinWaitTimeHTTP日志获取请求的频率0
% idleMaxWaitTime HTTP日志获取请求的最大频率adaptivePolling设置为true时使0
% requireFromPresenttrue requireFromPresent为truefalse
% verbosetrue
% restrictTyperestrictCollections
% restrictCollectionsrestrictType
%
% 200
% 405使HTTP方法时返回
% 500500
getRepApplierConfig(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/applier-config">>, [], undefined).
getRepApplierConfig(PoolNameOrSocket, IsGlobal) ->
case IsGlobal of
true ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/applier-config?global=true">>, [], undefined);
_ ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/applier-config">>, [], undefined)
end.
%
% PUT /_api/replication/applier-config
%
% truefalse
% JSON对象是必需的
% tcp//192.168.173.138529
% database
% username使ArangoDB用户名
% password使
% maxConnectRetries
% connectTimeout
% requestTimeout
% chunkSize使
% autoStart
% adaptivePollingtrue使使
% adaptivePolling设置为false将使复制者以固定的时间间隔与记录器服务器联系
% includeSystem
% autoResync
% autoResyncRetries0 autoResync
% initialSyncMaxWaitTime使autoResync设置为true时0
% connectionRetryWaitTime0
% idleMinWaitTimeHTTP日志获取请求的频率0
% idleMaxWaitTime HTTP日志获取请求的最大频率adaptivePolling设置为true时使 0
% requireFromPresenttrue requireFromPresent为truefalse
% verbosetrue
% restrictTyperestrictCollections ;
% restrictCollectionsrestrictType
%
% JSON对象
%
% 200
% 400400
% 405使HTTP方法时返回
% 500500
setRepApplierConfig(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/applier-config">>, [], BodyStr).
setRepApplierConfig(PoolNameOrSocket, MapData, IsGlobal) ->
BodyStr = jiffy:encode(MapData),
case IsGlobal of
true ->
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/applier-config?global=true">>, [], BodyStr);
_ ->
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/applier-config">>, [], BodyStr)
end.
%
% PUT /_api/replication/applier-start
%
% truefalse
% fromlastLogTick值使
%
% 线使
% / _api / replication / applier-state API
%
% 200
% 400
% 405使HTTP方法时返回
% 500500
startRepApplier(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/applier-start">>, [], undefined).
startRepApplier(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/replication/applier-start", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined).
%
% PUT /_api/replication/applier-stop
%
% truefalse
%
%
% 200
% 405使HTTP方法时返回
% 500500
stopRepApplier(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/applier-stop">>, [], undefined).
stopRepApplier(PoolNameOrSocket, IsGlobal) ->
case IsGlobal of
true ->
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/applier-stop?global=true">>, [], undefined);
_ ->
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/applier-stop">>, [], undefined)
end.
%
% GET /_api/replication/applier-state
%
% truefalse
%
% JSON对象
% stateJSON对象
% running
% lastAppliedContinuousTick
% lastProcessedContinuousTick
%
% lastAvailableContinuousTick
% ticksBehind/
% 使
% 使
% time
% totalRequests
% totalFailedConnects
% totalEvents
% totalOperationsExcludedrestrictCollections而被排除的日志事件总数
% progressJSON对象
%
%
% failedConnects
% lastErrorJSON对象
% errorNum
% errorMessage
%
% lastError将为空
% serverJSON对象
% version
% serverIdID
%
% database
%
%
% 200
% 405使HTTP方法时返回
% 500500
getRepApplierState(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/applier-state">>, [], undefined).
getRepApplierState(PoolNameOrSocket, IsGlobal) ->
case IsGlobal of
true ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/applier-state?global=true">>, [], undefined);
_ ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/applier-state">>, [], undefined)
end.
%
% PUT /_api/replication/make-slave
% JSON对象是必需的
% tcp//192.168.173.138529
% database
% username使ArangoDB用户名
% password使
% includeSystem
% strictTypeinclude或exclude
% restrictCollections使restrictTypelimitType为includelimitType为exclude
% maxConnectRetries
% connectTimeout
% requestTimeout
% chunkSize使
% adaptivePolling使
% autoResync
% autoResyncRetries0autoResync
% initialSyncMaxWaitTime使autoResync设置为true时0
% connectionRetryWaitTime0
% idleMinWaitTimeHTTP日志获取请求的频率0
% idleMaxWaitTime HTTP日志获取请求的最大频率adaptivePolling设置为true时使 0
% requireFromPresenttrue requireFromPresent为truefalse
% verbosetrue
% ArangoDB数据库的完整数据同步
%
% JSON对象
% stateJSON对象
% running
% lastAppliedContinuousTick
% lastProcessedContinuousTick
%
% lastAvailableContinuousTick
% ticksBehind/
% 使
% 使
% time
% totalRequests
% totalFailedConnects
% totalEvents
% totalOperationsExcludedrestrictCollections而被排除的日志事件总数
% progressJSON对象
%
%
% failedConnects
% lastErrorJSON对象
% errorNum
% errorMessage
%
% lastError将为空
% serverJSON对象
% version
% serverIdID
%
% database
%
% ArangoDB数据库
% 使
%
%
%
% 200
% 400
% 405使HTTP方法时返回
% 500
% 501
changeRepMakeSlave(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/make-slave">>, [], BodyStr).
%
%ID
%
%GET /_api/replication/server-id
%IDAPI方法也返回该IDID的简便方法
%serverId的JSON对象ID作为字符串返回
%
%200
%405使HTTP方法时返回
%500500
getRepServerId(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/server-id">>, [], undefined).
% WAL
% 线
% GET /_api/wal/range
% WAL文件的当前刻度值范围
% JSON对象
% tickMin
% tickMax
% time YYYY-MM-DDTHHMMSSZ
% serverversion和serverId的对象
%
% 200
% 405使HTTP方法时返回
% 500
% 501
getWalRange(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/wal/range">>, [], undefined).
%
%
% GET /_api/wal/lastTick
%
% ticktime和server的JSON对象
% tick
% time YYYY-MM-DDTHHMMSSZ
% serverversion和serverId的对象
%
%
% 200
% 405使HTTP方法时返回
% 500500
% 501
getWalLastTick(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/wal/lastTick">>, [], undefined).
%
% GET /_api/wal/tail
%
% false时 true仅在_system数据库上有效false
% fromAPI时x-arango-replication-lastincluded标头返回的值0
%
% lastScannedx-arango-replication-lastscanned标头的值0使rocksdb引擎可以通过多个响应分解大型事务
% chunkSize
% syncerIdID使 使this或serverId来获取使用rocksdb存储引擎读取的所有操作
% serverIdIDsyncerId使 使this或syncerId才能有机会读取rocksdb存储引擎的所有操作
% clientInfo
% barrierIdWAL条目的障碍的IDMMFiles存储引擎是必需的
% 便
% from值
% 使from查询参数时使from from值的日志条目from的日志条目将被排除使from值
% 使使to参数
% CHUNKSIZE查询参数可用于控制结果的大小CHUNKSIZE值也仅是被兑现chunkSize值太低可能导致服务器无法仅将一个日志条目放入结果中并将其返回chunkSize值 chunkSizechunkSize
% chunkSize使
% Content-Type是application / x-arango-dumpJSON对象
% tick
% type
%
% cuidView或collection的全局唯一ID
% db
% tidID
% data
%
% HTTP标头
% x-arango-replication-active使
% x-arango-replication-lastincluded0from的值
% x-arango-replication-lastscanned退lastScanned标头中使用此值使rocksdb引擎分解多个响应上的请求
% x-arango-replication-lasttick
% from参数中指定的刻度开始返回所有刻度值x-arango-replication-frompresent设置为truefalse
% x-arango-replication-checkmorelogger-follow
%
%
%
% 200
% 204
% 400from或to值无效
% 405使HTTP方法时返回
% 500500
% 501
getWalTail(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/wal/tail">>, [], undefined).
getWalTail(PoolNameOrSocket, QueryPars) ->
QueryBinary = agMiscUtils:spellQueryPars(QueryPars),
Path = <<"/_api/wal/tail", QueryBinary/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).

+ 89
- 0
src/arangoApi/agTasks.erl View File

@ -0,0 +1,89 @@
-module(agTasks).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/traversal.html
%HTTP任务接口
%ArangoDB的任务HTTP接口
%API操作提供了一些示例
%
% GET /_api/tasks/
%
% HTTP 200
% **
getTaskList(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/tasks/">>, [], undefined).
%
% GET /_api/tasks/{id}
%
% idID
% ID指定的服务器上获取一个现有任务
% HTTP 200
getTask(PoolNameOrSocket, TaskId) ->
Path = <<"/_api/tasks/", (agMiscUtils:toBinary(TaskId))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
% POST /_api/tasks
% JSON对象是必需的
% name
% JavaScript代码
% params
% period
% offset
% ID创建一个新任务
% HTTP 200
% id
% created
% [ periodictimed]
%
%
% period秒
% offset
% javascript函数
% database
% code200
% false
% 400HTTP 400
newTask(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/tasks">>, [], BodyStr).
% ID的新任务
% PUT /_api/tasks/{id}
%
% idid
% JSON对象是必需的
% name
% JavaScript代码
% params
% period
% offset
% ID的新任务
%
% 400ID已经存在或其余主体不正确HTTP 400
newTask(PoolNameOrSocket, TaskId, MapData) ->
Path = <<"/_api/tasks/", (agMiscUtils:toBinary(TaskId))/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr).
%
% DELETE /_api/tasks/{id}
%
% idid
% ID标识的任务
% HTTP 200HTTP 200
% code200
% false
% HTTP 404ID未知HTTP 404
% code404
% true
% errorMessage
delTask(PoolNameOrSocket, TaskId) ->
Path = <<"/_api/tasks/", (agMiscUtils:toBinary(TaskId))/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined).

+ 234
- 0
src/arangoApi/agUserMgr.erl View File

@ -0,0 +1,234 @@
-module(agUserMgr).
-include("erlArango.hrl").
-compile([export_all, nowarn_export_all]).
% doc_address:https://www.arangodb.com/docs/stable/http/user-management.html
% HTTP接口
% ArangoDB HTTP接口的简介
%
% _users中_users集合
%
% REST API中可用的所有功能
%
% ArangoDB的复制中不包括用户操作
%
% POST /_api/user
% JSON对象是必需的
% user
% passwd使ARANGODB_DEFAULT_ROOT_PASSWORD ARANGODB_DEFAULT_ROOT_PASSWORDArangoDBAmazon的实例标识符
% activetrue
% extraJSON对象
% 访 REST调用
%
% 201
% 400JSON格式不正确或请求中缺少必需数据
% 401_system 访访
% 403访访
% 409
newUser(PoolNameOrSocket, MapData) ->
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/user">>, [], BodyStr).
% 访
% PUT /_api/user/{user}/database/{dbname}
%
%
% dbname
% JSON对象是必需的
% grant使 rw访Administrate
% 使 ro访Access
% 使访 访
% user的数据库dbname设置数据库访问级别访REST调用
%
% 200访
% 400JSON格式不正确或请求中缺少必需数据
% 401_system 访访
% 403访访
setUserDbAccessLevel(PoolNameOrSocket, UserName, DbName, MapData) ->
Path = <<"/_api/user/", UserName/binary, "/database/", DbName/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr).
% 访
% PUT /_api/user/{user}/database/{dbname}/{collection}
%
%
% dbname
%
% JSON对象是必需的
% grant使 rw访 /
% 使 ro访
% 使访 访
% 访DBNAME 访REST调用
%
% 200访
% 400JSON格式不正确或请求中缺少必需数据
% 401_system 访访
% 403访访
setUserCollAccessLevel(PoolNameOrSocket, UserName, DbName, CollName, MapData) ->
Path = <<"/_api/user/", UserName/binary, "/database/", DbName/binary, "/", CollName/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr).
% 访访
% DELETE /_api/user/{user}/database/{dbname}
%
%
% dbname
% user的数据库dbname的数据库访问级别使访访No access_system数据库的权限才能执行此REST调用
%
% 202访
% 400JSON格式不正确或请求中缺少必需数据
clearUserDbAccessLevel(PoolNameOrSocket, UserName, DbName) ->
Path = <<"/_api/user/", UserName/binary, "/database/", DbName/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined).
% 访访
% DELETE /_api/user/{user}/database/{dbname}/{collection}
%
%
% dbname
%
% user的数据库dbname中集合集合的集合访问级别使访访No access_system数据库的权限才能执行此REST调用
%
% 202访
% 400
clearUserCollAccessLevel(PoolNameOrSocket, UserName, DbName, CollName) ->
Path = <<"/_api/user/", UserName/binary, "/database/", DbName/binary, "/", CollName/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined).
% 访
% GET /_api/user/{user}/database/
%
%
%
% 访
% 访REST调用
% 访JSON对象
% full
%
% 200
% 400访
% 401_system 访访
% 403访访
getUserDbList(PoolNameOrSocket, UserName) ->
Path = <<"/_api/user/", UserName/binary, "/database/">>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
% 访
% GET /_api/user/{user}/database/{dbname}
%
%
% dbname
% 访
%
% 200访
% 400访
% 401_system 访访
% 403访访
getUserDbAccessLevel(PoolNameOrSocket, UserName, DbName) ->
Path = <<"/_api/user/", UserName/binary, "/database/", DbName/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
% 访
% GET /_api/user/{user}/database/{dbname}/{collection}
%
%
% dbname
%
% 访
%
% 200访
% 400访
% 401_system 访访
% 403访访
getUserCollAccessLevel(PoolNameOrSocket, UserName, DbName, CollName) ->
Path = <<"/_api/user/", UserName/binary, "/database/", DbName/binary, "/", CollName/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
% PUT /_api/user/{user}
%
%
% JSON对象是必需的
% passwd使
% activetrue
% extraJSON对象
% user中指定访 REST调用/
%
% 200
% 400JSON格式不正确或请求中缺少必需数据
% 401_system 访访
% 403访访
% 404
replaceUser(PoolNameOrSocket, UserName, MapData) ->
Path = <<"/_api/user/", UserName/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr).
%
% PATCH /_api/user/{user}
%
%
% JSON对象是必需的
% passwd使
% activetrue
% extraJSON对象
% user中指定访 REST调用/
%
% 200
% 400JSON格式不正确或请求中缺少必需数据
% 401_system 访访
% 403访访
% 404
modifyUser(PoolNameOrSocket, UserName, MapData) ->
Path = <<"/_api/user/", UserName/binary>>,
BodyStr = jiffy:encode(MapData),
agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, [], BodyStr).
%
% DELETE /_api/user/{user}
%
%
% user标识的现有用户访REST调用
%
% 202
% 401_system 访访
% 403访访
% 404
delUser(PoolNameOrSocket, UserName) ->
Path = <<"/_api/user/", UserName/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined).
%
% GET /_api/user/{user}
%
%
% 访REST调用
%
% 200
% 401_system 访访
% 403访访
% 404
getUser(PoolNameOrSocket, UserName) ->
Path = <<"/_api/user/", UserName/binary>>,
agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined).
%
% GET /_api/user/
% 访REST调用
% JSON对象
% user
% active
% extraJSON对象
%
% 200
% 401_system 访访
% 403访访
getUserList(PoolNameOrSocket) ->
agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/user/">>, [], undefined).

+ 1
- 0
src/erlArango_sup.erl View File

@ -1,4 +1,5 @@
-module(erlArango_sup).
-include("agHttpCli.hrl").
-include("erlArango.hrl").

+ 1
- 2
src/httpCli/agAgencyPoolMgrIns.erl View File

@ -1,10 +1,9 @@
-module(agAgencyPoolMgrIns).
-include("agHttpCli.hrl").
-compile(inline).
-compile({inline_size, 128}).
-include("agHttpCli.hrl").
-include("erlArango.hrl").
-export([
startPool/2

Loading…
Cancel
Save