Skip to content

Commit

Permalink
[docs] rework docs after manual testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ToshY committed Nov 18, 2024
1 parent 7b7d80c commit e953f4c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/base-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ $baseApi->addPullZone(
- `2` = TopLeft
- `4` = Center
- `5` = CenterStretch
- The keys `CacheControlBrowserMaxAgeOverride` and `CacheControlBrowserMaxAgeOverride` accept any values in seconds. The UI will
- The keys `CacheControlBrowserMaxAgeOverride` and `CacheControlBrowserMaxAgeOverride` accept any values in seconds. The Bunny dashboard will
show the value `Match Server Cache Expiration` but the value updated through the API will be honored.
- The key `OriginShieldZoneCode` accepts the 2-digit code `FR` (France, Paris) or `IL` (Illinois, Chicago).
- The `WAF` related settings are not implemented yet. This feature is currently being worked on and does not have an ETA.
Expand Down Expand Up @@ -1283,7 +1283,7 @@ $baseApi->updatePullZone(
- `2` = TopLeft
- `4` = Center
- `5` = CenterStretch
- The keys `CacheControlBrowserMaxAgeOverride` and `CacheControlBrowserMaxAgeOverride` accept any values in seconds. The UI will
- The keys `CacheControlBrowserMaxAgeOverride` and `CacheControlBrowserMaxAgeOverride` accept any values in seconds. The Bunny dashboard will
show the value `Match Server Cache Expiration` but the value updated through the API will be honored.
- The key `OriginShieldZoneCode` accepts the 2-digit code `FR` (France, Paris) or `IL` (Illinois, Chicago).
- The `WAF` related settings are not implemented yet. This feature is currently being worked on and does not have an ETA.
Expand Down
27 changes: 19 additions & 8 deletions docs/edge-scripting-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $edgeScriptingApi->getCode(
$edgeScriptingApi->setCode(
id: 1,
body: [
'Code' => "import * as BunnySDK from \"https://esm.sh/@bunny.net/[email protected]\";\n\n/**\n * Returns an HTTP response.\n * @param {Request} request - The Fetch API Request object.\n * @return {Response} The HTTP response or string.\n */\nBunnySDK.net.http.serve(async (request: Request): Response | Promise<Response> => {\n const url = new URL(request.url);\n return new Response(\"Hello from \" + url.pathname);\n});\n",
'Code' => "import * as BunnySDK from \"https://esm.sh/@bunny.net/[email protected]\";\n\n/**\n * Returns an HTTP response.\n * @param {Request} request - The Fetch API Request object.\n * @return {Response} The HTTP response or string.\n */\nBunnySDK.net.http.serve(async (request: Request): Response | Promise<Response> => {\n const url = new URL(request.url);\n return new Response(\"Hello again from \" + url.pathname);\n});\n",
],
);
```
Expand All @@ -68,7 +68,7 @@ $edgeScriptingApi->listEdgeScripts(
```php
$edgeScriptingApi->addEdgeScript(
body: [
'Name' => 'Test Script Modified',
'Name' => 'Test Script',
'Code' => "import * as BunnySDK from \"https://esm.sh/@bunny.net/[email protected]\";\n\n/**\n * Returns an HTTP response.\n * @param {Request} request - The Fetch API Request object.\n * @return {Response} The HTTP response or string.\n */\nBunnySDK.net.http.serve(async (request: Request): Response | Promise<Response> => {\n const url = new URL(request.url);\n return new Response(\"Hello from \" + url.pathname);\n});\n",
'ScriptType' => 1,
'CreateLinkedPullZone' => true,
Expand Down Expand Up @@ -99,7 +99,7 @@ $edgeScriptingApi->addEdgeScript(
- `1` = Standalone (Standalone scripts are ideal for a wide range of applications, such as building RESTful APIs, delivering UI applications, and processing data at the edge.)
- `2` = Middleware (Middleware scripts common use cases include user authentication, error handling, logging, security enhancements, A/B testing, HTML manipulation, and more.)
- The key `RepositorySettings` is not required when creating, editing and deploying on Bunny.net.
- The key `DeployConfiguration` is not required when creating a new GitHub repository.
- The key `Id` (under `RepositorySettings`) and `DeployConfiguration` are not required when creating a new GitHub repository.
- The key `IntegrationId` is required when creating and deploying through GitHub. It can be retrieved from the [Get GitHub Integrations](base-api.md#get-github-integrations) endpoint.

!!! info
Expand Down Expand Up @@ -199,6 +199,11 @@ $edgeScriptingApi->deleteEdgeScript(

### Variable

!!! info

There is no "List Variables" endpoint to retrieve all variables for a specific script. Instead, you can retrieve
this information from the [Get Edge Script](#get-edge-script) endpoint.

#### [Get Variable](https://docs.bunny.net/reference/getedgescriptvariableendpoint_getvariable)

```php
Expand All @@ -214,7 +219,7 @@ $edgeScriptingApi->getVariable(
$edgeScriptingApi->addVariable(
id: 1,
body: [
'Name' => 'New Variable',
'Name' => 'NEW_VARIABLE',
'Required' => true,
'DefaultValue' => 'Hello World',
],
Expand All @@ -240,7 +245,7 @@ $edgeScriptingApi->updateVariable(
$edgeScriptingApi->upsertVariable(
id: 1,
body: [
'Name' => 'New Variable',
'Name' => 'NEW_VARIABLE',
'Required' => true,
'DefaultValue' => 'Hello World the Third',
],
Expand Down Expand Up @@ -272,7 +277,7 @@ $edgeScriptingApi->listSecrets(
$edgeScriptingApi->addSecret(
id: 1,
body: [
'Name' => 'VerySecretKey',
'Name' => 'SECRET_KEY',
'Secret' => 'V2UncmUgbm8gc3RyYW5nZXJzIHRvIGxvdmUKWW91IGtub3cgdGhlIHJ1bGVzIGFuZCBzbyBkbyBJIChEbyBJKQpBIGZ1bGwgY29tbWl0bWVudCdzIHdoYXQgSSdtIHRoaW5raW5nIG9mCllvdSB3b3VsZG4ndCBnZXQgdGhpcyBmcm9tIGFueSBvdGhlciBndXk=',
],
);
Expand All @@ -296,7 +301,7 @@ $edgeScriptingApi->updateSecret(
$edgeScriptingApi->upsertSecret(
id: 1,
body: [
'Name' => 'VerySecretKey',
'Name' => 'SECRET_KEY',
'Secret' => 'SSBqdXN0IHdhbm5hIHRlbGwgeW91IGhvdyBJJ20gZmVlbGluZwpHb3R0YSBtYWtlIHlvdSB1bmRlcnN0YW5k',
],
);
Expand Down Expand Up @@ -349,13 +354,19 @@ $edgeScriptingApi->publishRelease(
```php
$edgeScriptingApi->publishReleaseByUuid(
id: 1,
uuid: '173d4dfc-a8dd-42f5-a55c-cba765c75aa5',
uuid: 'Ab0CdE1F',
body: [
'Note' => 'Initial release',
],
);
```

!!! note

- The key `uuid` denotes an 8 character alphanumeric string (and **not** an ["UUID"](https://datatracker.ietf.org/doc/html/rfc9562)),
which can be retrieved from the [Get Releases](#get-releases) or [Get Active Release](#get-active-release) endpoints. It can also
be retrieved from the Bunny dashboard in the "Release ID" column of the deployments.

## Reference

* [Edge Scripting API](https://docs.bunny.net/reference/getedgescriptcodeendpoint_getcode)
Expand Down

0 comments on commit e953f4c

Please sign in to comment.