mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Changed status code to 201 for endpoints creating new resources
This commit is contained in:
+8
-3
@@ -550,7 +550,8 @@ $utopia->get('/v1/open-api-2.json')
|
||||
'email' => APP_EMAIL_TEAM,
|
||||
],
|
||||
'license' => [
|
||||
'name' => 'MIT',
|
||||
'name' => 'BSD 3-Clause',
|
||||
'url' => 'https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE',
|
||||
],
|
||||
],
|
||||
'host' => $domain,
|
||||
@@ -562,13 +563,13 @@ $utopia->get('/v1/open-api-2.json')
|
||||
'Project' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Project',
|
||||
'description' => '',
|
||||
'description' => 'Your Appwrite project ID. You can find your project ID in your Appwrite console project settings.',
|
||||
'in' => 'header',
|
||||
],
|
||||
'Key' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Key',
|
||||
'description' => '',
|
||||
'description' => 'Your Appwrite project secret key. You can can create a new API key from your Appwrite console API keys dashboard.',
|
||||
'in' => 'header',
|
||||
],
|
||||
'Locale' => [
|
||||
@@ -639,6 +640,10 @@ $utopia->get('/v1/open-api-2.json')
|
||||
),
|
||||
),
|
||||
),
|
||||
'externalDocs' => [
|
||||
'description' => 'Full API docs, specs and tutorials',
|
||||
'url' => APP_PROTOCOL . '://' . $domain . '/docs'
|
||||
]
|
||||
];
|
||||
|
||||
foreach ($utopia->getRoutes() as $key => $method) {
|
||||
|
||||
@@ -4,6 +4,7 @@ global $utopia, $register, $request, $response, $webhook, $audit, $projectDB;
|
||||
|
||||
use Utopia\App;
|
||||
use Utopia\Exception;
|
||||
use Utopia\Response;
|
||||
use Utopia\Validator\Range;
|
||||
use Utopia\Validator\WhiteList;
|
||||
use Utopia\Validator\Text;
|
||||
@@ -173,7 +174,10 @@ $utopia->post('/v1/database')
|
||||
/**
|
||||
* View
|
||||
*/
|
||||
$response->json($data);
|
||||
$response
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->json($data)
|
||||
;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -181,8 +185,8 @@ $utopia->put('/v1/database/:collectionId')
|
||||
->desc('Update Team')
|
||||
->label('scope', 'collections.write')
|
||||
->label('sdk.namespace', 'teams')
|
||||
->label('sdk.method', 'updateTeam')
|
||||
->label('sdk.description', 'Update team by its unique ID. Only team owners have write access for this resource.')
|
||||
->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)
|
||||
@@ -461,7 +465,10 @@ $utopia->post('/v1/database/:collectionId')
|
||||
/**
|
||||
* View
|
||||
*/
|
||||
$response->json($data);
|
||||
$response
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->json($data)
|
||||
;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -166,6 +166,10 @@ $utopia->get('/v1/health/stats')
|
||||
|
||||
$response
|
||||
->json([
|
||||
'server' => [
|
||||
'name' => 'nginx',
|
||||
'version' => shell_exec('nginx -v 2>&1'),
|
||||
],
|
||||
'storage' => [
|
||||
'used' => $device->human($device->getDirectorySize($device->getRoot() . '/')),
|
||||
'partitionTotal' => $device->human($device->getPartitionTotalSpace()),
|
||||
|
||||
@@ -10,7 +10,7 @@ $utopia->get('/v1/locale')
|
||||
->desc('Get User Locale')
|
||||
->label('scope', 'locale.read')
|
||||
->label('sdk.namespace', 'locale')
|
||||
->label('sdk.method', 'get')
|
||||
->label('sdk.method', 'getLocale')
|
||||
->label('sdk.description', '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.')
|
||||
->action(
|
||||
function() use ($response, $request, $utopia)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
global $utopia, $request, $response, $register, $user, $consoleDB, $projectDB, $providers;
|
||||
|
||||
use Utopia\Exception;
|
||||
use Utopia\Response;
|
||||
use Utopia\Validator\ArrayList;
|
||||
use Utopia\Validator\Text;
|
||||
use Utopia\Validator\WhiteList;
|
||||
@@ -286,7 +287,10 @@ $utopia->post('/v1/projects')
|
||||
|
||||
$consoleDB->createNamespace($project->getUid());
|
||||
|
||||
$response->json($project->getArrayCopy());
|
||||
$response
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->json($project->getArrayCopy())
|
||||
;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -527,7 +531,10 @@ $utopia->post('/v1/projects/:projectId/webhooks')
|
||||
throw new Exception('Failed saving project to DB', 500);
|
||||
}
|
||||
|
||||
$response->json($webhook->getArrayCopy());
|
||||
$response
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->json($webhook->getArrayCopy())
|
||||
;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -703,7 +710,10 @@ $utopia->post('/v1/projects/:projectId/keys')
|
||||
throw new Exception('Failed saving project to DB', 500);
|
||||
}
|
||||
|
||||
$response->json($key->getArrayCopy());
|
||||
$response
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->json($key->getArrayCopy())
|
||||
;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -917,7 +927,10 @@ $utopia->post('/v1/projects/:projectId/tasks')
|
||||
ResqueScheduler::enqueueAt($next, 'v1-tasks', 'TasksV1', $task->getArrayCopy());
|
||||
}
|
||||
|
||||
$response->json($task->getArrayCopy());
|
||||
$response
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->json($task->getArrayCopy())
|
||||
;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1117,7 +1130,10 @@ $utopia->post('/v1/projects/:projectId/platforms')
|
||||
throw new Exception('Failed saving project to DB', 500);
|
||||
}
|
||||
|
||||
$response->json($platform->getArrayCopy());
|
||||
$response
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->json($platform->getArrayCopy())
|
||||
;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
global $utopia, $request, $response, $register, $user, $audit, $usage, $project, $projectDB;
|
||||
|
||||
use Utopia\Exception;
|
||||
use Utopia\Response;
|
||||
use Utopia\Validator\ArrayList;
|
||||
use Utopia\Validator\WhiteList;
|
||||
use Utopia\Validator\Range;
|
||||
@@ -527,7 +528,10 @@ $utopia->post('/v1/storage/files')
|
||||
$list[] = $file->getArrayCopy();
|
||||
}
|
||||
|
||||
$response->json($list);
|
||||
$response
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->json($list)
|
||||
;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
global $utopia, $register, $request, $response, $projectDB, $project, $user, $audit, $mode;
|
||||
|
||||
use Utopia\Exception;
|
||||
use Utopia\Response;
|
||||
use Utopia\Validator\Email;
|
||||
use Utopia\Validator\Text;
|
||||
use Utopia\Validator\Host;
|
||||
@@ -174,7 +175,10 @@ $utopia->post('/v1/teams')
|
||||
}
|
||||
}
|
||||
|
||||
$response->json($team->getArrayCopy());
|
||||
$response
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->json($team->getArrayCopy())
|
||||
;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -385,7 +389,9 @@ $utopia->post('/v1/teams/:teamId/memberships')
|
||||
->setParam('event', 'auth.invite')
|
||||
;
|
||||
|
||||
$response->noContent();
|
||||
$response
|
||||
//->setStatusCode(Response::STATUS_CODE_CREATED) TODO change response of this endpoint
|
||||
->noContent();
|
||||
}
|
||||
);
|
||||
|
||||
@@ -462,7 +468,10 @@ $utopia->post('/v1/teams/:teamId/memberships/:inviteId/resend')
|
||||
->setParam('event', 'auth.invite.resend')
|
||||
;
|
||||
|
||||
$response->noContent();
|
||||
$response
|
||||
// ->setStatusCode(Response::STATUS_CODE_CREATED) TODO change response of this endpoint
|
||||
->noContent()
|
||||
;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
+29
-26
@@ -5,6 +5,7 @@ global $utopia, $response, $projectDB;
|
||||
use Auth\Auth;
|
||||
use Auth\Validator\Password;
|
||||
use Utopia\Exception;
|
||||
use Utopia\Response;
|
||||
use Utopia\Validator\WhiteList;
|
||||
use Utopia\Validator\Email;
|
||||
use Utopia\Validator\Text;
|
||||
@@ -318,37 +319,39 @@ $utopia->post('/v1/users')
|
||||
'name' => $name,
|
||||
]);
|
||||
|
||||
$response->json(array_merge($user->getArrayCopy([
|
||||
'$uid',
|
||||
'status',
|
||||
'email',
|
||||
'registration',
|
||||
'confirm',
|
||||
'name',
|
||||
'oauthBitbucket',
|
||||
'oauthBitBucketAccessToken',
|
||||
'oauthFacebook',
|
||||
'oauthFacebookAccessToken',
|
||||
'oauthGithub',
|
||||
'oauthGithubAccessToken',
|
||||
'oauthGitlab',
|
||||
'oauthGitlabAccessToken',
|
||||
'oauthGoogle',
|
||||
'oauthGoogleAccessToken',
|
||||
'oauthInstagram',
|
||||
'oauthInstagramAccessToken',
|
||||
'oauthLinkedin',
|
||||
'oauthLinkedinAccessToken',
|
||||
'oauthMicrosoft',
|
||||
'oauthMicrosoftAccessToken',
|
||||
'oauthTwitter',
|
||||
'oauthTwitterAccessToken',
|
||||
$response
|
||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||
->json(array_merge($user->getArrayCopy([
|
||||
'$uid',
|
||||
'status',
|
||||
'email',
|
||||
'registration',
|
||||
'confirm',
|
||||
'name',
|
||||
'oauthBitbucket',
|
||||
'oauthBitBucketAccessToken',
|
||||
'oauthFacebook',
|
||||
'oauthFacebookAccessToken',
|
||||
'oauthGithub',
|
||||
'oauthGithubAccessToken',
|
||||
'oauthGitlab',
|
||||
'oauthGitlabAccessToken',
|
||||
'oauthGoogle',
|
||||
'oauthGoogleAccessToken',
|
||||
'oauthInstagram',
|
||||
'oauthInstagramAccessToken',
|
||||
'oauthLinkedin',
|
||||
'oauthLinkedinAccessToken',
|
||||
'oauthMicrosoft',
|
||||
'oauthMicrosoftAccessToken',
|
||||
'oauthTwitter',
|
||||
'oauthTwitterAccessToken',
|
||||
]), ['roles' => Authorization::getRoles()]));
|
||||
}
|
||||
);
|
||||
|
||||
$utopia->patch('/v1/users/:userId/status')
|
||||
->desc('Block User')
|
||||
->desc('Update user status')
|
||||
->label('scope', 'users.write')
|
||||
->label('sdk.namespace', 'users')
|
||||
->label('sdk.method', 'updateUserStatus')
|
||||
|
||||
@@ -126,8 +126,6 @@ class Structure extends Validator
|
||||
|
||||
$this->id = $document->getUid();
|
||||
|
||||
$original = (!empty($this->id)) ? $this->database->getDocument($document->getUid()) : new Document([]);
|
||||
|
||||
if(is_null($document->getCollection())) {
|
||||
$this->message = 'Missing collection attribute $collection';
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user