Skip to content

Commit

Permalink
[Autodocs] PDK and API documentation (#5882)
Browse files Browse the repository at this point in the history
* PDK docs

* vale

* fix if_version

* API specs

* kong.vault fix
  • Loading branch information
Guaris authored Aug 3, 2023
1 parent cab719b commit 38d5880
Show file tree
Hide file tree
Showing 10 changed files with 8,088 additions and 33 deletions.
126 changes: 97 additions & 29 deletions api-specs/Gateway-EE/3.4/kong-ee-3.4.yaml

Large diffs are not rendered by default.

7,530 changes: 7,530 additions & 0 deletions api-specs/Gateway-OSS/3.4/kong-oss-3.4.yaml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions app/_data/docs_nav_gateway_3.4.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ items:
url: /plugin-development/pdk/kong.nginx
- text: kong.node
url: /plugin-development/pdk/kong.node
- text: kong.plugin
url: /plugin-development/pdk/kong.plugin
- text: kong.request
url: /plugin-development/pdk/kong.request
- text: kong.response
Expand Down
2 changes: 1 addition & 1 deletion app/_src/gateway/plugin-development/pdk/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Instance of Kong's DNS resolver, a client object from the
## kong.worker_events

Instance of Kong's IPC module for inter-workers communication from the
[lua-resty-worker-events](https://github.com/Kong/lua-resty-worker-events)
[lua-resty-events](https://github.com/Kong/lua-resty-events)
module.

**Note:** Usage of this module is currently reserved to the core or to
Expand Down
35 changes: 34 additions & 1 deletion app/_src/gateway/plugin-development/pdk/kong.client.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pdk: true
toc: true
source_url: https://github.com/Kong/kong/tree/master/kong/pdk
---

<!-- vale off -->
Client information module.

A set of functions to retrieve information about the client connecting to
Expand Down Expand Up @@ -237,10 +237,21 @@ end

## kong.client.authenticate(consumer, credential)

{% if_version gte:3.4.x %}
Sets the authenticated consumer and/or credential as well
as the authenticated consumer-group for the current request.
While both `consumer` and `credential` can be `nil`,
at least one of them must exist. Otherwise, this function will throw an
error.
{% endif_version %}

{% if_version lte:3.3.x %}
Sets the authenticated consumer and/or credential for the current request.

While both `consumer` and `credential` can be `nil`,
at least one of them must exist. Otherwise, this function will throw an
error.
{% endif_version %}

**Phases**

Expand All @@ -259,8 +270,30 @@ Sets the authenticated consumer and/or credential for the current request.
-- assuming `credential` and `consumer` have been set by some authentication code
kong.client.authenticate(consumer, credentials)
```
{% if_version gte:3.4.x %}


## _CLIENT.get_consumer_group()

Retrieves the authenticated consumer group for the current request.

**Phases**

* auth_and_later

**Returns**

* `table|nil`: The authenticated consumer group. Returns `nil` if no
consumer group has been authenticated for the current request.


**Usage**

``` lua
local group = _CLIENT.get_consumer_group()
```
{% endif_version %}


## kong.client.get_protocol([allow_terminated])

Expand Down
37 changes: 37 additions & 0 deletions app/_src/gateway/plugin-development/pdk/kong.plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
#
# WARNING: this file was auto-generated by a script.
# DO NOT edit this file directly. Instead, send a pull request to change
# https://github.com/Kong/kong/tree/master/autodoc/pdk/ldoc/ldoc.ltp
# or its associated files
#
title: kong.plugin
pdk: true
toc: true
source_url: https://github.com/Kong/kong/tree/master/kong/pdk
---

<!-- Plugin related APIs -->



## kong.plugin.get_id()

Returns the instance ID of the plugin.

**Phases**

* rewrite, access, header_filter, response, body_filter, log

**Returns**

* `string`: The ID of the running plugin


**Usage**

``` lua
kong.request.get_id() -- "123e4567-e89b-12d3-a456-426614174000"
```


3 changes: 1 addition & 2 deletions app/_src/gateway/plugin-development/pdk/kong.request.md
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,7 @@ Returns the request data as a key/value table.
body could not be parsed.

The optional argument `max_args` can be used to set a limit on the number
of form arguments parsed for `application/x-www-form-urlencoded` payloads,
which is by default **100** (or what has been configured using `lua_max_post_args`).
of form arguments parsed for `application/x-www-form-urlencoded` payloads, which is by default **100** (or what has been configured using `lua_max_post_args`).

The third return value is string containing the mimetype used to parsed
the body (as per the `mimetype` argument), allowing the caller to identify
Expand Down
6 changes: 6 additions & 0 deletions app/_src/gateway/plugin-development/pdk/kong.service.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ Sets whether TLS verification is enabled while handshaking with the Service.

**Phases**

{% if_version lte:3.3.x %}
* `rewrite`, `access`, `balancer`
{% endif_version %}

{% if_version gte:3.4.x %}
* `rewrite`, `access`, `balancer`, `preread`
{% endif_version %}

**Parameters**

Expand Down
10 changes: 10 additions & 0 deletions app/_src/gateway/plugin-development/pdk/kong.tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,14 @@ Update the value of should_sample for all spans

* **should_sample** (`bool`): value for the sample parameter

{% endif_version %}

{% if_version gte:3.4.x %}
## kong.tracing:set_should_sample(should_sample)

Update the value of should_sample for all spans

**Parameters**

* **should_sample** (`bool`): value for the sample parameter
{% endif_version %}
Loading

0 comments on commit 38d5880

Please sign in to comment.