Skip to content

Commit 636e268

Browse files
committed
chore: update PHP SDK to 23.0.0
1 parent 0f03f2e commit 636e268

8 files changed

Lines changed: 345 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
```php
2+
<?php
3+
4+
use Appwrite\Client;
5+
use Appwrite\Services\Project;
6+
7+
$client = (new Client())
8+
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
9+
->setProject('<YOUR_PROJECT_ID>') // Your project ID
10+
->setKey('<YOUR_API_KEY>'); // Your secret API key
11+
12+
$project = new Project($client);
13+
14+
$result = $project->updateLabels(
15+
labels: []
16+
);```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
```php
2+
<?php
3+
4+
use Appwrite\Client;
5+
use Appwrite\Services\Users;
6+
7+
$client = (new Client())
8+
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
9+
->setProject('<YOUR_PROJECT_ID>') // Your project ID
10+
->setKey('<YOUR_API_KEY>'); // Your secret API key
11+
12+
$users = new Users($client);
13+
14+
$result = $users->updateLabels(
15+
userId: '<USER_ID>',
16+
labels: []
17+
);```

docs/project.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ DELETE https://cloud.appwrite.io/v1/project/keys/{keyId}
7373
| keyId | string | **Required** Key ID. | |
7474

7575

76+
```http request
77+
PUT https://cloud.appwrite.io/v1/project/labels
78+
```
79+
80+
** Update the project labels. Labels can be used to easily filter projects in an organization. **
81+
82+
### Parameters
83+
84+
| Field Name | Type | Description | Default |
85+
| --- | --- | --- | --- |
86+
| labels | array | Array of project labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. | |
87+
88+
7689
```http request
7790
GET https://cloud.appwrite.io/v1/project/platforms
7891
```

docs/users.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,22 @@ POST https://cloud.appwrite.io/v1/users/{userId}/jwts
252252
| duration | integer | Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. | 900 |
253253

254254

255+
```http request
256+
PUT https://cloud.appwrite.io/v1/users/{userId}/labels
257+
```
258+
259+
** Update the user labels by its unique ID.
260+
261+
Labels can be used to grant access to resources. While teams are a way for user&#039;s to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info. **
262+
263+
### Parameters
264+
265+
| Field Name | Type | Description | Default |
266+
| --- | --- | --- | --- |
267+
| userId | string | **Required** User ID. | |
268+
| labels | array | Array of user labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. | |
269+
270+
255271
```http request
256272
GET https://cloud.appwrite.io/v1/users/{userId}/logs
257273
```

src/Appwrite/Services/Project.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,42 @@ public function deleteKey(string $keyId): string
210210

211211
}
212212

