fix: make variableId optional in createProjectVariable endpoint

This commit is contained in:
My Name
2026-04-05 18:23:58 -04:00
parent 9ac686ae31
commit 2cd91f509b
@@ -43,7 +43,7 @@ class Create extends Base
namespace: 'project',
group: 'variables',
name: 'createVariable',
description: <<<EOT
description: <<<'EOT'
Create a new project environment variable. These variables can be accessed by all functions and sites in the project.
EOT,
auth: [AuthType::ADMIN, AuthType::KEY],
@@ -51,13 +51,13 @@ class Create extends Base
new SDKResponse(
code: Response::STATUS_CODE_CREATED,
model: Response::MODEL_VARIABLE,
)
),
],
))
->param('variableId', '', fn (Database $dbForProject) => new CustomId(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'Variable ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', false, ['dbForProject'])
->param('key', null, new Text(Database::LENGTH_KEY), 'Variable key. Max length: ' . Database::LENGTH_KEY . ' chars.')
->param('variableId', 'unique()', fn (Database $dbForProject) => new CustomId(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'Variable ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', true, ['dbForProject'])
->param('key', null, new Text(Database::LENGTH_KEY), 'Variable key. Max length: '.Database::LENGTH_KEY.' chars.')
->param('value', null, new Text(8192, 0), 'Variable value. Max length: 8192 chars.')
->param('secret', true, new Boolean(), 'Secret variables can be updated or deleted, but only projects can read them during build and runtime.', true)
->param('secret', true, new Boolean, 'Secret variables can be updated or deleted, but only projects can read them during build and runtime.', true)
->inject('response')
->inject('queueForEvents')
->inject('dbForProject')
@@ -95,7 +95,7 @@ class Create extends Base
foreach (['functions', 'sites'] as $collection) {
$dbForProject->updateDocuments($collection, new Document([
'live' => false
'live' => false,
]));
}