Skip to content

Commit 71b764c

Browse files
committed
chore: update SDKs to new RC version
1 parent 6e68a65 commit 71b764c

File tree

7 files changed

+105
-12
lines changed

7 files changed

+105
-12
lines changed

docs/examples/functions/create.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ $result = $functions->create(
3232
templateRepository: '<TEMPLATE_REPOSITORY>', // optional
3333
templateOwner: '<TEMPLATE_OWNER>', // optional
3434
templateRootDirectory: '<TEMPLATE_ROOT_DIRECTORY>', // optional
35-
templateVersion: '<TEMPLATE_VERSION>' // optional
35+
templateVersion: '<TEMPLATE_VERSION>', // optional
36+
specification: '' // optional
3637
);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
use Appwrite\Client;
4+
use Appwrite\Services\Functions;
5+
6+
$client = (new Client())
7+
->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
8+
->setProject('&lt;YOUR_PROJECT_ID&gt;') // Your project ID
9+
->setKey('&lt;YOUR_API_KEY&gt;'); // Your secret API key
10+
11+
$functions = new Functions($client);
12+
13+
$result = $functions->listSpecifications();

docs/examples/functions/update.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ $result = $functions->update(
2727
providerRepositoryId: '<PROVIDER_REPOSITORY_ID>', // optional
2828
providerBranch: '<PROVIDER_BRANCH>', // optional
2929
providerSilentMode: false, // optional
30-
providerRootDirectory: '<PROVIDER_ROOT_DIRECTORY>' // optional
30+
providerRootDirectory: '<PROVIDER_ROOT_DIRECTORY>', // optional
31+
specification: '' // optional
3132
);

docs/functions.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ POST https://cloud.appwrite.io/v1/functions
4848
| templateOwner | string | The name of the owner of the template. | |
4949
| templateRootDirectory | string | Path to function code in the template repo. | |
5050
| templateVersion | string | Version (tag) for the repo linked to the function template. | |
51+
| specification | string | Runtime specification for the function and builds. | s-0.5vcpu-512mb |
5152

5253
## List runtimes
5354

@@ -57,6 +58,15 @@ GET https://cloud.appwrite.io/v1/functions/runtimes
5758

5859
** Get a list of all runtimes that are currently active on your instance. **
5960

61+
## List available function runtime specifications
62+
63+
```http request
64+
GET https://cloud.appwrite.io/v1/functions/specifications
65+
```
66+
67+
** List allowed function specifications for this instance.
68+
**
69+
6070
## List function templates
6171

