Skip to content

Commit

Permalink
added base api integrations endpoint required for add edge script api…
Browse files Browse the repository at this point in the history
… endpoint; updated docs
  • Loading branch information
ToshY committed Nov 17, 2024
1 parent 80017d6 commit 7f6a65e
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 9 deletions.
27 changes: 27 additions & 0 deletions docs/base-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,33 @@ $baseApi->listDrmCertificates(
```
A support ticket has been created at bunny.net regarding this issue.

### Integrations

#### Get GitHub Integrations

```php
$baseApi->getGitHubIntegrations();
```

!!! warning

This endpoint is (currently) undocumented.

!!! info

This endpoint returns the following response:
```json
{
"Accounts": [
{
"Id": 1,
"Name": "MyConnectedGitHubUsername"
}
]
}
```
The `id` can be used as `IntegrationId` for the [Add Edge Script](edge-scripting-api.md#add-edge-script) endpoint.

### Region

#### [List Regions](https://docs.bunny.net/reference/regionpublic_index)
Expand Down
51 changes: 42 additions & 9 deletions docs/edge-scripting-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ $edgeScriptingApi->addEdgeScript(
'Integration' => [
'IntegrationId' => 1234,
'RepositorySettings' => [
'Id' => 1234,
'Name' => 'Test Repo',
'Private' => true,
'TemplateUrl' => 'https://example.com',
'Id' => 1234,
'Name' => 'my-cool-es-return-repo',
'Private' => true,
'TemplateUrl' => 'https://github.com/BunnyWay/es-return-json',
],
'DeployConfiguration' => [
'Branch' => 1234,
'InstallCommand' => 'Test Repo',
'BuildCommand' => 'true',
'EntryFile' => 'test.js',
'CreateWorkflow' => false,
'Branch' => 'main',
'InstallCommand' => 'curl -fsSL https://deno.land/install.sh | sh -s v1.0.0',
'BuildCommand' => 'deno task build',
'EntryFile' => 'dist/main.js',
'CreateWorkflow' => true,
],
],
],
Expand All @@ -98,6 +98,9 @@ $edgeScriptingApi->addEdgeScript(
- The key `ScriptType` has the following possible values:
- `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 `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 All @@ -112,6 +115,36 @@ $edgeScriptingApi->addEdgeScript(
);
```

!!! example

Examples for `DeployConfiguration` payloads.

`Basic Deno`
```php
'DeployConfiguration' => [
'Branch' => 'main',
'InstallCommand' => 'curl -fsSL https://deno.land/install.sh | sh -s v1.0.0',
'BuildCommand' => 'deno task build',
'EntryFile' => 'dist/main.js',
'CreateWorkflow' => true,
],
```

`Basic Node.js`
```php
'DeployConfiguration' => [
'Branch' => 'main',
'InstallCommand' => 'npm install',
'BuildCommand' => 'npm run build',
'EntryFile' => 'dist/index.js',
'CreateWorkflow' => true,
],
```

!!! question

If you want to create a workflow file yourself, check out the [BunnyWay Github action deploy script](https://github.com/BunnyWay/actions/tree/main/deploy-script).

#### [Get Edge Script](https://docs.bunny.net/reference/getedgescriptbyidendpoint_getedgescriptbyid)

```php
Expand Down
16 changes: 16 additions & 0 deletions src/BaseAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use ToshY\BunnyNet\Model\API\Base\DNSZone\UpdateDNSRecord;
use ToshY\BunnyNet\Model\API\Base\DNSZone\UpdateDNSZone;
use ToshY\BunnyNet\Model\API\Base\DRMCertificate\ListDRMCertificates;
use ToshY\BunnyNet\Model\API\Base\Integration\GetGitHubIntegrations;
use ToshY\BunnyNet\Model\API\Base\PullZone\AddCustomCertificate;
use ToshY\BunnyNet\Model\API\Base\PullZone\AddCustomHostname;
use ToshY\BunnyNet\Model\API\Base\PullZone\AddEdgeRule;
Expand Down Expand Up @@ -596,6 +597,21 @@ public function listDrmCertificates(array $query = []): BunnyClientResponseInter
);
}

/**
* @throws ClientExceptionInterface
* @throws Exception\BunnyClientResponseException
* @throws Exception\JSONException
* @return BunnyClientResponseInterface
*/
public function getGitHubIntegrations(): BunnyClientResponseInterface
{
$endpoint = new GetGitHubIntegrations();

return $this->client->request(
endpoint: $endpoint,
);
}

/**
* @throws ClientExceptionInterface
* @throws Exception\BunnyClientResponseException
Expand Down
32 changes: 32 additions & 0 deletions src/Model/API/Base/Integration/GetGitHubIntegrations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace ToshY\BunnyNet\Model\API\Base\Integration;

use ToshY\BunnyNet\Enum\Header;
use ToshY\BunnyNet\Enum\Method;
use ToshY\BunnyNet\Model\EndpointInterface;

/**
* @note undocumented
*/
class GetGitHubIntegrations implements EndpointInterface
{
public function getMethod(): Method
{
return Method::GET;
}

public function getPath(): string
{
return 'integration/github';
}

public function getHeaders(): array
{
return [
Header::ACCEPT_JSON,
];
}
}

0 comments on commit 7f6a65e

Please sign in to comment.