Added collection validation
This commit is contained in:
parent
44ee22eb3e
commit
3115a1f349
|
@ -14,6 +14,7 @@ use Database\Document;
|
|||
use Database\Validator\UID;
|
||||
use Database\Validator\Key;
|
||||
use Database\Validator\Structure;
|
||||
use Database\Validator\Collection;
|
||||
use Database\Validator\Authorization;
|
||||
use Database\Exception\Authorization as AuthorizationException;
|
||||
use Database\Exception\Structure as StructureException;
|
||||
|
@ -133,7 +134,7 @@ $utopia->post('/v1/database')
|
|||
->param('name', '', function () {return new Text(256);}, 'Collection name.')
|
||||
->param('read', [], function () {return new ArrayList(new Text(64));}, 'An array of read permissions. [Learn more about permissions and roles](/docs/permissions).', true)
|
||||
->param('write', [], function () {return new ArrayList(new Text(64));}, 'An array of write permissions. [Learn more about permissions and roles](/docs/permissions).', true)
|
||||
->param('rules', [], function () {return new ArrayList(new Text(64));}, 'Array of collection structure rules. Each rule define a collection field name, data type and validation', true)
|
||||
->param('rules', [], function () use ($projectDB) {return new ArrayList(new Collection($projectDB, [Database::SYSTEM_COLLECTION_RULES]));}, 'Array of collection structure rules. Each rule define a collection field name, data type and validation', true)
|
||||
->action(
|
||||
function($name, $read, $write, $rules) use ($response, $projectDB, &$output, $webhook, $audit, $isDev)
|
||||
{
|
||||
|
@ -182,16 +183,16 @@ $utopia->post('/v1/database')
|
|||
);
|
||||
|
||||
$utopia->put('/v1/database/:collectionId')
|
||||
->desc('Update Team')
|
||||
->desc('Update Collection')
|
||||
->label('scope', 'collections.write')
|
||||
->label('sdk.namespace', 'teams')
|
||||
->label('sdk.namespace', 'database')
|
||||
->label('sdk.method', 'updateCollection')
|
||||
->label('sdk.description', 'Update collection by its unique ID.')
|
||||
->param('collectionId', '', function () {return new UID();}, 'Collection unique ID.')
|
||||
->param('name', null, function () {return new Text(256);}, 'Collection name.')
|
||||
->param('read', [], function () {return new ArrayList(new Text(64));}, 'An array of read permissions. [Learn more about permissions and roles](/docs/permissions).', true)
|
||||
->param('write', [], function () {return new ArrayList(new Text(64));}, 'An array of write permissions. [Learn more about permissions and roles](/docs/permissions).', true)
|
||||
->param('rules', [], function () {return new ArrayList(new Text(64));}, 'Array of collection structure rules. Each rule define a collection field name, data type and validation', true)
|
||||
->param('rules', [], function () use ($projectDB) {return new ArrayList(new Collection($projectDB, [Database::SYSTEM_COLLECTION_RULES]));}, 'Array of collection structure rules. Each rule define a collection field name, data type and validation', true)
|
||||
->action(
|
||||
function($collectionId, $name, $read, $write, $rules) use ($response, $projectDB)
|
||||
{
|
||||
|
@ -227,7 +228,7 @@ $utopia->delete('/v1/database/:collectionId')
|
|||
->label('sdk.description', 'Delete a collection by its unique ID. Only users with write permissions have access to delete this resource.')
|
||||
->param('collectionId', '', function () {return new UID();}, 'Collection unique ID.')
|
||||
->action(
|
||||
function($collectionId) use ($response, $projectDB, $audit, $usage) {
|
||||
function($collectionId) use ($response, $projectDB, $audit) {
|
||||
$collection = $projectDB->getDocument($collectionId, false);
|
||||
|
||||
if(empty($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# [Appwrite SDK for Javascript](https://appwrite.io) [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Appwrite%20is%20a%20backend%20as%20a%20service%20for%20building%20web%20or%20mobile%20apps&url=http%3A%2F%2Fappwrite.io&via=appwrite_io&hashtags=JS%2Cjavascript%2Creactjs%2Cangular%2Cios%2Candroid)
|
||||
|
||||
![License](https://img.shields.io/github/license/appwrite/sdk-for-js.svg?v=1)
|
||||
![Version](https://img.shields.io/badge/api%20version-v1.15.47-blue.svg?v=1)
|
||||
![Version](https://img.shields.io/badge/api%20version-v0.0.0dev-blue.svg?v=1)
|
||||
|
||||
**WORK IN PROGRESS - NOT READY FOR USAGE**
|
||||
|
||||
|
@ -11,7 +11,7 @@ Appwrite backend as a service cuts up to 70% of the time and costs required for
|
|||
|
||||
![Appwrite](https://appwrite.io/v1/images/github.png)
|
||||
|
||||
**API Version: v1.15.47**
|
||||
**API Version: v0.0.0dev**
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -23,4 +23,4 @@ npm install appwrite --save
|
|||
|
||||
## License
|
||||
|
||||
Please see the [MIT license]() file for more information.
|
||||
Please see the [BSD 3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information.
|
|
@ -2,7 +2,7 @@
|
|||
window.Appwrite = function () {
|
||||
|
||||
let config = {
|
||||
endpoint: 'https://appwrite.io/v1',
|
||||
endpoint: 'https://appwrite.test/v1',
|
||||
project: '',
|
||||
key: '',
|
||||
locale: '',
|
||||
|
@ -21,6 +21,9 @@
|
|||
|
||||
/**
|
||||
* Set Project
|
||||
*
|
||||
* Your Appwrite project ID. You can find your project ID in your Appwrite
|
||||
\ * console project settings.
|
||||
*
|
||||
* @param value string
|
||||
*
|
||||
|
@ -37,6 +40,9 @@
|
|||
|
||||
/**
|
||||
* Set Key
|
||||
*
|
||||
* Your Appwrite project secret key. You can can create a new API key from
|
||||
\ * your Appwrite console API keys dashboard.
|
||||
*
|
||||
* @param value string
|
||||
*
|
||||
|
@ -1122,6 +1128,40 @@
|
|||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Update Team
|
||||
*
|
||||
* Update collection by its unique ID.
|
||||
*
|
||||
* @param {string} collectionId
|
||||
* @param {string} name
|
||||
* @param {array} read
|
||||
* @param {array} write
|
||||
* @param {array} rules
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
updateCollection: function(collectionId, name, read = [], write = [], rules = []) {
|
||||
if(collectionId === undefined) {
|
||||
throw new Error('Missing required parameter: "collectionId"');
|
||||
}
|
||||
|
||||
if(name === undefined) {
|
||||
throw new Error('Missing required parameter: "name"');
|
||||
}
|
||||
|
||||
let path = '/database/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId);
|
||||
|
||||
return http
|
||||
.put(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
'name': name,
|
||||
'read': read,
|
||||
'write': write,
|
||||
'rules': rules
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete Collection
|
||||
*
|
||||
|
@ -1239,43 +1279,276 @@
|
|||
}
|
||||
};
|
||||
|
||||
let teams = {
|
||||
let locale = {
|
||||
|
||||
/**
|
||||
* Update Team
|
||||
* Get User Locale
|
||||
*
|
||||
* Update team by its unique ID. Only team owners have write access for this
|
||||
* resource.
|
||||
* Get the current user location based on IP. Returns an object with user
|
||||
* country code, country name, continent name, continent code, ip address and
|
||||
* suggested currency. You can use the locale header to get the data in
|
||||
* supported language.
|
||||
*
|
||||
* @param {string} collectionId
|
||||
* @param {string} name
|
||||
* @param {array} read
|
||||
* @param {array} write
|
||||
* @param {array} rules
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
updateTeam: function(collectionId, name, read = [], write = [], rules = []) {
|
||||
if(collectionId === undefined) {
|
||||
throw new Error('Missing required parameter: "collectionId"');
|
||||
}
|
||||
|
||||
if(name === undefined) {
|
||||
throw new Error('Missing required parameter: "name"');
|
||||
}
|
||||
|
||||
let path = '/database/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId);
|
||||
getLocale: function() {
|
||||
let path = '/locale';
|
||||
|
||||
return http
|
||||
.put(path, {'Content-type': 'application/json'},
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
'name': name,
|
||||
'read': read,
|
||||
'write': write,
|
||||
'rules': rules
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* List Countries
|
||||
*
|
||||
* List of all countries. You can use the locale header to get the data in
|
||||
* supported language.
|
||||
*
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
getCountries: function() {
|
||||
let path = '/locale/countries';
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* List EU Countries
|
||||
*
|
||||
* List of all countries that are currently members of the EU. You can use the
|
||||
* locale header to get the data in supported language.
|
||||
*
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
getCountriesEU: function() {
|
||||
let path = '/locale/countries/eu';
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* List Countries Phone Codes
|
||||
*
|
||||
* List of all countries phone codes. You can use the locale header to get the
|
||||
* data in supported language.
|
||||
*
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
getCountriesPhones: function() {
|
||||
let path = '/locale/countries/phones';
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let storage = {
|
||||
|
||||
/**
|
||||
* List Files
|
||||
*
|
||||
* Get a list of all the user files. You can use the query params to filter
|
||||
* your results. On admin mode, this endpoint will return a list of all of the
|
||||
* project files. [Learn more about different API modes](/docs/modes).
|
||||
*
|
||||
* @param {string} search
|
||||
* @param {number} limit
|
||||
* @param {number} offset
|
||||
* @param {string} orderType
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
listFiles: function(search = '', limit = 25, offset = 0, orderType = 'ASC') {
|
||||
let path = '/storage/files';
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
'search': search,
|
||||
'limit': limit,
|
||||
'offset': offset,
|
||||
'orderType': orderType
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Create File
|
||||
*
|
||||
* Create a new file. The user who creates the file will automatically be
|
||||
* assigned to read and write access unless he has passed custom values for
|
||||
* read and write arguments.
|
||||
*
|
||||
* @param {File} files
|
||||
* @param {array} read
|
||||
* @param {array} write
|
||||
* @param {string} folderId
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
createFile: function(files, read = [], write = [], folderId = '') {
|
||||
if(files === undefined) {
|
||||
throw new Error('Missing required parameter: "files"');
|
||||
}
|
||||
|
||||
let path = '/storage/files';
|
||||
|
||||
return http
|
||||
.post(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
'files': files,
|
||||
'read': read,
|
||||
'write': write,
|
||||
'folderId': folderId
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Get File
|
||||
*
|
||||
* Get file by its unique ID. This endpoint response returns a JSON object
|
||||
* with the file metadata.
|
||||
*
|
||||
* @param {string} fileId
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
getFile: function(fileId) {
|
||||
if(fileId === undefined) {
|
||||
throw new Error('Missing required parameter: "fileId"');
|
||||
}
|
||||
|
||||
let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId);
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete File
|
||||
*
|
||||
* Delete a file by its unique ID. Only users with write permissions have
|
||||
* access to delete this resource.
|
||||
*
|
||||
* @param {string} fileId
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
deleteFile: function(fileId) {
|
||||
if(fileId === undefined) {
|
||||
throw new Error('Missing required parameter: "fileId"');
|
||||
}
|
||||
|
||||
let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId);
|
||||
|
||||
return http
|
||||
.delete(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Download File
|
||||
*
|
||||
* Get file content by its unique ID. The endpoint response return with a
|
||||
* 'Content-Disposition: attachment' header that tells the browser to start
|
||||
* downloading the file to user downloads directory.
|
||||
*
|
||||
* @param {string} fileId
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
getFileDownload: function(fileId) {
|
||||
if(fileId === undefined) {
|
||||
throw new Error('Missing required parameter: "fileId"');
|
||||
}
|
||||
|
||||
let path = '/storage/files/{fileId}/download'.replace(new RegExp('{fileId}', 'g'), fileId);
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Preview File
|
||||
*
|
||||
* Get file preview image. Currently, this method supports preview for image
|
||||
* files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
|
||||
* and spreadsheets will return file icon image. You can also pass query
|
||||
* string arguments for cutting and resizing your preview image.
|
||||
*
|
||||
* @param {string} fileId
|
||||
* @param {number} width
|
||||
* @param {number} height
|
||||
* @param {number} quality
|
||||
* @param {string} background
|
||||
* @param {string} output
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
getFilePreview: function(fileId, width = 0, height = 0, quality = 100, background = '', output = '') {
|
||||
if(fileId === undefined) {
|
||||
throw new Error('Missing required parameter: "fileId"');
|
||||
}
|
||||
|
||||
let path = '/storage/files/{fileId}/preview'.replace(new RegExp('{fileId}', 'g'), fileId);
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
'width': width,
|
||||
'height': height,
|
||||
'quality': quality,
|
||||
'background': background,
|
||||
'output': output
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* View File
|
||||
*
|
||||
* Get file content by its unique ID. This endpoint is similar to the download
|
||||
* method but returns with no 'Content-Disposition: attachment' header.
|
||||
*
|
||||
* @param {string} fileId
|
||||
* @param {string} as
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
getFileView: function(fileId, as = '') {
|
||||
if(fileId === undefined) {
|
||||
throw new Error('Missing required parameter: "fileId"');
|
||||
}
|
||||
|
||||
let path = '/storage/files/{fileId}/view'.replace(new RegExp('{fileId}', 'g'), fileId);
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
'as': as
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let teams = {
|
||||
|
||||
/**
|
||||
* List Teams
|
||||
*
|
||||
|
@ -1603,274 +1876,6 @@
|
|||
}
|
||||
};
|
||||
|
||||
let locale = {
|
||||
|
||||
/**
|
||||
* Get User Locale
|
||||
*
|
||||
* Get the current user location based on IP. Returns an object with user
|
||||
* country code, country name, continent name, continent code, ip address and
|
||||
* suggested currency. You can use the locale header to get the data in
|
||||
* supported language.
|
||||
*
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
get: function() {
|
||||
let path = '/locale';
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* List Countries
|
||||
*
|
||||
* List of all countries. You can use the locale header to get the data in
|
||||
* supported language.
|
||||
*
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
getCountries: function() {
|
||||
let path = '/locale/countries';
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* List EU Countries
|
||||
*
|
||||
* List of all countries that are currently members of the EU. You can use the
|
||||
* locale header to get the data in supported language.
|
||||
*
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
getCountriesEU: function() {
|
||||
let path = '/locale/countries/eu';
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* List Countries Phone Codes
|
||||
*
|
||||
* List of all countries phone codes. You can use the locale header to get the
|
||||
* data in supported language.
|
||||
*
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
getCountriesPhones: function() {
|
||||
let path = '/locale/countries/phones';
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let storage = {
|
||||
|
||||
/**
|
||||
* List Files
|
||||
*
|
||||
* Get a list of all the user files. You can use the query params to filter
|
||||
* your results. On admin mode, this endpoint will return a list of all of the
|
||||
* project files. [Learn more about different API modes](/docs/modes).
|
||||
*
|
||||
* @param {string} search
|
||||
* @param {number} limit
|
||||
* @param {number} offset
|
||||
* @param {string} orderType
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
listFiles: function(search = '', limit = 25, offset = 0, orderType = 'ASC') {
|
||||
let path = '/storage/files';
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
'search': search,
|
||||
'limit': limit,
|
||||
'offset': offset,
|
||||
'orderType': orderType
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Create File
|
||||
*
|
||||
* Create a new file. The user who creates the file will automatically be
|
||||
* assigned to read and write access unless he has passed custom values for
|
||||
* read and write arguments.
|
||||
*
|
||||
* @param {File} files
|
||||
* @param {array} read
|
||||
* @param {array} write
|
||||
* @param {string} folderId
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
createFile: function(files, read = [], write = [], folderId = '') {
|
||||
if(files === undefined) {
|
||||
throw new Error('Missing required parameter: "files"');
|
||||
}
|
||||
|
||||
let path = '/storage/files';
|
||||
|
||||
return http
|
||||
.post(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
'files': files,
|
||||
'read': read,
|
||||
'write': write,
|
||||
'folderId': folderId
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Get File
|
||||
*
|
||||
* Get file by its unique ID. This endpoint response returns a JSON object
|
||||
* with the file metadata.
|
||||
*
|
||||
* @param {string} fileId
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
getFile: function(fileId) {
|
||||
if(fileId === undefined) {
|
||||
throw new Error('Missing required parameter: "fileId"');
|
||||
}
|
||||
|
||||
let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId);
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete File
|
||||
*
|
||||
* Delete a file by its unique ID. Only users with write permissions have
|
||||
* access to delete this resource.
|
||||
*
|
||||
* @param {string} fileId
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
deleteFile: function(fileId) {
|
||||
if(fileId === undefined) {
|
||||
throw new Error('Missing required parameter: "fileId"');
|
||||
}
|
||||
|
||||
let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId);
|
||||
|
||||
return http
|
||||
.delete(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Download File
|
||||
*
|
||||
* Get file content by its unique ID. The endpoint response return with a
|
||||
* 'Content-Disposition: attachment' header that tells the browser to start
|
||||
* downloading the file to user downloads directory.
|
||||
*
|
||||
* @param {string} fileId
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
getFileDownload: function(fileId) {
|
||||
if(fileId === undefined) {
|
||||
throw new Error('Missing required parameter: "fileId"');
|
||||
}
|
||||
|
||||
let path = '/storage/files/{fileId}/download'.replace(new RegExp('{fileId}', 'g'), fileId);
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Preview File
|
||||
*
|
||||
* Get file preview image. Currently, this method supports preview for image
|
||||
* files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
|
||||
* and spreadsheets will return file icon image. You can also pass query
|
||||
* string arguments for cutting and resizing your preview image.
|
||||
*
|
||||
* @param {string} fileId
|
||||
* @param {number} width
|
||||
* @param {number} height
|
||||
* @param {number} quality
|
||||
* @param {string} background
|
||||
* @param {string} output
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
getFilePreview: function(fileId, width = 0, height = 0, quality = 100, background = '', output = '') {
|
||||
if(fileId === undefined) {
|
||||
throw new Error('Missing required parameter: "fileId"');
|
||||
}
|
||||
|
||||
let path = '/storage/files/{fileId}/preview'.replace(new RegExp('{fileId}', 'g'), fileId);
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
'width': width,
|
||||
'height': height,
|
||||
'quality': quality,
|
||||
'background': background,
|
||||
'output': output
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* View File
|
||||
*
|
||||
* Get file content by its unique ID. This endpoint is similar to the download
|
||||
* method but returns with no 'Content-Disposition: attachment' header.
|
||||
*
|
||||
* @param {string} fileId
|
||||
* @param {string} as
|
||||
* @throws {Error}
|
||||
* @return {Array}
|
||||
*/
|
||||
getFileView: function(fileId, as = '') {
|
||||
if(fileId === undefined) {
|
||||
throw new Error('Missing required parameter: "fileId"');
|
||||
}
|
||||
|
||||
let path = '/storage/files/{fileId}/view'.replace(new RegExp('{fileId}', 'g'), fileId);
|
||||
|
||||
return http
|
||||
.get(path, {'Content-type': 'application/json'},
|
||||
{
|
||||
'as': as
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let users = {
|
||||
|
||||
/**
|
||||
|
@ -2069,7 +2074,7 @@
|
|||
},
|
||||
|
||||
/**
|
||||
* Block User
|
||||
* Update user status
|
||||
*
|
||||
* Update user status by its unique ID.
|
||||
*
|
||||
|
@ -2107,9 +2112,9 @@
|
|||
auth: auth,
|
||||
avatars: avatars,
|
||||
database: database,
|
||||
teams: teams,
|
||||
locale: locale,
|
||||
storage: storage,
|
||||
teams: teams,
|
||||
users: users
|
||||
};
|
||||
};
|
||||
|
|
26
app/sdks/js/src/sdk.min.js
vendored
26
app/sdks/js/src/sdk.min.js
vendored
|
@ -1,4 +1,4 @@
|
|||
(function(window){window.Appwrite=function(){let config={endpoint:'https://appwrite.io/v1',project:'',key:'',locale:'',mode:'',};let setEndpoint=function(endpoint){config.endpoint=endpoint;return this};let setProject=function(value){http.addGlobalHeader('X-Appwrite-Project',value);config.project=value;return this};let setKey=function(value){http.addGlobalHeader('X-Appwrite-Key',value);config.key=value;return this};let setLocale=function(value){http.addGlobalHeader('X-Appwrite-Locale',value);config.locale=value;return this};let setMode=function(value){http.addGlobalHeader('X-Appwrite-Mode',value);config.mode=value;return this};let http=function(document){let globalParams=[],globalHeaders=[];let addParam=function(url,param,value){let a=document.createElement('a'),regex=/(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g;let match,str=[];a.href=url;param=encodeURIComponent(param);while(match=regex.exec(a.search))if(param!==match[1])str.push(match[1]+(match[2]?"="+match[2]:""));str.push(param+(value?"="+encodeURIComponent(value):""));a.search=str.join("&");return a.href};let buildQuery=function(params){let str=[];for(let p in params){if(params.hasOwnProperty(p)){str.push(encodeURIComponent(p)+"="+encodeURIComponent(params[p]))}}
|
||||
(function(window){window.Appwrite=function(){let config={endpoint:'https://appwrite.test/v1',project:'',key:'',locale:'',mode:'',};let setEndpoint=function(endpoint){config.endpoint=endpoint;return this};let setProject=function(value){http.addGlobalHeader('X-Appwrite-Project',value);config.project=value;return this};let setKey=function(value){http.addGlobalHeader('X-Appwrite-Key',value);config.key=value;return this};let setLocale=function(value){http.addGlobalHeader('X-Appwrite-Locale',value);config.locale=value;return this};let setMode=function(value){http.addGlobalHeader('X-Appwrite-Mode',value);config.mode=value;return this};let http=function(document){let globalParams=[],globalHeaders=[];let addParam=function(url,param,value){let a=document.createElement('a'),regex=/(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g;let match,str=[];a.href=url;param=encodeURIComponent(param);while(match=regex.exec(a.search))if(param!==match[1])str.push(match[1]+(match[2]?"="+match[2]:""));str.push(param+(value?"="+encodeURIComponent(value):""));a.search=str.join("&");return a.href};let buildQuery=function(params){let str=[];for(let p in params){if(params.hasOwnProperty(p)){str.push(encodeURIComponent(p)+"="+encodeURIComponent(params[p]))}}
|
||||
return str.join("&")};let addGlobalHeader=function(key,value){globalHeaders[key]={key:key.toLowerCase(),value:value.toLowerCase()}};let addGlobalParam=function(key,value){globalParams.push({key:key,value:value})};addGlobalHeader('x-sdk-version','appwrite:javascript:v1.0.0');addGlobalHeader('content-type','');let call=function(method,path,headers={},params={},progress=null){let i;path=config.endpoint+path;if(-1===['GET','POST','PUT','DELETE','TRACE','HEAD','OPTIONS','CONNECT','PATCH'].indexOf(method)){throw new Error('var method must contain a valid HTTP method name')}
|
||||
if(typeof path!=='string'){throw new Error('var path must be of type string')}
|
||||
if(typeof headers!=='object'){throw new Error('var headers must be of type object')}
|
||||
|
@ -45,7 +45,9 @@ let path='/avatars/qr';return http.get(path,{'Content-type':'application/json'},
|
|||
let path='/database';return http.post(path,{'Content-type':'application/json'},{'name':name,'read':read,'write':write,'rules':rules})},listDocuments:function(collectionId,filters=[],offset=0,limit=50,orderField='$uid',orderType='ASC',orderCast='string',search='',first=0,last=0){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||
let path='/database/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);return http.get(path,{'Content-type':'application/json'},{'filters':filters,'offset':offset,'limit':limit,'order-field':orderField,'order-type':orderType,'order-cast':orderCast,'search':search,'first':first,'last':last})},createDocument:function(collectionId,data,read=[],write=[],parentDocument='',parentProperty='',parentPropertyType='assign'){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||
if(data===undefined){throw new Error('Missing required parameter: "data"')}
|
||||
let path='/database/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);return http.post(path,{'Content-type':'application/json'},{'data':data,'read':read,'write':write,'parentDocument':parentDocument,'parentProperty':parentProperty,'parentPropertyType':parentPropertyType})},deleteCollection:function(collectionId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||
let path='/database/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);return http.post(path,{'Content-type':'application/json'},{'data':data,'read':read,'write':write,'parentDocument':parentDocument,'parentProperty':parentProperty,'parentPropertyType':parentPropertyType})},updateCollection:function(collectionId,name,read=[],write=[],rules=[]){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||
if(name===undefined){throw new Error('Missing required parameter: "name"')}
|
||||
let path='/database/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);return http.put(path,{'Content-type':'application/json'},{'name':name,'read':read,'write':write,'rules':rules})},deleteCollection:function(collectionId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||
let path='/database/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);return http.delete(path,{'Content-type':'application/json'},{})},getDocument:function(collectionId,documentId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||
if(documentId===undefined){throw new Error('Missing required parameter: "documentId"')}
|
||||
let path='/database/{collectionId}/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);return http.get(path,{'Content-type':'application/json'},{})},updateDocument:function(collectionId,documentId,data,read=[],write=[]){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||
|
@ -53,9 +55,13 @@ if(documentId===undefined){throw new Error('Missing required parameter: "documen
|
|||
if(data===undefined){throw new Error('Missing required parameter: "data"')}
|
||||
let path='/database/{collectionId}/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);return http.patch(path,{'Content-type':'application/json'},{'data':data,'read':read,'write':write})},deleteDocument:function(collectionId,documentId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||
if(documentId===undefined){throw new Error('Missing required parameter: "documentId"')}
|
||||
let path='/database/{collectionId}/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);return http.delete(path,{'Content-type':'application/json'},{})}};let teams={updateTeam:function(collectionId,name,read=[],write=[],rules=[]){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||
if(name===undefined){throw new Error('Missing required parameter: "name"')}
|
||||
let path='/database/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);return http.put(path,{'Content-type':'application/json'},{'name':name,'read':read,'write':write,'rules':rules})},listTeams:function(search='',limit=25,offset=0,orderType='ASC'){let path='/teams';return http.get(path,{'Content-type':'application/json'},{'search':search,'limit':limit,'offset':offset,'orderType':orderType})},createTeam:function(name,roles=["owner"]){if(name===undefined){throw new Error('Missing required parameter: "name"')}
|
||||
let path='/database/{collectionId}/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);return http.delete(path,{'Content-type':'application/json'},{})}};let locale={getLocale:function(){let path='/locale';return http.get(path,{'Content-type':'application/json'},{})},getCountries:function(){let path='/locale/countries';return http.get(path,{'Content-type':'application/json'},{})},getCountriesEU:function(){let path='/locale/countries/eu';return http.get(path,{'Content-type':'application/json'},{})},getCountriesPhones:function(){let path='/locale/countries/phones';return http.get(path,{'Content-type':'application/json'},{})}};let storage={listFiles:function(search='',limit=25,offset=0,orderType='ASC'){let path='/storage/files';return http.get(path,{'Content-type':'application/json'},{'search':search,'limit':limit,'offset':offset,'orderType':orderType})},createFile:function(files,read=[],write=[],folderId=''){if(files===undefined){throw new Error('Missing required parameter: "files"')}
|
||||
let path='/storage/files';return http.post(path,{'Content-type':'application/json'},{'files':files,'read':read,'write':write,'folderId':folderId})},getFile:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);return http.get(path,{'Content-type':'application/json'},{})},deleteFile:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);return http.delete(path,{'Content-type':'application/json'},{})},getFileDownload:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}/download'.replace(new RegExp('{fileId}','g'),fileId);return http.get(path,{'Content-type':'application/json'},{})},getFilePreview:function(fileId,width=0,height=0,quality=100,background='',output=''){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}/preview'.replace(new RegExp('{fileId}','g'),fileId);return http.get(path,{'Content-type':'application/json'},{'width':width,'height':height,'quality':quality,'background':background,'output':output})},getFileView:function(fileId,as=''){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}/view'.replace(new RegExp('{fileId}','g'),fileId);return http.get(path,{'Content-type':'application/json'},{'as':as})}};let teams={listTeams:function(search='',limit=25,offset=0,orderType='ASC'){let path='/teams';return http.get(path,{'Content-type':'application/json'},{'search':search,'limit':limit,'offset':offset,'orderType':orderType})},createTeam:function(name,roles=["owner"]){if(name===undefined){throw new Error('Missing required parameter: "name"')}
|
||||
let path='/teams';return http.post(path,{'Content-type':'application/json'},{'name':name,'roles':roles})},getTeam:function(teamId){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')}
|
||||
let path='/teams/{teamId}'.replace(new RegExp('{teamId}','g'),teamId);return http.get(path,{'Content-type':'application/json'},{})},updateTeam:function(teamId,name){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')}
|
||||
if(name===undefined){throw new Error('Missing required parameter: "name"')}
|
||||
|
@ -74,13 +80,7 @@ let path='/teams/{teamId}/memberships/{inviteId}/resend'.replace(new RegExp('{te
|
|||
if(inviteId===undefined){throw new Error('Missing required parameter: "inviteId"')}
|
||||
if(userId===undefined){throw new Error('Missing required parameter: "userId"')}
|
||||
if(secret===undefined){throw new Error('Missing required parameter: "secret"')}
|
||||
let path='/teams/{teamId}/memberships/{inviteId}/status'.replace(new RegExp('{teamId}','g'),teamId).replace(new RegExp('{inviteId}','g'),inviteId);return http.patch(path,{'Content-type':'application/json'},{'userId':userId,'secret':secret,'success':success,'failure':failure})}};let locale={get:function(){let path='/locale';return http.get(path,{'Content-type':'application/json'},{})},getCountries:function(){let path='/locale/countries';return http.get(path,{'Content-type':'application/json'},{})},getCountriesEU:function(){let path='/locale/countries/eu';return http.get(path,{'Content-type':'application/json'},{})},getCountriesPhones:function(){let path='/locale/countries/phones';return http.get(path,{'Content-type':'application/json'},{})}};let storage={listFiles:function(search='',limit=25,offset=0,orderType='ASC'){let path='/storage/files';return http.get(path,{'Content-type':'application/json'},{'search':search,'limit':limit,'offset':offset,'orderType':orderType})},createFile:function(files,read=[],write=[],folderId=''){if(files===undefined){throw new Error('Missing required parameter: "files"')}
|
||||
let path='/storage/files';return http.post(path,{'Content-type':'application/json'},{'files':files,'read':read,'write':write,'folderId':folderId})},getFile:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);return http.get(path,{'Content-type':'application/json'},{})},deleteFile:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);return http.delete(path,{'Content-type':'application/json'},{})},getFileDownload:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}/download'.replace(new RegExp('{fileId}','g'),fileId);return http.get(path,{'Content-type':'application/json'},{})},getFilePreview:function(fileId,width=0,height=0,quality=100,background='',output=''){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}/preview'.replace(new RegExp('{fileId}','g'),fileId);return http.get(path,{'Content-type':'application/json'},{'width':width,'height':height,'quality':quality,'background':background,'output':output})},getFileView:function(fileId,as=''){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"')}
|
||||
let path='/storage/files/{fileId}/view'.replace(new RegExp('{fileId}','g'),fileId);return http.get(path,{'Content-type':'application/json'},{'as':as})}};let users={listUsers:function(search='',limit=25,offset=0,orderType='ASC'){let path='/users';return http.get(path,{'Content-type':'application/json'},{'search':search,'limit':limit,'offset':offset,'orderType':orderType})},createUser:function(email,password,name=''){if(email===undefined){throw new Error('Missing required parameter: "email"')}
|
||||
let path='/teams/{teamId}/memberships/{inviteId}/status'.replace(new RegExp('{teamId}','g'),teamId).replace(new RegExp('{inviteId}','g'),inviteId);return http.patch(path,{'Content-type':'application/json'},{'userId':userId,'secret':secret,'success':success,'failure':failure})}};let users={listUsers:function(search='',limit=25,offset=0,orderType='ASC'){let path='/users';return http.get(path,{'Content-type':'application/json'},{'search':search,'limit':limit,'offset':offset,'orderType':orderType})},createUser:function(email,password,name=''){if(email===undefined){throw new Error('Missing required parameter: "email"')}
|
||||
if(password===undefined){throw new Error('Missing required parameter: "password"')}
|
||||
let path='/users';return http.post(path,{'Content-type':'application/json'},{'email':email,'password':password,'name':name})},getUser:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"')}
|
||||
let path='/users/{userId}'.replace(new RegExp('{userId}','g'),userId);return http.get(path,{'Content-type':'application/json'},{})},getUserLogs:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"')}
|
||||
|
@ -91,4 +91,4 @@ let path='/users/{userId}/sessions'.replace(new RegExp('{userId}','g'),userId);r
|
|||
if(sessionId===undefined){throw new Error('Missing required parameter: "sessionId"')}
|
||||
let path='/users/{userId}/sessions/:session'.replace(new RegExp('{userId}','g'),userId);return http.delete(path,{'Content-type':'application/json'},{'sessionId':sessionId})},updateUserStatus:function(userId,status){if(userId===undefined){throw new Error('Missing required parameter: "userId"')}
|
||||
if(status===undefined){throw new Error('Missing required parameter: "status"')}
|
||||
let path='/users/{userId}/status'.replace(new RegExp('{userId}','g'),userId);return http.patch(path,{'Content-type':'application/json'},{'status':status})}};return{setEndpoint:setEndpoint,setProject:setProject,setKey:setKey,setLocale:setLocale,setMode:setMode,account:account,auth:auth,avatars:avatars,database:database,teams:teams,locale:locale,storage:storage,users:users}}})(window)
|
||||
let path='/users/{userId}/status'.replace(new RegExp('{userId}','g'),userId);return http.patch(path,{'Content-type':'application/json'},{'status':status})}};return{setEndpoint:setEndpoint,setProject:setProject,setKey:setKey,setLocale:setLocale,setMode:setMode,account:account,auth:auth,avatars:avatars,database:database,locale:locale,storage:storage,teams:teams,users:users}}})(window)
|
|
@ -1,7 +1,7 @@
|
|||
# [Appwrite SDK for PHP](https://appwrite.io) [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Appwrite%20is%20a%20backend%20as%20a%20service%20for%20building%20web%20or%20mobile%20apps&url=http%3A%2F%2Fappwrite.io&via=appwrite_io&hashtags=JS%2Cjavascript%2Creactjs%2Cangular%2Cios%2Candroid)
|
||||
|
||||
![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?v=1)
|
||||
![Version](https://img.shields.io/badge/api%20version-v1.15.47-blue.svg?v=1)
|
||||
![Version](https://img.shields.io/badge/api%20version-v0.0.0dev-blue.svg?v=1)
|
||||
|
||||
**WORK IN PROGRESS - NOT READY FOR USAGE**
|
||||
|
||||
|
@ -11,7 +11,7 @@ Appwrite backend as a service cuts up to 70% of the time and costs required for
|
|||
|
||||
![Appwrite](https://appwrite.io/v1/images/github.png)
|
||||
|
||||
**API Version: v1.15.47**
|
||||
**API Version: v0.0.0dev**
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -23,4 +23,4 @@ composer require appwrite/appwrite
|
|||
|
||||
## License
|
||||
|
||||
Please see the [MIT license]() file for more information.
|
||||
Please see the [BSD 3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information.
|
|
@ -2,7 +2,7 @@
|
|||
"name": "appwrite/appwrite",
|
||||
"description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"license": "BSD 3-Clause",
|
||||
"support": {
|
||||
"url": "https://appwrite.io/support",
|
||||
"email": "team@appwrite.io"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
## Get Account
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/account
|
||||
GET https://appwrite.test/v1/account
|
||||
```
|
||||
|
||||
** Get currently logged in user data as JSON object. **
|
||||
|
@ -11,7 +11,7 @@ GET https://appwrite.io/v1/account
|
|||
## Delete Account
|
||||
|
||||
```http request
|
||||
DELETE https://appwrite.io/v1/account
|
||||
DELETE https://appwrite.test/v1/account
|
||||
```
|
||||
|
||||
** Delete currently logged in user account. **
|
||||
|
@ -19,7 +19,7 @@ DELETE https://appwrite.io/v1/account
|
|||
## Update Account Email
|
||||
|
||||
```http request
|
||||
PATCH https://appwrite.io/v1/account/email
|
||||
PATCH https://appwrite.test/v1/account/email
|
||||
```
|
||||
|
||||
** Update currently logged in user account email address. After changing user address, user confirmation status is being reset and a new confirmation mail is sent. For security measures, user password is required to complete this request. **
|
||||
|
@ -34,7 +34,7 @@ PATCH https://appwrite.io/v1/account/email
|
|||
## Update Account Name
|
||||
|
||||
```http request
|
||||
PATCH https://appwrite.io/v1/account/name
|
||||
PATCH https://appwrite.test/v1/account/name
|
||||
```
|
||||
|
||||
** Update currently logged in user account name. **
|
||||
|
@ -48,7 +48,7 @@ PATCH https://appwrite.io/v1/account/name
|
|||
## Update Account Password
|
||||
|
||||
```http request
|
||||
PATCH https://appwrite.io/v1/account/password
|
||||
PATCH https://appwrite.test/v1/account/password
|
||||
```
|
||||
|
||||
** Update currently logged in user password. For validation, user is required to pass the password twice. **
|
||||
|
@ -63,7 +63,7 @@ PATCH https://appwrite.io/v1/account/password
|
|||
## Get Account Preferences
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/account/prefs
|
||||
GET https://appwrite.test/v1/account/prefs
|
||||
```
|
||||
|
||||
** Get currently logged in user preferences key-value object. **
|
||||
|
@ -71,7 +71,7 @@ GET https://appwrite.io/v1/account/prefs
|
|||
## Update Account Prefs
|
||||
|
||||
```http request
|
||||
PATCH https://appwrite.io/v1/account/prefs
|
||||
PATCH https://appwrite.test/v1/account/prefs
|
||||
```
|
||||
|
||||
** Update currently logged in user account preferences. You can pass only the specific settings you wish to update. **
|
||||
|
@ -85,7 +85,7 @@ PATCH https://appwrite.io/v1/account/prefs
|
|||
## Get Account Security Log
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/account/security
|
||||
GET https://appwrite.test/v1/account/security
|
||||
```
|
||||
|
||||
** Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log. **
|
||||
|
@ -93,7 +93,7 @@ GET https://appwrite.io/v1/account/security
|
|||
## Get Account Active Sessions
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/account/sessions
|
||||
GET https://appwrite.test/v1/account/sessions
|
||||
```
|
||||
|
||||
** Get currently logged in user list of active sessions across different devices. **
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
## Login User
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/auth/login
|
||||
POST https://appwrite.test/v1/auth/login
|
||||
```
|
||||
|
||||
** Allow the user to login into his account by providing a valid email and password combination. Use the success and failure arguments to provide a redirect URL\'s back to your app when login is completed.
|
||||
|
@ -24,7 +24,7 @@ When not using the success or failure redirect arguments this endpoint will resu
|
|||
## Logout Current Session
|
||||
|
||||
```http request
|
||||
DELETE https://appwrite.io/v1/auth/logout
|
||||
DELETE https://appwrite.test/v1/auth/logout
|
||||
```
|
||||
|
||||
** Use this endpoint to log out the currently logged in user from his account. When succeed this endpoint will delete the user session and remove the session secret cookie. **
|
||||
|
@ -32,7 +32,7 @@ DELETE https://appwrite.io/v1/auth/logout
|
|||
## Logout Specific Session
|
||||
|
||||
```http request
|
||||
DELETE https://appwrite.io/v1/auth/logout/{userId}
|
||||
DELETE https://appwrite.test/v1/auth/logout/{userId}
|
||||
```
|
||||
|
||||
** Use this endpoint to log out the currently logged in user from all his account sessions across all his different devices. When using the option id argument, only the session unique ID provider will be deleted. **
|
||||
|
@ -46,7 +46,7 @@ DELETE https://appwrite.io/v1/auth/logout/{userId}
|
|||
## Password Recovery
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/auth/recovery
|
||||
POST https://appwrite.test/v1/auth/recovery
|
||||
```
|
||||
|
||||
** Sends the user an email with a temporary secret token for password reset. When the user clicks the confirmation link he is redirected back to your app password reset redirect URL with a secret token and email address values attached to the URL query string. Use the query string params to submit a request to the /auth/password/reset endpoint to complete the process. **
|
||||
|
@ -61,7 +61,7 @@ POST https://appwrite.io/v1/auth/recovery
|
|||
## Password Reset
|
||||
|
||||
```http request
|
||||
PUT https://appwrite.io/v1/auth/recovery/reset
|
||||
PUT https://appwrite.test/v1/auth/recovery/reset
|
||||
```
|
||||
|
||||
** Use this endpoint to complete the user account password reset. Both the **userId** and **token** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the /auth/recovery endpoint.
|
||||
|
@ -80,7 +80,7 @@ Please notice that in order to avoid a [Redirect Attacks](https://github.com/OWA
|
|||
## Register User
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/auth/register
|
||||
POST https://appwrite.test/v1/auth/register
|
||||
```
|
||||
|
||||
** Use this endpoint to allow a new user to register an account in your project. Use the success and failure URL's to redirect users back to your application after signup completes.
|
||||
|
@ -105,7 +105,7 @@ When not using the success or failure redirect arguments this endpoint will resu
|
|||
## Confirm User
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/auth/register/confirm
|
||||
POST https://appwrite.test/v1/auth/register/confirm
|
||||
```
|
||||
|
||||
** Use this endpoint to complete the confirmation of the user account email address. Both the **userId** and **token** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the /auth/register endpoint. **
|
||||
|
@ -120,7 +120,7 @@ POST https://appwrite.io/v1/auth/register/confirm
|
|||
## Resend Confirmation
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/auth/register/confirm/resend
|
||||
POST https://appwrite.test/v1/auth/register/confirm/resend
|
||||
```
|
||||
|
||||
** This endpoint allows the user to request your app to resend him his email confirmation message. The redirect arguments acts the same way as in /auth/register endpoint.
|
||||
|
@ -136,7 +136,7 @@ Please notice that in order to avoid a [Redirect Attacks](https://github.com/OWA
|
|||
## OAuth Callback
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/oauth/callback/{provider}/{projectId}
|
||||
GET https://appwrite.test/v1/oauth/callback/{provider}/{projectId}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
@ -151,7 +151,7 @@ GET https://appwrite.io/v1/oauth/callback/{provider}/{projectId}
|
|||
## OAuth Login
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/oauth/{provider}
|
||||
GET https://appwrite.test/v1/oauth/{provider}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
## Get Browser Icon
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/avatars/browsers/{code}
|
||||
GET https://appwrite.test/v1/avatars/browsers/{code}
|
||||
```
|
||||
|
||||
** You can use this endpoint to show different browser icons to your users, The code argument receives the browser code as appear in your user /account/sessions endpoint. Use width, height and quality arguments to change the output settings. **
|
||||
|
@ -20,7 +20,7 @@ GET https://appwrite.io/v1/avatars/browsers/{code}
|
|||
## Get Credit Card Icon
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/avatars/credit-cards/{code}
|
||||
GET https://appwrite.test/v1/avatars/credit-cards/{code}
|
||||
```
|
||||
|
||||
** Need to display your users with your billing method or there payment methods? The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings. **
|
||||
|
@ -37,7 +37,7 @@ GET https://appwrite.io/v1/avatars/credit-cards/{code}
|
|||
## Get Favicon
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/avatars/favicon
|
||||
GET https://appwrite.test/v1/avatars/favicon
|
||||
```
|
||||
|
||||
** Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote website URL. **
|
||||
|
@ -51,7 +51,7 @@ GET https://appwrite.io/v1/avatars/favicon
|
|||
## Get Country Flag
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/avatars/flags/{code}
|
||||
GET https://appwrite.test/v1/avatars/flags/{code}
|
||||
```
|
||||
|
||||
** You can use this endpoint to show different country flags icons to your users, The code argument receives the a 2 letter country code. Use width, height and quality arguments to change the output settings. **
|
||||
|
@ -68,7 +68,7 @@ GET https://appwrite.io/v1/avatars/flags/{code}
|
|||
## Text to QR Generator
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/avatars/qr
|
||||
GET https://appwrite.test/v1/avatars/qr
|
||||
```
|
||||
|
||||
** Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image. **
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
## List Collections
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/database
|
||||
GET https://appwrite.test/v1/database
|
||||
```
|
||||
|
||||
** Get a list of all the user collections. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project collections. [Learn more about different API modes](/docs/modes). **
|
||||
|
@ -20,7 +20,7 @@ GET https://appwrite.io/v1/database
|
|||
## Create Collection
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/database
|
||||
POST https://appwrite.test/v1/database
|
||||
```
|
||||
|
||||
** Create a new Collection. **
|
||||
|
@ -37,7 +37,7 @@ POST https://appwrite.io/v1/database
|
|||
## List Documents
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/database/{collectionId}
|
||||
GET https://appwrite.test/v1/database/{collectionId}
|
||||
```
|
||||
|
||||
** Get a list of all the user documents. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project documents. [Learn more about different API modes](/docs/modes). **
|
||||
|
@ -60,7 +60,7 @@ GET https://appwrite.io/v1/database/{collectionId}
|
|||
## Create Document
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/database/{collectionId}
|
||||
POST https://appwrite.test/v1/database/{collectionId}
|
||||
```
|
||||
|
||||
** Create a new Document. **
|
||||
|
@ -77,10 +77,28 @@ POST https://appwrite.io/v1/database/{collectionId}
|
|||
| parentProperty | string | Parent document property name. Use when you want your new document to be a child of a parent document. | |
|
||||
| parentPropertyType | string | Parent document property connection type. You can set this value to **assign**, **append** or **prepend**, default value is assign. Use when you want your new document to be a child of a parent document. | assign |
|
||||
|
||||
## Update Team
|
||||
|
||||
```http request
|
||||
PUT https://appwrite.test/v1/database/{collectionId}
|
||||
```
|
||||
|
||||
** Update collection by its unique ID. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| collectionId | string | **Required** Collection unique ID. | |
|
||||
| name | string | Collection name. | |
|
||||
| read | array | An array of read permissions. [Learn more about permissions and roles](/docs/permissions). | [] |
|
||||
| write | array | An array of write permissions. [Learn more about permissions and roles](/docs/permissions). | [] |
|
||||
| rules | array | Array of collection structure rules. Each rule define a collection field name, data type and validation | [] |
|
||||
|
||||
## Delete Collection
|
||||
|
||||
```http request
|
||||
DELETE https://appwrite.io/v1/database/{collectionId}
|
||||
DELETE https://appwrite.test/v1/database/{collectionId}
|
||||
```
|
||||
|
||||
** Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. **
|
||||
|
@ -94,7 +112,7 @@ DELETE https://appwrite.io/v1/database/{collectionId}
|
|||
## Get Document
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/database/{collectionId}/{documentId}
|
||||
GET https://appwrite.test/v1/database/{collectionId}/{documentId}
|
||||
```
|
||||
|
||||
** Get document by its unique ID. This endpoint response returns a JSON object with the document data. **
|
||||
|
@ -109,7 +127,7 @@ GET https://appwrite.io/v1/database/{collectionId}/{documentId}
|
|||
## Update Document
|
||||
|
||||
```http request
|
||||
PATCH https://appwrite.io/v1/database/{collectionId}/{documentId}
|
||||
PATCH https://appwrite.test/v1/database/{collectionId}/{documentId}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
@ -125,7 +143,7 @@ PATCH https://appwrite.io/v1/database/{collectionId}/{documentId}
|
|||
## Delete Document
|
||||
|
||||
```http request
|
||||
DELETE https://appwrite.io/v1/database/{collectionId}/{documentId}
|
||||
DELETE https://appwrite.test/v1/database/{collectionId}/{documentId}
|
||||
```
|
||||
|
||||
** Delete document by its unique ID. This endpoint deletes only the parent documents, his attributes and relations to other documents. Child documents **will not** be deleted. **
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
## Get User Locale
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/locale
|
||||
GET https://appwrite.test/v1/locale
|
||||
```
|
||||
|
||||
** Get the current user location based on IP. Returns an object with user country code, country name, continent name, continent code, ip address and suggested currency. You can use the locale header to get the data in supported language. **
|
||||
|
@ -11,7 +11,7 @@ GET https://appwrite.io/v1/locale
|
|||
## List Countries
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/locale/countries
|
||||
GET https://appwrite.test/v1/locale/countries
|
||||
```
|
||||
|
||||
** List of all countries. You can use the locale header to get the data in supported language. **
|
||||
|
@ -19,7 +19,7 @@ GET https://appwrite.io/v1/locale/countries
|
|||
## List EU Countries
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/locale/countries/eu
|
||||
GET https://appwrite.test/v1/locale/countries/eu
|
||||
```
|
||||
|
||||
** List of all countries that are currently members of the EU. You can use the locale header to get the data in supported language. **
|
||||
|
@ -27,7 +27,7 @@ GET https://appwrite.io/v1/locale/countries/eu
|
|||
## List Countries Phone Codes
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/locale/countries/phones
|
||||
GET https://appwrite.test/v1/locale/countries/phones
|
||||
```
|
||||
|
||||
** List of all countries phone codes. You can use the locale header to get the data in supported language. **
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
## List Files
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/storage/files
|
||||
GET https://appwrite.test/v1/storage/files
|
||||
```
|
||||
|
||||
** Get a list of all the user files. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project files. [Learn more about different API modes](/docs/modes). **
|
||||
|
@ -20,7 +20,7 @@ GET https://appwrite.io/v1/storage/files
|
|||
## Create File
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/storage/files
|
||||
POST https://appwrite.test/v1/storage/files
|
||||
```
|
||||
|
||||
** Create a new file. The user who creates the file will automatically be assigned to read and write access unless he has passed custom values for read and write arguments. **
|
||||
|
@ -37,7 +37,7 @@ POST https://appwrite.io/v1/storage/files
|
|||
## Get File
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/storage/files/{fileId}
|
||||
GET https://appwrite.test/v1/storage/files/{fileId}
|
||||
```
|
||||
|
||||
** Get file by its unique ID. This endpoint response returns a JSON object with the file metadata. **
|
||||
|
@ -51,7 +51,7 @@ GET https://appwrite.io/v1/storage/files/{fileId}
|
|||
## Delete File
|
||||
|
||||
```http request
|
||||
DELETE https://appwrite.io/v1/storage/files/{fileId}
|
||||
DELETE https://appwrite.test/v1/storage/files/{fileId}
|
||||
```
|
||||
|
||||
** Delete a file by its unique ID. Only users with write permissions have access to delete this resource. **
|
||||
|
@ -65,7 +65,7 @@ DELETE https://appwrite.io/v1/storage/files/{fileId}
|
|||
## Download File
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/storage/files/{fileId}/download
|
||||
GET https://appwrite.test/v1/storage/files/{fileId}/download
|
||||
```
|
||||
|
||||
** Get file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. **
|
||||
|
@ -79,7 +79,7 @@ GET https://appwrite.io/v1/storage/files/{fileId}/download
|
|||
## Preview File
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/storage/files/{fileId}/preview
|
||||
GET https://appwrite.test/v1/storage/files/{fileId}/preview
|
||||
```
|
||||
|
||||
** Get file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets will return file icon image. You can also pass query string arguments for cutting and resizing your preview image. **
|
||||
|
@ -98,7 +98,7 @@ GET https://appwrite.io/v1/storage/files/{fileId}/preview
|
|||
## View File
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/storage/files/{fileId}/view
|
||||
GET https://appwrite.test/v1/storage/files/{fileId}/view
|
||||
```
|
||||
|
||||
** Get file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header. **
|
||||
|
|
|
@ -1,27 +1,9 @@
|
|||
# Teams Service
|
||||
|
||||
## Update Team
|
||||
|
||||
```http request
|
||||
PUT https://appwrite.io/v1/database/{collectionId}
|
||||
```
|
||||
|
||||
** Update team by its unique ID. Only team owners have write access for this resource. **
|
||||
|
||||
### Parameters
|
||||
|
||||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| collectionId | string | **Required** Collection unique ID. | |
|
||||
| name | string | Collection name. | |
|
||||
| read | array | An array of read permissions. [Learn more about permissions and roles](/docs/permissions). | [] |
|
||||
| write | array | An array of write permissions. [Learn more about permissions and roles](/docs/permissions). | [] |
|
||||
| rules | array | Array of collection structure rules. Each rule define a collection field name, data type and validation | [] |
|
||||
|
||||
## List Teams
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/teams
|
||||
GET https://appwrite.test/v1/teams
|
||||
```
|
||||
|
||||
** Get a list of all the current user teams. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project teams. [Learn more about different API modes](/docs/modes). **
|
||||
|
@ -38,7 +20,7 @@ GET https://appwrite.io/v1/teams
|
|||
## Create Team
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/teams
|
||||
POST https://appwrite.test/v1/teams
|
||||
```
|
||||
|
||||
** Create a new team. The user who creates the team will automatically be assigned as the owner of the team. The team owner can invite new members, who will be able add new owners and update or delete the team from your project. **
|
||||
|
@ -53,7 +35,7 @@ POST https://appwrite.io/v1/teams
|
|||
## Get Team
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/teams/{teamId}
|
||||
GET https://appwrite.test/v1/teams/{teamId}
|
||||
```
|
||||
|
||||
** Get team by its unique ID. All team members have read access for this resource. **
|
||||
|
@ -67,7 +49,7 @@ GET https://appwrite.io/v1/teams/{teamId}
|
|||
## Update Team
|
||||
|
||||
```http request
|
||||
PUT https://appwrite.io/v1/teams/{teamId}
|
||||
PUT https://appwrite.test/v1/teams/{teamId}
|
||||
```
|
||||
|
||||
** Update team by its unique ID. Only team owners have write access for this resource. **
|
||||
|
@ -82,7 +64,7 @@ PUT https://appwrite.io/v1/teams/{teamId}
|
|||
## Delete Team
|
||||
|
||||
```http request
|
||||
DELETE https://appwrite.io/v1/teams/{teamId}
|
||||
DELETE https://appwrite.test/v1/teams/{teamId}
|
||||
```
|
||||
|
||||
** Delete team by its unique ID. Only team owners have write access for this resource. **
|
||||
|
@ -96,7 +78,7 @@ DELETE https://appwrite.io/v1/teams/{teamId}
|
|||
## Get Team Members
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/teams/{teamId}/members
|
||||
GET https://appwrite.test/v1/teams/{teamId}/members
|
||||
```
|
||||
|
||||
** Get team members by the team unique ID. All team members have read access for this list of resources. **
|
||||
|
@ -110,7 +92,7 @@ GET https://appwrite.io/v1/teams/{teamId}/members
|
|||
## Create Team Membership
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/teams/{teamId}/memberships
|
||||
POST https://appwrite.test/v1/teams/{teamId}/memberships
|
||||
```
|
||||
|
||||
** Use this endpoint to invite a new member to your team. An email with a link to join the team will be sent to the new member email address. If member doesn't exists in the project it will be automatically created.
|
||||
|
@ -132,7 +114,7 @@ Please notice that in order to avoid a [Redirect Attacks](https://github.com/OWA
|
|||
## Delete Team Membership
|
||||
|
||||
```http request
|
||||
DELETE https://appwrite.io/v1/teams/{teamId}/memberships/{inviteId}
|
||||
DELETE https://appwrite.test/v1/teams/{teamId}/memberships/{inviteId}
|
||||
```
|
||||
|
||||
** This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. **
|
||||
|
@ -147,7 +129,7 @@ DELETE https://appwrite.io/v1/teams/{teamId}/memberships/{inviteId}
|
|||
## Create Team Membership (Resend Invitation Email)
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/teams/{teamId}/memberships/{inviteId}/resend
|
||||
POST https://appwrite.test/v1/teams/{teamId}/memberships/{inviteId}/resend
|
||||
```
|
||||
|
||||
** Use this endpoint to resend your invitation email for a user to join a team. **
|
||||
|
@ -163,7 +145,7 @@ POST https://appwrite.io/v1/teams/{teamId}/memberships/{inviteId}/resend
|
|||
## Update Team Membership Status
|
||||
|
||||
```http request
|
||||
PATCH https://appwrite.io/v1/teams/{teamId}/memberships/{inviteId}/status
|
||||
PATCH https://appwrite.test/v1/teams/{teamId}/memberships/{inviteId}/status
|
||||
```
|
||||
|
||||
** Use this endpoint to let user accept an invitation to join a team after he is being redirect back to your app from the invitation email. Use the success and failure URL's to redirect users back to your application after the request completes.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
## List Users
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/users
|
||||
GET https://appwrite.test/v1/users
|
||||
```
|
||||
|
||||
** Get a list of all the project users. You can use the query params to filter your results. **
|
||||
|
@ -20,7 +20,7 @@ GET https://appwrite.io/v1/users
|
|||
## Create User
|
||||
|
||||
```http request
|
||||
POST https://appwrite.io/v1/users
|
||||
POST https://appwrite.test/v1/users
|
||||
```
|
||||
|
||||
** Create a new user. **
|
||||
|
@ -36,7 +36,7 @@ POST https://appwrite.io/v1/users
|
|||
## Get User
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/users/{userId}
|
||||
GET https://appwrite.test/v1/users/{userId}
|
||||
```
|
||||
|
||||
** Get user by its unique ID. **
|
||||
|
@ -50,7 +50,7 @@ GET https://appwrite.io/v1/users/{userId}
|
|||
## Get User Logs
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/users/{userId}/logs
|
||||
GET https://appwrite.test/v1/users/{userId}/logs
|
||||
```
|
||||
|
||||
** Get user activity logs list by its unique ID. **
|
||||
|
@ -64,7 +64,7 @@ GET https://appwrite.io/v1/users/{userId}/logs
|
|||
## Get User Prefs
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/users/{userId}/prefs
|
||||
GET https://appwrite.test/v1/users/{userId}/prefs
|
||||
```
|
||||
|
||||
** Get user preferences by its unique ID. **
|
||||
|
@ -78,7 +78,7 @@ GET https://appwrite.io/v1/users/{userId}/prefs
|
|||
## Get User Sessions
|
||||
|
||||
```http request
|
||||
GET https://appwrite.io/v1/users/{userId}/sessions
|
||||
GET https://appwrite.test/v1/users/{userId}/sessions
|
||||
```
|
||||
|
||||
** Get user sessions list by its unique ID. **
|
||||
|
@ -92,7 +92,7 @@ GET https://appwrite.io/v1/users/{userId}/sessions
|
|||
## Delete User Sessions
|
||||
|
||||
```http request
|
||||
DELETE https://appwrite.io/v1/users/{userId}/sessions
|
||||
DELETE https://appwrite.test/v1/users/{userId}/sessions
|
||||
```
|
||||
|
||||
** Delete all user sessions by its unique ID. **
|
||||
|
@ -106,7 +106,7 @@ DELETE https://appwrite.io/v1/users/{userId}/sessions
|
|||
## Delete User Session
|
||||
|
||||
```http request
|
||||
DELETE https://appwrite.io/v1/users/{userId}/sessions/:session
|
||||
DELETE https://appwrite.test/v1/users/{userId}/sessions/:session
|
||||
```
|
||||
|
||||
** Delete user sessions by its unique ID. **
|
||||
|
@ -118,10 +118,10 @@ DELETE https://appwrite.io/v1/users/{userId}/sessions/:session
|
|||
| userId | string | **Required** User unique ID. | |
|
||||
| sessionId | string | User unique session ID. | |
|
||||
|
||||
## Block User
|
||||
## Update user status
|
||||
|
||||
```http request
|
||||
PATCH https://appwrite.io/v1/users/{userId}/status
|
||||
PATCH https://appwrite.test/v1/users/{userId}/status
|
||||
```
|
||||
|
||||
** Update user status by its unique ID. **
|
||||
|
|
|
@ -28,7 +28,7 @@ class Client
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $endpoint = 'https://appwrite.io/v1';
|
||||
protected $endpoint = 'https://appwrite.test/v1';
|
||||
|
||||
/**
|
||||
* Global Headers
|
||||
|
@ -50,6 +50,8 @@ class Client
|
|||
/**
|
||||
* Set Project
|
||||
*
|
||||
* Your Appwrite project ID. You can find your project ID in your Appwrite console project settings.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return Client
|
||||
|
@ -64,6 +66,8 @@ class Client
|
|||
/**
|
||||
* Set Key
|
||||
*
|
||||
* Your Appwrite project secret key. You can can create a new API key from your Appwrite console API keys dashboard.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return Client
|
||||
|
|
|
@ -134,6 +134,33 @@ class Database extends Service
|
|||
], $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Team
|
||||
*
|
||||
* Update collection by its unique ID.
|
||||
*
|
||||
* @param string $collectionId
|
||||
* @param string $name
|
||||
* @param array $read
|
||||
* @param array $write
|
||||
* @param array $rules
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
public function updateCollection($collectionId, $name, $read = [], $write = [], $rules = [])
|
||||
{
|
||||
$path = str_replace(['{collectionId}'], [$collectionId], '/database/{collectionId}');
|
||||
$params = [];
|
||||
|
||||
$params['name'] = $name;
|
||||
$params['read'] = $read;
|
||||
$params['write'] = $write;
|
||||
$params['rules'] = $rules;
|
||||
|
||||
return $this->client->call(Client::METHOD_PUT, $path, [
|
||||
], $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Collection
|
||||
*
|
||||
|
|
|
@ -19,7 +19,7 @@ class Locale extends Service
|
|||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
public function get()
|
||||
public function getLocale()
|
||||
{
|
||||
$path = str_replace([], [], '/locale');
|
||||
$params = [];
|
||||
|
|
|
@ -8,34 +8,6 @@ use Appwrite\Service;
|
|||
|
||||
class Teams extends Service
|
||||
{
|
||||
/**
|
||||
* Update Team
|
||||
*
|
||||
* Update team by its unique ID. Only team owners have write access for this
|
||||
* resource.
|
||||
*
|
||||
* @param string $collectionId
|
||||
* @param string $name
|
||||
* @param array $read
|
||||
* @param array $write
|
||||
* @param array $rules
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
public function updateTeam($collectionId, $name, $read = [], $write = [], $rules = [])
|
||||
{
|
||||
$path = str_replace(['{collectionId}'], [$collectionId], '/database/{collectionId}');
|
||||
$params = [];
|
||||
|
||||
$params['name'] = $name;
|
||||
$params['read'] = $read;
|
||||
$params['write'] = $write;
|
||||
$params['rules'] = $rules;
|
||||
|
||||
return $this->client->call(Client::METHOD_PUT, $path, [
|
||||
], $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* List Teams
|
||||
*
|
||||
|
|
|
@ -176,7 +176,7 @@ class Users extends Service
|
|||
}
|
||||
|
||||
/**
|
||||
* Block User
|
||||
* Update user status
|
||||
*
|
||||
* Update user status by its unique ID.
|
||||
*
|
||||
|
|
|
@ -33,8 +33,8 @@ $cli
|
|||
|
||||
Console::success('Fetching API Spec');
|
||||
|
||||
$spec = getSSLPage('https://appwrite.test/v1/open-api-2.json');
|
||||
$spec = getSSLPage('https://appwrite.io/v1/open-api-2.json');
|
||||
$spec = getSSLPage('https://appwrite.test/v1/open-api-2.json');
|
||||
|
||||
$clients = [
|
||||
'php' => [
|
||||
|
@ -54,7 +54,7 @@ $cli
|
|||
'gitUserName' => 'appwrite',
|
||||
],
|
||||
'node' => [
|
||||
'version' => 'v1.0.13',
|
||||
'version' => 'v1.0.15',
|
||||
'result' => __DIR__ . '/../sdks/node/',
|
||||
'gitURL' => 'https://github.com/appwrite/sdk-for-node.git',
|
||||
'gitRepo' => 'git@github.com:appwrite/sdk-for-node.git',
|
||||
|
|
|
@ -2,60 +2,50 @@
|
|||
|
||||
namespace Database\Validator;
|
||||
|
||||
use Database\Database;
|
||||
use Database\Document;
|
||||
use Utopia\Validator;
|
||||
|
||||
class Collection extends Validator
|
||||
class Collection extends Structure
|
||||
{
|
||||
/**
|
||||
* @var Document
|
||||
* @var string
|
||||
*/
|
||||
protected $whitelist = [];
|
||||
protected $message = 'Unknown Error';
|
||||
|
||||
/**
|
||||
* Structure constructor.
|
||||
*
|
||||
* @param array $whitelist
|
||||
* @var array
|
||||
*/
|
||||
public function __construct(array $whitelist)
|
||||
protected $collections = [];
|
||||
|
||||
/**
|
||||
* @param Database $database
|
||||
* @param array $collections
|
||||
*/
|
||||
public function __construct(Database $database, array $collections)
|
||||
{
|
||||
$this->whitelist = $whitelist;
|
||||
$this->collections = $collections;
|
||||
|
||||
return parent::__construct($database);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Description
|
||||
*
|
||||
* Returns validator description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
if(count($this->whitelist) <= 1) {
|
||||
return 'Collection must be of type: [' . implode(',', $this->whitelist) . ']';
|
||||
}
|
||||
|
||||
return 'Collection must be one of this types: [' . implode(',', $this->whitelist) . ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* Is valid
|
||||
*
|
||||
* Returns true if valid or false if not.
|
||||
*
|
||||
* @param array $document
|
||||
* @param Document $document
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid($document) /* @var $document Document */
|
||||
public function isValid($document)
|
||||
{
|
||||
if(!$document instanceof Document) {
|
||||
$document = (is_array($document)) ? new Document($document) : $document;
|
||||
|
||||
if(is_null($document->getCollection())) {
|
||||
$this->message = 'Missing collection attribute $collection';
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!in_array($document->getCollection(), $this->whitelist)) {
|
||||
if(!in_array($document->getCollection(), $this->collections)) {
|
||||
$this->message = 'Collection is not allowed';
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return parent::isValid($document);
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Validator;
|
||||
|
||||
use Utopia\Validator;
|
||||
|
||||
class Role extends Validator
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $message = 'Unknown Error';
|
||||
|
||||
/**
|
||||
* Get Description
|
||||
*
|
||||
* Returns validator description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is valid
|
||||
*
|
||||
* Returns true if valid or false if not.
|
||||
*
|
||||
* @param array $value
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
/*
|
||||
[
|
||||
'$collection' => self::SYSTEM_COLLECTION_RULES,
|
||||
'label' => 'Platforms',
|
||||
'key' => 'platforms',
|
||||
'type' => 'document',
|
||||
'default' => [],
|
||||
'required' => false,
|
||||
'array' => true,
|
||||
'options' => [
|
||||
'$collection' => self::SYSTEM_COLLECTION_OPTIONS,
|
||||
'whitelist' => [self::SYSTEM_COLLECTION_PLATFORMS]
|
||||
],
|
||||
],
|
||||
*/
|
||||
|
||||
if(!is_array($value) && !empty($value)) {
|
||||
$this->message = 'Invalid permissions data structure';
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($value as $action => $roles) {
|
||||
if(!in_array($action, ['read', 'write'])) {
|
||||
$this->message = 'Unknown action ("' . $action. '")';
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($roles as $role) {
|
||||
if(!is_string($role)) {
|
||||
$this->message = 'Permissions role must be a string';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -131,7 +131,7 @@ class Structure extends Validator
|
|||
return false;
|
||||
}
|
||||
|
||||
$collection = $this->database->getDocument($document->getCollection());
|
||||
$collection = $this->getCollection($document->getCollection());
|
||||
|
||||
if(is_null($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
|
||||
$this->message = 'Collection not found';
|
||||
|
@ -189,9 +189,7 @@ class Structure extends Validator
|
|||
$validator = new Key();
|
||||
break;
|
||||
case 'document':
|
||||
$validator = new Validator\Multiple(
|
||||
new Collection((isset($ruleOptions['whitelist'])) ? $ruleOptions['whitelist'] : []),
|
||||
new self($this->database));
|
||||
$validator = new Collection($this->database, (isset($ruleOptions['whitelist'])) ? $ruleOptions['whitelist'] : []);
|
||||
$value = $document->getAttribute($key);
|
||||
break;
|
||||
}
|
||||
|
@ -248,4 +246,9 @@ class Structure extends Validator
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getCollection($uid)
|
||||
{
|
||||
return $this->database->getDocument($uid);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue