Skip to content

Commit

Permalink
refactored compute script variable to edge scripting variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ToshY committed Nov 17, 2024
1 parent 7f8a2ac commit f110f7e
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 233 deletions.
124 changes: 0 additions & 124 deletions docs/base-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,86 +220,6 @@ $baseApi->applyPromoCode(

### Compute

#### [List Compute Scripts](https://docs.bunny.net/reference/computeedgescriptpublic_index)

```php
$baseApi->listComputeScripts(
query: [
'page' => 1,
'perPage' => 1000,
],
);
```

#### [Add Compute Script](https://docs.bunny.net/reference/computeedgescriptpublic_addscript)

```php
$baseApi->addComputeScript(
body: [
'Name' => 'Test',
'ScriptType' => 1000,
],
);
```

!!! note

- The key `ScriptType` has the following possible values:
- `0` = CDN
- `1` = DNS

#### [Get Compute Script](https://docs.bunny.net/reference/computeedgescriptpublic_index2)

```php
$baseApi->getComputeScript(
id: 1,
);
```

#### [Update Compute Script](https://docs.bunny.net/reference/computeedgescriptpublic_update)

```php
$baseApi->updateComputeScript(
id: 1,
body: [
'Name' => 'Test',
'ScriptType' => 1000,
],
);
```

!!! note

- The key `ScriptType` has the following possible values:
- `0` = CDN
- `1` = DNS

#### [Delete Compute Script](https://docs.bunny.net/reference/computeedgescriptpublic_delete)

```php
$baseApi->deleteComputeScript(
id: 1,
);
```

#### [Get Compute Script Code](https://docs.bunny.net/reference/computeedgescriptpublic_getcode)

```php
$baseApi->getComputeScriptCode(
id: 1,
);
```

#### [Update Compute Script Code](https://docs.bunny.net/reference/computeedgescriptpublic_setcode)

```php
$baseApi->updateComputeScriptCode(
id: 1,
body: [
'Code' => "export default function handleQuery(event) {\n console.log(\"Hello world!\")\n return new TxtRecord(\"Hello world!\");\n}",
],
);
```

#### [List Compute Script Releases](https://docs.bunny.net/reference/computeedgescriptpublic_getreleases)

Expand Down Expand Up @@ -339,50 +259,6 @@ $baseApi->publishComputeScriptByPathParameter(
);
```

#### [Add Compute Script Variable](https://docs.bunny.net/reference/computeedgescriptpublic_addvariable)

```php
$baseApi->addComputeScriptVariable(
id: 1,
body: [
'Name' => 'New Variable',
'Required' => true,
'DefaultValue' => 'Hello World',
],
);
```

#### [Update Compute Script Variable](https://docs.bunny.net/reference/computeedgescriptpublic_updatevariable)

```php
$baseApi->updateComputeScriptVariable(
id: 1,
variableId: 2,
body: [
'DefaultValue' => 'Hello World the Sequel',
'Required' => false,
],
);
```

#### [Get Compute Script Variable](https://docs.bunny.net/reference/computeedgescriptpublic_getvariable)

```php
$baseApi->getComputeScriptVariable(
id: 1,
variableId: 2,
);
```

#### [Delete Compute Script Variable](https://docs.bunny.net/reference/computeedgescriptpublic_deletevariable)

```php
$baseApi->deleteComputeScriptVariable(
id: 1,
variableId: 2,
);
```

### Support

#### [List Tickets](https://docs.bunny.net/reference/supportpublic_index)
Expand Down
59 changes: 59 additions & 0 deletions docs/edge-scripting-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,65 @@ $edgeScriptingApi->deleteEdgeScript(
);
```

### Variable

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

```php
$edgeScriptingApi->getVariable(
id: 1,
variableId: 2,
);
```

#### [Add Variable](https://docs.bunny.net/reference/addedgescriptvariableendpoint_addedgescriptvariable)

```php
$edgeScriptingApi->addVariable(
id: 1,
body: [
'Name' => 'New Variable',
'Required' => true,
'DefaultValue' => 'Hello World',
],
);
```

#### [Update Variable](https://docs.bunny.net/reference/updateedgescriptvariableendpoint_updatevariable)

```php
$edgeScriptingApi->updateVariable(
id: 1,
variableId: 2,
body: [
'Required' => false,
'DefaultValue' => 'Hello World the Sequel',
],
);
```

#### [Upsert Variable](https://docs.bunny.net/reference/upsertedgescriptvariableendpoint_upsertedgescriptvariable)

```php
$edgeScriptingApi->upsertVariable(
id: 1,
body: [
'Name' => 'New Variable',
'Required' => true,
'DefaultValue' => 'Hello World the Third',
],
);
```

#### [Delete Variable](https://docs.bunny.net/reference/deleteedgescriptvariableendpoint_deletevariable)

```php
$edgeScriptingApi->deleteVariable(
id: 1,
variableId: 2,
);
```

## Reference

* [Edge Scripting API](https://docs.bunny.net/reference/getedgescriptcodeendpoint_getcode)
Expand Down
98 changes: 0 additions & 98 deletions src/BaseAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@
use ToshY\BunnyNet\Model\API\Base\Billing\GetBillingSummaryPDF;
use ToshY\BunnyNet\Model\API\Base\Billing\GetCoinifyBitcoinExchangeRate;
use ToshY\BunnyNet\Model\API\Base\Billing\PreparePaymentAuthorization;
use ToshY\BunnyNet\Model\API\Base\Compute\AddComputeScriptVariable;
use ToshY\BunnyNet\Model\API\Base\Compute\DeleteComputeScriptVariable;
use ToshY\BunnyNet\Model\API\Base\Compute\GetComputeScriptVariable;
use ToshY\BunnyNet\Model\API\Base\Compute\ListComputeScriptReleases;
use ToshY\BunnyNet\Model\API\Base\Compute\PublishComputeScript;
use ToshY\BunnyNet\Model\API\Base\Compute\PublishComputeScriptByPathParameter;
use ToshY\BunnyNet\Model\API\Base\Compute\UpdateComputeScriptVariable;
use ToshY\BunnyNet\Model\API\Base\Countries\ListCountries;
use ToshY\BunnyNet\Model\API\Base\DNSZone\AddDNSRecord;
use ToshY\BunnyNet\Model\API\Base\DNSZone\AddDNSZone;
Expand Down Expand Up @@ -560,100 +556,6 @@ public function publishComputeScriptByPathParameter(
);
}

/**
* @throws ClientExceptionInterface
* @throws Exception\BunnyClientResponseException
* @throws Exception\JSONException
* @throws Exception\InvalidTypeForKeyValueException
* @throws Exception\InvalidTypeForListValueException
* @throws Exception\ParameterIsRequiredException
* @return BunnyClientResponseInterface
* @param int $id
* @param array<string,mixed> $body
*/
public function addComputeScriptVariable(
int $id,
array $body,
): BunnyClientResponseInterface {
$endpoint = new AddComputeScriptVariable();

ParameterValidator::validate($body, $endpoint->getBody());

return $this->client->request(
endpoint: $endpoint,
parameters: [$id],
body: BodyContentHelper::getBody($body),
);
}

/**
* @throws ClientExceptionInterface
* @throws Exception\BunnyClientResponseException
* @throws Exception\JSONException
* @throws Exception\InvalidTypeForKeyValueException
* @throws Exception\InvalidTypeForListValueException
* @throws Exception\ParameterIsRequiredException
* @param int $variableId
* @param array<string,mixed> $body
* @return BunnyClientResponseInterface
* @param int $id
*/
public function updateComputeScriptVariable(
int $id,
int $variableId,
array $body,
): BunnyClientResponseInterface {
$endpoint = new UpdateComputeScriptVariable();

ParameterValidator::validate($body, $endpoint->getBody());

return $this->client->request(
endpoint: $endpoint,
parameters: [$id, $variableId],
body: BodyContentHelper::getBody($body),
);
}

/**
* @throws ClientExceptionInterface
* @throws Exception\BunnyClientResponseException
* @throws Exception\JSONException
* @param int $variableId
* @return BunnyClientResponseInterface
* @param int $id
*/
public function getComputeScriptVariable(
int $id,
int $variableId,
): BunnyClientResponseInterface {
$endpoint = new GetComputeScriptVariable();

return $this->client->request(
endpoint: $endpoint,
parameters: [$id, $variableId],
);
}

/**
* @throws ClientExceptionInterface
* @throws Exception\BunnyClientResponseException
* @throws Exception\JSONException
* @param int $variableId
* @return BunnyClientResponseInterface
* @param int $id
*/
public function deleteComputeScriptVariable(
int $id,
int $variableId,
): BunnyClientResponseInterface {
$endpoint = new DeleteComputeScriptVariable();

return $this->client->request(
endpoint: $endpoint,
parameters: [$id, $variableId],
);
}

/**
* @throws ClientExceptionInterface
* @throws Exception\BunnyClientResponseException
Expand Down
Loading

0 comments on commit f110f7e

Please sign in to comment.