213+
/**
214+
* Update the project labels. Labels can be used to easily filter projects in
215+
* an organization.
216+
*
217+
* @param array $labels
218+
* @throws AppwriteException
219+
* @return \Appwrite\Models\Project
220+
*/
221+
public function updateLabels(array $labels): \Appwrite\Models\Project
222+
{
223+
$apiPath = str_replace(
224+
[],
225+
[],
226+
'/project/labels'
227+
);
228+
229+
$apiParams = [];
230+
$apiParams['labels'] = $labels;
231+
232+
$apiHeaders = [];
233+
$apiHeaders['content-type'] = 'application/json';
234+
235+
$response = $this->client->call(
236+
Client::METHOD_PUT,
237+
$apiPath,
238+
$apiHeaders,
239+
$apiParams
240+
);
241+
242+
return $this->parseResponse(
243+
$response,
244+
[\Appwrite\Models\Project::class]
245+
);
246+
247+
}
248+
213249
/**
214250
* Get a list of all platforms in the project. This endpoint returns an array
215251
* of all platforms and their configurations.

src/Appwrite/Services/Users.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,48 @@ public function createJWT(string $userId, ?string $sessionId = null, ?int $durat
741741

742742
}
743743

744+
/**
745+
* Update the user labels by its unique ID.
746+
*
747+
* Labels can be used to grant access to resources. While teams are a way for
748+
* user's to share access to a resource, labels can be defined by the
749+
* developer to grant access without an invitation. See the [Permissions
750+
* docs](https://appwrite.io/docs/permissions) for more info.
751+
*
752+
* @param string $userId
753+
* @param array $labels
754+
* @throws AppwriteException
755+
* @return \Appwrite\Models\User
756+
*/
757+
public function updateLabels(string $userId, array $labels): \Appwrite\Models\User
758+
{
759+
$apiPath = str_replace(
760+
['{userId}'],
761+
[$userId],
762+
'/users/{userId}/labels'
763+
);
764+
765+
$apiParams = [];
766+
$apiParams['userId'] = $userId;
767+
$apiParams['labels'] = $labels;
768+
769+
$apiHeaders = [];
770+
$apiHeaders['content-type'] = 'application/json';
771+
772+
$response = $this->client->call(
773+
Client::METHOD_PUT,
774+
$apiPath,
775+
$apiHeaders,
776+
$apiParams
777+
);
778+
779+
return $this->parseResponse(
780+
$response,
781+
[\Appwrite\Models\User::class]
782+
);
783+
784+
}
785+
744786
/**
745787
* Get the user activity logs list by its unique ID.
746788
*

tests/Appwrite/Services/ProjectTest.php

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,167 @@ public function testMethodDeleteKey(): void
143143
$this->assertSame($data, $response);
144144
}
145145

146+
public function testMethodUpdateLabels(): void
147+
{
148+
$data = array(
149+
"\$id" => "5e5ea5c16897e",
150+
"\$createdAt" => "2020-10-15T06:38:00.000+00:00",
151+
"\$updatedAt" => "2020-10-15T06:38:00.000+00:00",
152+
"name" => "New Project",
153+
"description" => "This is a new project.",
154+
"teamId" => "1592981250",
155+
"logo" => "5f5c451b403cb",
156+
"url" => "5f5c451b403cb",
157+
"legalName" => "Company LTD.",
158+
"legalCountry" => "US",
159+
"legalState" => "New York",
160+
"legalCity" => "New York City.",
161+
"legalAddress" => "620 Eighth Avenue, New York, NY 10018",
162+
"legalTaxId" => "131102020",
163+
"authDuration" => 60,
164+
"authLimit" => 100,
165+
"authSessionsLimit" => 10,
166+
"authPasswordHistory" => 5,
167+
"authPasswordDictionary" => true,
168+
"authPersonalDataCheck" => true,
169+
"authDisposableEmails" => true,
170+
"authCanonicalEmails" => true,
171+
"authFreeEmails" => true,
172+
"authMockNumbers" => array(
173+
array(
174+
"phone" => "+1612842323",
175+
"otp" => "123456"
176+
)
177+
),
178+
"authSessionAlerts" => true,
179+
"authMembershipsUserName" => true,
180+
"authMembershipsUserEmail" => true,
181+
"authMembershipsMfa" => true,
182+
"authInvalidateSessions" => true,
183+
"oAuthProviders" => array(
184+
array(
185+
"key" => "github",
186+
"name" => "GitHub",
187+
"appId" => "259125845563242502",
188+
"secret" => "Bpw_g9c2TGXxfgLshDbSaL8tsCcqgczQ",
189+
"enabled" => true
190+
)
191+
),
192+
"platforms" => array(),
193+
"webhooks" => array(
194+
array(
195+
"\$id" => "5e5ea5c16897e",
196+
"\$createdAt" => "2020-10-15T06:38:00.000+00:00",
197+
"\$updatedAt" => "2020-10-15T06:38:00.000+00:00",
198+
"name" => "My Webhook",
199+
"url" => "https://example.com/webhook",
200+
"events" => array(),
201+
"tls" => true,
202+
"authUsername" => "username",
203+
"authPassword" => "password",
204+
"secret" => "ad3d581ca230e2b7059c545e5a",
205+
"enabled" => true,
206+
"logs" => "Failed to connect to remote server.",
207+
"attempts" => 10
208+
)
209+
),
210+
"keys" => array(
211+
array(
212+
"\$id" => "5e5ea5c16897e",
213+
"\$createdAt" => "2020-10-15T06:38:00.000+00:00",
214+
"\$updatedAt" => "2020-10-15T06:38:00.000+00:00",
215+
"name" => "My API Key",
216+
"expire" => "2020-10-15T06:38:00.000+00:00",
217+
"scopes" => array(),
218+
"secret" => "919c2d18fb5d4...a2ae413da83346ad2",
219+
"accessedAt" => "2020-10-15T06:38:00.000+00:00",
220+
"sdks" => array()
221+
)
222+
),
223+
"devKeys" => array(
224+
array(
225+
"\$id" => "5e5ea5c16897e",
226+
"\$createdAt" => "2020-10-15T06:38:00.000+00:00",
227+
"\$updatedAt" => "2020-10-15T06:38:00.000+00:00",
228+
"name" => "Dev API Key",
229+
"expire" => "2020-10-15T06:38:00.000+00:00",
230+
"secret" => "919c2d18fb5d4...a2ae413da83346ad2",
231+
"accessedAt" => "2020-10-15T06:38:00.000+00:00",
232+
"sdks" => array()
233+
)
234+
),
235+
"smtpEnabled" => true,
236+
"smtpSenderName" => "John Appwrite",
237+
"smtpSenderEmail" => "john@appwrite.io",
238+
"smtpReplyTo" => "support@appwrite.io",
239+
"smtpHost" => "mail.appwrite.io",
240+
"smtpPort" => 25,
241+
"smtpUsername" => "emailuser",
242+
"smtpPassword" => "securepassword",
243+
"smtpSecure" => "tls",
244+
"pingCount" => 1,
245+
"pingedAt" => "2020-10-15T06:38:00.000+00:00",
246+
"labels" => array(),
247+
"status" => "active",
248+
"authEmailPassword" => true,
249+
"authUsersAuthMagicURL" => true,
250+
"authEmailOtp" => true,
251+
"authAnonymous" => true,
252+
"authInvites" => true,
253+
"authJWT" => true,
254+
"authPhone" => true,
255+
"serviceStatusForAccount" => true,
256+
"serviceStatusForAvatars" => true,
257+
"serviceStatusForDatabases" => true,
258+
"serviceStatusForTablesdb" => true,
259+
"serviceStatusForLocale" => true,
260+
"serviceStatusForHealth" => true,
261+
"serviceStatusForProject" => true,
262+
"serviceStatusForStorage" => true,
263+
"serviceStatusForTeams" => true,
264+
"serviceStatusForUsers" => true,
265+
"serviceStatusForVcs" => true,
266+
"serviceStatusForSites" => true,
267+
"serviceStatusForFunctions" => true,
268+
"serviceStatusForProxy" => true,
269+
"serviceStatusForGraphql" => true,
270+
"serviceStatusForMigrations" => true,
271+
"serviceStatusForMessaging" => true,
272+
"protocolStatusForRest" => true,
273+
"protocolStatusForGraphql" => true,
274+
"protocolStatusForWebsocket" => true,
275+
"region" => "fra",
276+
"billingLimits" => array(
277+
"bandwidth" => 5,
278+
"storage" => 150,
279+
"users" => 200000,
280+
"executions" => 750000,
281+
"GBHours" => 100,
282+
"imageTransformations" => 100,
283+
"authPhone" => 10,
284+
"budgetLimit" => 100
285+
),
286+
"blocks" => array(
287+
array(
288+
"\$createdAt" => "2020-10-15T06:38:00.000+00:00",
289+
"resourceType" => "project",
290+
"resourceId" => "5e5ea5c16897e"
291+
)
292+
),
293+
"consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00"
294+
);
295+
296+
$this->client
297+
->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any())
298+
->andReturn($data);
299+
300+
$response = $this->project->updateLabels(
301+
array()
302+
);
303+
304+
$this->assertInstanceOf(\Appwrite\Models\Project::class, $response);
305+
}
306+
146307
public function testMethodListPlatforms(): void
147308
{
148309
$data = array(

tests/Appwrite/Services/UsersTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,50 @@ public function testMethodCreateJWT(): void
640640
$this->assertInstanceOf(\Appwrite\Models\Jwt::class, $response);
641641
}
642642

643+
public function testMethodUpdateLabels(): void
644+
{
645+
$data = array(
646+
"\$id" => "5e5ea5c16897e",
647+
"\$createdAt" => "2020-10-15T06:38:00.000+00:00",
648+
"\$updatedAt" => "2020-10-15T06:38:00.000+00:00",
649+
"name" => "John Doe",
650+
"registration" => "2020-10-15T06:38:00.000+00:00",
651+
"status" => true,
652+
"labels" => array(),
653+
"passwordUpdate" => "2020-10-15T06:38:00.000+00:00",
654+
"email" => "john@appwrite.io",
655+
"phone" => "+4930901820",
656+
"emailVerification" => true,
657+
"phoneVerification" => true,
658+
"mfa" => true,
659+
"prefs" => array(),
660+
"targets" => array(
661+
array(
662+
"\$id" => "259125845563242502",
663+
"\$createdAt" => "2020-10-15T06:38:00.000+00:00",
664+
"\$updatedAt" => "2020-10-15T06:38:00.000+00:00",
665+
"name" => "Apple iPhone 12",
666+
"userId" => "259125845563242502",
667+
"providerType" => "email",
668+
"identifier" => "token",
669+
"expired" => true
670+
)
671+
),
672+
"accessedAt" => "2020-10-15T06:38:00.000+00:00"
673+
);
674+
675+
$this->client
676+
->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any())
677+
->andReturn($data);
678+
679+
$response = $this->users->updateLabels(
680+
"<USER_ID>",
681+
array()
682+
);
683+
684+
$this->assertInstanceOf(\Appwrite\Models\User::class, $response);
685+
}
686+
643687
public function testMethodListLogs(): void
644688
{
645689
$data = array(

0 commit comments

Comments
 (0)