Skip to content

Commit

Permalink
change: update list URIs for V3 feature (apache#7622)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzssangglass authored and Liu-Junlin committed Nov 4, 2022
1 parent a9575db commit ba3cc5b
Show file tree
Hide file tree
Showing 40 changed files with 174 additions and 176 deletions.
2 changes: 0 additions & 2 deletions apisix/admin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ local resources = {
upstreams = require("apisix.admin.upstreams"),
consumers = require("apisix.admin.consumers"),
schema = require("apisix.admin.schema"),
ssl = require("apisix.admin.ssl"),
ssls = require("apisix.admin.ssl"),
plugins = require("apisix.admin.plugins"),
proto = require("apisix.admin.proto"),
protos = require("apisix.admin.proto"),
global_rules = require("apisix.admin.global_rules"),
stream_routes = require("apisix.admin.stream_routes"),
Expand Down
8 changes: 4 additions & 4 deletions apisix/admin/proto.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function _M.put(id, conf)
return 400, err
end

local key = "/proto/" .. id
local key = "/protos/" .. id

local ok, err = utils.inject_conf_with_prev_conf("proto", key, conf)
if not ok then
Expand All @@ -88,7 +88,7 @@ end


function _M.get(id)
local key = "/proto"
local key = "/protos"
if id then
key = key .. "/" .. id
end
Expand All @@ -111,7 +111,7 @@ function _M.post(id, conf)
return 400, err
end

local key = "/proto"
local key = "/protos"
utils.inject_timestamp(conf)
local res, err = core.etcd.push(key, conf)
if not res then
Expand Down Expand Up @@ -183,7 +183,7 @@ function _M.delete(id)
end
core.log.info("proto delete service ref check pass: ", id)

local key = "/proto/" .. id
local key = "/protos/" .. id
-- core.log.info("key: ", key)
local res, err = core.etcd.delete(key)
if not res then
Expand Down
10 changes: 5 additions & 5 deletions apisix/admin/ssl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function _M.put(id, conf)
end
end

local key = "/ssl/" .. id
local key = "/ssls/" .. id

local ok, err = utils.inject_conf_with_prev_conf("ssl", key, conf)
if not ok then
Expand All @@ -91,7 +91,7 @@ end


function _M.get(id)
local key = "/ssl"
local key = "/ssls"
if id then
key = key .. "/" .. id
end
Expand Down Expand Up @@ -128,7 +128,7 @@ function _M.post(id, conf)
end
end

local key = "/ssl"
local key = "/ssls"
utils.inject_timestamp(conf)
local res, err = core.etcd.push(key, conf)
if not res then
Expand All @@ -145,7 +145,7 @@ function _M.delete(id)
return 400, {error_msg = "missing ssl id"}
end

local key = "/ssl/" .. id
local key = "/ssls/" .. id
-- core.log.info("key: ", key)
local res, err = core.etcd.delete(key)
if not res then
Expand All @@ -170,7 +170,7 @@ function _M.patch(id, conf, sub_path)
return 400, {error_msg = "invalid configuration"}
end

local key = "/ssl"
local key = "/ssls"
if id then
key = key .. "/" .. id
end
Expand Down
6 changes: 3 additions & 3 deletions apisix/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ return {
HTTP_ETCD_DIRECTORY = {
["/upstreams"] = true,
["/plugins"] = true,
["/ssl"] = true,
["/ssls"] = true,
["/stream_routes"] = true,
["/plugin_metadata"] = true,
["/routes"] = true,
["/services"] = true,
["/consumers"] = true,
["/global_rules"] = true,
["/proto"] = true,
["/protos"] = true,
["/plugin_configs"] = true,
},
STREAM_ETCD_DIRECTORY = {
["/upstreams"] = true,
["/plugins"] = true,
["/ssl"] = true,
["/ssls"] = true,
["/stream_routes"] = true,
["/plugin_metadata"] = true,
},
Expand Down
2 changes: 1 addition & 1 deletion apisix/plugins/grpc-transcode/proto.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ end

function _M.init()
local err
protos, err = core.config.new("/proto", {
protos, err = core.config.new("/protos", {
automatic = true,
item_schema = core.schema.proto
})
Expand Down
4 changes: 2 additions & 2 deletions apisix/ssl/router/radixtree_sni.lua
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ end

function _M.init_worker()
local err
ssl_certificates, err = core.config.new("/ssl", {
ssl_certificates, err = core.config.new("/ssls", {
automatic = true,
item_schema = core.schema.ssl,
checker = function (item, schema_type)
Expand All @@ -264,7 +264,7 @@ end

function _M.get_by_id(ssl_id)
local ssl
local ssls = core.config.fetch_created_obj("/ssl")
local ssls = core.config.fetch_created_obj("/ssls")
if ssls then
ssl = ssls:get(tostring(ssl_id))
end
Expand Down
2 changes: 1 addition & 1 deletion apisix/upstream.lua
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ local function check_upstream_conf(in_dp, conf)

local ssl_id = conf.tls and conf.tls.client_cert_id
if ssl_id then
local key = "/ssl/" .. ssl_id
local key = "/ssls/" .. ssl_id
local res, err = core.etcd.get(key)
if not res then
return nil, "failed to fetch ssl info by "
Expand Down
12 changes: 6 additions & 6 deletions docs/en/latest/admin-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -766,17 +766,17 @@ Currently, the response is returned from etcd.

## SSL

**API**:/apisix/admin/ssl/{id}
**API**:/apisix/admin/ssls/{id}

### Request Methods

| Method | Request URI | Request Body | Description |
| ------ | ---------------------- | ------------ | ----------------------------------------------- |
| GET | /apisix/admin/ssl | NULL | Fetches a list of all configured SSL resources. |
| GET | /apisix/admin/ssl/{id} | NULL | Fetch specified resource by id. |
| PUT | /apisix/admin/ssl/{id} | {...} | Creates a resource with the specified id. |
| POST | /apisix/admin/ssl | {...} | Creates a resource and assigns a random id. |
| DELETE | /apisix/admin/ssl/{id} | NULL | Removes the resource with the specified id. |
| GET | /apisix/admin/ssls | NULL | Fetches a list of all configured SSL resources. |
| GET | /apisix/admin/ssls/{id} | NULL | Fetch specified resource by id. |
| PUT | /apisix/admin/ssls/{id} | {...} | Creates a resource with the specified id. |
| POST | /apisix/admin/ssls | {...} | Creates a resource and assigns a random id. |
| DELETE | /apisix/admin/ssls/{id} | NULL | Removes the resource with the specified id. |

### Request Body Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/en/latest/certificate.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ with open(sys.argv[2]) as f:
key = f.read()
sni = sys.argv[3]
api_key = "edd1c9f034335f136f87ad84b625c8f1"
resp = requests.put("http://127.0.0.1:9080/apisix/admin/ssl/1", json={
resp = requests.put("http://127.0.0.1:9080/apisix/admin/ssls/1", json={
"cert": cert,
"key": key,
"snis": [sni],
Expand Down
2 changes: 1 addition & 1 deletion docs/en/latest/mtls.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ if len(sys.argv) >= 5:
reqParam["client"]["ca"] = clientCert
if len(sys.argv) >= 6:
reqParam["client"]["depth"] = int(sys.argv[5])
resp = requests.put("http://127.0.0.1:9080/apisix/admin/ssl/1", json=reqParam, headers={
resp = requests.put("http://127.0.0.1:9080/apisix/admin/ssls/1", json=reqParam, headers={
"X-API-KEY": api_key,
})
print(resp.status_code)
Expand Down
6 changes: 3 additions & 3 deletions docs/en/latest/plugins/grpc-transcode.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ APISIX takes in an HTTP request, transcodes it and forwards it to a gRPC service

Before enabling the Plugin, you have to add the content of your `.proto` or `.pb` files to APISIX.

You can use the `/admin/proto/id` endpoint and add the contents of the file to the `content` field:
You can use the `/admin/protos/id` endpoint and add the contents of the file to the `content` field:

```shell
curl http://127.0.0.1:9080/apisix/admin/proto/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
curl http://127.0.0.1:9080/apisix/admin/protos/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"content" : "syntax = \"proto3\";
package helloworld;
Expand Down Expand Up @@ -122,7 +122,7 @@ api_key = "edd1c9f034335f136f87ad84b625c8f1" # use a different API key
reqParam = {
"content": content,
}
resp = requests.put("http://127.0.0.1:9080/apisix/admin/proto/" + id, json=reqParam, headers={
resp = requests.put("http://127.0.0.1:9080/apisix/admin/protos/" + id, json=reqParam, headers={
"X-API-KEY": api_key,
})
print(resp.status_code)
Expand Down
12 changes: 6 additions & 6 deletions docs/zh/latest/admin-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -774,19 +774,19 @@ $ curl http://127.0.0.1:9080/get

## SSL

*地址*:/apisix/admin/ssl/{id}
*地址*:/apisix/admin/ssls/{id}

*说明*:SSL.

### 请求方法

| 名字 | 请求 uri | 请求 body | 说明 |
| ------ | ---------------------- | --------- | ------------------------------- |
| GET | /apisix/admin/ssl || 获取资源列表 |
| GET | /apisix/admin/ssl/{id} || 获取资源 |
| PUT | /apisix/admin/ssl/{id} | {...} | 根据 id 创建资源 |
| POST | /apisix/admin/ssl | {...} | 创建资源,id 由后台服务自动生成 |
| DELETE | /apisix/admin/ssl/{id} || 删除资源 |
| GET | /apisix/admin/ssls || 获取资源列表 |
| GET | /apisix/admin/ssls/{id} || 获取资源 |
| PUT | /apisix/admin/ssls/{id} | {...} | 根据 id 创建资源 |
| POST | /apisix/admin/ssls | {...} | 创建资源,id 由后台服务自动生成 |
| DELETE | /apisix/admin/ssls/{id} || 删除资源 |

### body 请求参数

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/latest/certificate.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ with open(sys.argv[2]) as f:
key = f.read()
sni = sys.argv[3]
api_key = "edd1c9f034335f136f87ad84b625c8f1"
resp = requests.put("http://127.0.0.1:9080/apisix/admin/ssl/1", json={
resp = requests.put("http://127.0.0.1:9080/apisix/admin/ssls/1", json={
"cert": cert,
"key": key,
"snis": [sni],
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/latest/mtls.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ if len(sys.argv) >= 5:
reqParam["client"]["ca"] = clientCert
if len(sys.argv) >= 6:
reqParam["client"]["depth"] = int(sys.argv[5])
resp = requests.put("http://127.0.0.1:9080/apisix/admin/ssl/1", json=reqParam, headers={
resp = requests.put("http://127.0.0.1:9080/apisix/admin/ssls/1", json=reqParam, headers={
"X-API-KEY": api_key,
})
print(resp.status_code)
Expand Down
6 changes: 3 additions & 3 deletions docs/zh/latest/plugins/grpc-transcode.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ APISIX 接收 HTTP 请求后,首先对请求进行转码,并将转码后的

在启用插件之前,你必须将 `.proto``.pb` 文件的内容添加到 APISIX。

可以使用 `/admin/proto/id` 接口将文件的内容添加到 `content` 字段:
可以使用 `/admin/protos/id` 接口将文件的内容添加到 `content` 字段:

```shell
curl http://127.0.0.1:9080/apisix/admin/proto/1 \
curl http://127.0.0.1:9080/apisix/admin/protos/1 \
-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"content" : "syntax = \"proto3\";
Expand Down Expand Up @@ -123,7 +123,7 @@ api_key = "edd1c9f034335f136f87ad84b625c8f1" # use your API key
reqParam = {
"content": content,
}
resp = requests.put("http://127.0.0.1:9080/apisix/admin/proto/" + id, json=reqParam, headers={
resp = requests.put("http://127.0.0.1:9080/apisix/admin/protos/" + id, json=reqParam, headers={
"X-API-KEY": api_key,
})
print(resp.status_code)
Expand Down
10 changes: 5 additions & 5 deletions t/admin/proto.t
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ __DATA__
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, message = t('/apisix/admin/proto/1',
local code, message = t('/apisix/admin/protos/1',
ngx.HTTP_PUT,
[[{
"content": "syntax = \"proto3\";
Expand Down Expand Up @@ -88,7 +88,7 @@ __DATA__
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, message = t('/apisix/admin/proto/1',
local code, message = t('/apisix/admin/protos/1',
ngx.HTTP_DELETE,
nil,
[[{
Expand All @@ -115,7 +115,7 @@ __DATA__
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, message = t('/apisix/admin/proto/2',
local code, message = t('/apisix/admin/protos/2',
ngx.HTTP_PUT,
[[{
"content": "syntax = \"proto3\";
Expand Down Expand Up @@ -184,7 +184,7 @@ __DATA__
ngx.sleep(0.1) -- ensure reference is synced from etcd
code, message = t('/apisix/admin/proto/2',
code, message = t('/apisix/admin/protos/2',
ngx.HTTP_DELETE,
nil,
[[{
Expand All @@ -207,7 +207,7 @@ __DATA__
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, message = t('/apisix/admin/proto/1',
local code, message = t('/apisix/admin/protos/1',
ngx.HTTP_PUT,
[[{
"content": "syntax = \"proto3\";
Expand Down
Loading

0 comments on commit ba3cc5b

Please sign in to comment.