From 9f2257d9dfb0426c36ae45176e0530e1e63e31b1 Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Thu, 26 Mar 2020 13:01:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/agHttpCli.hrl | 12 +--- include/erlArango.hrl | 12 ++-- src/arangoApi/agAdminMonitor.erl | 28 ++++----- src/arangoApi/agAnalyzers.erl | 10 +-- src/arangoApi/agAqlMod.erl | 38 ++++++------ src/arangoApi/agAsyncResultHandling.erl | 12 ++-- src/arangoApi/agBulkImportExport.erl | 6 +- src/arangoApi/agCluster.erl | 10 +-- src/arangoApi/agCollections.erl | 60 +++++++++--------- src/arangoApi/agDbMgr.erl | 10 +-- src/arangoApi/agDocuments.erl | 42 ++++++------- src/arangoApi/agEdges.erl | 2 +- src/arangoApi/agEndPoints.erl | 2 +- src/arangoApi/agFoxxServices.erl | 46 +++++++------- src/arangoApi/agGeneralGraphs.erl | 72 +++++++++++----------- src/arangoApi/agHotBackup.erl | 12 ++-- src/arangoApi/agIndexes.erl | 20 +++--- src/arangoApi/agMiscFun.erl | 26 ++++---- src/arangoApi/agRepairJobs.erl | 4 +- src/arangoApi/agReplication.erl | 60 +++++++++--------- src/arangoApi/agTasks.erl | 10 +-- src/arangoApi/agTransactions.erl | 12 ++-- src/arangoApi/agUserMgr.erl | 26 ++++---- src/arangoApi/agViews.erl | 16 ++--- src/httpCli/agAgencyPoolMgrIns.erl | 1 - src/httpCli/agAgencyUtils.erl | 4 +- src/httpCli/agHttpCli.erl | 27 ++++---- src/httpCli/agHttpProtocol.erl | 10 ++- src/httpCli/agMiscUtils.erl | 15 ++++- src/httpCli/agSslAgencyIns.erl | 15 +++-- src/httpCli/agTcpAgencyIns.erl | 16 +++-- src/{httpCli/test.erl => user_default.erl} | 4 +- 32 files changed, 322 insertions(+), 318 deletions(-) rename src/{httpCli/test.erl => user_default.erl} (96%) diff --git a/include/agHttpCli.hrl b/include/agHttpCli.hrl index 8bd3c31..203697b 100644 --- a/include/agHttpCli.hrl +++ b/include/agHttpCli.hrl @@ -36,18 +36,11 @@ , isSystem = false :: boolean() }). --record(miAgHttpCliRet, { +-record(miRequestRet, { requestId :: requestId(), reply :: term() }). --record(requestRet, { - statusCode :: undefined | 100..505, - contentLength :: undefined | non_neg_integer() | chunked, - headers :: undefined | [binary()], - body :: undefined | binary() -}). - -record(recvState, { stage = header :: header | body | done, %% 一个请求收到tcp可能会有多个包 最多分三个阶接收 contentLength :: undefined | non_neg_integer() | chunked, @@ -107,8 +100,7 @@ }). -type miRequest() :: #miRequest{}. --type miAgHttpCliRet() :: #miAgHttpCliRet{}. --type requestRet() :: #requestRet{}. +-type miRequestRet() :: #miRequestRet{}. -type recvState() :: #recvState{}. -type srvState() :: #srvState{}. -type cliState() :: #cliState{}. diff --git a/include/erlArango.hrl b/include/erlArango.hrl index 065343c..cdfb0e4 100644 --- a/include/erlArango.hrl +++ b/include/erlArango.hrl @@ -1,6 +1,6 @@ --define(Get, <<"GET">>). --define(Put, <<"PUT">>). --define(Post, <<"POST">>). --define(Head, <<"HEAD">>). --define(Patch, <<"PATCH">>). --define(Delete, <<"DELETE">>). \ No newline at end of file +-define(AgGet, <<"GET ">>). +-define(AgPut, <<"PUT ">>). +-define(AgPost, <<"POST ">>). +-define(AgHead, <<"HEAD ">>). +-define(AgPatch, <<"PATCH ">>). +-define(AgDelete, <<"DELETE ">>). \ No newline at end of file diff --git a/src/arangoApi/agAdminMonitor.erl b/src/arangoApi/agAdminMonitor.erl index 939567c..9bf86e9 100644 --- a/src/arangoApi/agAdminMonitor.erl +++ b/src/arangoApi/agAdminMonitor.erl @@ -31,12 +31,12 @@ % 400:如果为up或level指定了无效值,则返回。 % 500:如果服务器由于内存不足错误而无法生成结果,则返回。 getAdminLog(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/log">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/log">>, [], undefined). getAdminLog(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_admin/log", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 返回当前的日志级别设置 % GET /_admin/log/level @@ -45,7 +45,7 @@ getAdminLog(PoolNameOrSocket, QueryPars) -> % 200:如果请求有效,则返回 % 500:如果服务器由于内存不足错误而无法生成结果,则返回。 getAdminLogLevel(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/log/level">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/log/level">>, [], undefined). % 修改当前的日志级别设置 % PUT /_admin/log/level @@ -107,7 +107,7 @@ getAdminLogLevel(PoolNameOrSocket) -> % 500:如果服务器由于内存不足错误而无法生成结果,则返回。 modifyAdminLogLevel(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_admin/log/level">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, <<"/_admin/log/level">>, [], BodyStr). % 返回统计信息 % GET /_admin/statistics @@ -177,7 +177,7 @@ modifyAdminLogLevel(PoolNameOrSocket, MapData) -> % 进行中:当前繁忙的工作线程数 % 排队:排队等待工作线程可用的作业数 getAdminStatistics(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/statistics">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/statistics">>, [], undefined). % 统计数据说明 % 获取统计信息的描述性信息 @@ -211,7 +211,7 @@ getAdminStatistics(PoolNameOrSocket) -> % code:HTTP状态码 % 错误:错误,在这种情况下为false getAdminStatisticsDesc(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/statistics-description">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/statistics-description">>, [], undefined). % 返回当前实例指标 % GET /_admin/metrics @@ -222,7 +222,7 @@ getAdminStatisticsDesc(PoolNameOrSocket) -> % 200:指标已成功返回。 % 404:可以使用--server.export-metrics-api false 服务器中的设置禁用指标API 。在这种情况下,调用结果表明找不到该API。 getAdminMetrics(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/metrics">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/metrics">>, [], undefined). % 集群 @@ -234,7 +234,7 @@ getAdminMetrics(PoolNameOrSocket) -> % 返回码 % 200:如果一切正常,此API将返回HTTP 200 getAdminServerMode(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/server/mode">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/server/mode">>, [], undefined). % 返回集群永久链接中服务器的ID % 了解服务器的内部ID @@ -244,7 +244,7 @@ getAdminServerMode(PoolNameOrSocket) -> % 200:当服务器以群集模式运行时返回。 % 500:当服务器未在群集模式下运行时返回。 getAdminServerId(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/server/id">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/server/id">>, [], undefined). % 返回集群中服务器的角色 % GET /_admin/server/role @@ -261,7 +261,7 @@ getAdminServerId(PoolNameOrSocket) -> % errorNum:服务器错误号 % 作用:之一[ SINGLE,协调员,PRIMARY,SECONDARY,AGENT,UNDEFINED ] getAdminServerRole(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/server/role">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/server/role">>, [], undefined). % 返回服务器是否可用 @@ -272,7 +272,7 @@ getAdminServerRole(PoolNameOrSocket) -> % 200:如果服务器已启动并且正在运行并且可用于任意操作,并且未设置为只读模式,并且在活动故障转移设置的情况下当前不是关注者,则此API将返回HTTP 200。 % 503:如果服务器在启动或关闭过程中,设置为只读模式或当前在活动故障转移设置中为关注者,则将返回HTTP 503。 getAdminServerAvailability(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/server/availability">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/server/availability">>, [], undefined). % DBserver 永久链接的查询统计信息 % 允许查询集群中数据库服务器的统计信息 @@ -285,7 +285,7 @@ getAdminServerAvailability(PoolNameOrSocket) -> % 403: getAdminClusterStatistics(PoolNameOrSocket, DBserver) -> Path = <<"/_admin/clusterStatistics?DBserver=", (agMiscUtils:toBinary(DBserver))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 查询集群的运行状况以监视Permalink % 返回由监督(机构)评估的集群的运行状况 @@ -316,7 +316,7 @@ getAdminClusterStatistics(PoolNameOrSocket, DBserver) -> % 返回码 % 200: getAdminClusterHealth(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/cluster/health">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/cluster/health">>, [], undefined). % 重新加载路由表。 % POST /_admin/routing/reload @@ -324,4 +324,4 @@ getAdminClusterHealth(PoolNameOrSocket) -> % 返回码 % 200:路由信息重新加载成功 reloadAdminRouting(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/routing/reload">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_admin/routing/reload">>, [], undefined). diff --git a/src/arangoApi/agAnalyzers.erl b/src/arangoApi/agAnalyzers.erl index dc1d5aa..08c57b6 100644 --- a/src/arangoApi/agAnalyzers.erl +++ b/src/arangoApi/agAnalyzers.erl @@ -25,7 +25,7 @@ % 403:用户无权使用此配置创建和分析器。 newAnalyzer(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/analyzer">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_api/analyzer">>, [], BodyStr). % 返回分析器定义 % GET /_api/analyzer/{analyzer-name} @@ -41,7 +41,7 @@ newAnalyzer(PoolNameOrSocket, MapData) -> % 404:不存在这种分析器配置。 getAnalyzer(PoolNameOrSocket, AnalyzerName) -> Path = <<"/_api/analyzer/", AnalyzerName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 返回可用的分析器定义列表 % GET /_api/analyzer @@ -53,7 +53,7 @@ getAnalyzer(PoolNameOrSocket, AnalyzerName) -> % 返回码 % 200:分析器定义已成功检索。 getAnalyzerList(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/analyzer">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/analyzer">>, [], undefined). % 删除分析仪 % DELETE /_api/analyzer/{analyzer-name} @@ -74,7 +74,7 @@ getAnalyzerList(PoolNameOrSocket) -> delAnalyzer(PoolNameOrSocket, AnalyzerName) -> Path = <<"/_api/analyzer/", AnalyzerName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). delAnalyzer(PoolNameOrSocket, AnalyzerName, IsForce) -> Path = @@ -84,4 +84,4 @@ delAnalyzer(PoolNameOrSocket, AnalyzerName, IsForce) -> _ -> <<"/_api/analyzer/", AnalyzerName/binary>> end, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). diff --git a/src/arangoApi/agAqlMod.erl b/src/arangoApi/agAqlMod.erl index 9ba0515..4b517dc 100644 --- a/src/arangoApi/agAqlMod.erl +++ b/src/arangoApi/agAqlMod.erl @@ -69,7 +69,7 @@ % 405:如果使用了不受支持的HTTP方法,则服务器将以HTTP 405进行响应。 newAqlCursor(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/cursor">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_api/cursor">>, [], BodyStr). % 从现有游标返回下一个结果 @@ -88,7 +88,7 @@ newAqlCursor(PoolNameOrSocket, MapData) -> % 404:如果找不到具有指定标识符的游标,则服务器将使用HTTP 404进行响应。 nextAqlCursor(PoolNameOrSocket, CursorId) -> Path = <<"/_api/cursor/", (agMiscUtils:toBinary(CursorId))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], undefined). % 删除光标 % DELETE /_api/cursor/{cursor-identifier} @@ -102,7 +102,7 @@ nextAqlCursor(PoolNameOrSocket, CursorId) -> % 404:如果服务器不知道游标,则返回404。如果在销毁游标后使用了游标,也将返回该值。 delAqlCursor(PoolNameOrSocket, CursorId) -> Path = <<"/_api/cursor/", (agMiscUtils:toBinary(CursorId))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). % AQL查询的HTTP接口 % @@ -137,7 +137,7 @@ delAqlCursor(PoolNameOrSocket, CursorId) -> % 404:如果查询中访问了不存在的集合,服务器将以HTTP 404进行响应。 explainAqlQuery(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/explain">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_api/explain">>, [], BodyStr). % 解析一个AQL查询并返回有关它的信息 @@ -150,7 +150,7 @@ explainAqlQuery(PoolNameOrSocket, MapData) -> % 400:如果请求格式错误或查询包含解析错误,服务器将以HTTP 400响应。响应的正文将包含嵌入在JSON对象中的错误详细信息。 parseAqlQuery(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/query">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_api/query">>, [], BodyStr). % 查询跟踪固定链接 % ArangoDB具有HTTP接口,用于检索当前正在执行的AQL查询列表和慢速AQL查询列表。为了有意义地使用这些API,需要在执行HTTP请求的数据库中启用查询跟踪。 @@ -168,7 +168,7 @@ parseAqlQuery(PoolNameOrSocket, MapData) -> % 200:如果成功检索到属性,则返回。 % 400:如果请求格式错误,服务器将以HTTP 400进行响应, getAqlQueryProperties(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/query/properties">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_api/query/properties">>, [], undefined). % 更改AQL查询跟踪的配置 @@ -187,7 +187,7 @@ getAqlQueryProperties(PoolNameOrSocket) -> % 400:如果请求格式错误,服务器将以HTTP 400进行响应, changeAqlQueryProperties(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/query/properties">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, <<"/_api/query/properties">>, [], BodyStr). % 返回当前正在运行的AQL查询的列表 @@ -204,7 +204,7 @@ changeAqlQueryProperties(PoolNameOrSocket, MapData) -> % 200:可以成功检索查询列表时返回。 % 400:如果请求格式错误,服务器将以HTTP 400进行响应, getAqlQueryCurrent(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/query/current">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/query/current">>, [], undefined). % 返回运行缓慢的AQL查询的列表 @@ -222,7 +222,7 @@ getAqlQueryCurrent(PoolNameOrSocket) -> % 200:可以成功检索查询列表时返回。 % 400:如果请求格式错误,服务器将以HTTP 400进行响应, getAqlQuerySlow(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/query/slow">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/query/slow">>, [], undefined). % 清除慢速AQL查询列表 @@ -232,7 +232,7 @@ getAqlQuerySlow(PoolNameOrSocket) -> % 200:成功清除查询列表后,服务器将以HTTP 200响应。 % 400:如果请求格式错误,服务器将使用HTTP 400进行响应。 delAqlQuerySlow(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, <<"/_api/query/slow">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, <<"/_api/query/slow">>, [], undefined). % 杀死一个AQL查询 @@ -246,7 +246,7 @@ delAqlQuerySlow(PoolNameOrSocket) -> % 404:当找不到指定ID的查询时,服务器将以HTTP 404响应。 killAqlQuery(PoolNameOrSocket, QueryId) -> Path = <<"/_api/query/", (agMiscUtils:toBinary(QueryId))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). % AQL查询结果缓存的HTTP接口 % 本节介绍用于控制AQL查询结果缓存的API方法。 @@ -268,7 +268,7 @@ killAqlQuery(PoolNameOrSocket, QueryId) -> % 200:可以成功检索结果列表时返回。 % 400:如果请求格式错误,服务器将以HTTP 400进行响应, getAqlQueryCaches(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/query-cache/entries">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/query-cache/entries">>, [], undefined). % 清除AQL查询结果缓存 @@ -278,7 +278,7 @@ getAqlQueryCaches(PoolNameOrSocket) -> % 200:成功清除缓存后,服务器将以HTTP 200响应。 % 400:如果请求格式错误,服务器将使用HTTP 400进行响应。 clearAqlQueryCaches(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, <<"/_api/query-cache">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, <<"/_api/query-cache">>, [], undefined). % 返回AQL查询结果缓存的全局配置 @@ -293,7 +293,7 @@ clearAqlQueryCaches(PoolNameOrSocket) -> % 200:如果可以成功检索属性,则返回。 % 400:如果请求格式错误,服务器将以HTTP 400进行响应, getAqlQueryCacheProperties(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/query-cache/properties">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/query-cache/properties">>, [], undefined). % 更改AQL查询结果缓存的配置 @@ -311,7 +311,7 @@ getAqlQueryCacheProperties(PoolNameOrSocket) -> % 400:如果请求格式错误,服务器将以HTTP 400进行响应, changeAqlQueryCacheProperties(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/query-cache/properties">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/query-cache/properties">>, [], BodyStr). % 用于AQL用户功能管理的HTTP接口 % AQL用户功能管理 @@ -346,7 +346,7 @@ changeAqlQueryCacheProperties(PoolNameOrSocket, MapData) -> % errorMessage:描述性错误消息 newAqlUserFun(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/aqlfunction">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_api/aqlfunction">>, [], BodyStr). % 删除现有的AQL用户功能 % DELETE /_api/aqlfunction/{name} @@ -372,7 +372,7 @@ newAqlUserFun(PoolNameOrSocket, MapData) -> % errorMessage:描述性错误消息 delAqlUserFun(PoolNameOrSocket, UserFunName) -> Path = <<"/_api/aqlfunction/", (agMiscUtils:toBinary(UserFunName))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). % 返回注册的AQL用户功能 @@ -394,11 +394,11 @@ delAqlUserFun(PoolNameOrSocket, UserFunName) -> % errorNum:服务器错误号 % errorMessage:描述性错误消息 getAqlUserFuns(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/aqlfunction">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/aqlfunction">>, [], undefined). getAqlUserFuns(PoolNameOrSocket, Namespace) -> Path = <<"/_api/aqlfunction?namespace=", (agMiscUtils:toBinary(Namespace))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). diff --git a/src/arangoApi/agAsyncResultHandling.erl b/src/arangoApi/agAsyncResultHandling.erl index d63f2ce..a8069f1 100644 --- a/src/arangoApi/agAsyncResultHandling.erl +++ b/src/arangoApi/agAsyncResultHandling.erl @@ -48,7 +48,7 @@ % 404:如果找不到或已经从作业结果列表中删除或提取了作业,则返回404。在这种情况下,不会返回x-arango-async-id HTTP标头。 getAsyncJobRet(PoolNameOrSocket, JodId) -> Path = <<"/_api/job/", (agMiscUtils:toBinary(JodId))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], undefined). % 取消异步作业 @@ -62,7 +62,7 @@ getAsyncJobRet(PoolNameOrSocket, JodId) -> % 404:如果找不到或已经从作业结果列表中删除或提取了作业,则返回404。在这种情况下,不会返回x-arango-async-id HTTP标头。 cancelAsyncJob(PoolNameOrSocket, JodId) -> Path = <<"/_api/job/", (agMiscUtils:toBinary(JodId))/binary, "/cancel">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], undefined). % 删除异步作业结果 % DELETE /_api/job/{type}#by-type @@ -86,7 +86,7 @@ delAsyncJobRet(PoolNameOrSocket, TypeOrJodId, Stamp) -> _ -> <<"/_api/job/", (agMiscUtils:toBinary(TypeOrJodId))/binary>> end, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). % 返回特定作业的状态 @@ -100,7 +100,7 @@ delAsyncJobRet(PoolNameOrSocket, TypeOrJodId, Stamp) -> % 404:如果找不到或已经从作业结果列表中删除或提取了作业,则返回404。 getAsyncJobStatus(PoolNameOrSocket, JodId) -> Path = <<"/_api/job/", (agMiscUtils:toBinary(JodId))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 返回具有特定状态的工作结果ID @@ -115,9 +115,9 @@ getAsyncJobStatus(PoolNameOrSocket, JodId) -> % 400:如果未指定type或值无效,则返回。 getAsyncJobList(PoolNameOrSocket, Type) -> Path = <<"/_api/job/", (agMiscUtils:toBinary(Type))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). getAsyncJobList(PoolNameOrSocket, Type, Count) -> Path = <<"/_api/job/", (agMiscUtils:toBinary(Type))/binary, "?count=", (agMiscUtils:toBinary(Count))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). diff --git a/src/arangoApi/agBulkImportExport.erl b/src/arangoApi/agBulkImportExport.erl index ba9841e..c59929d 100644 --- a/src/arangoApi/agBulkImportExport.erl +++ b/src/arangoApi/agBulkImportExport.erl @@ -54,7 +54,7 @@ importFormDocument(PoolNameOrSocket, ListOfList, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/import", QueryBinary/binary>>, BodyStr = jiffy:encode(ListOfList), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). % 从JSON 导入文档 @@ -96,7 +96,7 @@ importFormJson(PoolNameOrSocket, MapDataList, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/import", QueryBinary/binary>>, BodyStr = jiffy:encode(MapDataList), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). % 批处理请求的HTTP接口 % 客户端通常在单独的HTTP请求中向ArangoDB发送单独的操作。这是直接且简单的,但是具有以下缺点:如果连续发出许多小请求,则网络开销可能会很大。 @@ -159,4 +159,4 @@ importFormJson(PoolNameOrSocket, MapDataList, QueryPars) -> exportDocuments(PoolNameOrSocket, CollName, MapData) -> Path = <<"/_api/export?collection=", CollName/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). \ No newline at end of file + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). \ No newline at end of file diff --git a/src/arangoApi/agCluster.erl b/src/arangoApi/agCluster.erl index 067b929..1225e92 100644 --- a/src/arangoApi/agCluster.erl +++ b/src/arangoApi/agCluster.erl @@ -23,7 +23,7 @@ % 200:当服务器以群集模式运行时返回。 % 500:当服务器未在群集模式下运行时返回。 getServerId(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/server/id">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/server/id">>, [], undefined). %返回集群中服务器的角色 %GET /_admin/server/role @@ -40,7 +40,7 @@ getServerId(PoolNameOrSocket) -> %errorNum:服务器错误号 %作用:之一[ SINGLE,协调员,PRIMARY,SECONDARY,AGENT,UNDEFINED ] getServerRole(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/server/role">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/server/role">>, [], undefined). % DBserver查询统计 % 允许查询集群中数据库服务器的统计信息 @@ -52,7 +52,7 @@ getServerRole(PoolNameOrSocket) -> % 400:数据库服务器的ID % 403: getClusterStatistics(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/clusterStatistics">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/clusterStatistics">>, [], undefined). % 查询集群的运行状况以进行监视 % 返回由监督(机构)评估的集群的运行状况 @@ -82,7 +82,7 @@ getClusterStatistics(PoolNameOrSocket) -> % LastAckedTime:自上次以来的时间(acked以秒为单位)。 % 返回码 200: getClusterHealth(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/cluster/health">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/cluster/health">>, [], undefined). % 启用或禁用监督维护模式 % 启用或禁用集群监督(机构)维护模式 @@ -95,7 +95,7 @@ getClusterHealth(PoolNameOrSocket) -> % 501: % 504: setClusterMaintenance(PoolNameOrSocket, OnOrOff) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_admin/cluster/maintenance">>, [], OnOrOff). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, <<"/_admin/cluster/maintenance">>, [], OnOrOff). diff --git a/src/arangoApi/agCollections.erl b/src/arangoApi/agCollections.erl index 315e342..7036d7a 100644 --- a/src/arangoApi/agCollections.erl +++ b/src/arangoApi/agCollections.erl @@ -75,34 +75,34 @@ % 404:如果集合名称未知,则返回HTTP 404。 newColl(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/collection">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_api/collection">>, [], BodyStr). newColl(PoolNameOrSocket, MapData, WaitForSyncReplication, ForceReplicationFactor) -> BodyStr = jiffy:encode(MapData), Path = <<"/_api/collection?waitForSyncReplication=", (agMiscUtils:toBinary(WaitForSyncReplication))/binary, "&forceReplicationFactor=", (agMiscUtils:toBinary(ForceReplicationFactor))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). % 删除集合 % DELETE /_api/collection/{collection-name} delColl(PoolNameOrSocket, CollName) -> Path = <<"/_api/collection/", CollName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). delColl(PoolNameOrSocket, CollName, IsSystem) -> case IsSystem of true -> Path = <<"/_api/collection/", CollName/binary, "?isSystem=true">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined); + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined); _ -> Path = <<"/_api/collection/", CollName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined) + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined) end. % 截断集合 % PUT /_api/collection/{collection-name}/truncate clearColl(PoolNameOrSocket, CollName) -> Path = <<"/_api/collection/", CollName/binary, "/truncate">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], undefined). % 返回有关集合的信息 % GET /_api/collection/{collection-name} @@ -126,13 +126,13 @@ clearColl(PoolNameOrSocket, CollName) -> % 404:如果集合名称未知,则返回HTTP 404。 collInfo(PoolNameOrSocket, CollName) -> Path = <<"/_api/collection/", CollName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 读取指定集合的属性 % GET /_api/collection/{collection-name}/properties collProperties(PoolNameOrSocket, CollName) -> Path = <<"/_api/collection/", (CollName)/binary, "/properties">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 返回集合中的文档数量 % 计算集合中的文档 @@ -140,7 +140,7 @@ collProperties(PoolNameOrSocket, CollName) -> % GET /_api/collection/{collection-name}/count collCount(PoolNameOrSocket, CollName) -> Path = <<"/_api/collection/", CollName/binary, "/count">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 获取集合的统计信息 % GET /_api/collection/{collection-name}/figures @@ -154,7 +154,7 @@ collCount(PoolNameOrSocket, CollName) -> % 仍然可以将fileSize值的总和用作磁盘使用率的下限近似值。 collFigures(PoolNameOrSocket, CollName) -> Path = <<"/_api/collection/", CollName/binary, "/figures">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 返回负责文档的分片 % PUT /_api/collection/{collection-name}/responsibleShard @@ -171,7 +171,7 @@ collFigures(PoolNameOrSocket, CollName) -> collResponsibleShard(PoolNameOrSocket, CollName, MapData) -> Path = <<"/_api/collection/", CollName/binary, "/responsibleShard">>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], BodyStr). % 返回集合永久链接的分片 ID % 返回集合的分片ID @@ -183,16 +183,16 @@ collResponsibleShard(PoolNameOrSocket, CollName, MapData) -> % details (optional):如果设置为true,则返回值还将包含集合碎片的负责服务器。 collShards(PoolNameOrSocket, CollName) -> Path = <<"/_api/collection/", CollName/binary, "/shards">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). collShards(PoolNameOrSocket, CollName, IsDetails) -> case IsDetails of true -> Path = <<"/_api/collection/", CollName/binary, "/shards?details=true">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined); + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined); _ -> Path = <<"/_api/collection/", CollName/binary, "/shards">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined) + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined) end. % 返回集合修订版ID @@ -201,7 +201,7 @@ collShards(PoolNameOrSocket, CollName, IsDetails) -> % GET /_api/collection/{collection-name}/revision collRevision(PoolNameOrSocket, CollName) -> Path = <<"/_api/collection/", CollName/binary, "/revision">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 返回集合永久链接的校验和 % 返回指定集合的​​校验和 @@ -220,17 +220,17 @@ collRevision(PoolNameOrSocket, CollName) -> % GET /_api/collection/{collection-name}/checksum collChecksum(PoolNameOrSocket, CollName) -> Path = <<"/_api/collection/", CollName/binary, "/checksum">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). collChecksum(PoolNameOrSocket, CollName, IsWithRevisions, IsWithData) -> case IsWithRevisions orelse IsWithData of false -> Path = <<"/_api/collection/", CollName/binary, "/checksum">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined); + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined); _ -> Path = <<"/_api/collection/", CollName/binary, "/checksum?withRevisions=", (agMiscUtils:toBinary(IsWithRevisions, utf8))/binary, "&withData=", (erlang:atom_to_binary(IsWithRevisions, utf8))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined) + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined) end. % 返回所有集合 @@ -238,15 +238,15 @@ collChecksum(PoolNameOrSocket, CollName, IsWithRevisions, IsWithData) -> % excludeSystem(可选):是否应从结果中排除系统集合。 % GET /_api/collection collList(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/collection">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/collection">>, [], undefined). collList(PoolNameOrSocket, IsExcludeSystem) -> case IsExcludeSystem of false -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/collection">>, [], undefined); + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/collection">>, [], undefined); _ -> Path = <<"/_api/collection/?excludeSystem=true">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined) + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined) end. % 加载集合 @@ -255,17 +255,17 @@ collList(PoolNameOrSocket, IsExcludeSystem) -> % PUT /_api/collection/{collection-name}/load collLoad(PoolNameOrSocket, CollName) -> Path = <<"/_api/collection/", CollName/binary, "/load">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], undefined). collLoad(PoolNameOrSocket, CollName, IsCount) -> case IsCount of false -> Path = <<"/_api/collection/", CollName/binary, "/load">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], <<"{\"count\":false}">>); + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], <<"{\"count\":false}">>); _ -> Path = <<"/_api/collection/", CollName/binary, "/load">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined) + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], undefined) end. % 卸载集合 @@ -282,7 +282,7 @@ collLoad(PoolNameOrSocket, CollName, IsCount) -> collUnload(PoolNameOrSocket, CollName) -> Path = <<"/_api/collection/", CollName/binary, "/unload">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], undefined). % 将索引加载到内存中 % PUT /_api/collection/{collection-name}/loadIndexesIntoMemory @@ -298,7 +298,7 @@ collUnload(PoolNameOrSocket, CollName) -> collLoadIndexesIntoMemory(PoolNameOrSocket, CollName) -> Path = <<"/_api/collection/", CollName/binary, "/loadIndexesIntoMemory">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], undefined). % 更改集合的属性 % PUT /_api/collection/{collection-name}/properties @@ -327,7 +327,7 @@ collLoadIndexesIntoMemory(PoolNameOrSocket, CollName) -> collChangeProperties(PoolNameOrSocket, CollName, MapData) -> Path = <<"/_api/collection/", CollName/binary, "/properties">>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). % 重命名集合 % PUT /_api/collection/{collection-name}/rename @@ -348,7 +348,7 @@ collChangeProperties(PoolNameOrSocket, CollName, MapData) -> collRename(PoolNameOrSocket, OldName, NewName) -> Path = <<"/_api/collection/", OldName/binary, "/rename">>, NameStr = jiffy:encode(NewName), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], <<"{\"name\":", NameStr/binary, "}">>). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], <<"{\"name\":", NameStr/binary, "}">>). % 旋转收藏夹的日记 % PUT /_api/collection/{collection-name}/rotate @@ -364,7 +364,7 @@ collRename(PoolNameOrSocket, OldName, NewName) -> % 404:如果集合名称未知,则返回HTTP 404。 collRotate(PoolNameOrSocket, CollName) -> Path = <<"/_api/collection/", CollName/binary, "/rotate">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], undefined). % 重新计算集合的文档数 @@ -377,4 +377,4 @@ collRotate(PoolNameOrSocket, CollName) -> % 注意:此方法特定于RocksDB存储引擎 collRecalculateCount(PoolNameOrSocket, CollName) -> Path = <<"/_api/collection/", CollName/binary, "/recalculateCount">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined). \ No newline at end of file + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], undefined). \ No newline at end of file diff --git a/src/arangoApi/agDbMgr.erl b/src/arangoApi/agDbMgr.erl index 839a41c..c54a80f 100644 --- a/src/arangoApi/agDbMgr.erl +++ b/src/arangoApi/agDbMgr.erl @@ -8,17 +8,17 @@ %% 检索有关当前数据库的信息(别名 /_api/database/properties) %% GET /_api/database/current curDbInfo(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/database/current">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/database/current">>, [], undefined). %% 检索当前用户可以访问的所有数据库的列表 %% GET /_api/database/user curVisitDbs(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/database/user">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/database/user">>, [], undefined). %% 检索所有现有数据库的列表 %% GET /_api/database curDbList(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/database">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/database">>, [], undefined). %% 创建一个新的数据库 @@ -42,11 +42,11 @@ curDbList(PoolNameOrSocket) -> newDb(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/database">>, [], BodyStr, true). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_api/database">>, [], BodyStr, true). %% 删除现有数据库 %% DELETE /_api/database/{database-name} delDb(PoolNameOrSocket, Name) -> Path = <<"/_api/database/", Name/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined, true). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined, true). diff --git a/src/arangoApi/agDocuments.erl b/src/arangoApi/agDocuments.erl index 17685b5..a4515a8 100644 --- a/src/arangoApi/agDocuments.erl +++ b/src/arangoApi/agDocuments.erl @@ -20,11 +20,11 @@ % 412:如果给出“ If-Match”标头并且找到的文档具有不同版本,则返回412。响应还将在_rev属性中包含找到的文档的当前修订。此外,将返回属性_id和_key。 getDocument(PoolNameOrSocket, CollName, Key) -> Path = <<"/_api/document/", CollName/binary, "/", (agMiscUtils:toBinary(Key))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). getDocument(PoolNameOrSocket, CollName, Key, Headers) -> Path = <<"/_api/document/", CollName/binary, "/", (agMiscUtils:toBinary(Key))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, Headers, undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, Headers, undefined). % 读取单个文档头 @@ -44,11 +44,11 @@ getDocument(PoolNameOrSocket, CollName, Key, Headers) -> getDocHead(PoolNameOrSocket, CollName, Key) -> Path = <<"/_api/document/", CollName/binary, "/", (agMiscUtils:toBinary(Key))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Head, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgHead, Path, [], undefined). getDocHead(PoolNameOrSocket, CollName, Key, Headers) -> Path = <<"/_api/document/", CollName/binary, "/", (agMiscUtils:toBinary(Key))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Head, Path, Headers, undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgHead, Path, Headers, undefined). % 创建文档 % POST /_api/document/{collection} @@ -82,13 +82,13 @@ getDocHead(PoolNameOrSocket, CollName, Key, Headers) -> newDocument(PoolNameOrSocket, CollName, MapData) -> Path = <<"/_api/document/", CollName/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). newDocument(PoolNameOrSocket, CollName, MapData, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/document/", CollName/binary, QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). % 替换文档 % PUT /_api/document/{collection}/{key} @@ -126,13 +126,13 @@ newDocument(PoolNameOrSocket, CollName, MapData, QueryPars) -> replaceDocument(PoolNameOrSocket, CollName, Key, MapData) -> Path = <<"/_api/document/", CollName/binary, "/", (agMiscUtils:toBinary(Key))/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). replaceDocument(PoolNameOrSocket, CollName, Key, MapData, Headers, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/document/", CollName/binary, "/", (agMiscUtils:toBinary(Key))/binary, QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, Headers, BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, Headers, BodyStr). % 更新文档 % PATCH /_api/document/{collection}/{key} @@ -173,13 +173,13 @@ replaceDocument(PoolNameOrSocket, CollName, Key, MapData, Headers, QueryPars) -> updateDocument(PoolNameOrSocket, CollName, Key, MapData) -> Path = <<"/_api/document/", CollName/binary, "/", (agMiscUtils:toBinary(Key))/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPatch, Path, [], BodyStr). updateDocument(PoolNameOrSocket, CollName, Key, MapData, Headers, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/document/", CollName/binary, "/", (agMiscUtils:toBinary(Key))/binary, QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, Headers, BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPatch, Path, Headers, BodyStr). % 删除文档 % DELETE /_api/document/{collection}/{key} @@ -203,12 +203,12 @@ updateDocument(PoolNameOrSocket, CollName, Key, MapData, Headers, QueryPars) -> delDocument(PoolNameOrSocket, CollName, Key) -> Path = <<"/_api/document/", CollName/binary, "/", (agMiscUtils:toBinary(Key))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). delDocument(PoolNameOrSocket, CollName, Key, Headers, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/document/", CollName/binary, "/", (agMiscUtils:toBinary(Key))/binary, QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, Headers, undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, Headers, undefined). % 批量文档操作 % ArangoDB支持批量处理文档。批量操作影响 单个集合。使用此API变体可使客户端分摊整批文档中的单个请求的开销。不能保证批量操作可以串行执行,ArangoDB 可以并行执行这些操作。这可以转化为大幅的性能提升,尤其是在集群部署中。 @@ -236,7 +236,7 @@ getDocuments(PoolNameOrSocket, CollName, KeyOrMapDataList, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/document/", CollName/binary, QueryBinary/binary>>, BodyStr = jiffy:encode(KeyOrMapDataList), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). % 创建多个文档 @@ -271,13 +271,13 @@ getDocuments(PoolNameOrSocket, CollName, KeyOrMapDataList, QueryPars) -> newDocuments(PoolNameOrSocket, CollName, MapDataList) -> Path = <<"/_api/document/", CollName/binary>>, BodyStr = jiffy:encode(MapDataList), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). newDocuments(PoolNameOrSocket, CollName, MapDataList, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/document/", CollName/binary, QueryBinary/binary>>, BodyStr = jiffy:encode(MapDataList), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). % 替换多个文件 % PUT /_api/document/{collection} @@ -308,13 +308,13 @@ newDocuments(PoolNameOrSocket, CollName, MapDataList, QueryPars) -> replaceDocuments(PoolNameOrSocket, CollName, MapDataList) -> Path = <<"/_api/document/", CollName/binary>>, BodyStr = jiffy:encode(MapDataList), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). replaceDocuments(PoolNameOrSocket, CollName, MapDataList, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/document/", CollName/binary, QueryBinary/binary>>, BodyStr = jiffy:encode(MapDataList), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). % 更新多个文件 % PATCH /_api/document/{collection} @@ -348,13 +348,13 @@ replaceDocuments(PoolNameOrSocket, CollName, MapDataList, QueryPars) -> updateDocuments(PoolNameOrSocket, CollName, MapDataList) -> Path = <<"/_api/document/", CollName/binary>>, BodyStr = jiffy:encode(MapDataList), - agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPatch, Path, [], BodyStr). updateDocuments(PoolNameOrSocket, CollName, MapDataList, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/document/", CollName/binary, QueryBinary/binary>>, BodyStr = jiffy:encode(MapDataList), - agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPatch, Path, [], BodyStr). % 删除多个文件 @@ -380,10 +380,10 @@ updateDocuments(PoolNameOrSocket, CollName, MapDataList, QueryPars) -> delDocuments(PoolNameOrSocket, CollName, KeyOrMapDataList) -> Path = <<"/_api/document/", CollName/binary, "/">>, BodyStr = jiffy:encode(KeyOrMapDataList), - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], BodyStr). delDocuments(PoolNameOrSocket, CollName, KeyOrMapDataList, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/document/", CollName/binary, QueryBinary/binary>>, BodyStr = jiffy:encode(KeyOrMapDataList), - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], BodyStr). diff --git a/src/arangoApi/agEdges.erl b/src/arangoApi/agEdges.erl index b67c5b8..13a7068 100644 --- a/src/arangoApi/agEdges.erl +++ b/src/arangoApi/agEdges.erl @@ -23,4 +23,4 @@ getEdges(PoolNameOrSocket, CollName, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/edges/", CollName/binary, QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). diff --git a/src/arangoApi/agEndPoints.erl b/src/arangoApi/agEndPoints.erl index 8be9ed5..f29a663 100644 --- a/src/arangoApi/agEndPoints.erl +++ b/src/arangoApi/agEndPoints.erl @@ -25,7 +25,7 @@ % 端点:协调器的绑定,例如tcp://[::1]:8530 % 501: getClusterEndpoints(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/cluster/endpoints">>, [], undefined, true). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/cluster/endpoints">>, [], undefined, true). % 所有端点的返回列表永久链接 % 此API调用返回所有端点(单个服务器)的列表。 diff --git a/src/arangoApi/agFoxxServices.erl b/src/arangoApi/agFoxxServices.erl index b302904..64c98ed 100644 --- a/src/arangoApi/agFoxxServices.erl +++ b/src/arangoApi/agFoxxServices.erl @@ -29,14 +29,14 @@ % 返回码 % 200:如果请求成功,则返回。 getFoxxList(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/foxx">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/foxx">>, [], undefined). getFoxxList(PoolNameOrSocket, ExcludeSystem) -> case ExcludeSystem of true -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/foxx?excludeSystem=true">>, [], undefined); + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/foxx?excludeSystem=true">>, [], undefined); _ -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/foxx?excludeSystem=false">>, [], undefined) + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/foxx?excludeSystem=false">>, [], undefined) end. % 服务说明 @@ -58,7 +58,7 @@ getFoxxList(PoolNameOrSocket, ExcludeSystem) -> % 400:如果安装路径未知,则返回。 getFoxxService(PoolNameOrSocket, Mount) -> Path = <<"/_api/foxx/service?mount=", (agMiscUtils:toBinary(Mount))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 安装新服务 @@ -89,7 +89,7 @@ installFoxx(PoolNameOrSocket, MapData, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx", QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). % 卸载服务 @@ -104,7 +104,7 @@ installFoxx(PoolNameOrSocket, MapData, QueryPars) -> uninstallFoxx(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/service", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). % 更换服务 % PUT /_api/foxx/service @@ -135,7 +135,7 @@ replaceFoxx(PoolNameOrSocket, MapData, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/service", QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). % 升级服务 % PATCH /_api/foxx/service @@ -166,7 +166,7 @@ upgradeFoxx(PoolNameOrSocket, MapData, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/service", QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPatch, Path, [], BodyStr). % Foxx服务配置/依赖关系 % 这是用于管理Foxx服务配置和依赖关系的ArangoDB HTTP接口的简介。 @@ -182,7 +182,7 @@ upgradeFoxx(PoolNameOrSocket, MapData, QueryPars) -> getFoxxConfig(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/configuration", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 更新配置选项 % PATCH /_api/foxx/configuration @@ -198,7 +198,7 @@ updateFoxxConfig(PoolNameOrSocket, MapData, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/configuration", QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPatch, Path, [], BodyStr). % 替换配置选项 % PUT /_api/foxx/configuration @@ -214,7 +214,7 @@ replaceFoxxConfig(PoolNameOrSocket, MapData, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/configuration", QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). % 获取依赖项选项 % GET /_api/foxx/dependencies @@ -227,7 +227,7 @@ replaceFoxxConfig(PoolNameOrSocket, MapData, QueryPars) -> getFoxxDependencies(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/dependencies", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 更新依赖项选项 @@ -244,7 +244,7 @@ updateFoxxDependencies(PoolNameOrSocket, MapData, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/dependencies", QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPatch, Path, [], BodyStr). % 替换依赖项选项 % PUT /_api/foxx/dependencies @@ -260,7 +260,7 @@ replaceFoxxDependencies(PoolNameOrSocket, MapData, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/dependencies", QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). % Foxx服务杂项 % @@ -275,7 +275,7 @@ replaceFoxxDependencies(PoolNameOrSocket, MapData, QueryPars) -> getFoxxScripts(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/scripts", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 运行服务脚本 % POST /_api/foxx/scripts/{name} @@ -293,7 +293,7 @@ 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). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). % 运行服务测试 % POST /_api/foxx/tests @@ -319,7 +319,7 @@ runFoxxScripts(PoolNameOrSocket, ScriptName, MapData, QueryPars) -> runFoxxTest(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/tests", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], undefined). % 启用开发模式 @@ -336,7 +336,7 @@ runFoxxTest(PoolNameOrSocket, QueryPars) -> enableFoxxDevelopment(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/development", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], undefined). % 禁用开发模式 % DELETE /_api/foxx/development @@ -349,7 +349,7 @@ enableFoxxDevelopment(PoolNameOrSocket, QueryPars) -> disableFoxxDevelopment(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/development", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). % 服务自述文件 @@ -363,7 +363,7 @@ disableFoxxDevelopment(PoolNameOrSocket, QueryPars) -> getFoxxReadme(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/readme", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 招摇说明 % GET /_api/foxx/swagger @@ -376,7 +376,7 @@ getFoxxReadme(PoolNameOrSocket, QueryPars) -> getFoxxSwagger(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/swagger", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 下载服务包 % POST /_api/foxx/download @@ -391,7 +391,7 @@ getFoxxSwagger(PoolNameOrSocket, QueryPars) -> downloadFoxxBundle(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/download", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], undefined). % 提交本地服务状态 % POST /_api/foxx/commit @@ -404,4 +404,4 @@ downloadFoxxBundle(PoolNameOrSocket, QueryPars) -> commitFoxxState(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/foxx/commit", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], undefined). \ No newline at end of file + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], undefined). \ No newline at end of file diff --git a/src/arangoApi/agGeneralGraphs.erl b/src/arangoApi/agGeneralGraphs.erl index 723b451..77a9dec 100644 --- a/src/arangoApi/agGeneralGraphs.erl +++ b/src/arangoApi/agGeneralGraphs.erl @@ -23,7 +23,7 @@ % isSmart:标记图形是否为SmartGraph(仅限企业版)。 % smartGraphAttribute:智能图例中的分片属性名称(仅企业版) getGharialList(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/gharial">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/gharial">>, [], undefined). % 在图形模块中创建一个新图形。 @@ -68,7 +68,7 @@ getGharialList(PoolNameOrSocket) -> % errorMessage:为此错误创建的消息。 newGharial(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/gharial">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_api/gharial">>, [], BodyStr). newGharial(PoolNameOrSocket, MapData, WaitForSync) -> Path = @@ -79,7 +79,7 @@ newGharial(PoolNameOrSocket, MapData, WaitForSync) -> <<"/_api/gharial?waitForSync=false">> end, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). % 获取图表 % GET /_api/gharial/{graph} @@ -97,7 +97,7 @@ newGharial(PoolNameOrSocket, MapData, WaitForSync) -> % errorMessage:为此错误创建的消息。 getGharial(PoolNameOrSocket, GraphName) -> Path = <<"/_api/gharial/", GraphName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 删除现有图 @@ -122,7 +122,7 @@ getGharial(PoolNameOrSocket, GraphName) -> % errorMessage:为此错误创建的消息。 delGharial(PoolNameOrSocket, GraphName) -> Path = <<"/_api/gharial/", GraphName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). delGharial(PoolNameOrSocket, GraphName, DropCollections) -> Path = @@ -132,7 +132,7 @@ delGharial(PoolNameOrSocket, GraphName, DropCollections) -> _ -> <<"/_api/gharial/", GraphName/binary, "?dropCollections=false">> end, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). % 列出此图中使用的所有顶点集合。 @@ -151,7 +151,7 @@ delGharial(PoolNameOrSocket, GraphName, DropCollections) -> % errorMessage:为此错误创建的消息。 getGharialVertexCollList(PoolNameOrSocket, GraphName) -> Path = <<"/_api/gharial/", GraphName/binary, "/vertex">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 向图中添加一个额外的顶点集合。 % POST /_api/gharial/{graph}/vertex @@ -188,7 +188,7 @@ getGharialVertexCollList(PoolNameOrSocket, GraphName) -> addGharialVertexColl(PoolNameOrSocket, GraphName, MapData) -> Path = <<"/_api/gharial/", GraphName/binary, "/vertex">>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). % 从图形中删除顶点集合。 % DELETE /_api/gharial/{graph}/vertex/{collection} @@ -224,7 +224,7 @@ addGharialVertexColl(PoolNameOrSocket, GraphName, MapData) -> % errorMessage:为此错误创建的消息。 delGharialVertexColl(PoolNameOrSocket, GraphName, CollName) -> Path = <<"/_api/gharial/", GraphName/binary, "/vertex/", CollName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). delGharialVertexColl(PoolNameOrSocket, GraphName, CollName, DropCollection) -> Path = @@ -234,7 +234,7 @@ delGharialVertexColl(PoolNameOrSocket, GraphName, CollName, DropCollection) -> _ -> <<"/_api/gharial/", GraphName/binary, "/vertex/", CollName/binary, "?dropCollection=false">> end, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). % 列出所有边缘定义 @@ -253,7 +253,7 @@ delGharialVertexColl(PoolNameOrSocket, GraphName, CollName, DropCollection) -> % errorMessage:为此错误创建的消息。 getGharialEdgeDefList(PoolNameOrSocket, GraphName) -> Path = <<"/_api/gharial/", GraphName/binary, "/edge">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 向图添加新的边定义 @@ -293,7 +293,7 @@ getGharialEdgeDefList(PoolNameOrSocket, GraphName) -> addGharialEdgeDef(PoolNameOrSocket, GraphName, MapData) -> Path = <<"/_api/gharial/", GraphName/binary, "/edge">>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). % 替换现有的边缘定义 @@ -336,13 +336,13 @@ addGharialEdgeDef(PoolNameOrSocket, GraphName, MapData) -> replaceGharialEdgeDef(PoolNameOrSocket, GraphName, CollName, MapData) -> Path = <<"/_api/gharial/", GraphName/binary, "/edge/", CollName/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). replaceGharialEdgeDef(PoolNameOrSocket, GraphName, CollName, MapData, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/gharial/", GraphName/binary, "/edge/", CollName/binary, QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). % 从图形中删除边缘定义 @@ -376,12 +376,12 @@ replaceGharialEdgeDef(PoolNameOrSocket, GraphName, CollName, MapData, QueryPars) delGharialEdgeDef(PoolNameOrSocket, GraphName, CollName) -> Path = <<"/_api/gharial/", GraphName/binary, "/edge/", CollName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). delGharialEdgeDef(PoolNameOrSocket, GraphName, CollName, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/gharial/", GraphName/binary, "/edge/", CollName/binary, QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). % 创建一个新顶点 @@ -419,13 +419,13 @@ delGharialEdgeDef(PoolNameOrSocket, GraphName, CollName, QueryPars) -> newGharialVertex(PoolNameOrSocket, GraphName, CollName, MapData) -> Path = <<"/_api/gharial/", GraphName/binary, "/vertex/", CollName/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). newGharialVertex(PoolNameOrSocket, GraphName, CollName, MapData, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/gharial/", GraphName/binary, "/vertex/", CollName/binary, QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). % 获取现有顶点 @@ -471,12 +471,12 @@ newGharialVertex(PoolNameOrSocket, GraphName, CollName, MapData, QueryPars) -> % errorMessage:为此错误创建的消息。 getGharialVertex(PoolNameOrSocket, GraphName, CollName, VertexKey) -> Path = <<"/_api/gharial/", GraphName/binary, "/vertex/", CollName/binary, "/", (agMiscUtils:toBinary(VertexKey) / binary)>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). getGharialVertex(PoolNameOrSocket, GraphName, CollName, VertexKey, Headers, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/gharial/", GraphName/binary, "/vertex/", CollName/binary, "/", (agMiscUtils:toBinary(VertexKey) / binary), QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, Headers, undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, Headers, undefined). % 更新现有顶点 @@ -530,13 +530,13 @@ getGharialVertex(PoolNameOrSocket, GraphName, CollName, VertexKey, Headers, Quer updateGharialVertex(PoolNameOrSocket, GraphName, CollName, VertexKey, MapData) -> Path = <<"/_api/gharial/", GraphName/binary, "/vertex/", CollName/binary, "/", (agMiscUtils:toBinary(VertexKey) / binary)>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPatch, Path, [], BodyStr). updateGharialVertex(PoolNameOrSocket, GraphName, CollName, VertexKey, MapData, Headers, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/gharial/", GraphName/binary, "/vertex/", CollName/binary, "/", (agMiscUtils:toBinary(VertexKey) / binary), QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, Headers, BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPatch, Path, Headers, BodyStr). % 替换现有的顶点 @@ -590,13 +590,13 @@ updateGharialVertex(PoolNameOrSocket, GraphName, CollName, VertexKey, MapData, H replaceGharialVertex(PoolNameOrSocket, GraphName, CollName, VertexKey, MapData) -> Path = <<"/_api/gharial/", GraphName/binary, "/vertex/", CollName/binary, "/", (agMiscUtils:toBinary(VertexKey) / binary)>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). replaceGharialVertex(PoolNameOrSocket, GraphName, CollName, VertexKey, MapData, Headers, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/gharial/", GraphName/binary, "/vertex/", CollName/binary, "/", (agMiscUtils:toBinary(VertexKey) / binary), QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, Headers, BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, Headers, BodyStr). % 从图中删除顶点 % DELETE /_api/gharial/{graph}/vertex/{collection}/{vertex} @@ -642,12 +642,12 @@ replaceGharialVertex(PoolNameOrSocket, GraphName, CollName, VertexKey, MapData, % errorMessage:为此错误创建的消息。 delGharialVertex(PoolNameOrSocket, GraphName, CollName, VertexKey) -> Path = <<"/_api/gharial/", GraphName/binary, "/vertex/", CollName/binary, "/", (agMiscUtils:toBinary(VertexKey) / binary)>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], undefined). delGharialVertex(PoolNameOrSocket, GraphName, CollName, VertexKey, Headers, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/gharial/", GraphName/binary, "/vertex/", CollName/binary, "/", (agMiscUtils:toBinary(VertexKey) / binary), QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, Headers, undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, Headers, undefined). % 在现有图形中创建边 @@ -695,13 +695,13 @@ delGharialVertex(PoolNameOrSocket, GraphName, CollName, VertexKey, Headers, Quer newGharialEdge(PoolNameOrSocket, GraphName, CollName, MapData) -> Path = <<"/_api/gharial/", GraphName/binary, "/edge/", CollName/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). newGharialEdge(PoolNameOrSocket, GraphName, CollName, MapData, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/gharial/", GraphName/binary, "/edge/", CollName/binary, QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). % 获得边 % GET /_api/gharial/{graph}/edge/{collection}/{edge} @@ -746,11 +746,11 @@ newGharialEdge(PoolNameOrSocket, GraphName, CollName, MapData, QueryPars) -> % errorMessage:为此错误创建的消息。 getGharialEdge(PoolNameOrSocket, GraphName, CollName, EdgeKey) -> Path = <<"/_api/gharial/", GraphName/binary, "/edge/", CollName/binary, "/", (agMiscUtils:toBinary(EdgeKey))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). getGharialEdge(PoolNameOrSocket, GraphName, CollName, EdgeKey, Headers) -> Path = <<"/_api/gharial/", GraphName/binary, "/edge/", CollName/binary, "/", (agMiscUtils:toBinary(EdgeKey))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, Headers, undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, Headers, undefined). % 修改现有边 @@ -805,13 +805,13 @@ getGharialEdge(PoolNameOrSocket, GraphName, CollName, EdgeKey, Headers) -> updateGharialEdge(PoolNameOrSocket, GraphName, CollName, EdgeKey, MapData) -> Path = <<"/_api/gharial/", GraphName/binary, "/edge/", CollName/binary, "/", (agMiscUtils:toBinary(EdgeKey))/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPatch, Path, [], BodyStr). updateGharialEdge(PoolNameOrSocket, GraphName, CollName, EdgeKey, MapData, Headers, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/gharial/", GraphName/binary, "/edge/", CollName/binary, "/", (agMiscUtils:toBinary(EdgeKey))/binary, QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, Headers, BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPatch, Path, Headers, BodyStr). % 替换现有边的内容 @@ -867,13 +867,13 @@ updateGharialEdge(PoolNameOrSocket, GraphName, CollName, EdgeKey, MapData, Heade replaceGharialEdge(PoolNameOrSocket, GraphName, CollName, EdgeKey, MapData) -> Path = <<"/_api/gharial/", GraphName/binary, "/edge/", CollName/binary, "/", (agMiscUtils:toBinary(EdgeKey))/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). replaceGharialEdge(PoolNameOrSocket, GraphName, CollName, EdgeKey, MapData, Headers, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/gharial/", GraphName/binary, "/edge/", CollName/binary, "/", (agMiscUtils:toBinary(EdgeKey))/binary, QueryBinary/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, Headers, BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, Headers, BodyStr). % 从图形中删除边 % DELETE /_api/gharial/{graph}/edge/{collection}/{edge} @@ -919,11 +919,11 @@ replaceGharialEdge(PoolNameOrSocket, GraphName, CollName, EdgeKey, MapData, Head % errorMessage:为此错误创建的消息。 delGharialEdge(PoolNameOrSocket, GraphName, CollName, EdgeKey) -> Path = <<"/_api/gharial/", GraphName/binary, "/edge/", CollName/binary, "/", (agMiscUtils:toBinary(EdgeKey))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). delGharialEdge(PoolNameOrSocket, GraphName, CollName, EdgeKey, Headers, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/gharial/", GraphName/binary, "/edge/", CollName/binary, "/", (agMiscUtils:toBinary(EdgeKey))/binary, QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, Headers, undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, Headers, undefined). diff --git a/src/arangoApi/agHotBackup.erl b/src/arangoApi/agHotBackup.erl index f570629..a2858d6 100644 --- a/src/arangoApi/agHotBackup.erl +++ b/src/arangoApi/agHotBackup.erl @@ -29,7 +29,7 @@ % 408:如果操作无法在超时时间内获得全局事务锁定,则返回HTTP 408。 newBackup(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/backup/create">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_admin/backup/create">>, [], BodyStr). % 从本地备份还原 % POST /_admin/backup/restore @@ -41,7 +41,7 @@ newBackup(PoolNameOrSocket, MapData) -> % 400:如果使用错误的参数或除以外的任何HTTP方法调用了restore命令POST,则返回HTTP 400。具体细节在返回的错误文档中有详细说明。 restoreBackup(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/backup/restore">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_admin/backup/restore">>, [], BodyStr). % 删除特定的本地备份 % POST /_admin/backup/delete @@ -54,7 +54,7 @@ restoreBackup(PoolNameOrSocket, MapData) -> % 404:如果id找不到与该标识符相对应的备份。 delBackup(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/backup/delete">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_admin/backup/delete">>, [], BodyStr). % 列出所有本地备份 % POST /_admin/backup/list @@ -67,7 +67,7 @@ delBackup(PoolNameOrSocket, MapData) -> % 404:如果id给出了ID或ID列表,但未找到给定ID作为备份的标识符,则返回HTTP 404 NOT FOUND。 % 405:如果使用以外的任何HTTP方法调用了list命令POST,则返回HTTP 405 METHOD NOT ALLOWED。 getBackupList(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/backup/list">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_admin/backup/list">>, [], undefined). % 上传特定的本地备份 % POST /_admin/backup/upload @@ -86,7 +86,7 @@ getBackupList(PoolNameOrSocket) -> % 404:如果id 找不到对应于标识符的备份,或者没有已知的上载操作uploadId。 uploadBackup(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/backup/upload">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_admin/backup/upload">>, [], BodyStr). % 下载特定的本地备份 % POST /_admin/backup/download @@ -105,4 +105,4 @@ uploadBackup(PoolNameOrSocket, MapData) -> % 404:如果id 找不到与该标识符相对应的备份,或者如果没有已知的与的下载操作downloadId。 downloadBackup(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/backup/download">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_admin/backup/download">>, [], BodyStr). diff --git a/src/arangoApi/agIndexes.erl b/src/arangoApi/agIndexes.erl index da51987..37a3a02 100644 --- a/src/arangoApi/agIndexes.erl +++ b/src/arangoApi/agIndexes.erl @@ -49,7 +49,7 @@ % 404:如果索引不存在,则 返回HTTP 404。 getIndexInfo(PoolNameOrSocket, IndexId) -> Path = <<"/_api/index/", (agMiscUtils:toBinary(IndexId))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 创建索引 % 创建一个索引 @@ -77,7 +77,7 @@ getIndexInfo(PoolNameOrSocket, IndexId) -> newIndex(PoolNameOrSocket, CollName, MapData) -> Path = <<"/_api/index?collection=", CollName/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). % 删除索引 @@ -90,7 +90,7 @@ newIndex(PoolNameOrSocket, CollName, MapData) -> % 404:如果index-id未知,则返回HTTP 404。 delIndex(PoolNameOrSocket, IndexId) -> Path = <<"/_api/index/", (agMiscUtils:toBinary(IndexId))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). % 返回集合的所有索引 % GET /_api/index @@ -101,7 +101,7 @@ delIndex(PoolNameOrSocket, IndexId) -> % 200:返回一个JSON对象,其中包含该集合的索引列表。 getIndexList(PoolNameOrSocket, CollName) -> Path = <<"/_api/index", CollName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 使用哈希索引 % 如果存在合适的哈希索引,/_api/simple/by-example则将使用该索引执行示例查询。 @@ -130,7 +130,7 @@ newIndexOfHash(PoolNameOrSocket, CollName, MapData) -> #{<<"type">> := <<"hash">>} -> Path = <<"/_api/index?collection=", CollName/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr); + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr); _ -> {error, param} end. @@ -197,7 +197,7 @@ newIndexOfSkipList(PoolNameOrSocket, CollName, MapData) -> #{<<"type">> := <<"skiplist">>} -> Path = <<"/_api/index?collection=", CollName/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr); + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr); _ -> {error, param} end. @@ -228,7 +228,7 @@ newIndexOfPersistent(PoolNameOrSocket, CollName, MapData) -> #{<<"type">> := <<"persistent">>} -> Path = <<"/_api/index?collection=", CollName/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr); + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr); _ -> {error, param} end. @@ -254,7 +254,7 @@ newIndexOfTtl(PoolNameOrSocket, CollName, MapData) -> #{<<"type">> := <<"ttl">>} -> Path = <<"/_api/index?collection=", CollName/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr); + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr); _ -> {error, param} end. @@ -282,7 +282,7 @@ newIndexOfGeo(PoolNameOrSocket, CollName, MapData) -> #{<<"type">> := <<"geo">>} -> Path = <<"/_api/index?collection=", CollName/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr); + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr); _ -> {error, param} end. @@ -354,7 +354,7 @@ newIndexOfFulltext(PoolNameOrSocket, CollName, MapData) -> #{<<"type">> := <<"fulltext">>} -> Path = <<"/_api/index?collection=", CollName/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr); + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr); _ -> {error, param} end. diff --git a/src/arangoApi/agMiscFun.erl b/src/arangoApi/agMiscFun.erl index dd830ec..f6fec3f 100644 --- a/src/arangoApi/agMiscFun.erl +++ b/src/arangoApi/agMiscFun.erl @@ -48,12 +48,12 @@ % 模式:我们作为-[ 服务器,控制台,脚本 ]中的一种运行的模式 % host:主机ID getSrvVersion(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/version">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/version">>, [], undefined). getSrvVersion(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/version", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 返回运行服务器的引擎类型 % GET /_api/engine @@ -61,7 +61,7 @@ getSrvVersion(PoolNameOrSocket, QueryPars) -> % 在所有情况下均返回HTTP 200。 % 名称:将是mmfiles或rocksdb getSrvEngine(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/engine">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/engine">>, [], undefined). % 将WAL同步到磁盘。 % PUT /_admin/wal/flush @@ -73,7 +73,7 @@ getSrvEngine(PoolNameOrSocket) -> % 200:操作成功返回。 % 405:使用无效的HTTP方法时返回。 flushWal(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_admin/wal/flush">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, <<"/_admin/wal/flush">>, [], undefined). % 检索预写日志的配置永久链接 % 获取当前配置。 @@ -90,7 +90,7 @@ flushWal(PoolNameOrSocket) -> % 200:操作成功返回。 % 405:使用无效的HTTP方法时返回。 getWalProperties(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/wal/properties">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/wal/properties">>, [], undefined). % 配置预写日志永久链接 % 配置沃尔玛的参数 @@ -108,7 +108,7 @@ getWalProperties(PoolNameOrSocket) -> % 405:使用无效的HTTP方法时返回。 setWalProperties(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_admin/wal/properties">>, BodyStr, undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, <<"/_admin/wal/properties">>, BodyStr, undefined). % 关于当前运行的事务返回信息永久链接 % 返回有关当前正在运行的事务的信息 @@ -121,7 +121,7 @@ setWalProperties(PoolNameOrSocket, MapData) -> % 200:操作成功返回。 % 405:使用无效的HTTP方法时返回。 getTransactions(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/wal/transactions">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/wal/transactions">>, [], undefined). % 返回系统时间固定链接 % 获取系统的当前时间 @@ -132,7 +132,7 @@ getTransactions(PoolNameOrSocket) -> % code:HTTP状态码 % time:当前系统时间(以Unix时间戳记为单位,服务器以微秒为单位) getDbTime(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/time">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/time">>, [], undefined). % 发回所发送的内容,标题,帖子正文等。 % POST /_admin/echo @@ -164,7 +164,7 @@ getDbTime(PoolNameOrSocket) -> % path:此请求的相对路径 % rawRequestBody:已发送字符的数字列表 echo(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/echo">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_admin/echo">>, [], undefined). % 返回数据库的版本。 % GET /_admin/database/target-version @@ -172,7 +172,7 @@ echo(PoolNameOrSocket) -> % 返回码 % 200:在所有情况下均返回。 getTargetVersion(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/database/target-version">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/database/target-version">>, [], undefined). % 启动关机序列 % DELETE /_admin/shutdown @@ -180,7 +180,7 @@ getTargetVersion(PoolNameOrSocket) -> % 返回码 % 200:在所有情况下OK都将返回,成功时将在结果缓冲区中返回。 shutDown(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, <<"/_admin/shutdown">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, <<"/_admin/shutdown">>, [], undefined). % 在服务器上执行脚本。 @@ -196,7 +196,7 @@ shutDown(PoolNameOrSocket) -> % 404:如果未为群集操作编译ArangoDB,则返回404。 execute(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/execute">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_admin/execute">>, [], BodyStr). % 返回服务器的状态信息。 % GET /_admin/status @@ -230,5 +230,5 @@ execute(PoolNameOrSocket, MapData) -> % 返回码 % 200:状态信息返回成功 getDbStatus(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/status">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/status">>, [], undefined). diff --git a/src/arangoApi/agRepairJobs.erl b/src/arangoApi/agRepairJobs.erl index 843208f..c5f8e3c 100644 --- a/src/arangoApi/agRepairJobs.erl +++ b/src/arangoApi/agRepairJobs.erl @@ -8,9 +8,9 @@ %% 检查修复 %% GET /_admin/repairs/distributeShardsLike checkRepir(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_admin/repairs/distributeShardsLike">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_admin/repairs/distributeShardsLike">>, [], undefined). %% 修复 %% POST /_admin/repairs/distributeShardsLike repir(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_admin/repairs/distributeShardsLike">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_admin/repairs/distributeShardsLike">>, [], undefined). diff --git a/src/arangoApi/agReplication.erl b/src/arangoApi/agReplication.erl index 33aa3aa..18cd18a 100644 --- a/src/arangoApi/agReplication.erl +++ b/src/arangoApi/agReplication.erl @@ -41,7 +41,7 @@ getRepInventory(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/replication/inventory", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 处理转储批处理命令 % POST /_api/replication/batch @@ -59,7 +59,7 @@ getRepInventory(PoolNameOrSocket, QueryPars) -> % 405:使用无效的HTTP方法时返回。 newRepBatch(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/replication/batch">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_api/replication/batch">>, [], BodyStr). % 删除现有的转储批次 @@ -76,7 +76,7 @@ newRepBatch(PoolNameOrSocket, MapData) -> % 405:使用无效的HTTP方法时返回。 delRepBatch(PoolNameOrSocket, BatchId) -> Path = <<"/_api/replication/batch/", (agMiscUtils:toBinary(BatchId))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], undefined). % 处理转储批处理命令 @@ -99,7 +99,7 @@ delRepBatch(PoolNameOrSocket, BatchId) -> prolongRepBatch(PoolNameOrSocket, BatchId, MapData) -> Path = <<"/_api/replication/batch/", (agMiscUtils:toBinary(BatchId))/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). % 返回一个集合的全部内容 % GET /_api/replication/dump @@ -138,7 +138,7 @@ prolongRepBatch(PoolNameOrSocket, BatchId, MapData) -> getRepDump(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/replication/dump", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 从远程端点同步数据 % 开始复制 @@ -170,7 +170,7 @@ getRepDump(PoolNameOrSocket, QueryPars) -> % 501:在集群中的协调器上调用此操作时返回。 startRepSync(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/sync">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, <<"/_api/replication/sync">>, [], BodyStr). % 返回集合和索引的集群清单 % 重建集群中的集合和索引的概述 @@ -186,7 +186,7 @@ startRepSync(PoolNameOrSocket, MapData) -> getRepClusterInventory(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/replication/clusterInventory", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 复制记录器命令 % 返回复制记录器的状态 @@ -211,7 +211,7 @@ getRepClusterInventory(PoolNameOrSocket, QueryPars) -> % 405:使用无效的HTTP方法时返回。 % 500:如果无法确定记录器状态,则返回。 getRepLoggerState(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/logger-state">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/replication/logger-state">>, [], undefined). % 返回日志条目永久链接固定链接 % 从服务器获取日志行 @@ -265,7 +265,7 @@ getRepLoggerState(PoolNameOrSocket) -> % 500:如果组装响应时发生错误,则返回500。 % 501:在集群中的协调器上调用此操作时返回。 getRepLoggerFirstTick(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/logger-first-tick">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/replication/logger-first-tick">>, [], undefined). % 返回日志文件中可用的刻度值范围 % GET /_api/replication/logger-tick-ranges @@ -281,7 +281,7 @@ getRepLoggerFirstTick(PoolNameOrSocket) -> % 500:如果无法确定记录器状态,则返回。 % 501:在集群中的协调器上调用此操作时返回。 getRepLoggerTickRanges(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/logger-tick-ranges">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/replication/logger-tick-ranges">>, [], undefined). % 复制应用程序命令 % applier命令允许远程启动,停止和查询ArangoDB数据库复制应用程序的状态和配置。 @@ -317,14 +317,14 @@ getRepLoggerTickRanges(PoolNameOrSocket) -> % 405:使用无效的HTTP方法时返回。 % 500:如果组装响应时发生错误,则返回500。 getRepApplierConfig(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/applier-config">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_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, ?AgGet, <<"/_api/replication/applier-config?global=true">>, [], undefined); _ -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/applier-config">>, [], undefined) + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/replication/applier-config">>, [], undefined) end. % 设置申请者的配置值 @@ -363,15 +363,15 @@ getRepApplierConfig(PoolNameOrSocket, IsGlobal) -> % 500:如果组装响应时发生错误,则返回500。 setRepApplierConfig(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/applier-config">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, <<"/_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, ?AgPut, <<"/_api/replication/applier-config?global=true">>, [], BodyStr); _ -> - agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/applier-config">>, [], BodyStr) + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, <<"/_api/replication/applier-config">>, [], BodyStr) end. % 启动复制应用程序 @@ -388,12 +388,12 @@ setRepApplierConfig(PoolNameOrSocket, MapData, IsGlobal) -> % 405:使用无效的HTTP方法时返回。 % 500:如果组装响应时发生错误,则返回500。 startRepApplier(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/applier-start">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, <<"/_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). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], undefined). % 停止复制 % PUT /_api/replication/applier-stop @@ -405,14 +405,14 @@ startRepApplier(PoolNameOrSocket, QueryPars) -> % 405:使用无效的HTTP方法时返回。 % 500:如果组装响应时发生错误,则返回500。 stopRepApplier(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/applier-stop">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, <<"/_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, ?AgPut, <<"/_api/replication/applier-stop?global=true">>, [], undefined); _ -> - agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/applier-stop">>, [], undefined) + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, <<"/_api/replication/applier-stop">>, [], undefined) end. % 输出复制的当前状态 @@ -455,14 +455,14 @@ stopRepApplier(PoolNameOrSocket, IsGlobal) -> % 405:使用无效的HTTP方法时返回。 % 500:如果组装响应时发生错误,则返回500。 getRepApplierState(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/applier-state">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_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, ?AgGet, <<"/_api/replication/applier-state?global=true">>, [], undefined); _ -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/applier-state">>, [], undefined) + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/replication/applier-state">>, [], undefined) end. @@ -533,7 +533,7 @@ getRepApplierState(PoolNameOrSocket, IsGlobal) -> % 501:在集群中的协调器上调用此操作时返回。 changeRepMakeSlave(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, <<"/_api/replication/make-slave">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, <<"/_api/replication/make-slave">>, [], BodyStr). %其他复制命令 %返回服务器ID @@ -546,7 +546,7 @@ changeRepMakeSlave(PoolNameOrSocket, MapData) -> %405:使用无效的HTTP方法时返回。 %500:如果组装响应时发生错误,则返回500。 getRepServerId(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/replication/server-id">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/replication/server-id">>, [], undefined). % WAL 固定链接操作中可用的返回刻度范围 % 返回预写日志中可用的刻度线范围 @@ -563,7 +563,7 @@ getRepServerId(PoolNameOrSocket) -> % 500:如果无法确定服务器操作状态,则返回。 % 501:在集群中的协调器上调用此操作时返回。 getWalRange(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/wal/range">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/wal/range">>, [], undefined). % 返回最后一个可用的刻度值固定链接 % 返回最后一个可用的刻度值 @@ -580,7 +580,7 @@ getWalRange(PoolNameOrSocket) -> % 500:如果组装响应时发生错误,则返回500。 % 501:在集群中的协调器上调用此操作时返回。 getWalLastTick(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/wal/lastTick">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/wal/lastTick">>, [], undefined). % 获取最近的操作 % GET /_api/wal/tail @@ -626,10 +626,10 @@ getWalLastTick(PoolNameOrSocket) -> % 500:如果组装响应时发生错误,则返回500。 % 501:在集群中的协调器上调用此操作时返回。 getWalTail(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/wal/tail">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/wal/tail">>, [], undefined). getWalTail(PoolNameOrSocket, QueryPars) -> QueryBinary = agMiscUtils:spellQueryPars(QueryPars), Path = <<"/_api/wal/tail", QueryBinary/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). diff --git a/src/arangoApi/agTasks.erl b/src/arangoApi/agTasks.erl index c295eb2..5391c27 100644 --- a/src/arangoApi/agTasks.erl +++ b/src/arangoApi/agTasks.erl @@ -16,7 +16,7 @@ % HTTP 200任务列表 % **:所有任务的列表 getTaskList(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/tasks/">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/tasks/">>, [], undefined). % 检索一个当前活动的服务器任务 % GET /_api/tasks/{id} @@ -26,7 +26,7 @@ getTaskList(PoolNameOrSocket) -> % HTTP 200请求的任务 getTask(PoolNameOrSocket, TaskId) -> Path = <<"/_api/tasks/", (agMiscUtils:toBinary(TaskId))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 创建一个新任务 % POST /_api/tasks @@ -52,7 +52,7 @@ getTask(PoolNameOrSocket, TaskId) -> % 400:如果帖子正文不正确,则返回HTTP 400。 newTask(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/tasks">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_api/tasks">>, [], BodyStr). % 注册具有预定义ID的新任务;与负载均衡器不兼容 % PUT /_api/tasks/{id} @@ -70,7 +70,7 @@ newTask(PoolNameOrSocket, MapData) -> newTask(PoolNameOrSocket, TaskId, MapData) -> Path = <<"/_api/tasks/", (agMiscUtils:toBinary(TaskId))/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, Path, [], BodyStr). % 删除一个当前活动的服务器任务 % DELETE /_api/tasks/{id} @@ -86,4 +86,4 @@ newTask(PoolNameOrSocket, TaskId, MapData) -> % errorMessage:一条纯文本消息,指出出了什么问题。 delTask(PoolNameOrSocket, TaskId) -> Path = <<"/_api/tasks/", (agMiscUtils:toBinary(TaskId))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). diff --git a/src/arangoApi/agTransactions.erl b/src/arangoApi/agTransactions.erl index 1a4dcd9..b34471a 100644 --- a/src/arangoApi/agTransactions.erl +++ b/src/arangoApi/agTransactions.erl @@ -38,7 +38,7 @@ % errorMessage:描述性错误消息 beginTransaction(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/transaction/begin">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_api/transaction/begin">>, [], BodyStr). % 获取交易状态 % 提取服务器端事务的状态 @@ -54,7 +54,7 @@ beginTransaction(PoolNameOrSocket, MapData) -> % 404:如果找不到具有指定标识符的交易,则服务器将使用HTTP 404进行响应。 getTransactionStatus(PoolNameOrSocket, TransactionId) -> Path = <<"/_api/transaction/", (agMiscUtils:toBinary(TransactionId))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 提交服务器端事务 @@ -81,7 +81,7 @@ getTransactionStatus(PoolNameOrSocket, TransactionId) -> % 409:如果事务已经中止,则服务器将使用HTTP 409进行响应。 commitTransaction(PoolNameOrSocket, TransactionId) -> Path = <<"/_api/transaction/", (agMiscUtils:toBinary(TransactionId))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], undefined). % 中止服务器端事务 % DELETE /_api/transaction/{transaction-id} @@ -107,7 +107,7 @@ commitTransaction(PoolNameOrSocket, TransactionId) -> % 409:如果事务已经提交,则服务器将以HTTP 409响应。 abortTransaction(PoolNameOrSocket, TransactionId) -> Path = <<"/_api/transaction/", (agMiscUtils:toBinary(TransactionId))/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). % 返回当前运行的服务器端事务 % GET /_api/transaction @@ -118,7 +118,7 @@ abortTransaction(PoolNameOrSocket, TransactionId) -> % 返回码 % 200:如果可以成功检索事务列表,则将返回HTTP 200 getTransactionList(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/transaction">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/transaction">>, [], undefined). % JavaScript交易的HTTP接口 % ArangoDB的JS事务在服务器上执行。客户端可以通过将事务描述发送给服务器来启动事务。 @@ -155,7 +155,7 @@ getTransactionList(PoolNameOrSocket) -> % 500:用户抛出的异常将使服务器以HTTP 500的返回码进行响应 executeTransaction(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/transaction">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_api/transaction">>, [], BodyStr). diff --git a/src/arangoApi/agUserMgr.erl b/src/arangoApi/agUserMgr.erl index 12daf38..b44dc17 100644 --- a/src/arangoApi/agUserMgr.erl +++ b/src/arangoApi/agUserMgr.erl @@ -31,7 +31,7 @@ % 409:如果已经存在同名用户,则返回。 newUser(PoolNameOrSocket, MapData) -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/user">>, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_api/user">>, [], BodyStr). % 设置数据库访问级别。 % PUT /_api/user/{user}/database/{dbname} @@ -51,7 +51,7 @@ newUser(PoolNameOrSocket, MapData) -> setUserDbAccessLevel(PoolNameOrSocket, UserName, DbName, MapData) -> Path = <<"/_api/user/", UserName/binary, "/database/", DbName/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). % 设置收集访问级别。 % PUT /_api/user/{user}/database/{dbname}/{collection} @@ -72,7 +72,7 @@ setUserDbAccessLevel(PoolNameOrSocket, UserName, DbName, MapData) -> 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). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). % 清除数据库访问级别,恢复为默认访问级别 % DELETE /_api/user/{user}/database/{dbname} @@ -85,7 +85,7 @@ setUserCollAccessLevel(PoolNameOrSocket, UserName, DbName, CollName, MapData) -> % 400:如果JSON格式不正确或请求中缺少必需数据。 clearUserDbAccessLevel(PoolNameOrSocket, UserName, DbName) -> Path = <<"/_api/user/", UserName/binary, "/database/", DbName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). % 清除集合访问级别,恢复为默认访问级别 @@ -100,7 +100,7 @@ clearUserDbAccessLevel(PoolNameOrSocket, UserName, DbName) -> % 400:如果有错误 clearUserCollAccessLevel(PoolNameOrSocket, UserName, DbName, CollName) -> Path = <<"/_api/user/", UserName/binary, "/database/", DbName/binary, "/", CollName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). % 列出用户的可访问数据库 % GET /_api/user/{user}/database/ @@ -118,7 +118,7 @@ clearUserCollAccessLevel(PoolNameOrSocket, UserName, DbName, CollName) -> % 403:如果您没有访问服务器访问级别,则返回。 getUserDbList(PoolNameOrSocket, UserName) -> Path = <<"/_api/user/", UserName/binary, "/database/">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 获取特定的数据库访问级别 % GET /_api/user/{user}/database/{dbname} @@ -133,7 +133,7 @@ getUserDbList(PoolNameOrSocket, UserName) -> % 403:如果您没有访问服务器访问级别,则返回。 getUserDbAccessLevel(PoolNameOrSocket, UserName, DbName) -> Path = <<"/_api/user/", UserName/binary, "/database/", DbName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 获取集合访问级别 % GET /_api/user/{user}/database/{dbname}/{collection} @@ -149,7 +149,7 @@ getUserDbAccessLevel(PoolNameOrSocket, UserName, DbName) -> % 403:如果您没有访问服务器访问级别,则返回。 getUserCollAccessLevel(PoolNameOrSocket, UserName, DbName, CollName) -> Path = <<"/_api/user/", UserName/binary, "/database/", DbName/binary, "/", CollName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 替换现有用户。 % PUT /_api/user/{user} @@ -169,7 +169,7 @@ getUserCollAccessLevel(PoolNameOrSocket, UserName, DbName, CollName) -> replaceUser(PoolNameOrSocket, UserName, MapData) -> Path = <<"/_api/user/", UserName/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). % 修改现有用的属性户 % PATCH /_api/user/{user} @@ -189,7 +189,7 @@ replaceUser(PoolNameOrSocket, UserName, MapData) -> modifyUser(PoolNameOrSocket, UserName, MapData) -> Path = <<"/_api/user/", UserName/binary>>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPatch, Path, [], BodyStr). % 永久删除用户。 % DELETE /_api/user/{user} @@ -203,7 +203,7 @@ modifyUser(PoolNameOrSocket, UserName, MapData) -> % 404:指定的用户不存在 delUser(PoolNameOrSocket, UserName) -> Path = <<"/_api/user/", UserName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). % 获取用户的属性。 % GET /_api/user/{user} @@ -217,7 +217,7 @@ delUser(PoolNameOrSocket, UserName) -> % 404:指定用户名不存在。 getUser(PoolNameOrSocket, UserName) -> Path = <<"/_api/user/", UserName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 列出可用的用户 % GET /_api/user/ @@ -231,4 +231,4 @@ getUser(PoolNameOrSocket, UserName) -> % 401:如果您没有对_system 数据库的访问数据库访问级别,则返回。 % 403:如果您没有访问服务器访问级别,则返回。 getUserList(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/user/">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/user/">>, [], undefined). diff --git a/src/arangoApi/agViews.erl b/src/arangoApi/agViews.erl index 6134889..63e8a8c 100644 --- a/src/arangoApi/agViews.erl +++ b/src/arangoApi/agViews.erl @@ -43,7 +43,7 @@ newViewOfArangoSearch(PoolNameOrSocket, MapData) -> case MapData of #{<<"type">> := <<"arangosearch">>} -> BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Post, <<"/_api/view">>, [], BodyStr); + agHttpCli:callAgency(PoolNameOrSocket, ?AgPost, <<"/_api/view">>, [], BodyStr); _ -> {error, param} end. @@ -60,7 +60,7 @@ newViewOfArangoSearch(PoolNameOrSocket, MapData) -> % 404:如果视图名称未知,则返回HTTP 404。 getViewInfo(PoolNameOrSocket, ViewName) -> Path = <<"/_api/view/", ViewName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 读取指定视图的属性 @@ -74,7 +74,7 @@ getViewInfo(PoolNameOrSocket, ViewName) -> % 404:如果视图名称未知,则返回HTTP 404。 getViewProperties(PoolNameOrSocket, ViewName) -> Path = <<"/_api/view/", ViewName/binary, "/properties">>, - agHttpCli:callAgency(PoolNameOrSocket, ?Get, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, Path, [], undefined). % 返回所有视图 @@ -86,7 +86,7 @@ getViewProperties(PoolNameOrSocket, ViewName) -> % 返回码 % 200:视图列表 getViewList(PoolNameOrSocket) -> - agHttpCli:callAgency(PoolNameOrSocket, ?Get, <<"/_api/view">>, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgGet, <<"/_api/view">>, [], undefined). % 更改ArangoSearch视图的所有属性 % @@ -125,7 +125,7 @@ getViewList(PoolNameOrSocket) -> changeViewAllProperties(PoolNameOrSocket, ViewName, MapData) -> Path = <<"/_api/view/", ViewName/binary, "/properties">>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], BodyStr). % 部分更改ArangoSearch视图的属性 % PATCH /_api/view/{view-name}/properties#ArangoSearch @@ -163,7 +163,7 @@ changeViewAllProperties(PoolNameOrSocket, ViewName, MapData) -> changeViewPartProperties(PoolNameOrSocket, ViewName, MapData) -> Path = <<"/_api/view/", ViewName/binary, "/properties">>, BodyStr = jiffy:encode(MapData), - agHttpCli:callAgency(PoolNameOrSocket, ?Patch, Path, [], BodyStr). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPatch, Path, [], BodyStr). % 重命名视图 % PUT /_api/view/{view-name}/rename @@ -182,7 +182,7 @@ changeViewPartProperties(PoolNameOrSocket, ViewName, MapData) -> renameView(PoolNameOrSocket, ViewName, NewViewName) -> Path = <<"/_api/view/", ViewName/binary, "/rename">>, NameStr = jiffy:encode(NewViewName), - agHttpCli:callAgency(PoolNameOrSocket, ?Put, Path, [], <<"{\"name\":", NameStr/binary, "}">>). + agHttpCli:callAgency(PoolNameOrSocket, ?AgPut, Path, [], <<"{\"name\":", NameStr/binary, "}">>). % 删除视图 % DELETE /_api/view/{view-name} @@ -197,4 +197,4 @@ renameView(PoolNameOrSocket, ViewName, NewViewName) -> % 404:如果视图名称未知,则返回HTTP 404。 delView(PoolNameOrSocket, ViewName) -> Path = <<"/_api/view/", ViewName/binary>>, - agHttpCli:callAgency(PoolNameOrSocket, ?Delete, Path, [], undefined). + agHttpCli:callAgency(PoolNameOrSocket, ?AgDelete, Path, [], undefined). diff --git a/src/httpCli/agAgencyPoolMgrIns.erl b/src/httpCli/agAgencyPoolMgrIns.erl index d25c289..f361fc7 100644 --- a/src/httpCli/agAgencyPoolMgrIns.erl +++ b/src/httpCli/agAgencyPoolMgrIns.erl @@ -42,7 +42,6 @@ handleMsg(_Msg, State) -> {ok, State}. terminate(_Reason, _State) -> - io:format("IMY******************* agAgencyPoolMgrIns terminate ~p~n ", [_Reason]), ets:delete_all_objects(?ETS_AG_Pool), ets:delete_all_objects(?ETS_AG_Agency), agKvsToBeam:load(?agBeamPool, []), diff --git a/src/httpCli/agAgencyUtils.erl b/src/httpCli/agAgencyUtils.erl index 131fb30..1632ba3 100644 --- a/src/httpCli/agAgencyUtils.erl +++ b/src/httpCli/agAgencyUtils.erl @@ -54,7 +54,7 @@ agencyReply({undefined, _RequestId, TimerRef}, _Reply) -> agAgencyUtils:cancelTimer(TimerRef); agencyReply({PidForm, RequestId, TimerRef}, Reply) -> agAgencyUtils:cancelTimer(TimerRef), - catch PidForm ! #miAgHttpCliRet{requestId = RequestId, reply = Reply}, + catch PidForm ! #miRequestRet{requestId = RequestId, reply = Reply}, ok; agencyReply(undefined, _RequestRet) -> ok. @@ -65,7 +65,7 @@ agencyReply(undefined, _RequestId, TimerRef, _Reply) -> ok; agencyReply(FormPid, RequestId, TimerRef, Reply) -> agAgencyUtils:cancelTimer(TimerRef), - catch FormPid ! #miAgHttpCliRet{requestId = RequestId, reply = Reply}, + catch FormPid ! #miRequestRet{requestId = RequestId, reply = Reply}, ok. -spec agencyReplyAll(term()) -> ok. diff --git a/src/httpCli/agHttpCli.erl b/src/httpCli/agHttpCli.erl index 064cf70..f1036cc 100644 --- a/src/httpCli/agHttpCli.erl +++ b/src/httpCli/agHttpCli.erl @@ -85,7 +85,6 @@ castAgency(PoolNameOrSocket, Method, Path, Headers, Body, Pid, IsSystem, Timeout case getCurDbInfo(PoolNameOrSocket) of {DbName, UserPassWord, Host, Protocol} -> Request = agHttpProtocol:request(IsSystem, Body, Method, Host, DbName, Path, [UserPassWord | Headers]), - io:format("IMY*******************************~n~p ~n", [Request]), case Protocol of tcp -> case gen_tcp:send(PoolNameOrSocket, Request) of @@ -97,7 +96,7 @@ castAgency(PoolNameOrSocket, Method, Path, Headers, Body, Pid, IsSystem, Timeout _ -> erlang:start_timer(OverTime, self(), waiting_over, [{abs, true}]) end, - receiveTcpData(undefined, PoolNameOrSocket, TimerRef, binary:compile_pattern(<<"\r\n">>), binary:compile_pattern(<<"\r\n\r\n">>), Method == ?Head); + receiveTcpData(undefined, PoolNameOrSocket, TimerRef, binary:compile_pattern(<<"\r\n">>), binary:compile_pattern(<<"\r\n\r\n">>), Method == ?AgHead); {error, Reason} = Err -> ?WARN(castAgency, ":gen_tcp send error: ~p ~n", [Reason]), disConnectDb(PoolNameOrSocket), @@ -113,7 +112,7 @@ castAgency(PoolNameOrSocket, Method, Path, Headers, Body, Pid, IsSystem, Timeout _ -> erlang:start_timer(OverTime, self(), waiting_over, [{abs, true}]) end, - receiveSslData(undefined, PoolNameOrSocket, TimerRef, binary:compile_pattern(<<"\r\n">>), binary:compile_pattern(<<"\r\n\r\n">>), Method == ?Head); + receiveSslData(undefined, PoolNameOrSocket, TimerRef, binary:compile_pattern(<<"\r\n">>), binary:compile_pattern(<<"\r\n\r\n">>), Method == ?AgHead); {error, Reason} = Err -> ?WARN(castAgency, ":ssl send error: ~p ~n", [Reason]), disConnectDb(PoolNameOrSocket), @@ -128,21 +127,25 @@ castAgency(PoolNameOrSocket, Method, Path, Headers, Body, Pid, IsSystem, Timeout -spec receiveResponse(requestId(), reference()) -> term() | {error, term()}. receiveResponse(RequestId, MonitorRef) -> receive - #miAgHttpCliRet{requestId = RequestId, reply = Reply} -> + #miRequestRet{requestId = RequestId, reply = Reply} -> erlang:demonitor(MonitorRef), - Reply; + case Reply of + {ok, Headers, Body} -> + {ok, Headers, jiffy:decode(Body, [return_maps])}; + _ -> + Reply + end; {'DOWN', MonitorRef, process, _Pid, Reason} -> {error, {agencyDown, Reason}} end. --spec receiveTcpData(recvState() | undefined, socket(), reference() | undefined, binary:cp(), binary:cp(), boolean()) -> requestRet() | {error, term()}. +-spec receiveTcpData(recvState() | undefined, socket(), reference() | undefined, binary:cp(), binary:cp(), boolean()) -> {ok, term(), term()} | {error, term()}. receiveTcpData(RecvState, Socket, TimerRef, Rn, RnRn, IsHeadMethod) -> receive {tcp, Socket, Data} -> - io:format("IMY******************************* ~p ~n ", [Data]), try agHttpProtocol:response(RecvState, Rn, RnRn, Data, IsHeadMethod) of - {done, #recvState{statusCode = StatusCode, contentLength = ContentLength, headers = Headers, body = Body}} -> - #requestRet{statusCode = StatusCode, contentLength = ContentLength, headers = Headers, body = Body}; + {done, #recvState{headers = Headers, body = Body}} -> + {ok, Headers, jiffy:decode(Body, [return_maps])}; {ok, NewRecvState} -> receiveTcpData(NewRecvState, Socket, TimerRef, Rn, RnRn, IsHeadMethod); {error, Reason} -> @@ -168,13 +171,13 @@ receiveTcpData(RecvState, Socket, TimerRef, Rn, RnRn, IsHeadMethod) -> receiveTcpData(RecvState, Socket, TimerRef, Rn, RnRn, IsHeadMethod) end. --spec receiveSslData(recvState() | undefined, socket(), reference() | undefined, binary:cp(), binary:cp(), boolean()) -> requestRet() | {error, term()}. +-spec receiveSslData(recvState() | undefined, socket(), reference() | undefined, binary:cp(), binary:cp(), boolean()) -> {ok, term(), term()} | {error, term()}. receiveSslData(RecvState, Socket, TimerRef, Rn, RnRn, IsHeadMethod) -> receive {ssl, Socket, Data} -> try agHttpProtocol:response(RecvState, Rn, RnRn, Data, IsHeadMethod) of - {done, #recvState{statusCode = StatusCode, contentLength = ContentLength, body = Body}} -> - #requestRet{statusCode = StatusCode, contentLength = ContentLength, body = Body}; + {done, #recvState{headers = Headers, body = Body}} -> + {ok, Headers, jiffy:decode(Body, [return_maps])}; {ok, NewRecvState} -> receiveTcpData(NewRecvState, Socket, TimerRef, Rn, RnRn, IsHeadMethod); {error, Reason} -> diff --git a/src/httpCli/agHttpProtocol.erl b/src/httpCli/agHttpProtocol.erl index e494b91..8977d9b 100644 --- a/src/httpCli/agHttpProtocol.erl +++ b/src/httpCli/agHttpProtocol.erl @@ -15,13 +15,13 @@ -spec request(boolean(), body(), method(), host(), binary(), path(), headers()) -> iolist(). request(true, undefined, Method, Host, _DbName, Path, Headers) -> [ - Method, <<" ">>, Path, <<" HTTP/1.1\r\nHost: ">>, Host, <<"_db/_system">>, + Method, Path, <<" HTTP/1.1\r\nHost: ">>, Host, <<"_db/_system">>, <<"\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: 0\r\n">>, spellHeaders(Headers), <<"\r\n">> ]; request(false, undefined, Method, Host, DbName, Path, Headers) -> [ - Method, <<" ">>, Path, <<" HTTP/1.1\r\nHost: ">>, Host, DbName, + Method, Path, <<" HTTP/1.1\r\nHost: ">>, Host, DbName, <<"\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: 0\r\n">>, spellHeaders(Headers), <<"\r\n">> ]; @@ -29,8 +29,7 @@ request(false, Body, Method, Host, DbName, Path, Headers) -> ContentLength = integer_to_binary(iolist_size(Body)), NewHeaders = [{<<"Content-Length">>, ContentLength} | Headers], [ - Method, <<" ">>, Path, - <<" HTTP/1.1\r\nHost: ">>, Host, DbName, + Method, Path, <<" HTTP/1.1\r\nHost: ">>, Host, DbName, <<"\r\nContent-Type: application/json; charset=utf-8\r\n">>, spellHeaders(NewHeaders), <<"\r\n">>, Body ]; @@ -38,8 +37,7 @@ request(true, Body, Method, Host, _DbName, Path, Headers) -> ContentLength = integer_to_binary(iolist_size(Body)), NewHeaders = [{<<"Content-Length">>, ContentLength} | Headers], [ - Method, <<" ">>, Path, - <<" HTTP/1.1\r\nHost: ">>, Host, <<"_db/_system">>, + Method, Path, <<" HTTP/1.1\r\nHost: ">>, Host, <<"_db/_system">>, <<"\r\nContent-Type: application/json; charset=utf-8\r\n">>, spellHeaders(NewHeaders), <<"\r\n">>, Body ]. diff --git a/src/httpCli/agMiscUtils.erl b/src/httpCli/agMiscUtils.erl index 19158a2..c85594e 100644 --- a/src/httpCli/agMiscUtils.erl +++ b/src/httpCli/agMiscUtils.erl @@ -13,6 +13,7 @@ , randomElement/1 , toBinary/1 , spellQueryPars/1 + , lookHeader/2 ]). -spec parseUrl(binary()) -> dbOpts() | {error, invalid_url}. @@ -104,4 +105,16 @@ spellQueryPars([{Key, Value}]) -> spellQueryPars([{Key, Value} | Tail]) -> FirstBinary = <<"?", (toBinary(Key))/binary, "=", (toBinary(Value))/binary>>, TailBinary = <<<<"&", (toBinary(OtherKey))/binary, "=", (toBinary(OtherValue))/binary>> || {OtherKey, OtherValue} <- Tail>>, - <>. \ No newline at end of file + <>. + +-spec lookHeader(binary, list()) -> binary(). +lookHeader(_Header, []) -> + <<>>; +lookHeader(Header, [H | T]) -> + case binary:split(H, <<": ">>) of + [Header, Value] -> + Value; + _ -> + lookHeader(Header, T) + end. + diff --git a/src/httpCli/agSslAgencyIns.erl b/src/httpCli/agSslAgencyIns.erl index 6563153..26be99e 100644 --- a/src/httpCli/agSslAgencyIns.erl +++ b/src/httpCli/agSslAgencyIns.erl @@ -45,7 +45,7 @@ handleMsg(#miRequest{method = Method, path = Path, headers = Headers, body = Bod _ -> erlang:start_timer(OverTime, self(), waiting_over, [{abs, true}]) end, - {ok, SrvState, CliState#cliState{isHeadMethod = Method == ?Head, status = waiting, backlogNum = BacklogNum + 1, curInfo = {FromPid, RequestId, TimerRef}}}; + {ok, SrvState, CliState#cliState{isHeadMethod = Method == ?AgHead, status = waiting, backlogNum = BacklogNum + 1, curInfo = {FromPid, RequestId, TimerRef}}}; {error, Reason} -> ?WARN(ServerName, ":send error: ~p ~p ~p ~n", [Reason, FromPid, RequestId]), ssl:close(Socket), @@ -62,8 +62,8 @@ handleMsg({ssl, Socket, Data}, #srvState{serverName = ServerName, rn = Rn, rnrn = RnRn, socket = Socket} = SrvState, #cliState{isHeadMethod = IsHeadMethod, backlogNum = BacklogNum, curInfo = CurInfo, requestsOut = RequestsOut, recvState = RecvState} = CliState) -> try agHttpProtocol:response(RecvState, Rn, RnRn, Data, IsHeadMethod) of - {done, #recvState{statusCode = StatusCode, contentLength = ContentLength, body = Body}} -> - agAgencyUtils:agencyReply(CurInfo, #requestRet{statusCode = StatusCode, contentLength = ContentLength, body = Body}), + {done, #recvState{headers = Headers, body = Body}} -> + agAgencyUtils:agencyReply(CurInfo, {ok, Headers, Body}), case agAgencyUtils:getQueue(RequestsOut + 1) of undefined -> {ok, SrvState, CliState#cliState{backlogNum = BacklogNum - 1, status = leisure, curInfo = undefined, recvState = undefined}}; @@ -132,7 +132,6 @@ handleMsg(Msg, #srvState{serverName = ServerName} = SrvState, CliState) -> terminate(_Reason, #srvState{socket = Socket} = SrvState, CliState) -> - io:format("IMY*******************terminate ~p~n", [_Reason]), {ok, NewSrvState, NewCliState} = overAllWork(SrvState, CliState), ssl:close(Socket), agAgencyUtils:dealClose(NewSrvState, NewCliState, {error, shutdown}), @@ -178,7 +177,7 @@ overDealQueueRequest(#miRequest{method = Method, path = Path, headers = Headers, _ -> erlang:start_timer(OverTime, self(), waiting_over, [{abs, true}]) end, - overReceiveSslData(SrvState, CliState#cliState{isHeadMethod = Method == ?Head, status = waiting, requestsOut = RequestsOut + 1, curInfo = {FromPid, RequestId, TimerRef}}); + overReceiveSslData(SrvState, CliState#cliState{isHeadMethod = Method == ?AgHead, status = waiting, requestsOut = RequestsOut + 1, curInfo = {FromPid, RequestId, TimerRef}}); {error, Reason} -> ?WARN(ServerName, ":send error: ~p~n", [Reason]), ssl:close(Socket), @@ -193,8 +192,8 @@ overReceiveSslData(#srvState{poolName = PoolName, serverName = ServerName, rn = receive {ssl, Socket, Data} -> try agHttpProtocol:response(RecvState, Rn, RnRn, Data, IsHeadMethod) of - {done, #recvState{statusCode = StatusCode, contentLength = ContentLength, headers = Headers, body = Body}} -> - agAgencyUtils:agencyReply(CurInfo, #requestRet{statusCode = StatusCode, contentLength = ContentLength, headers = Headers, body = Body}), + {done, #recvState{headers = Headers, body = Body}} -> + agAgencyUtils:agencyReply(CurInfo, {ok, Headers, Body}), case agAgencyUtils:getQueue(RequestsOut + 1) of undefined -> {ok, SrvState, CliState#cliState{backlogNum = BacklogNum - 1, status = leisure, curInfo = undefined, recvState = undefined}}; @@ -294,7 +293,7 @@ dealQueueRequest(#miRequest{method = Method, path = Path, headers = Headers, bod _ -> erlang:start_timer(OverTime, self(), waiting_over, [{abs, true}]) end, - {ok, SrvState, CliState#cliState{isHeadMethod = Method == ?Head, status = waiting, requestsOut = RequestsOut + 1, curInfo = {FromPid, RequestId, TimerRef}}}; + {ok, SrvState, CliState#cliState{isHeadMethod = Method == ?AgHead, status = waiting, requestsOut = RequestsOut + 1, curInfo = {FromPid, RequestId, TimerRef}}}; {error, Reason} -> ?WARN(ServerName, ":send error: ~p~n", [Reason]), ssl:close(Socket), diff --git a/src/httpCli/agTcpAgencyIns.erl b/src/httpCli/agTcpAgencyIns.erl index a642658..e2ce751 100644 --- a/src/httpCli/agTcpAgencyIns.erl +++ b/src/httpCli/agTcpAgencyIns.erl @@ -36,7 +36,6 @@ handleMsg(#miRequest{method = Method, path = Path, headers = Headers, body = Bod case Status of leisure -> %% 空闲模式 Request = agHttpProtocol:request(IsSystem, Body, Method, Host, DbName, Path, [UserPassWord | Headers]), - io:format("IMY*******************************~n~p ~n", [Request]), case gen_tcp:send(Socket, Request) of ok -> TimerRef = @@ -46,7 +45,7 @@ handleMsg(#miRequest{method = Method, path = Path, headers = Headers, body = Bod _ -> erlang:start_timer(OverTime, self(), waiting_over, [{abs, true}]) end, - {ok, SrvState, CliState#cliState{isHeadMethod = Method == ?Head, status = waiting, backlogNum = BacklogNum + 1, curInfo = {FromPid, RequestId, TimerRef}}}; + {ok, SrvState, CliState#cliState{isHeadMethod = Method == ?AgHead, status = waiting, backlogNum = BacklogNum + 1, curInfo = {FromPid, RequestId, TimerRef}}}; {error, Reason} -> ?WARN(ServerName, ":send error: ~p ~p ~p ~n", [Reason, FromPid, RequestId]), gen_tcp:close(Socket), @@ -63,8 +62,8 @@ handleMsg({tcp, Socket, Data}, #srvState{serverName = ServerName, rn = Rn, rnrn = RnRn, socket = Socket} = SrvState, #cliState{isHeadMethod = IsHeadMethod, backlogNum = BacklogNum, curInfo = CurInfo, requestsOut = RequestsOut, recvState = RecvState} = CliState) -> try agHttpProtocol:response(RecvState, Rn, RnRn, Data, IsHeadMethod) of - {done, #recvState{statusCode = StatusCode, contentLength = ContentLength, body = Body}} -> - agAgencyUtils:agencyReply(CurInfo, #requestRet{statusCode = StatusCode, contentLength = ContentLength, body = Body}), + {done, #recvState{headers = Headers, body = Body}} -> + agAgencyUtils:agencyReply(CurInfo, {ok, Headers, Body}), case agAgencyUtils:getQueue(RequestsOut + 1) of undefined -> {ok, SrvState, CliState#cliState{backlogNum = BacklogNum - 1, status = leisure, curInfo = undefined, recvState = undefined}}; @@ -132,7 +131,6 @@ handleMsg(Msg, #srvState{serverName = ServerName} = SrvState, CliState) -> terminate(_Reason, #srvState{socket = Socket} = SrvState, CliState) -> - io:format("IMY*******************terminate ~p~n", [_Reason]), {ok, NewSrvState, NewCliState} = overAllWork(SrvState, CliState), gen_tcp:close(Socket), agAgencyUtils:dealClose(NewSrvState, NewCliState, {error, shutdown}), @@ -178,7 +176,7 @@ overDealQueueRequest(#miRequest{method = Method, path = Path, headers = Headers, _ -> erlang:start_timer(OverTime, self(), waiting_over, [{abs, true}]) end, - overReceiveTcpData(SrvState, CliState#cliState{isHeadMethod = Method == ?Head, status = waiting, requestsOut = RequestsOut + 1, curInfo = {FromPid, RequestId, TimerRef}}); + overReceiveTcpData(SrvState, CliState#cliState{isHeadMethod = Method == ?AgHead, status = waiting, requestsOut = RequestsOut + 1, curInfo = {FromPid, RequestId, TimerRef}}); {error, Reason} -> ?WARN(ServerName, ":send error: ~p~n", [Reason]), gen_tcp:close(Socket), @@ -193,8 +191,8 @@ overReceiveTcpData(#srvState{poolName = PoolName, serverName = ServerName, rn = receive {tcp, Socket, Data} -> try agHttpProtocol:response(RecvState, Rn, RnRn, Data, IsHeadMethod) of - {done, #recvState{statusCode = StatusCode, contentLength = ContentLength, headers = Headers, body = Body}} -> - agAgencyUtils:agencyReply(CurInfo, #requestRet{statusCode = StatusCode, contentLength = ContentLength, headers = Headers, body = Body}), + {done, #recvState{headers = Headers, body = Body}} -> + agAgencyUtils:agencyReply(CurInfo, {ok, Headers, Body}), case agAgencyUtils:getQueue(RequestsOut + 1) of undefined -> {ok, SrvState, CliState#cliState{backlogNum = BacklogNum - 1, status = leisure, curInfo = undefined, recvState = undefined}}; @@ -294,7 +292,7 @@ dealQueueRequest(#miRequest{method = Method, path = Path, headers = Headers, bod _ -> erlang:start_timer(OverTime, self(), waiting_over, [{abs, true}]) end, - {ok, SrvState, CliState#cliState{isHeadMethod = Method == ?Head, status = waiting, requestsOut = RequestsOut + 1, curInfo = {FromPid, RequestId, TimerRef}}}; + {ok, SrvState, CliState#cliState{isHeadMethod = Method == ?AgHead, status = waiting, requestsOut = RequestsOut + 1, curInfo = {FromPid, RequestId, TimerRef}}}; {error, Reason} -> ?WARN(ServerName, ":send error: ~p~n", [Reason]), gen_tcp:close(Socket), diff --git a/src/httpCli/test.erl b/src/user_default.erl similarity index 96% rename from src/httpCli/test.erl rename to src/user_default.erl index 5e933df..b90c96c 100644 --- a/src/httpCli/test.erl +++ b/src/user_default.erl @@ -1,5 +1,7 @@ --module(test). +-module(user_default). +-include("agHttpCli.hrl"). +-compile([export_all, nowarn_export_all]). -compile([export_all, nowarn_export_all]).