@appwrite.io/console 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +18 -0
- package/CHANGELOG.md +1 -0
- package/LICENSE +12 -0
- package/README.md +111 -0
- package/dist/cjs/package.json +3 -0
- package/dist/esm/package.json +3 -0
- package/docs/examples/account/create-anonymous-session.md +18 -0
- package/docs/examples/account/create-email-session.md +18 -0
- package/docs/examples/account/create-j-w-t.md +18 -0
- package/docs/examples/account/create-magic-u-r-l-session.md +18 -0
- package/docs/examples/account/create-o-auth2session.md +14 -0
- package/docs/examples/account/create-phone-session.md +18 -0
- package/docs/examples/account/create-phone-verification.md +18 -0
- package/docs/examples/account/create-recovery.md +18 -0
- package/docs/examples/account/create-verification.md +18 -0
- package/docs/examples/account/create.md +18 -0
- package/docs/examples/account/delete-session.md +18 -0
- package/docs/examples/account/delete-sessions.md +18 -0
- package/docs/examples/account/get-prefs.md +18 -0
- package/docs/examples/account/get-session.md +18 -0
- package/docs/examples/account/get.md +18 -0
- package/docs/examples/account/list-logs.md +18 -0
- package/docs/examples/account/list-sessions.md +18 -0
- package/docs/examples/account/update-email.md +18 -0
- package/docs/examples/account/update-magic-u-r-l-session.md +18 -0
- package/docs/examples/account/update-name.md +18 -0
- package/docs/examples/account/update-password.md +18 -0
- package/docs/examples/account/update-phone-session.md +18 -0
- package/docs/examples/account/update-phone-verification.md +18 -0
- package/docs/examples/account/update-phone.md +18 -0
- package/docs/examples/account/update-prefs.md +18 -0
- package/docs/examples/account/update-recovery.md +18 -0
- package/docs/examples/account/update-session.md +18 -0
- package/docs/examples/account/update-status.md +18 -0
- package/docs/examples/account/update-verification.md +18 -0
- package/docs/examples/avatars/get-browser.md +14 -0
- package/docs/examples/avatars/get-credit-card.md +14 -0
- package/docs/examples/avatars/get-favicon.md +14 -0
- package/docs/examples/avatars/get-flag.md +14 -0
- package/docs/examples/avatars/get-image.md +14 -0
- package/docs/examples/avatars/get-initials.md +14 -0
- package/docs/examples/avatars/get-q-r.md +14 -0
- package/docs/examples/databases/create-boolean-attribute.md +18 -0
- package/docs/examples/databases/create-collection.md +18 -0
- package/docs/examples/databases/create-datetime-attribute.md +18 -0
- package/docs/examples/databases/create-document.md +18 -0
- package/docs/examples/databases/create-email-attribute.md +18 -0
- package/docs/examples/databases/create-enum-attribute.md +18 -0
- package/docs/examples/databases/create-float-attribute.md +18 -0
- package/docs/examples/databases/create-index.md +18 -0
- package/docs/examples/databases/create-integer-attribute.md +18 -0
- package/docs/examples/databases/create-ip-attribute.md +18 -0
- package/docs/examples/databases/create-string-attribute.md +18 -0
- package/docs/examples/databases/create-url-attribute.md +18 -0
- package/docs/examples/databases/create.md +18 -0
- package/docs/examples/databases/delete-attribute.md +18 -0
- package/docs/examples/databases/delete-collection.md +18 -0
- package/docs/examples/databases/delete-document.md +18 -0
- package/docs/examples/databases/delete-index.md +18 -0
- package/docs/examples/databases/delete.md +18 -0
- package/docs/examples/databases/get-attribute.md +18 -0
- package/docs/examples/databases/get-collection-usage.md +18 -0
- package/docs/examples/databases/get-collection.md +18 -0
- package/docs/examples/databases/get-database-usage.md +18 -0
- package/docs/examples/databases/get-document.md +18 -0
- package/docs/examples/databases/get-index.md +18 -0
- package/docs/examples/databases/get-usage.md +18 -0
- package/docs/examples/databases/get.md +18 -0
- package/docs/examples/databases/list-attributes.md +18 -0
- package/docs/examples/databases/list-collection-logs.md +18 -0
- package/docs/examples/databases/list-collections.md +18 -0
- package/docs/examples/databases/list-document-logs.md +18 -0
- package/docs/examples/databases/list-documents.md +18 -0
- package/docs/examples/databases/list-indexes.md +18 -0
- package/docs/examples/databases/list-logs.md +18 -0
- package/docs/examples/databases/list.md +18 -0
- package/docs/examples/databases/update-collection.md +18 -0
- package/docs/examples/databases/update-document.md +18 -0
- package/docs/examples/databases/update.md +18 -0
- package/docs/examples/functions/create-build.md +18 -0
- package/docs/examples/functions/create-deployment.md +18 -0
- package/docs/examples/functions/create-execution.md +18 -0
- package/docs/examples/functions/create-variable.md +18 -0
- package/docs/examples/functions/create.md +18 -0
- package/docs/examples/functions/delete-deployment.md +18 -0
- package/docs/examples/functions/delete-variable.md +18 -0
- package/docs/examples/functions/delete.md +18 -0
- package/docs/examples/functions/get-deployment.md +18 -0
- package/docs/examples/functions/get-execution.md +18 -0
- package/docs/examples/functions/get-function-usage.md +18 -0
- package/docs/examples/functions/get-usage.md +18 -0
- package/docs/examples/functions/get-variable.md +18 -0
- package/docs/examples/functions/get.md +18 -0
- package/docs/examples/functions/list-deployments.md +18 -0
- package/docs/examples/functions/list-executions.md +18 -0
- package/docs/examples/functions/list-runtimes.md +18 -0
- package/docs/examples/functions/list-variables.md +18 -0
- package/docs/examples/functions/list.md +18 -0
- package/docs/examples/functions/update-deployment.md +18 -0
- package/docs/examples/functions/update-variable.md +18 -0
- package/docs/examples/functions/update.md +18 -0
- package/docs/examples/graphql/mutation.md +18 -0
- package/docs/examples/graphql/query.md +18 -0
- package/docs/examples/health/get-antivirus.md +18 -0
- package/docs/examples/health/get-cache.md +18 -0
- package/docs/examples/health/get-d-b.md +18 -0
- package/docs/examples/health/get-queue-certificates.md +18 -0
- package/docs/examples/health/get-queue-functions.md +18 -0
- package/docs/examples/health/get-queue-logs.md +18 -0
- package/docs/examples/health/get-queue-webhooks.md +18 -0
- package/docs/examples/health/get-storage-local.md +18 -0
- package/docs/examples/health/get-time.md +18 -0
- package/docs/examples/health/get.md +18 -0
- package/docs/examples/locale/get.md +18 -0
- package/docs/examples/locale/list-continents.md +18 -0
- package/docs/examples/locale/list-countries-e-u.md +18 -0
- package/docs/examples/locale/list-countries-phones.md +18 -0
- package/docs/examples/locale/list-countries.md +18 -0
- package/docs/examples/locale/list-currencies.md +18 -0
- package/docs/examples/locale/list-languages.md +18 -0
- package/docs/examples/projects/create-domain.md +18 -0
- package/docs/examples/projects/create-key.md +18 -0
- package/docs/examples/projects/create-platform.md +18 -0
- package/docs/examples/projects/create-webhook.md +18 -0
- package/docs/examples/projects/create.md +18 -0
- package/docs/examples/projects/delete-domain.md +18 -0
- package/docs/examples/projects/delete-key.md +18 -0
- package/docs/examples/projects/delete-platform.md +18 -0
- package/docs/examples/projects/delete-webhook.md +18 -0
- package/docs/examples/projects/delete.md +18 -0
- package/docs/examples/projects/get-domain.md +18 -0
- package/docs/examples/projects/get-key.md +18 -0
- package/docs/examples/projects/get-platform.md +18 -0
- package/docs/examples/projects/get-usage.md +18 -0
- package/docs/examples/projects/get-webhook.md +18 -0
- package/docs/examples/projects/get.md +18 -0
- package/docs/examples/projects/list-domains.md +18 -0
- package/docs/examples/projects/list-keys.md +18 -0
- package/docs/examples/projects/list-platforms.md +18 -0
- package/docs/examples/projects/list-webhooks.md +18 -0
- package/docs/examples/projects/list.md +18 -0
- package/docs/examples/projects/update-auth-duration.md +18 -0
- package/docs/examples/projects/update-auth-limit.md +18 -0
- package/docs/examples/projects/update-auth-sessions-limit.md +18 -0
- package/docs/examples/projects/update-auth-status.md +18 -0
- package/docs/examples/projects/update-domain-verification.md +18 -0
- package/docs/examples/projects/update-key.md +18 -0
- package/docs/examples/projects/update-o-auth2.md +18 -0
- package/docs/examples/projects/update-platform.md +18 -0
- package/docs/examples/projects/update-service-status.md +18 -0
- package/docs/examples/projects/update-webhook-signature.md +18 -0
- package/docs/examples/projects/update-webhook.md +18 -0
- package/docs/examples/projects/update.md +18 -0
- package/docs/examples/storage/create-bucket.md +18 -0
- package/docs/examples/storage/create-file.md +18 -0
- package/docs/examples/storage/delete-bucket.md +18 -0
- package/docs/examples/storage/delete-file.md +18 -0
- package/docs/examples/storage/get-bucket-usage.md +18 -0
- package/docs/examples/storage/get-bucket.md +18 -0
- package/docs/examples/storage/get-file-download.md +14 -0
- package/docs/examples/storage/get-file-preview.md +14 -0
- package/docs/examples/storage/get-file-view.md +14 -0
- package/docs/examples/storage/get-file.md +18 -0
- package/docs/examples/storage/get-usage.md +18 -0
- package/docs/examples/storage/list-buckets.md +18 -0
- package/docs/examples/storage/list-files.md +18 -0
- package/docs/examples/storage/update-bucket.md +18 -0
- package/docs/examples/storage/update-file.md +18 -0
- package/docs/examples/teams/create-membership.md +18 -0
- package/docs/examples/teams/create.md +18 -0
- package/docs/examples/teams/delete-membership.md +18 -0
- package/docs/examples/teams/delete.md +18 -0
- package/docs/examples/teams/get-membership.md +18 -0
- package/docs/examples/teams/get.md +18 -0
- package/docs/examples/teams/list-logs.md +18 -0
- package/docs/examples/teams/list-memberships.md +18 -0
- package/docs/examples/teams/list.md +18 -0
- package/docs/examples/teams/update-membership-roles.md +18 -0
- package/docs/examples/teams/update-membership-status.md +18 -0
- package/docs/examples/teams/update.md +18 -0
- package/docs/examples/users/create-argon2user.md +18 -0
- package/docs/examples/users/create-bcrypt-user.md +18 -0
- package/docs/examples/users/create-m-d5user.md +18 -0
- package/docs/examples/users/create-p-h-pass-user.md +18 -0
- package/docs/examples/users/create-s-h-a-user.md +18 -0
- package/docs/examples/users/create-scrypt-modified-user.md +18 -0
- package/docs/examples/users/create-scrypt-user.md +18 -0
- package/docs/examples/users/create.md +18 -0
- package/docs/examples/users/delete-session.md +18 -0
- package/docs/examples/users/delete-sessions.md +18 -0
- package/docs/examples/users/delete.md +18 -0
- package/docs/examples/users/get-prefs.md +18 -0
- package/docs/examples/users/get-usage.md +18 -0
- package/docs/examples/users/get.md +18 -0
- package/docs/examples/users/list-logs.md +18 -0
- package/docs/examples/users/list-memberships.md +18 -0
- package/docs/examples/users/list-sessions.md +18 -0
- package/docs/examples/users/list.md +18 -0
- package/docs/examples/users/update-email-verification.md +18 -0
- package/docs/examples/users/update-email.md +18 -0
- package/docs/examples/users/update-name.md +18 -0
- package/docs/examples/users/update-password.md +18 -0
- package/docs/examples/users/update-phone-verification.md +18 -0
- package/docs/examples/users/update-phone.md +18 -0
- package/docs/examples/users/update-prefs.md +18 -0
- package/docs/examples/users/update-status.md +18 -0
- package/package.json +40 -0
- package/rollup.config.js +31 -0
- package/src/client.ts +472 -0
- package/src/id.ts +9 -0
- package/src/index.ts +17 -0
- package/src/models.ts +2540 -0
- package/src/permission.ts +22 -0
- package/src/query.ts +56 -0
- package/src/role.ts +34 -0
- package/src/service.ts +30 -0
- package/src/services/account.ts +1009 -0
- package/src/services/avatars.ts +351 -0
- package/src/services/databases.ts +1525 -0
- package/src/services/functions.ts +814 -0
- package/src/services/graphql.ts +68 -0
- package/src/services/health.ts +202 -0
- package/src/services/locale.ts +150 -0
- package/src/services/projects.ts +1235 -0
- package/src/services/storage.ts +691 -0
- package/src/services/teams.ts +445 -0
- package/src/services/users.ts +1020 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,1525 @@
|
|
|
1
|
+
import { Service } from '../service';
|
|
2
|
+
import { AppwriteException, Client } from '../client';
|
|
3
|
+
import type { Models } from '../models';
|
|
4
|
+
import type { UploadProgress, Payload } from '../client';
|
|
5
|
+
|
|
6
|
+
export class Databases extends Service {
|
|
7
|
+
|
|
8
|
+
constructor(client: Client)
|
|
9
|
+
{
|
|
10
|
+
super(client);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* List Databases
|
|
15
|
+
*
|
|
16
|
+
* Get a list of all databases from the current Appwrite project. You can use
|
|
17
|
+
* the search parameter to filter your results.
|
|
18
|
+
*
|
|
19
|
+
* @param {string[]} queries
|
|
20
|
+
* @param {string} search
|
|
21
|
+
* @throws {AppwriteException}
|
|
22
|
+
* @returns {Promise}
|
|
23
|
+
*/
|
|
24
|
+
async list(queries?: string[], search?: string): Promise<Models.DatabaseList> {
|
|
25
|
+
let path = '/databases';
|
|
26
|
+
let payload: Payload = {};
|
|
27
|
+
|
|
28
|
+
if (typeof queries !== 'undefined') {
|
|
29
|
+
payload['queries'] = queries;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (typeof search !== 'undefined') {
|
|
33
|
+
payload['search'] = search;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
37
|
+
return await this.client.call('get', uri, {
|
|
38
|
+
'content-type': 'application/json',
|
|
39
|
+
}, payload);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Create Database
|
|
44
|
+
*
|
|
45
|
+
* Create a new Database.
|
|
46
|
+
*
|
|
47
|
+
*
|
|
48
|
+
* @param {string} databaseId
|
|
49
|
+
* @param {string} name
|
|
50
|
+
* @throws {AppwriteException}
|
|
51
|
+
* @returns {Promise}
|
|
52
|
+
*/
|
|
53
|
+
async create(databaseId: string, name: string): Promise<Models.Database> {
|
|
54
|
+
if (typeof databaseId === 'undefined') {
|
|
55
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (typeof name === 'undefined') {
|
|
59
|
+
throw new AppwriteException('Missing required parameter: "name"');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let path = '/databases';
|
|
63
|
+
let payload: Payload = {};
|
|
64
|
+
|
|
65
|
+
if (typeof databaseId !== 'undefined') {
|
|
66
|
+
payload['databaseId'] = databaseId;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (typeof name !== 'undefined') {
|
|
70
|
+
payload['name'] = name;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
74
|
+
return await this.client.call('post', uri, {
|
|
75
|
+
'content-type': 'application/json',
|
|
76
|
+
}, payload);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Get usage stats for the database
|
|
81
|
+
*
|
|
82
|
+
*
|
|
83
|
+
* @param {string} range
|
|
84
|
+
* @throws {AppwriteException}
|
|
85
|
+
* @returns {Promise}
|
|
86
|
+
*/
|
|
87
|
+
async getUsage(range?: string): Promise<Models.UsageDatabases> {
|
|
88
|
+
let path = '/databases/usage';
|
|
89
|
+
let payload: Payload = {};
|
|
90
|
+
|
|
91
|
+
if (typeof range !== 'undefined') {
|
|
92
|
+
payload['range'] = range;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
96
|
+
return await this.client.call('get', uri, {
|
|
97
|
+
'content-type': 'application/json',
|
|
98
|
+
}, payload);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Get Database
|
|
103
|
+
*
|
|
104
|
+
* Get a database by its unique ID. This endpoint response returns a JSON
|
|
105
|
+
* object with the database metadata.
|
|
106
|
+
*
|
|
107
|
+
* @param {string} databaseId
|
|
108
|
+
* @throws {AppwriteException}
|
|
109
|
+
* @returns {Promise}
|
|
110
|
+
*/
|
|
111
|
+
async get(databaseId: string): Promise<Models.Database> {
|
|
112
|
+
if (typeof databaseId === 'undefined') {
|
|
113
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
let path = '/databases/{databaseId}'.replace('{databaseId}', databaseId);
|
|
117
|
+
let payload: Payload = {};
|
|
118
|
+
|
|
119
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
120
|
+
return await this.client.call('get', uri, {
|
|
121
|
+
'content-type': 'application/json',
|
|
122
|
+
}, payload);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Update Database
|
|
127
|
+
*
|
|
128
|
+
* Update a database by its unique ID.
|
|
129
|
+
*
|
|
130
|
+
* @param {string} databaseId
|
|
131
|
+
* @param {string} name
|
|
132
|
+
* @throws {AppwriteException}
|
|
133
|
+
* @returns {Promise}
|
|
134
|
+
*/
|
|
135
|
+
async update(databaseId: string, name: string): Promise<Models.Database> {
|
|
136
|
+
if (typeof databaseId === 'undefined') {
|
|
137
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (typeof name === 'undefined') {
|
|
141
|
+
throw new AppwriteException('Missing required parameter: "name"');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
let path = '/databases/{databaseId}'.replace('{databaseId}', databaseId);
|
|
145
|
+
let payload: Payload = {};
|
|
146
|
+
|
|
147
|
+
if (typeof name !== 'undefined') {
|
|
148
|
+
payload['name'] = name;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
152
|
+
return await this.client.call('put', uri, {
|
|
153
|
+
'content-type': 'application/json',
|
|
154
|
+
}, payload);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Delete Database
|
|
159
|
+
*
|
|
160
|
+
* Delete a database by its unique ID. Only API keys with with databases.write
|
|
161
|
+
* scope can delete a database.
|
|
162
|
+
*
|
|
163
|
+
* @param {string} databaseId
|
|
164
|
+
* @throws {AppwriteException}
|
|
165
|
+
* @returns {Promise}
|
|
166
|
+
*/
|
|
167
|
+
async delete(databaseId: string): Promise<{}> {
|
|
168
|
+
if (typeof databaseId === 'undefined') {
|
|
169
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
let path = '/databases/{databaseId}'.replace('{databaseId}', databaseId);
|
|
173
|
+
let payload: Payload = {};
|
|
174
|
+
|
|
175
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
176
|
+
return await this.client.call('delete', uri, {
|
|
177
|
+
'content-type': 'application/json',
|
|
178
|
+
}, payload);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* List Collections
|
|
183
|
+
*
|
|
184
|
+
* Get a list of all collections that belong to the provided databaseId. You
|
|
185
|
+
* can use the search parameter to filter your results.
|
|
186
|
+
*
|
|
187
|
+
* @param {string} databaseId
|
|
188
|
+
* @param {string[]} queries
|
|
189
|
+
* @param {string} search
|
|
190
|
+
* @throws {AppwriteException}
|
|
191
|
+
* @returns {Promise}
|
|
192
|
+
*/
|
|
193
|
+
async listCollections(databaseId: string, queries?: string[], search?: string): Promise<Models.CollectionList> {
|
|
194
|
+
if (typeof databaseId === 'undefined') {
|
|
195
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
let path = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId);
|
|
199
|
+
let payload: Payload = {};
|
|
200
|
+
|
|
201
|
+
if (typeof queries !== 'undefined') {
|
|
202
|
+
payload['queries'] = queries;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (typeof search !== 'undefined') {
|
|
206
|
+
payload['search'] = search;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
210
|
+
return await this.client.call('get', uri, {
|
|
211
|
+
'content-type': 'application/json',
|
|
212
|
+
}, payload);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Create Collection
|
|
217
|
+
*
|
|
218
|
+
* Create a new Collection. Before using this route, you should create a new
|
|
219
|
+
* database resource using either a [server
|
|
220
|
+
* integration](/docs/server/databases#databasesCreateCollection) API or
|
|
221
|
+
* directly from your database console.
|
|
222
|
+
*
|
|
223
|
+
* @param {string} databaseId
|
|
224
|
+
* @param {string} collectionId
|
|
225
|
+
* @param {string} name
|
|
226
|
+
* @param {string[]} permissions
|
|
227
|
+
* @param {boolean} documentSecurity
|
|
228
|
+
* @throws {AppwriteException}
|
|
229
|
+
* @returns {Promise}
|
|
230
|
+
*/
|
|
231
|
+
async createCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean): Promise<Models.Collection> {
|
|
232
|
+
if (typeof databaseId === 'undefined') {
|
|
233
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (typeof collectionId === 'undefined') {
|
|
237
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (typeof name === 'undefined') {
|
|
241
|
+
throw new AppwriteException('Missing required parameter: "name"');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
let path = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId);
|
|
245
|
+
let payload: Payload = {};
|
|
246
|
+
|
|
247
|
+
if (typeof collectionId !== 'undefined') {
|
|
248
|
+
payload['collectionId'] = collectionId;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (typeof name !== 'undefined') {
|
|
252
|
+
payload['name'] = name;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (typeof permissions !== 'undefined') {
|
|
256
|
+
payload['permissions'] = permissions;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (typeof documentSecurity !== 'undefined') {
|
|
260
|
+
payload['documentSecurity'] = documentSecurity;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
264
|
+
return await this.client.call('post', uri, {
|
|
265
|
+
'content-type': 'application/json',
|
|
266
|
+
}, payload);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Get Collection
|
|
271
|
+
*
|
|
272
|
+
* Get a collection by its unique ID. This endpoint response returns a JSON
|
|
273
|
+
* object with the collection metadata.
|
|
274
|
+
*
|
|
275
|
+
* @param {string} databaseId
|
|
276
|
+
* @param {string} collectionId
|
|
277
|
+
* @throws {AppwriteException}
|
|
278
|
+
* @returns {Promise}
|
|
279
|
+
*/
|
|
280
|
+
async getCollection(databaseId: string, collectionId: string): Promise<Models.Collection> {
|
|
281
|
+
if (typeof databaseId === 'undefined') {
|
|
282
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (typeof collectionId === 'undefined') {
|
|
286
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
290
|
+
let payload: Payload = {};
|
|
291
|
+
|
|
292
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
293
|
+
return await this.client.call('get', uri, {
|
|
294
|
+
'content-type': 'application/json',
|
|
295
|
+
}, payload);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Update Collection
|
|
300
|
+
*
|
|
301
|
+
* Update a collection by its unique ID.
|
|
302
|
+
*
|
|
303
|
+
* @param {string} databaseId
|
|
304
|
+
* @param {string} collectionId
|
|
305
|
+
* @param {string} name
|
|
306
|
+
* @param {string[]} permissions
|
|
307
|
+
* @param {boolean} documentSecurity
|
|
308
|
+
* @param {boolean} enabled
|
|
309
|
+
* @throws {AppwriteException}
|
|
310
|
+
* @returns {Promise}
|
|
311
|
+
*/
|
|
312
|
+
async updateCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise<Models.Collection> {
|
|
313
|
+
if (typeof databaseId === 'undefined') {
|
|
314
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (typeof collectionId === 'undefined') {
|
|
318
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (typeof name === 'undefined') {
|
|
322
|
+
throw new AppwriteException('Missing required parameter: "name"');
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
326
|
+
let payload: Payload = {};
|
|
327
|
+
|
|
328
|
+
if (typeof name !== 'undefined') {
|
|
329
|
+
payload['name'] = name;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (typeof permissions !== 'undefined') {
|
|
333
|
+
payload['permissions'] = permissions;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (typeof documentSecurity !== 'undefined') {
|
|
337
|
+
payload['documentSecurity'] = documentSecurity;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (typeof enabled !== 'undefined') {
|
|
341
|
+
payload['enabled'] = enabled;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
345
|
+
return await this.client.call('put', uri, {
|
|
346
|
+
'content-type': 'application/json',
|
|
347
|
+
}, payload);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Delete Collection
|
|
352
|
+
*
|
|
353
|
+
* Delete a collection by its unique ID. Only users with write permissions
|
|
354
|
+
* have access to delete this resource.
|
|
355
|
+
*
|
|
356
|
+
* @param {string} databaseId
|
|
357
|
+
* @param {string} collectionId
|
|
358
|
+
* @throws {AppwriteException}
|
|
359
|
+
* @returns {Promise}
|
|
360
|
+
*/
|
|
361
|
+
async deleteCollection(databaseId: string, collectionId: string): Promise<{}> {
|
|
362
|
+
if (typeof databaseId === 'undefined') {
|
|
363
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (typeof collectionId === 'undefined') {
|
|
367
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
371
|
+
let payload: Payload = {};
|
|
372
|
+
|
|
373
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
374
|
+
return await this.client.call('delete', uri, {
|
|
375
|
+
'content-type': 'application/json',
|
|
376
|
+
}, payload);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* List Attributes
|
|
381
|
+
*
|
|
382
|
+
*
|
|
383
|
+
* @param {string} databaseId
|
|
384
|
+
* @param {string} collectionId
|
|
385
|
+
* @throws {AppwriteException}
|
|
386
|
+
* @returns {Promise}
|
|
387
|
+
*/
|
|
388
|
+
async listAttributes(databaseId: string, collectionId: string): Promise<Models.AttributeList> {
|
|
389
|
+
if (typeof databaseId === 'undefined') {
|
|
390
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (typeof collectionId === 'undefined') {
|
|
394
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/attributes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
398
|
+
let payload: Payload = {};
|
|
399
|
+
|
|
400
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
401
|
+
return await this.client.call('get', uri, {
|
|
402
|
+
'content-type': 'application/json',
|
|
403
|
+
}, payload);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Create Boolean Attribute
|
|
408
|
+
*
|
|
409
|
+
* Create a boolean attribute.
|
|
410
|
+
*
|
|
411
|
+
*
|
|
412
|
+
* @param {string} databaseId
|
|
413
|
+
* @param {string} collectionId
|
|
414
|
+
* @param {string} key
|
|
415
|
+
* @param {boolean} required
|
|
416
|
+
* @param {boolean} xdefault
|
|
417
|
+
* @param {boolean} array
|
|
418
|
+
* @throws {AppwriteException}
|
|
419
|
+
* @returns {Promise}
|
|
420
|
+
*/
|
|
421
|
+
async createBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise<Models.AttributeBoolean> {
|
|
422
|
+
if (typeof databaseId === 'undefined') {
|
|
423
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if (typeof collectionId === 'undefined') {
|
|
427
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
if (typeof key === 'undefined') {
|
|
431
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
if (typeof required === 'undefined') {
|
|
435
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
439
|
+
let payload: Payload = {};
|
|
440
|
+
|
|
441
|
+
if (typeof key !== 'undefined') {
|
|
442
|
+
payload['key'] = key;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
if (typeof required !== 'undefined') {
|
|
446
|
+
payload['required'] = required;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
if (typeof xdefault !== 'undefined') {
|
|
450
|
+
payload['default'] = xdefault;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if (typeof array !== 'undefined') {
|
|
454
|
+
payload['array'] = array;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
458
|
+
return await this.client.call('post', uri, {
|
|
459
|
+
'content-type': 'application/json',
|
|
460
|
+
}, payload);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Create DateTime Attribute
|
|
465
|
+
*
|
|
466
|
+
*
|
|
467
|
+
* @param {string} databaseId
|
|
468
|
+
* @param {string} collectionId
|
|
469
|
+
* @param {string} key
|
|
470
|
+
* @param {boolean} required
|
|
471
|
+
* @param {string} xdefault
|
|
472
|
+
* @param {boolean} array
|
|
473
|
+
* @throws {AppwriteException}
|
|
474
|
+
* @returns {Promise}
|
|
475
|
+
*/
|
|
476
|
+
async createDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeDatetime> {
|
|
477
|
+
if (typeof databaseId === 'undefined') {
|
|
478
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (typeof collectionId === 'undefined') {
|
|
482
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
if (typeof key === 'undefined') {
|
|
486
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
if (typeof required === 'undefined') {
|
|
490
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
494
|
+
let payload: Payload = {};
|
|
495
|
+
|
|
496
|
+
if (typeof key !== 'undefined') {
|
|
497
|
+
payload['key'] = key;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
if (typeof required !== 'undefined') {
|
|
501
|
+
payload['required'] = required;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
if (typeof xdefault !== 'undefined') {
|
|
505
|
+
payload['default'] = xdefault;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
if (typeof array !== 'undefined') {
|
|
509
|
+
payload['array'] = array;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
513
|
+
return await this.client.call('post', uri, {
|
|
514
|
+
'content-type': 'application/json',
|
|
515
|
+
}, payload);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Create Email Attribute
|
|
520
|
+
*
|
|
521
|
+
* Create an email attribute.
|
|
522
|
+
*
|
|
523
|
+
*
|
|
524
|
+
* @param {string} databaseId
|
|
525
|
+
* @param {string} collectionId
|
|
526
|
+
* @param {string} key
|
|
527
|
+
* @param {boolean} required
|
|
528
|
+
* @param {string} xdefault
|
|
529
|
+
* @param {boolean} array
|
|
530
|
+
* @throws {AppwriteException}
|
|
531
|
+
* @returns {Promise}
|
|
532
|
+
*/
|
|
533
|
+
async createEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeEmail> {
|
|
534
|
+
if (typeof databaseId === 'undefined') {
|
|
535
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (typeof collectionId === 'undefined') {
|
|
539
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
if (typeof key === 'undefined') {
|
|
543
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (typeof required === 'undefined') {
|
|
547
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
551
|
+
let payload: Payload = {};
|
|
552
|
+
|
|
553
|
+
if (typeof key !== 'undefined') {
|
|
554
|
+
payload['key'] = key;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
if (typeof required !== 'undefined') {
|
|
558
|
+
payload['required'] = required;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
if (typeof xdefault !== 'undefined') {
|
|
562
|
+
payload['default'] = xdefault;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
if (typeof array !== 'undefined') {
|
|
566
|
+
payload['array'] = array;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
570
|
+
return await this.client.call('post', uri, {
|
|
571
|
+
'content-type': 'application/json',
|
|
572
|
+
}, payload);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Create Enum Attribute
|
|
577
|
+
*
|
|
578
|
+
*
|
|
579
|
+
* @param {string} databaseId
|
|
580
|
+
* @param {string} collectionId
|
|
581
|
+
* @param {string} key
|
|
582
|
+
* @param {string[]} elements
|
|
583
|
+
* @param {boolean} required
|
|
584
|
+
* @param {string} xdefault
|
|
585
|
+
* @param {boolean} array
|
|
586
|
+
* @throws {AppwriteException}
|
|
587
|
+
* @returns {Promise}
|
|
588
|
+
*/
|
|
589
|
+
async createEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeEnum> {
|
|
590
|
+
if (typeof databaseId === 'undefined') {
|
|
591
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
if (typeof collectionId === 'undefined') {
|
|
595
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
if (typeof key === 'undefined') {
|
|
599
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if (typeof elements === 'undefined') {
|
|
603
|
+
throw new AppwriteException('Missing required parameter: "elements"');
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
if (typeof required === 'undefined') {
|
|
607
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
611
|
+
let payload: Payload = {};
|
|
612
|
+
|
|
613
|
+
if (typeof key !== 'undefined') {
|
|
614
|
+
payload['key'] = key;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
if (typeof elements !== 'undefined') {
|
|
618
|
+
payload['elements'] = elements;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
if (typeof required !== 'undefined') {
|
|
622
|
+
payload['required'] = required;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
if (typeof xdefault !== 'undefined') {
|
|
626
|
+
payload['default'] = xdefault;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
if (typeof array !== 'undefined') {
|
|
630
|
+
payload['array'] = array;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
634
|
+
return await this.client.call('post', uri, {
|
|
635
|
+
'content-type': 'application/json',
|
|
636
|
+
}, payload);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Create Float Attribute
|
|
641
|
+
*
|
|
642
|
+
* Create a float attribute. Optionally, minimum and maximum values can be
|
|
643
|
+
* provided.
|
|
644
|
+
*
|
|
645
|
+
*
|
|
646
|
+
* @param {string} databaseId
|
|
647
|
+
* @param {string} collectionId
|
|
648
|
+
* @param {string} key
|
|
649
|
+
* @param {boolean} required
|
|
650
|
+
* @param {number} min
|
|
651
|
+
* @param {number} max
|
|
652
|
+
* @param {number} xdefault
|
|
653
|
+
* @param {boolean} array
|
|
654
|
+
* @throws {AppwriteException}
|
|
655
|
+
* @returns {Promise}
|
|
656
|
+
*/
|
|
657
|
+
async createFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise<Models.AttributeFloat> {
|
|
658
|
+
if (typeof databaseId === 'undefined') {
|
|
659
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if (typeof collectionId === 'undefined') {
|
|
663
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
if (typeof key === 'undefined') {
|
|
667
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
if (typeof required === 'undefined') {
|
|
671
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
675
|
+
let payload: Payload = {};
|
|
676
|
+
|
|
677
|
+
if (typeof key !== 'undefined') {
|
|
678
|
+
payload['key'] = key;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
if (typeof required !== 'undefined') {
|
|
682
|
+
payload['required'] = required;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
if (typeof min !== 'undefined') {
|
|
686
|
+
payload['min'] = min;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
if (typeof max !== 'undefined') {
|
|
690
|
+
payload['max'] = max;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
if (typeof xdefault !== 'undefined') {
|
|
694
|
+
payload['default'] = xdefault;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
if (typeof array !== 'undefined') {
|
|
698
|
+
payload['array'] = array;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
702
|
+
return await this.client.call('post', uri, {
|
|
703
|
+
'content-type': 'application/json',
|
|
704
|
+
}, payload);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Create Integer Attribute
|
|
709
|
+
*
|
|
710
|
+
* Create an integer attribute. Optionally, minimum and maximum values can be
|
|
711
|
+
* provided.
|
|
712
|
+
*
|
|
713
|
+
*
|
|
714
|
+
* @param {string} databaseId
|
|
715
|
+
* @param {string} collectionId
|
|
716
|
+
* @param {string} key
|
|
717
|
+
* @param {boolean} required
|
|
718
|
+
* @param {number} min
|
|
719
|
+
* @param {number} max
|
|
720
|
+
* @param {number} xdefault
|
|
721
|
+
* @param {boolean} array
|
|
722
|
+
* @throws {AppwriteException}
|
|
723
|
+
* @returns {Promise}
|
|
724
|
+
*/
|
|
725
|
+
async createIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise<Models.AttributeInteger> {
|
|
726
|
+
if (typeof databaseId === 'undefined') {
|
|
727
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
if (typeof collectionId === 'undefined') {
|
|
731
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
if (typeof key === 'undefined') {
|
|
735
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
if (typeof required === 'undefined') {
|
|
739
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
743
|
+
let payload: Payload = {};
|
|
744
|
+
|
|
745
|
+
if (typeof key !== 'undefined') {
|
|
746
|
+
payload['key'] = key;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
if (typeof required !== 'undefined') {
|
|
750
|
+
payload['required'] = required;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
if (typeof min !== 'undefined') {
|
|
754
|
+
payload['min'] = min;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
if (typeof max !== 'undefined') {
|
|
758
|
+
payload['max'] = max;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
if (typeof xdefault !== 'undefined') {
|
|
762
|
+
payload['default'] = xdefault;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
if (typeof array !== 'undefined') {
|
|
766
|
+
payload['array'] = array;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
770
|
+
return await this.client.call('post', uri, {
|
|
771
|
+
'content-type': 'application/json',
|
|
772
|
+
}, payload);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Create IP Address Attribute
|
|
777
|
+
*
|
|
778
|
+
* Create IP address attribute.
|
|
779
|
+
*
|
|
780
|
+
*
|
|
781
|
+
* @param {string} databaseId
|
|
782
|
+
* @param {string} collectionId
|
|
783
|
+
* @param {string} key
|
|
784
|
+
* @param {boolean} required
|
|
785
|
+
* @param {string} xdefault
|
|
786
|
+
* @param {boolean} array
|
|
787
|
+
* @throws {AppwriteException}
|
|
788
|
+
* @returns {Promise}
|
|
789
|
+
*/
|
|
790
|
+
async createIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeIp> {
|
|
791
|
+
if (typeof databaseId === 'undefined') {
|
|
792
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
if (typeof collectionId === 'undefined') {
|
|
796
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
if (typeof key === 'undefined') {
|
|
800
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
if (typeof required === 'undefined') {
|
|
804
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
808
|
+
let payload: Payload = {};
|
|
809
|
+
|
|
810
|
+
if (typeof key !== 'undefined') {
|
|
811
|
+
payload['key'] = key;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
if (typeof required !== 'undefined') {
|
|
815
|
+
payload['required'] = required;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
if (typeof xdefault !== 'undefined') {
|
|
819
|
+
payload['default'] = xdefault;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
if (typeof array !== 'undefined') {
|
|
823
|
+
payload['array'] = array;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
827
|
+
return await this.client.call('post', uri, {
|
|
828
|
+
'content-type': 'application/json',
|
|
829
|
+
}, payload);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* Create String Attribute
|
|
834
|
+
*
|
|
835
|
+
* Create a string attribute.
|
|
836
|
+
*
|
|
837
|
+
*
|
|
838
|
+
* @param {string} databaseId
|
|
839
|
+
* @param {string} collectionId
|
|
840
|
+
* @param {string} key
|
|
841
|
+
* @param {number} size
|
|
842
|
+
* @param {boolean} required
|
|
843
|
+
* @param {string} xdefault
|
|
844
|
+
* @param {boolean} array
|
|
845
|
+
* @throws {AppwriteException}
|
|
846
|
+
* @returns {Promise}
|
|
847
|
+
*/
|
|
848
|
+
async createStringAttribute(databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeString> {
|
|
849
|
+
if (typeof databaseId === 'undefined') {
|
|
850
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
if (typeof collectionId === 'undefined') {
|
|
854
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
if (typeof key === 'undefined') {
|
|
858
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
if (typeof size === 'undefined') {
|
|
862
|
+
throw new AppwriteException('Missing required parameter: "size"');
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
if (typeof required === 'undefined') {
|
|
866
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
870
|
+
let payload: Payload = {};
|
|
871
|
+
|
|
872
|
+
if (typeof key !== 'undefined') {
|
|
873
|
+
payload['key'] = key;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
if (typeof size !== 'undefined') {
|
|
877
|
+
payload['size'] = size;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
if (typeof required !== 'undefined') {
|
|
881
|
+
payload['required'] = required;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
if (typeof xdefault !== 'undefined') {
|
|
885
|
+
payload['default'] = xdefault;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
if (typeof array !== 'undefined') {
|
|
889
|
+
payload['array'] = array;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
893
|
+
return await this.client.call('post', uri, {
|
|
894
|
+
'content-type': 'application/json',
|
|
895
|
+
}, payload);
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Create URL Attribute
|
|
900
|
+
*
|
|
901
|
+
* Create a URL attribute.
|
|
902
|
+
*
|
|
903
|
+
*
|
|
904
|
+
* @param {string} databaseId
|
|
905
|
+
* @param {string} collectionId
|
|
906
|
+
* @param {string} key
|
|
907
|
+
* @param {boolean} required
|
|
908
|
+
* @param {string} xdefault
|
|
909
|
+
* @param {boolean} array
|
|
910
|
+
* @throws {AppwriteException}
|
|
911
|
+
* @returns {Promise}
|
|
912
|
+
*/
|
|
913
|
+
async createUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeUrl> {
|
|
914
|
+
if (typeof databaseId === 'undefined') {
|
|
915
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
if (typeof collectionId === 'undefined') {
|
|
919
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
if (typeof key === 'undefined') {
|
|
923
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
if (typeof required === 'undefined') {
|
|
927
|
+
throw new AppwriteException('Missing required parameter: "required"');
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
931
|
+
let payload: Payload = {};
|
|
932
|
+
|
|
933
|
+
if (typeof key !== 'undefined') {
|
|
934
|
+
payload['key'] = key;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
if (typeof required !== 'undefined') {
|
|
938
|
+
payload['required'] = required;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
if (typeof xdefault !== 'undefined') {
|
|
942
|
+
payload['default'] = xdefault;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
if (typeof array !== 'undefined') {
|
|
946
|
+
payload['array'] = array;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
950
|
+
return await this.client.call('post', uri, {
|
|
951
|
+
'content-type': 'application/json',
|
|
952
|
+
}, payload);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Get Attribute
|
|
957
|
+
*
|
|
958
|
+
*
|
|
959
|
+
* @param {string} databaseId
|
|
960
|
+
* @param {string} collectionId
|
|
961
|
+
* @param {string} key
|
|
962
|
+
* @throws {AppwriteException}
|
|
963
|
+
* @returns {Promise}
|
|
964
|
+
*/
|
|
965
|
+
async getAttribute(databaseId: string, collectionId: string, key: string): Promise<{}> {
|
|
966
|
+
if (typeof databaseId === 'undefined') {
|
|
967
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
if (typeof collectionId === 'undefined') {
|
|
971
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
if (typeof key === 'undefined') {
|
|
975
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
|
|
979
|
+
let payload: Payload = {};
|
|
980
|
+
|
|
981
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
982
|
+
return await this.client.call('get', uri, {
|
|
983
|
+
'content-type': 'application/json',
|
|
984
|
+
}, payload);
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* Delete Attribute
|
|
989
|
+
*
|
|
990
|
+
*
|
|
991
|
+
* @param {string} databaseId
|
|
992
|
+
* @param {string} collectionId
|
|
993
|
+
* @param {string} key
|
|
994
|
+
* @throws {AppwriteException}
|
|
995
|
+
* @returns {Promise}
|
|
996
|
+
*/
|
|
997
|
+
async deleteAttribute(databaseId: string, collectionId: string, key: string): Promise<{}> {
|
|
998
|
+
if (typeof databaseId === 'undefined') {
|
|
999
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
if (typeof collectionId === 'undefined') {
|
|
1003
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
if (typeof key === 'undefined') {
|
|
1007
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
|
|
1011
|
+
let payload: Payload = {};
|
|
1012
|
+
|
|
1013
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
1014
|
+
return await this.client.call('delete', uri, {
|
|
1015
|
+
'content-type': 'application/json',
|
|
1016
|
+
}, payload);
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
* List Documents
|
|
1021
|
+
*
|
|
1022
|
+
* Get a list of all the user's documents in a given collection. You can use
|
|
1023
|
+
* the query params to filter your results.
|
|
1024
|
+
*
|
|
1025
|
+
* @param {string} databaseId
|
|
1026
|
+
* @param {string} collectionId
|
|
1027
|
+
* @param {string[]} queries
|
|
1028
|
+
* @throws {AppwriteException}
|
|
1029
|
+
* @returns {Promise}
|
|
1030
|
+
*/
|
|
1031
|
+
async listDocuments<Document extends Models.Document>(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.DocumentList<Document>> {
|
|
1032
|
+
if (typeof databaseId === 'undefined') {
|
|
1033
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
if (typeof collectionId === 'undefined') {
|
|
1037
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
1041
|
+
let payload: Payload = {};
|
|
1042
|
+
|
|
1043
|
+
if (typeof queries !== 'undefined') {
|
|
1044
|
+
payload['queries'] = queries;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
1048
|
+
return await this.client.call('get', uri, {
|
|
1049
|
+
'content-type': 'application/json',
|
|
1050
|
+
}, payload);
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* Create Document
|
|
1055
|
+
*
|
|
1056
|
+
* Create a new Document. Before using this route, you should create a new
|
|
1057
|
+
* collection resource using either a [server
|
|
1058
|
+
* integration](/docs/server/databases#databasesCreateCollection) API or
|
|
1059
|
+
* directly from your database console.
|
|
1060
|
+
*
|
|
1061
|
+
* @param {string} databaseId
|
|
1062
|
+
* @param {string} collectionId
|
|
1063
|
+
* @param {string} documentId
|
|
1064
|
+
* @param {Omit<Document, keyof Models.Document>} data
|
|
1065
|
+
* @param {string[]} permissions
|
|
1066
|
+
* @throws {AppwriteException}
|
|
1067
|
+
* @returns {Promise}
|
|
1068
|
+
*/
|
|
1069
|
+
async createDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, data: Omit<Document, keyof Models.Document>, permissions?: string[]): Promise<Document> {
|
|
1070
|
+
if (typeof databaseId === 'undefined') {
|
|
1071
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
if (typeof collectionId === 'undefined') {
|
|
1075
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
if (typeof documentId === 'undefined') {
|
|
1079
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
if (typeof data === 'undefined') {
|
|
1083
|
+
throw new AppwriteException('Missing required parameter: "data"');
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
1087
|
+
let payload: Payload = {};
|
|
1088
|
+
|
|
1089
|
+
if (typeof documentId !== 'undefined') {
|
|
1090
|
+
payload['documentId'] = documentId;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
if (typeof data !== 'undefined') {
|
|
1094
|
+
payload['data'] = data;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
if (typeof permissions !== 'undefined') {
|
|
1098
|
+
payload['permissions'] = permissions;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
1102
|
+
return await this.client.call('post', uri, {
|
|
1103
|
+
'content-type': 'application/json',
|
|
1104
|
+
}, payload);
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
/**
|
|
1108
|
+
* Get Document
|
|
1109
|
+
*
|
|
1110
|
+
* Get a document by its unique ID. This endpoint response returns a JSON
|
|
1111
|
+
* object with the document data.
|
|
1112
|
+
*
|
|
1113
|
+
* @param {string} databaseId
|
|
1114
|
+
* @param {string} collectionId
|
|
1115
|
+
* @param {string} documentId
|
|
1116
|
+
* @throws {AppwriteException}
|
|
1117
|
+
* @returns {Promise}
|
|
1118
|
+
*/
|
|
1119
|
+
async getDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string): Promise<Document> {
|
|
1120
|
+
if (typeof databaseId === 'undefined') {
|
|
1121
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
if (typeof collectionId === 'undefined') {
|
|
1125
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
if (typeof documentId === 'undefined') {
|
|
1129
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
|
|
1133
|
+
let payload: Payload = {};
|
|
1134
|
+
|
|
1135
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
1136
|
+
return await this.client.call('get', uri, {
|
|
1137
|
+
'content-type': 'application/json',
|
|
1138
|
+
}, payload);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* Update Document
|
|
1143
|
+
*
|
|
1144
|
+
* Update a document by its unique ID. Using the patch method you can pass
|
|
1145
|
+
* only specific fields that will get updated.
|
|
1146
|
+
*
|
|
1147
|
+
* @param {string} databaseId
|
|
1148
|
+
* @param {string} collectionId
|
|
1149
|
+
* @param {string} documentId
|
|
1150
|
+
* @param {Partial<Omit<Document, keyof Models.Document>>} data
|
|
1151
|
+
* @param {string[]} permissions
|
|
1152
|
+
* @throws {AppwriteException}
|
|
1153
|
+
* @returns {Promise}
|
|
1154
|
+
*/
|
|
1155
|
+
async updateDocument<Document extends Models.Document>(databaseId: string, collectionId: string, documentId: string, data?: Partial<Omit<Document, keyof Models.Document>>, permissions?: string[]): Promise<Document> {
|
|
1156
|
+
if (typeof databaseId === 'undefined') {
|
|
1157
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
if (typeof collectionId === 'undefined') {
|
|
1161
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
if (typeof documentId === 'undefined') {
|
|
1165
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
|
|
1169
|
+
let payload: Payload = {};
|
|
1170
|
+
|
|
1171
|
+
if (typeof data !== 'undefined') {
|
|
1172
|
+
payload['data'] = data;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
if (typeof permissions !== 'undefined') {
|
|
1176
|
+
payload['permissions'] = permissions;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
1180
|
+
return await this.client.call('patch', uri, {
|
|
1181
|
+
'content-type': 'application/json',
|
|
1182
|
+
}, payload);
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
/**
|
|
1186
|
+
* Delete Document
|
|
1187
|
+
*
|
|
1188
|
+
* Delete a document by its unique ID.
|
|
1189
|
+
*
|
|
1190
|
+
* @param {string} databaseId
|
|
1191
|
+
* @param {string} collectionId
|
|
1192
|
+
* @param {string} documentId
|
|
1193
|
+
* @throws {AppwriteException}
|
|
1194
|
+
* @returns {Promise}
|
|
1195
|
+
*/
|
|
1196
|
+
async deleteDocument(databaseId: string, collectionId: string, documentId: string): Promise<{}> {
|
|
1197
|
+
if (typeof databaseId === 'undefined') {
|
|
1198
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
if (typeof collectionId === 'undefined') {
|
|
1202
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
if (typeof documentId === 'undefined') {
|
|
1206
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
|
|
1210
|
+
let payload: Payload = {};
|
|
1211
|
+
|
|
1212
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
1213
|
+
return await this.client.call('delete', uri, {
|
|
1214
|
+
'content-type': 'application/json',
|
|
1215
|
+
}, payload);
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* List Document Logs
|
|
1220
|
+
*
|
|
1221
|
+
* Get the document activity logs list by its unique ID.
|
|
1222
|
+
*
|
|
1223
|
+
* @param {string} databaseId
|
|
1224
|
+
* @param {string} collectionId
|
|
1225
|
+
* @param {string} documentId
|
|
1226
|
+
* @param {string[]} queries
|
|
1227
|
+
* @throws {AppwriteException}
|
|
1228
|
+
* @returns {Promise}
|
|
1229
|
+
*/
|
|
1230
|
+
async listDocumentLogs(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise<Models.LogList> {
|
|
1231
|
+
if (typeof databaseId === 'undefined') {
|
|
1232
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
if (typeof collectionId === 'undefined') {
|
|
1236
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
if (typeof documentId === 'undefined') {
|
|
1240
|
+
throw new AppwriteException('Missing required parameter: "documentId"');
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/logs'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
|
|
1244
|
+
let payload: Payload = {};
|
|
1245
|
+
|
|
1246
|
+
if (typeof queries !== 'undefined') {
|
|
1247
|
+
payload['queries'] = queries;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
1251
|
+
return await this.client.call('get', uri, {
|
|
1252
|
+
'content-type': 'application/json',
|
|
1253
|
+
}, payload);
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
/**
|
|
1257
|
+
* List Indexes
|
|
1258
|
+
*
|
|
1259
|
+
*
|
|
1260
|
+
* @param {string} databaseId
|
|
1261
|
+
* @param {string} collectionId
|
|
1262
|
+
* @throws {AppwriteException}
|
|
1263
|
+
* @returns {Promise}
|
|
1264
|
+
*/
|
|
1265
|
+
async listIndexes(databaseId: string, collectionId: string): Promise<Models.IndexList> {
|
|
1266
|
+
if (typeof databaseId === 'undefined') {
|
|
1267
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
if (typeof collectionId === 'undefined') {
|
|
1271
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
1275
|
+
let payload: Payload = {};
|
|
1276
|
+
|
|
1277
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
1278
|
+
return await this.client.call('get', uri, {
|
|
1279
|
+
'content-type': 'application/json',
|
|
1280
|
+
}, payload);
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* Create Index
|
|
1285
|
+
*
|
|
1286
|
+
*
|
|
1287
|
+
* @param {string} databaseId
|
|
1288
|
+
* @param {string} collectionId
|
|
1289
|
+
* @param {string} key
|
|
1290
|
+
* @param {string} type
|
|
1291
|
+
* @param {string[]} attributes
|
|
1292
|
+
* @param {string[]} orders
|
|
1293
|
+
* @throws {AppwriteException}
|
|
1294
|
+
* @returns {Promise}
|
|
1295
|
+
*/
|
|
1296
|
+
async createIndex(databaseId: string, collectionId: string, key: string, type: string, attributes: string[], orders?: string[]): Promise<Models.Index> {
|
|
1297
|
+
if (typeof databaseId === 'undefined') {
|
|
1298
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
if (typeof collectionId === 'undefined') {
|
|
1302
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
if (typeof key === 'undefined') {
|
|
1306
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
if (typeof type === 'undefined') {
|
|
1310
|
+
throw new AppwriteException('Missing required parameter: "type"');
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
if (typeof attributes === 'undefined') {
|
|
1314
|
+
throw new AppwriteException('Missing required parameter: "attributes"');
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
1318
|
+
let payload: Payload = {};
|
|
1319
|
+
|
|
1320
|
+
if (typeof key !== 'undefined') {
|
|
1321
|
+
payload['key'] = key;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
if (typeof type !== 'undefined') {
|
|
1325
|
+
payload['type'] = type;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
if (typeof attributes !== 'undefined') {
|
|
1329
|
+
payload['attributes'] = attributes;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
if (typeof orders !== 'undefined') {
|
|
1333
|
+
payload['orders'] = orders;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
1337
|
+
return await this.client.call('post', uri, {
|
|
1338
|
+
'content-type': 'application/json',
|
|
1339
|
+
}, payload);
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
/**
|
|
1343
|
+
* Get Index
|
|
1344
|
+
*
|
|
1345
|
+
*
|
|
1346
|
+
* @param {string} databaseId
|
|
1347
|
+
* @param {string} collectionId
|
|
1348
|
+
* @param {string} key
|
|
1349
|
+
* @throws {AppwriteException}
|
|
1350
|
+
* @returns {Promise}
|
|
1351
|
+
*/
|
|
1352
|
+
async getIndex(databaseId: string, collectionId: string, key: string): Promise<Models.Index> {
|
|
1353
|
+
if (typeof databaseId === 'undefined') {
|
|
1354
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
if (typeof collectionId === 'undefined') {
|
|
1358
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
if (typeof key === 'undefined') {
|
|
1362
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
|
|
1366
|
+
let payload: Payload = {};
|
|
1367
|
+
|
|
1368
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
1369
|
+
return await this.client.call('get', uri, {
|
|
1370
|
+
'content-type': 'application/json',
|
|
1371
|
+
}, payload);
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
/**
|
|
1375
|
+
* Delete Index
|
|
1376
|
+
*
|
|
1377
|
+
*
|
|
1378
|
+
* @param {string} databaseId
|
|
1379
|
+
* @param {string} collectionId
|
|
1380
|
+
* @param {string} key
|
|
1381
|
+
* @throws {AppwriteException}
|
|
1382
|
+
* @returns {Promise}
|
|
1383
|
+
*/
|
|
1384
|
+
async deleteIndex(databaseId: string, collectionId: string, key: string): Promise<{}> {
|
|
1385
|
+
if (typeof databaseId === 'undefined') {
|
|
1386
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
if (typeof collectionId === 'undefined') {
|
|
1390
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
if (typeof key === 'undefined') {
|
|
1394
|
+
throw new AppwriteException('Missing required parameter: "key"');
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
|
|
1398
|
+
let payload: Payload = {};
|
|
1399
|
+
|
|
1400
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
1401
|
+
return await this.client.call('delete', uri, {
|
|
1402
|
+
'content-type': 'application/json',
|
|
1403
|
+
}, payload);
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
/**
|
|
1407
|
+
* List Collection Logs
|
|
1408
|
+
*
|
|
1409
|
+
* Get the collection activity logs list by its unique ID.
|
|
1410
|
+
*
|
|
1411
|
+
* @param {string} databaseId
|
|
1412
|
+
* @param {string} collectionId
|
|
1413
|
+
* @param {string[]} queries
|
|
1414
|
+
* @throws {AppwriteException}
|
|
1415
|
+
* @returns {Promise}
|
|
1416
|
+
*/
|
|
1417
|
+
async listCollectionLogs(databaseId: string, collectionId: string, queries?: string[]): Promise<Models.LogList> {
|
|
1418
|
+
if (typeof databaseId === 'undefined') {
|
|
1419
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
if (typeof collectionId === 'undefined') {
|
|
1423
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/logs'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
1427
|
+
let payload: Payload = {};
|
|
1428
|
+
|
|
1429
|
+
if (typeof queries !== 'undefined') {
|
|
1430
|
+
payload['queries'] = queries;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
1434
|
+
return await this.client.call('get', uri, {
|
|
1435
|
+
'content-type': 'application/json',
|
|
1436
|
+
}, payload);
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* Get usage stats for a collection
|
|
1441
|
+
*
|
|
1442
|
+
*
|
|
1443
|
+
* @param {string} databaseId
|
|
1444
|
+
* @param {string} collectionId
|
|
1445
|
+
* @param {string} range
|
|
1446
|
+
* @throws {AppwriteException}
|
|
1447
|
+
* @returns {Promise}
|
|
1448
|
+
*/
|
|
1449
|
+
async getCollectionUsage(databaseId: string, collectionId: string, range?: string): Promise<Models.UsageCollection> {
|
|
1450
|
+
if (typeof databaseId === 'undefined') {
|
|
1451
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
if (typeof collectionId === 'undefined') {
|
|
1455
|
+
throw new AppwriteException('Missing required parameter: "collectionId"');
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
let path = '/databases/{databaseId}/collections/{collectionId}/usage'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
|
|
1459
|
+
let payload: Payload = {};
|
|
1460
|
+
|
|
1461
|
+
if (typeof range !== 'undefined') {
|
|
1462
|
+
payload['range'] = range;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
1466
|
+
return await this.client.call('get', uri, {
|
|
1467
|
+
'content-type': 'application/json',
|
|
1468
|
+
}, payload);
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
/**
|
|
1472
|
+
* List Database Logs
|
|
1473
|
+
*
|
|
1474
|
+
* Get the database activity logs list by its unique ID.
|
|
1475
|
+
*
|
|
1476
|
+
* @param {string} databaseId
|
|
1477
|
+
* @param {string[]} queries
|
|
1478
|
+
* @throws {AppwriteException}
|
|
1479
|
+
* @returns {Promise}
|
|
1480
|
+
*/
|
|
1481
|
+
async listLogs(databaseId: string, queries?: string[]): Promise<Models.LogList> {
|
|
1482
|
+
if (typeof databaseId === 'undefined') {
|
|
1483
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
let path = '/databases/{databaseId}/logs'.replace('{databaseId}', databaseId);
|
|
1487
|
+
let payload: Payload = {};
|
|
1488
|
+
|
|
1489
|
+
if (typeof queries !== 'undefined') {
|
|
1490
|
+
payload['queries'] = queries;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
1494
|
+
return await this.client.call('get', uri, {
|
|
1495
|
+
'content-type': 'application/json',
|
|
1496
|
+
}, payload);
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
/**
|
|
1500
|
+
* Get usage stats for the database
|
|
1501
|
+
*
|
|
1502
|
+
*
|
|
1503
|
+
* @param {string} databaseId
|
|
1504
|
+
* @param {string} range
|
|
1505
|
+
* @throws {AppwriteException}
|
|
1506
|
+
* @returns {Promise}
|
|
1507
|
+
*/
|
|
1508
|
+
async getDatabaseUsage(databaseId: string, range?: string): Promise<Models.UsageDatabase> {
|
|
1509
|
+
if (typeof databaseId === 'undefined') {
|
|
1510
|
+
throw new AppwriteException('Missing required parameter: "databaseId"');
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
let path = '/databases/{databaseId}/usage'.replace('{databaseId}', databaseId);
|
|
1514
|
+
let payload: Payload = {};
|
|
1515
|
+
|
|
1516
|
+
if (typeof range !== 'undefined') {
|
|
1517
|
+
payload['range'] = range;
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
1521
|
+
return await this.client.call('get', uri, {
|
|
1522
|
+
'content-type': 'application/json',
|
|
1523
|
+
}, payload);
|
|
1524
|
+
}
|
|
1525
|
+
};
|