6272
```http request
@@ -131,6 +141,7 @@ PUT https://cloud.appwrite.io/v1/functions/{functionId}
131141
| providerBranch | string | Production branch for the repo linked to the function | |
132142
| providerSilentMode | boolean | Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. | |
133143
| providerRootDirectory | string | Path to function code in the linked repo. | |
144+
| specification | string | Runtime specification for the function and builds. | s-0.5vcpu-512mb |
134145

135146
## Delete function
136147

src/Appwrite/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ class Client
3737
*/
3838
protected array $headers = [
3939
'content-type' => '',
40-
'user-agent' => 'AppwritePHPSDK/12.0.0-rc.1 ()',
40+
'user-agent' => 'AppwritePHPSDK/12.0.0-rc.2 ()',
4141
'x-sdk-name'=> 'PHP',
4242
'x-sdk-platform'=> 'server',
4343
'x-sdk-language'=> 'php',
44-
'x-sdk-version'=> '12.0.0-rc.1',
44+
'x-sdk-version'=> '12.0.0-rc.2',
4545
];
4646

4747
/**

src/Appwrite/Services/Functions.php

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,11 @@ public function list(?array $queries = null, ?string $search = null): array
8585
* @param ?string $templateOwner
8686
* @param ?string $templateRootDirectory
8787
* @param ?string $templateVersion
88+
* @param ?string $specification
8889
* @throws AppwriteException
8990
* @return array
9091
*/
91-
public function create(string $functionId, string $name, Runtime $runtime, ?array $execute = null, ?array $events = null, ?string $schedule = null, ?int $timeout = null, ?bool $enabled = null, ?bool $logging = null, ?string $entrypoint = null, ?string $commands = null, ?array $scopes = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?string $templateRepository = null, ?string $templateOwner = null, ?string $templateRootDirectory = null, ?string $templateVersion = null): array
92+
public function create(string $functionId, string $name, Runtime $runtime, ?array $execute = null, ?array $events = null, ?string $schedule = null, ?int $timeout = null, ?bool $enabled = null, ?bool $logging = null, ?string $entrypoint = null, ?string $commands = null, ?array $scopes = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?string $templateRepository = null, ?string $templateOwner = null, ?string $templateRootDirectory = null, ?string $templateVersion = null, ?string $specification = null): array
9293
{
9394
$apiPath = str_replace(
9495
[],
@@ -173,6 +174,10 @@ public function create(string $functionId, string $name, Runtime $runtime, ?arra
173174
$apiParams['templateVersion'] = $templateVersion;
174175
}
175176

177+
if (!is_null($specification)) {
178+
$apiParams['specification'] = $specification;
179+
}
180+
176181
$apiHeaders = [];
177182
$apiHeaders['content-type'] = 'application/json';
178183

@@ -213,6 +218,36 @@ public function listRuntimes(): array
213218
);
214219
}
215220

221+
/**
222+
* List available function runtime specifications
223+
*
224+
* List allowed function specifications for this instance.
225+
*
226+
*
227+
* @throws AppwriteException
228+
* @return array
229+
*/
230+
public function listSpecifications(): array
231+
{
232+
$apiPath = str_replace(
233+
[],
234+
[],
235+
'/functions/specifications'
236+
);
237+
238+
$apiParams = [];
239+
240+
$apiHeaders = [];
241+
$apiHeaders['content-type'] = 'application/json';
242+
243+
return $this->client->call(
244+
Client::METHOD_GET,
245+
$apiPath,
246+
$apiHeaders,
247+
$apiParams
248+
);
249+
}
250+
216251
/**
217252
* List function templates
218253
*
@@ -350,10 +385,11 @@ public function get(string $functionId): array
350385
* @param ?string $providerBranch
351386
* @param ?bool $providerSilentMode
352387
* @param ?string $providerRootDirectory
388+
* @param ?string $specification
353389
* @throws AppwriteException
354390
* @return array
355391
*/
356-
public function update(string $functionId, string $name, ?Runtime $runtime = null, ?array $execute = null, ?array $events = null, ?string $schedule = null, ?int $timeout = null, ?bool $enabled = null, ?bool $logging = null, ?string $entrypoint = null, ?string $commands = null, ?array $scopes = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null): array
392+
public function update(string $functionId, string $name, ?Runtime $runtime = null, ?array $execute = null, ?array $events = null, ?string $schedule = null, ?int $timeout = null, ?bool $enabled = null, ?bool $logging = null, ?string $entrypoint = null, ?string $commands = null, ?array $scopes = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?string $specification = null): array
357393
{
358394
$apiPath = str_replace(
359395
['{functionId}'],
@@ -422,6 +458,10 @@ public function update(string $functionId, string $name, ?Runtime $runtime = nul
422458
$apiParams['providerRootDirectory'] = $providerRootDirectory;
423459
}
424460

461+
if (!is_null($specification)) {
462+
$apiParams['specification'] = $specification;
463+
}
464+
425465
$apiHeaders = [];
426466
$apiHeaders['content-type'] = 'application/json';
427467

@@ -887,7 +927,7 @@ public function listExecutions(string $functionId, ?array $queries = null, ?stri
887927
* @throws AppwriteException
888928
* @return array
889929
*/
890-
public function createExecution(string $functionId, ?string $body = null, ?bool $async = null, ?string $xpath = null, ?ExecutionMethod $method = null, ?array $headers = null, ?string $scheduledAt = null, callable $onProgress = null): array
930+
public function createExecution(string $functionId, ?string $body = null, ?bool $async = null, ?string $xpath = null, ?ExecutionMethod $method = null, ?array $headers = null, ?string $scheduledAt = null): array
891931
{
892932
$apiPath = str_replace(
893933
['{functionId}'],
@@ -923,8 +963,14 @@ public function createExecution(string $functionId, ?string $body = null, ?bool
923963
}
924964

925965
$apiHeaders = [];
926-
$apiHeaders['content-type'] = 'multipart/form-data';
966+
$apiHeaders['content-type'] = 'application/json';
927967

968+
return $this->client->call(
969+
Client::METHOD_POST,
970+
$apiPath,
971+
$apiHeaders,
972+
$apiParams
973+
);
928974
}
929975

930976
/**

tests/Appwrite/Services/FunctionsTest.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ public function testMethodCreate(): void {
5858
"providerRepositoryId" => "appwrite",
5959
"providerBranch" => "main",
6060
"providerRootDirectory" => "functions/helloWorld",
61-
"providerSilentMode" => true,);
61+
"providerSilentMode" => true,
62+
"specification" => "s-0.5vcpu-512mb",);
6263

6364

6465
$this->client
@@ -91,6 +92,23 @@ public function testMethodListRuntimes(): void {
9192
$this->assertSame($data, $response);
9293
}
9394

95+
public function testMethodListSpecifications(): void {
96+
97+
$data = array(
98+
"total" => 5,
99+
"specifications" => array(),);
100+
101+
102+
$this->client
103+
->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any())
104+
->andReturn($data);
105+
106+
$response = $this->functions->listSpecifications(
107+
);
108+
109+
$this->assertSame($data, $response);
110+
}
111+
94112
public function testMethodListTemplates(): void {
95113

96114
$data = array(
@@ -166,7 +184,8 @@ public function testMethodGet(): void {
166184
"providerRepositoryId" => "appwrite",
167185
"providerBranch" => "main",
168186
"providerRootDirectory" => "functions/helloWorld",
169-
"providerSilentMode" => true,);
187+
"providerSilentMode" => true,
188+
"specification" => "s-0.5vcpu-512mb",);
170189

171190

172191
$this->client
@@ -205,7 +224,8 @@ public function testMethodUpdate(): void {
205224
"providerRepositoryId" => "appwrite",
206225
"providerBranch" => "main",
207226
"providerRootDirectory" => "functions/helloWorld",
208-
"providerSilentMode" => true,);
227+
"providerSilentMode" => true,
228+
"specification" => "s-0.5vcpu-512mb",);
209229

210230

211231
$this->client
@@ -360,7 +380,8 @@ public function testMethodUpdateDeployment(): void {
360380
"providerRepositoryId" => "appwrite",
361381
"providerBranch" => "main",
362382
"providerRootDirectory" => "functions/helloWorld",
363-
"providerSilentMode" => true,);
383+
"providerSilentMode" => true,
384+
"specification" => "s-0.5vcpu-512mb",);
364385

365386

366387
$this->client

0 commit comments

Comments
 (0)