mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Separate response models for list repos
This commit is contained in:
@@ -722,7 +722,11 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories')
|
||||
responses: [
|
||||
new SDKResponse(
|
||||
code: Response::STATUS_CODE_OK,
|
||||
model: Response::MODEL_PROVIDER_REPOSITORY_LIST,
|
||||
model: Response::MODEL_RUNTIME_PROVIDER_REPOSITORY_LIST,
|
||||
),
|
||||
new SDKResponse(
|
||||
code: Response::STATUS_CODE_OK,
|
||||
model: Response::MODEL_FRAMEWORK_PROVIDER_REPOSITORY_LIST,
|
||||
)
|
||||
]
|
||||
))
|
||||
@@ -847,9 +851,9 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories')
|
||||
}, $repos);
|
||||
|
||||
$response->dynamic(new Document([
|
||||
'providerRepositories' => $repos,
|
||||
$type === 'framework' ? 'frameworkProviderRepositories' : 'runtimeProviderRepositories' => $repos,
|
||||
'total' => \count($repos),
|
||||
]), Response::MODEL_PROVIDER_REPOSITORY_LIST);
|
||||
]), ($type === 'framework') ? Response::MODEL_FRAMEWORK_PROVIDER_REPOSITORY_LIST : Response::MODEL_RUNTIME_PROVIDER_REPOSITORY_LIST);
|
||||
});
|
||||
|
||||
App::post('/v1/vcs/github/installations/:installationId/providerRepositories')
|
||||
@@ -864,7 +868,7 @@ App::post('/v1/vcs/github/installations/:installationId/providerRepositories')
|
||||
responses: [
|
||||
new SDKResponse(
|
||||
code: Response::STATUS_CODE_OK,
|
||||
model: Response::MODEL_PROVIDER_REPOSITORY,
|
||||
model: Response::MODEL_RUNTIME_PROVIDER_REPOSITORY,
|
||||
)
|
||||
]
|
||||
))
|
||||
@@ -961,7 +965,7 @@ App::post('/v1/vcs/github/installations/:installationId/providerRepositories')
|
||||
$repository['organization'] = $installation->getAttribute('organization', '');
|
||||
$repository['provider'] = $installation->getAttribute('provider', '');
|
||||
|
||||
$response->dynamic(new Document($repository), Response::MODEL_PROVIDER_REPOSITORY);
|
||||
$response->dynamic(new Document($repository), Response::MODEL_RUNTIME_PROVIDER_REPOSITORY);
|
||||
});
|
||||
|
||||
App::get('/v1/vcs/github/installations/:installationId/providerRepositories/:providerRepositoryId')
|
||||
@@ -976,7 +980,7 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories/:pro
|
||||
responses: [
|
||||
new SDKResponse(
|
||||
code: Response::STATUS_CODE_OK,
|
||||
model: Response::MODEL_PROVIDER_REPOSITORY,
|
||||
model: Response::MODEL_RUNTIME_PROVIDER_REPOSITORY,
|
||||
)
|
||||
]
|
||||
))
|
||||
@@ -1015,7 +1019,7 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories/:pro
|
||||
$repository['organization'] = $installation->getAttribute('organization', '');
|
||||
$repository['provider'] = $installation->getAttribute('provider', '');
|
||||
|
||||
$response->dynamic(new Document($repository), Response::MODEL_PROVIDER_REPOSITORY);
|
||||
$response->dynamic(new Document($repository), Response::MODEL_RUNTIME_PROVIDER_REPOSITORY);
|
||||
});
|
||||
|
||||
App::get('/v1/vcs/github/installations/:installationId/providerRepositories/:providerRepositoryId/branches')
|
||||
|
||||
@@ -46,6 +46,7 @@ use Appwrite\Utopia\Response\Model\File;
|
||||
use Appwrite\Utopia\Response\Model\Framework;
|
||||
use Appwrite\Utopia\Response\Model\FrameworkAdapter;
|
||||
use Appwrite\Utopia\Response\Model\FrameworkDetection;
|
||||
use Appwrite\Utopia\Response\Model\FrameworkProviderRepository;
|
||||
use Appwrite\Utopia\Response\Model\Func;
|
||||
use Appwrite\Utopia\Response\Model\Headers;
|
||||
use Appwrite\Utopia\Response\Model\HealthAntivirus;
|
||||
@@ -82,10 +83,10 @@ use Appwrite\Utopia\Response\Model\Platform;
|
||||
use Appwrite\Utopia\Response\Model\Preferences;
|
||||
use Appwrite\Utopia\Response\Model\Project;
|
||||
use Appwrite\Utopia\Response\Model\Provider;
|
||||
use Appwrite\Utopia\Response\Model\ProviderRepository;
|
||||
use Appwrite\Utopia\Response\Model\Rule;
|
||||
use Appwrite\Utopia\Response\Model\Runtime;
|
||||
use Appwrite\Utopia\Response\Model\RuntimeDetection;
|
||||
use Appwrite\Utopia\Response\Model\RuntimeProviderRepository;
|
||||
use Appwrite\Utopia\Response\Model\Session;
|
||||
use Appwrite\Utopia\Response\Model\Site;
|
||||
use Appwrite\Utopia\Response\Model\Specification;
|
||||
@@ -246,8 +247,10 @@ class Response extends SwooleResponse
|
||||
// VCS
|
||||
public const MODEL_INSTALLATION = 'installation';
|
||||
public const MODEL_INSTALLATION_LIST = 'installationList';
|
||||
public const MODEL_PROVIDER_REPOSITORY = 'providerRepository';
|
||||
public const MODEL_PROVIDER_REPOSITORY_LIST = 'providerRepositoryList';
|
||||
public const MODEL_FRAMEWORK_PROVIDER_REPOSITORY = 'frameworkProviderRepository';
|
||||
public const MODEL_FRAMEWORK_PROVIDER_REPOSITORY_LIST = 'frameworkProviderRepositoryList';
|
||||
public const MODEL_RUNTIME_PROVIDER_REPOSITORY = 'runtimeProviderRepository';
|
||||
public const MODEL_RUNTIME_PROVIDER_REPOSITORY_LIST = 'runtimeProviderRepositoryList';
|
||||
public const MODEL_BRANCH = 'branch';
|
||||
public const MODEL_BRANCH_LIST = 'branchList';
|
||||
public const MODEL_FRAMEWORK_DETECTION = 'frameworkDetection';
|
||||
@@ -377,7 +380,8 @@ class Response extends SwooleResponse
|
||||
->setModel(new BaseList('Functions List', self::MODEL_FUNCTION_LIST, 'functions', self::MODEL_FUNCTION))
|
||||
->setModel(new BaseList('Function Templates List', self::MODEL_TEMPLATE_FUNCTION_LIST, 'templates', self::MODEL_TEMPLATE_FUNCTION))
|
||||
->setModel(new BaseList('Installations List', self::MODEL_INSTALLATION_LIST, 'installations', self::MODEL_INSTALLATION))
|
||||
->setModel(new BaseList('Provider Repositories List', self::MODEL_PROVIDER_REPOSITORY_LIST, 'providerRepositories', self::MODEL_PROVIDER_REPOSITORY))
|
||||
->setModel(new BaseList('Framework Provider Repositories List', self::MODEL_FRAMEWORK_PROVIDER_REPOSITORY_LIST, 'frameworkProviderRepositories', self::MODEL_FRAMEWORK_PROVIDER_REPOSITORY))
|
||||
->setModel(new BaseList('Runtime Provider Repositories List', self::MODEL_RUNTIME_PROVIDER_REPOSITORY_LIST, 'runtimeProviderRepositories', self::MODEL_RUNTIME_PROVIDER_REPOSITORY))
|
||||
->setModel(new BaseList('Branches List', self::MODEL_BRANCH_LIST, 'branches', self::MODEL_BRANCH))
|
||||
->setModel(new BaseList('Frameworks List', self::MODEL_FRAMEWORK_LIST, 'frameworks', self::MODEL_FRAMEWORK))
|
||||
->setModel(new BaseList('Runtimes List', self::MODEL_RUNTIME_LIST, 'runtimes', self::MODEL_RUNTIME))
|
||||
@@ -454,7 +458,8 @@ class Response extends SwooleResponse
|
||||
->setModel(new TemplateRuntime())
|
||||
->setModel(new TemplateVariable())
|
||||
->setModel(new Installation())
|
||||
->setModel(new ProviderRepository())
|
||||
->setModel(new FrameworkProviderRepository())
|
||||
->setModel(new RuntimeProviderRepository())
|
||||
->setModel(new FrameworkDetection())
|
||||
->setModel(new RuntimeDetection())
|
||||
->setModel(new VcsContent())
|
||||
|
||||
+3
-9
@@ -5,7 +5,7 @@ namespace Appwrite\Utopia\Response\Model;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class ProviderRepository extends Model
|
||||
class FrameworkProviderRepository extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
@@ -41,12 +41,6 @@ class ProviderRepository extends Model
|
||||
'default' => false,
|
||||
'example' => true,
|
||||
])
|
||||
->addRule('runtime', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Auto-detected runtime suggestion. Empty if getting response of getRuntime().',
|
||||
'default' => '',
|
||||
'example' => 'node',
|
||||
])
|
||||
->addRule('framework', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Auto-detected framework suggestion. Empty if getting response of getFramework().',
|
||||
@@ -69,7 +63,7 @@ class ProviderRepository extends Model
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'ProviderRepository';
|
||||
return 'FrameworkProviderRepository';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,6 +73,6 @@ class ProviderRepository extends Model
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_PROVIDER_REPOSITORY;
|
||||
return Response::MODEL_FRAMEWORK_PROVIDER_REPOSITORY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class RuntimeProviderRepository extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->addRule('id', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'VCS (Version Control System) repository ID.',
|
||||
'default' => '',
|
||||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('name', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'VCS (Version Control System) repository name.',
|
||||
'default' => '',
|
||||
'example' => 'appwrite',
|
||||
])
|
||||
->addRule('organization', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'VCS (Version Control System) organization name',
|
||||
'default' => [],
|
||||
'example' => 'appwrite',
|
||||
'array' => false,
|
||||
])
|
||||
->addRule('provider', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'VCS (Version Control System) provider name.',
|
||||
'default' => '',
|
||||
'example' => 'github',
|
||||
])
|
||||
->addRule('private', [
|
||||
'type' => self::TYPE_BOOLEAN,
|
||||
'description' => 'Is VCS (Version Control System) repository private?',
|
||||
'default' => false,
|
||||
'example' => true,
|
||||
])
|
||||
->addRule('runtime', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Auto-detected runtime suggestion. Empty if getting response of getRuntime().',
|
||||
'default' => '',
|
||||
'example' => 'node',
|
||||
])
|
||||
->addRule('pushedAt', [
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => 'Last commit date in ISO 8601 format.',
|
||||
'default' => APP_DATABASE_ATTRIBUTE_DATETIME,
|
||||
'example' => APP_DATABASE_ATTRIBUTE_DATETIME,
|
||||
'array' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'RuntimeProviderRepository';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_RUNTIME_PROVIDER_REPOSITORY;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user