def update(
project: str,
environment: str,
patch: EnvironmentPatch,
*,
product: str | None = None,
timeout: float | None = None,
) -> EnvironmentResourceasync def update(
project: str,
environment: str,
patch: EnvironmentPatch,
*,
product: str | None = None,
timeout: float | None = None,
) -> EnvironmentResourcePartially updates the name, the slug or both, addressed by the environment current slug. Unlike create, the new slug is validated as-is rather than slugified, so an uppercase or spaced value returns 400 instead of being cleaned up for you.
This route returns the updated environment with the same fields get returns, exposed and updatedAt included. exposed is read-only here: putting it in the patch is silently ignored, so use expose and unexpose for that. Changing the slug changes the address every later call has to use.
Example
from envless import envless
environment = envless.environments.update(
'api', 'production', {'name': 'Production EU'}
)
print(environment['exposed'], environment['updatedAt'])import asyncio
from envless import AsyncEnvless
async def main() -> None:
async with AsyncEnvless() as envless:
environment = await envless.environments.update(
'api', 'production', {'name': 'Production EU'}
)
print(environment['exposed'], environment['updatedAt'])
asyncio.run(main())Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project | str | Yes | Project slug or uniqueId that owns the environment. |
environment | str | Yes | Current environment slug; ids are not accepted. |
patch['name'] | str | No | New display name, 2 to 50 characters. |
patch['slug'] | str | No | New lowercase hyphenated slug, validated as-is and unique within the project. |
product | str | No | Product slug that disambiguates an ambiguous project slug. |
timeout | float | No | Seconds each attempt of this call may take, the response body included, before it raises EnvlessNetworkError with is_timeout set. Overrides the client's timeout for this call, and 0 turns the limit off. |
Returns
EnvironmentResource reflecting the stored values, including exposed and updatedAt.
Worth knowing
- A slug another environment in the project already owns fails with
environment.slug_conflict.
Required scopes
environments:write
Underlying endpoint
PATCH /projects/{slug}/environments/{environmentSlug}
Request and response schema, every error code, and a live playground.
In TypeScript
envless.environments.update()
The same method in @goenvless/sdk, with the same request, retries and errors.