Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add deployment [WIP]
Tomas Valenta9e04edc0b2fc
diff --git a/api-service/.openapi-generator/FILES b/api-service/.openapi-generator/FILESindex 6113d9cd0..b407f69f0 100644--- a/api-service/.openapi-generator/FILES+++ b/api-service/.openapi-generator/FILES@@ -21,6 +21,7 @@ playground_client/docs/ProcessResponse.mdplayground_client/docs/ReadFilesystemFileResponse.mdplayground_client/docs/SessionResponse.mdplayground_client/docs/StartProcessParams.md+playground_client/docs/UpdateDeploymentRequest.mdplayground_client/docs/WriteFilesystemFileRequest.mdplayground_client/docs/WriteProcessStdinRequest.mdplayground_client/exceptions.py@@ -42,6 +43,7 @@ playground_client/models/process_response.pyplayground_client/models/read_filesystem_file_response.pyplayground_client/models/session_response.pyplayground_client/models/start_process_params.py+playground_client/models/update_deployment_request.pyplayground_client/models/write_filesystem_file_request.pyplayground_client/models/write_process_stdin_request.pyplayground_client/rest.py@@ -64,6 +66,7 @@ playground_client/test/test_process_response.pyplayground_client/test/test_read_filesystem_file_response.pyplayground_client/test/test_session_response.pyplayground_client/test/test_start_process_params.py+playground_client/test/test_update_deployment_request.pyplayground_client/test/test_write_filesystem_file_request.pyplayground_client/test/test_write_process_stdin_request.pyplayground_client_README.mddiff --git a/api-service/deploy_test.py b/api-service/deploy_test.pyindex d30d29eeb..3b5633293 100644--- a/api-service/deploy_test.py+++ b/api-service/deploy_test.py@@ -21,4 +21,4 @@ app.listen(3000, () =># console.log('')# """-deployment.new("test-project", code, [])+deployment.new("te-ddx", code, [])diff --git a/api-service/playground/src/deployments/deployment.ts b/api-service/playground/src/deployments/deployment.tsnew file mode 100644index 000000000..1a7ab99ca--- /dev/null+++ b/api-service/playground/src/deployments/deployment.ts@@ -0,0 +1,145 @@+import {+ LambdaClient,+ CreateFunctionCommand,+ UpdateFunctionCodeCommand,+ UpdateFunctionConfigurationCommand,+ CreateFunctionUrlConfigCommand,+ waitUntilFunctionUpdatedV2,+ AddPermissionCommand,+ Cors,+} from '@aws-sdk/client-lambda'+import {+ APIGatewayClient,+} from '@aws-sdk/client-api-gateway'+import {+ EnvVars,+ Session,+} from '@devbookhq/sdk'++import { packageFunction } from './packaging'++// TODO: Env var for aws initialization+// TODO: lambda.destroy() on quit?+const lambda = new LambdaClient({+ region: 'us-east-1',+ credentials: {+ accessKeyId: '',+ secretAccessKey: '',+ },+})++const gateway = new APIGatewayClient({+ region: 'us-east-1',+ credentials: {+ accessKeyId: '',+ secretAccessKey: '',+ },+})++const deploymentParams = {+ Runtime: 'nodejs16.x',+ // TODO: Replace lambda role with valid role+ Role: 'arn:aws:iam::066766119186:role/service-role/test-1-role-lgud7u7z',+ Handler: 'index.handler',+}++async function waitForUpdate(projectID: string) {+ await waitUntilFunctionUpdatedV2({+ client: lambda,+ maxWaitTime: 30,+ }, {+ FunctionName: projectID,+ })+}++export async function createDeploymentInSession(+ session: Session,+ projectID: string,+ code: string,+ envVars: EnvVars,+) {+ const zip = await packageFunction(session, code)++ try {+ await lambda.send(new CreateFunctionCommand({+ ...deploymentParams,+ FunctionName: projectID,+ Code: {+ ZipFile: zip,+ },+ Environment: {+ Variables: envVars,+ }+ })).catch(err => console.error(err))+ await waitForUpdate(projectID)++ await lambda.send(new CreateFunctionUrlConfigCommand({+ FunctionName: projectID,+ AuthType: 'NONE',+ Cors: {},+ })).catch(err => console.error(err))+ await waitForUpdate(projectID)++ await lambda.send(new AddPermissionCommand({+ Action: 'lambda:InvokeFunctionUrl',+ FunctionName: projectID,+ Principal: '*',+ StatementId: `${projectID}-url-permission`,+ FunctionUrlAuthType: 'NONE',+ })).catch(err => console.error(err))+ await waitForUpdate(projectID)++ // TODO: Configure the Gateway to handle custom domain wildcards+ } catch (err: any) {+ if (err.name === 'ResourceConflictException') {+ await lambda.send(new UpdateFunctionConfigurationCommand({+ ...deploymentParams,+ FunctionName: projectID,+ Environment: {+ Variables: envVars,+ }+ }))+ await waitForUpdate(projectID)++ await lambda.send(new UpdateFunctionCodeCommand({+ FunctionName: projectID,+ ZipFile: zip,+ }))+ await waitForUpdate(projectID)++ return+ } else {+ throw err+ }+ }+}++export async function updateDeploymentInSession(+ session: Session,+ projectID: string,+ code?: string,+ envVars?: EnvVars,+) {+ const zipPromise = code ? packageFunction(session, code) : Promise.resolve(undefined)++ if (envVars) {+ await lambda.send(new UpdateFunctionConfigurationCommand({+ ...deploymentParams,+ FunctionName: projectID,+ Environment: {+ Variables: envVars,+ }+ }))+ await waitForUpdate(projectID)+ }++ const zip = await zipPromise++ if (zip) {+ await lambda.send(new UpdateFunctionCodeCommand({+ FunctionName: projectID,+ ZipFile: zip,+ }))+ await waitForUpdate(projectID)+ }+}diff --git a/api-service/playground/src/deployments/deploymentsController.ts b/api-service/playground/src/deployments/deploymentsController.tsindex 587000522..9c572c2a7 100644--- a/api-service/playground/src/deployments/deploymentsController.ts+++ b/api-service/playground/src/deployments/deploymentsController.ts@@ -3,6 +3,7 @@ import {BodyProp,Put,Path,+ Patch,Route,Query,} from 'tsoa'@@ -23,31 +24,43 @@ export class DeploymentsController extends Controller {* @param sessionID active session to use for deployment* @param code* @param envVars- */+ */@Put('{projectID}')public async createDeployment(@Path() projectID: string,@Query() sessionID: string,@BodyProp() code: string,@BodyProp() envVars: EnvVars = {},- @Query() update?: boolean,): Promise<void> {const cachedSession = CachedSession.findSession(sessionID)+ await createDeploymentInSession(+ cachedSession.session,+ projectID,+ code,+ envVars,+ )+ }- if (update) {- await updateDeploymentInSession(- cachedSession.session,- projectID,- code,- envVars,- )- } else {- await createDeploymentInSession(- cachedSession.session,- projectID,- code,- envVars,- )- }+ /**+ *+ * @param projectID+ * @param sessionID active session to use for deployment+ * @param code+ * @param envVars+ */+ @Patch('{projectID}')+ public async updateDeployment(+ @Path() projectID: string,+ @Query() sessionID: string,+ @BodyProp() envVars?: EnvVars,+ @BodyProp() code?: string,+ ): Promise<void> {+ const cachedSession = CachedSession.findSession(sessionID)+ await updateDeploymentInSession(+ cachedSession.session,+ projectID,+ code,+ envVars,+ )}}diff --git a/api-service/playground/src/deployments/packaging.ts b/api-service/playground/src/deployments/packaging.tsindex b16124d7f..f0aad0012 100644--- a/api-service/playground/src/deployments/packaging.ts+++ b/api-service/playground/src/deployments/packaging.ts@@ -15,8 +15,14 @@ const bundleDir = 'bundles'const rootfilePath = path.join(rootdir, functionsDir, 'index.mjs')const bundlePath = path.join(rootdir, bundleDir, 'index.zip')+const dumpPath = path.join(rootdir, bundleDir, 'base')-+/**+ *+ * TODO: Configure esbuild to use Nodejs 18 and to minify the output.+ * TODO: Explore .js/.mjs bundling differences.+ *+ */export async function packageFunction(session: Session, code: string) {const stderr: OutStderrResponse[] = []@@ -25,37 +31,38 @@ export async function packageFunction(session: Session, code: string) {manager: session.process,cmd: `zip-it-and-ship-it ${functionsDir} ${bundleDir}`,rootdir,- onStderr: stderr.push,+ onStderr: o => stderr.push(o),})await bundling.exitedif (stderr.length > 0) {- console.error(stderr)+ console.error(stderr.map(o => o.line).join('\n'))}- const zip = await readFileAsBase64(session.process!, bundlePath)+ const zip = await readFileAsBase64(session, bundlePath)return Buffer.from(zip, 'base64')}/*** TODO: Implement binary file reading in devbookd so we don't have to send data via base64 (cca 25% overhead) and process stdout.*/-async function readFileAsBase64(manager: ProcessManager, filepath: string) {- const stderr: OutStderrResponse[] = []- const stdout: OutStdoutResponse[] = []+async function readFileAsBase64(session: Session, filepath: string) {+ if (!session.filesystem || !session.process) {+ throw new Error('Session is not active')+ }- const process = await createSessionProcess({- manager,- onStderr: stderr.push,- onStdout: stdout.push,- cmd: `base64 -w 0 ${filepath}`,+ const stderr: OutStderrResponse[] = []+ const dumpToBase64 = await createSessionProcess({+ manager: session.process,+ onStderr: o => stderr.push(o),+ cmd: `base64 -w 0 ${filepath} > ${dumpPath}`,})- await process.exited+ await dumpToBase64.exitedif (stderr.length > 0) {throw new Error(`Error reading file ${stderr.map(o => o.line).join('\n')}`)}- return stdout.map(o => o.line).join('\n')+ return await session.filesystem.read(dumpPath)}diff --git a/api-service/playground/src/generated/routes.ts b/api-service/playground/src/generated/routes.tsindex 4c8cf5bae..316d1e23f 100644--- a/api-service/playground/src/generated/routes.ts+++ b/api-service/playground/src/generated/routes.ts@@ -185,7 +185,6 @@ export function RegisterRoutes(app: Router) {sessionID: {"in":"query","name":"sessionID","required":true,"dataType":"string"},code: {"in":"body-prop","name":"code","required":true,"dataType":"string"},envVars: {"default":{},"in":"body-prop","name":"envVars","ref":"EnvVars"},- update: {"in":"query","name":"update","dataType":"boolean"},};// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa@@ -204,6 +203,34 @@ export function RegisterRoutes(app: Router) {}});// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa+ app.patch('/deployments/:projectID',+ ...(fetchMiddlewares<RequestHandler>(DeploymentsController)),+ ...(fetchMiddlewares<RequestHandler>(DeploymentsController.prototype.updateDeployment)),++ function DeploymentsController_updateDeployment(request: any, response: any, next: any) {+ const args = {+ projectID: {"in":"path","name":"projectID","required":true,"dataType":"string"},+ sessionID: {"in":"query","name":"sessionID","required":true,"dataType":"string"},+ envVars: {"in":"body-prop","name":"envVars","ref":"EnvVars"},+ code: {"in":"body-prop","name":"code","dataType":"string"},+ };++ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa++ let validatedArgs: any[] = [];+ try {+ validatedArgs = getValidatedArgs(args, request, response);++ const controller = new DeploymentsController();+++ const promise = controller.updateDeployment.apply(controller, validatedArgs as any);+ promiseHandler(controller, promise, response, undefined, next);+ } catch (err) {+ return next(err);+ }+ });+ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoaapp.get('/sessions/:sessionID/filesystem/dir',...(fetchMiddlewares<RequestHandler>(FilesystemController)),...(fetchMiddlewares<RequestHandler>(FilesystemController.prototype.listFilesystemDir)),diff --git a/api-service/playground/swagger.json b/api-service/playground/swagger.jsonindex 025618780..7c8e5beab 100644--- a/api-service/playground/swagger.json+++ b/api-service/playground/swagger.json@@ -316,14 +316,6 @@"schema": {"type": "string"}- },- {- "in": "query",- "name": "update",- "required": false,- "schema": {- "type": "boolean"- }}],"requestBody": {@@ -347,6 +339,52 @@}}}+ },+ "patch": {+ "operationId": "UpdateDeployment",+ "responses": {+ "204": {+ "description": "No content"+ }+ },+ "security": [],+ "parameters": [+ {+ "in": "path",+ "name": "projectID",+ "required": true,+ "schema": {+ "type": "string"+ }+ },+ {+ "description": "active session to use for deployment",+ "in": "query",+ "name": "sessionID",+ "required": true,+ "schema": {+ "type": "string"+ }+ }+ ],+ "requestBody": {+ "required": true,+ "content": {+ "application/json": {+ "schema": {+ "properties": {+ "envVars": {+ "$ref": "#/components/schemas/EnvVars"+ },+ "code": {+ "type": "string"+ }+ },+ "type": "object"+ }+ }+ }+ }}},"/sessions/{sessionID}/filesystem/dir": {diff --git a/api-service/playground_client/__init__.py b/api-service/playground_client/__init__.pyindex c43f8789f..ebbf6e795 100644--- a/api-service/playground_client/__init__.py+++ b/api-service/playground_client/__init__.py@@ -46,5 +46,6 @@ from playground_client.models.process_response import ProcessResponsefrom playground_client.models.read_filesystem_file_response import ReadFilesystemFileResponsefrom playground_client.models.session_response import SessionResponsefrom playground_client.models.start_process_params import StartProcessParams+from playground_client.models.update_deployment_request import UpdateDeploymentRequestfrom playground_client.models.write_filesystem_file_request import WriteFilesystemFileRequestfrom playground_client.models.write_process_stdin_request import WriteProcessStdinRequestdiff --git a/api-service/playground_client/api/default_api.py b/api-service/playground_client/api/default_api.pyindex 4e35f0561..685b0f12a 100644--- a/api-service/playground_client/api/default_api.py+++ b/api-service/playground_client/api/default_api.py@@ -30,6 +30,7 @@ from playground_client.models.process_response import ProcessResponsefrom playground_client.models.read_filesystem_file_response import ReadFilesystemFileResponsefrom playground_client.models.session_response import SessionResponsefrom playground_client.models.start_process_params import StartProcessParams+from playground_client.models.update_deployment_request import UpdateDeploymentRequestfrom playground_client.models.write_filesystem_file_request import WriteFilesystemFileRequestfrom playground_client.models.write_process_stdin_request import WriteProcessStdinRequest@@ -53,13 +54,13 @@ class DefaultApi(object):self.api_client = api_client@validate_arguments- def create_deployment(self, project_id : StrictStr, session_id : Annotated[StrictStr, Field(..., description="active session to use for deployment")], create_deployment_request : CreateDeploymentRequest, update : Optional[StrictBool] = None, **kwargs) -> None: # noqa: E501+ def create_deployment(self, project_id : StrictStr, session_id : Annotated[StrictStr, Field(..., description="active session to use for deployment")], create_deployment_request : CreateDeploymentRequest, **kwargs) -> None: # noqa: E501"""create_deployment # noqa: E501This method makes a synchronous HTTP request by default. To make anasynchronous HTTP request, please pass async_req=True- >>> thread = api.create_deployment(project_id, session_id, create_deployment_request, update, async_req=True)+ >>> thread = api.create_deployment(project_id, session_id, create_deployment_request, async_req=True)>>> result = thread.get():param project_id: (required)@@ -68,8 +69,6 @@ class DefaultApi(object)::type session_id: str:param create_deployment_request: (required):type create_deployment_request: CreateDeploymentRequest- :param update:- :type update: bool:param async_req: Whether to execute the request asynchronously.:type async_req: bool, optional:param _preload_content: if False, the urllib3.HTTPResponse object will@@ -86,16 +85,16 @@ class DefaultApi(object)::rtype: None"""kwargs['_return_http_data_only'] = True- return self.create_deployment_with_http_info(project_id, session_id, create_deployment_request, update, **kwargs) # noqa: E501+ return self.create_deployment_with_http_info(project_id, session_id, create_deployment_request, **kwargs) # noqa: E501@validate_arguments- def create_deployment_with_http_info(self, project_id : StrictStr, session_id : Annotated[StrictStr, Field(..., description="active session to use for deployment")], create_deployment_request : CreateDeploymentRequest, update : Optional[StrictBool] = None, **kwargs): # noqa: E501+ def create_deployment_with_http_info(self, project_id : StrictStr, session_id : Annotated[StrictStr, Field(..., description="active session to use for deployment")], create_deployment_request : CreateDeploymentRequest, **kwargs): # noqa: E501"""create_deployment # noqa: E501This method makes a synchronous HTTP request by default. To make anasynchronous HTTP request, please pass async_req=True- >>> thread = api.create_deployment_with_http_info(project_id, session_id, create_deployment_request, update, async_req=True)+ >>> thread = api.create_deployment_with_http_info(project_id, session_id, create_deployment_request, async_req=True)>>> result = thread.get():param project_id: (required)@@ -104,8 +103,6 @@ class DefaultApi(object)::type session_id: str:param create_deployment_request: (required):type create_deployment_request: CreateDeploymentRequest- :param update:- :type update: bool:param async_req: Whether to execute the request asynchronously.:type async_req: bool, optional:param _return_http_data_only: response data without head status code@@ -135,8 +132,7 @@ class DefaultApi(object):_all_params = ['project_id','session_id',- 'create_deployment_request',- 'update'+ 'create_deployment_request']_all_params.extend([@@ -171,8 +167,6 @@ class DefaultApi(object):_query_params = []if _params.get('session_id') is not None: # noqa: E501_query_params.append(('sessionID', _params['session_id']))- if _params.get('update') is not None: # noqa: E501- _query_params.append(('update', _params['update']))# process the header parameters_header_params = dict(_params.get('_headers', {}))@@ -1839,6 +1833,162 @@ class DefaultApi(object):collection_formats=_collection_formats,_request_auth=_params.get('_request_auth'))+ @validate_arguments+ def update_deployment(self, project_id : StrictStr, session_id : Annotated[StrictStr, Field(..., description="active session to use for deployment")], update_deployment_request : UpdateDeploymentRequest, **kwargs) -> None: # noqa: E501+ """update_deployment # noqa: E501++ This method makes a synchronous HTTP request by default. To make an+ asynchronous HTTP request, please pass async_req=True++ >>> thread = api.update_deployment(project_id, session_id, update_deployment_request, async_req=True)+ >>> result = thread.get()++ :param project_id: (required)+ :type project_id: str+ :param session_id: active session to use for deployment (required)+ :type session_id: str+ :param update_deployment_request: (required)+ :type update_deployment_request: UpdateDeploymentRequest+ :param async_req: Whether to execute the request asynchronously.+ :type async_req: bool, optional+ :param _preload_content: if False, the urllib3.HTTPResponse object will+ be returned without reading/decoding response+ data. Default is True.+ :type _preload_content: bool, optional+ :param _request_timeout: timeout setting for this request. If one+ number provided, it will be total request+ timeout. It can also be a pair (tuple) of+ (connection, read) timeouts.+ :return: Returns the result object.+ If the method is called asynchronously,+ returns the request thread.+ :rtype: None+ """+ kwargs['_return_http_data_only'] = True+ return self.update_deployment_with_http_info(project_id, session_id, update_deployment_request, **kwargs) # noqa: E501++ @validate_arguments+ def update_deployment_with_http_info(self, project_id : StrictStr, session_id : Annotated[StrictStr, Field(..., description="active session to use for deployment")], update_deployment_request : UpdateDeploymentRequest, **kwargs): # noqa: E501+ """update_deployment # noqa: E501++ This method makes a synchronous HTTP request by default. To make an+ asynchronous HTTP request, please pass async_req=True++ >>> thread = api.update_deployment_with_http_info(project_id, session_id, update_deployment_request, async_req=True)+ >>> result = thread.get()++ :param project_id: (required)+ :type project_id: str+ :param session_id: active session to use for deployment (required)+ :type session_id: str+ :param update_deployment_request: (required)+ :type update_deployment_request: UpdateDeploymentRequest+ :param async_req: Whether to execute the request asynchronously.+ :type async_req: bool, optional+ :param _return_http_data_only: response data without head status code+ and headers+ :type _return_http_data_only: bool, optional+ :param _preload_content: if False, the urllib3.HTTPResponse object will+ be returned without reading/decoding response+ data. Default is True.+ :type _preload_content: bool, optional+ :param _request_timeout: timeout setting for this request. If one+ number provided, it will be total request+ timeout. It can also be a pair (tuple) of+ (connection, read) timeouts.+ :param _request_auth: set to override the auth_settings for an a single+ request; this effectively ignores the authentication+ in the spec for a single request.+ :type _request_auth: dict, optional+ :type _content_type: string, optional: force content-type for the request+ :return: Returns the result object.+ If the method is called asynchronously,+ returns the request thread.+ :rtype: None+ """++ _params = locals()++ _all_params = [+ 'project_id',+ 'session_id',+ 'update_deployment_request'+ ]+ _all_params.extend(+ [+ 'async_req',+ '_return_http_data_only',+ '_preload_content',+ '_request_timeout',+ '_request_auth',+ '_content_type',+ '_headers'+ ]+ )++ # validate the arguments+ for _key, _val in _params['kwargs'].items():+ if _key not in _all_params:+ raise ApiTypeError(+ "Got an unexpected keyword argument '%s'"+ " to method update_deployment" % _key+ )+ _params[_key] = _val+ del _params['kwargs']++ _collection_formats = {}++ # process the path parameters+ _path_params = {}+ if _params['project_id']:+ _path_params['projectID'] = _params['project_id']++ # process the query parameters+ _query_params = []+ if _params.get('session_id') is not None: # noqa: E501+ _query_params.append(('sessionID', _params['session_id']))++ # process the header parameters+ _header_params = dict(_params.get('_headers', {}))++ # process the form parameters+ _form_params = []+ _files = {}++ # process the body parameter+ _body_params = None+ if _params['update_deployment_request']:+ _body_params = _params['update_deployment_request']++ # set the HTTP header `Content-Type`+ _content_types_list = _params.get('_content_type',+ self.api_client.select_header_content_type(+ ['application/json']))+ if _content_types_list:+ _header_params['Content-Type'] = _content_types_list++ # authentication setting+ _auth_settings = [] # noqa: E501++ _response_types_map = {}++ return self.api_client.call_api(+ '/deployments/{projectID}', 'PATCH',+ _path_params,+ _query_params,+ _header_params,+ body=_body_params,+ post_params=_form_params,+ files=_files,+ response_types_map=_response_types_map,+ auth_settings=_auth_settings,+ async_req=_params.get('async_req'),+ _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501+ _preload_content=_params.get('_preload_content', True),+ _request_timeout=_params.get('_request_timeout'),+ collection_formats=_collection_formats,+ _request_auth=_params.get('_request_auth'))+@validate_argumentsdef write_filesystem_file(self, session_id : StrictStr, path : StrictStr, write_filesystem_file_request : WriteFilesystemFileRequest, **kwargs) -> None: # noqa: E501"""write_filesystem_file # noqa: E501diff --git a/api-service/playground_client/docs/DefaultApi.md b/api-service/playground_client/docs/DefaultApi.mdindex c1c9fc9df..46a4390cc 100644--- a/api-service/playground_client/docs/DefaultApi.md+++ b/api-service/playground_client/docs/DefaultApi.md@@ -16,12 +16,13 @@ Method | HTTP request | Description[**read_filesystem_file**](DefaultApi.md#read_filesystem_file) | **GET** /sessions/{sessionID}/filesystem/file |[**start_process**](DefaultApi.md#start_process) | **POST** /sessions/{sessionID}/processes |[**stop_process**](DefaultApi.md#stop_process) | **DELETE** /sessions/{sessionID}/processes/{processID} |+[**update_deployment**](DefaultApi.md#update_deployment) | **PATCH** /deployments/{projectID} |[**write_filesystem_file**](DefaultApi.md#write_filesystem_file) | **PUT** /sessions/{sessionID}/filesystem/file |[**write_process_stdin**](DefaultApi.md#write_process_stdin) | **POST** /sessions/{sessionID}/processes/{processID}/stdin |# **create_deployment**-> create_deployment(project_id, session_id, create_deployment_request, update=update)+> create_deployment(project_id, session_id, create_deployment_request)@@ -48,10 +49,9 @@ with playground_client.ApiClient(configuration) as api_client:project_id = 'project_id_example' # str |session_id = 'session_id_example' # str | active session to use for deploymentcreate_deployment_request = playground_client.CreateDeploymentRequest() # CreateDeploymentRequest |- update = True # bool | (optional)try:- api_instance.create_deployment(project_id, session_id, create_deployment_request, update=update)+ api_instance.create_deployment(project_id, session_id, create_deployment_request)except Exception as e:print("Exception when calling DefaultApi->create_deployment: %s\n" % e)```@@ -63,7 +63,6 @@ Name | Type | Description | Notes**project_id** | **str**| |**session_id** | **str**| active session to use for deployment |**create_deployment_request** | [**CreateDeploymentRequest**](CreateDeploymentRequest.md)| |- **update** | **bool**| | [optional]### Return type@@ -770,6 +769,69 @@ No authorization required[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)+# **update_deployment**+> update_deployment(project_id, session_id, update_deployment_request)++++### Example++```python+from __future__ import print_function+import time+import os+import playground_client+from playground_client.rest import ApiException+from pprint import pprint+# Defining the host is optional and defaults to https://localhost:9001+# See configuration.py for a list of all supported configuration parameters.+configuration = playground_client.Configuration(+ host = "https://localhost:9001"+)+++# Enter a context with an instance of the API client+with playground_client.ApiClient(configuration) as api_client:+ # Create an instance of the API class+ api_instance = playground_client.DefaultApi(api_client)+ project_id = 'project_id_example' # str |+ session_id = 'session_id_example' # str | active session to use for deployment+ update_deployment_request = playground_client.UpdateDeploymentRequest() # UpdateDeploymentRequest |++ try:+ api_instance.update_deployment(project_id, session_id, update_deployment_request)+ except Exception as e:+ print("Exception when calling DefaultApi->update_deployment: %s\n" % e)+```++### Parameters++Name | Type | Description | Notes+------------- | ------------- | ------------- | -------------+ **project_id** | **str**| |+ **session_id** | **str**| active session to use for deployment |+ **update_deployment_request** | [**UpdateDeploymentRequest**](UpdateDeploymentRequest.md)| |++### Return type++void (empty response body)++### Authorization++No authorization required++### HTTP request headers++ - **Content-Type**: application/json+ - **Accept**: Not defined++### HTTP response details+| Status code | Description | Response headers |+|-------------|-------------|------------------|+**204** | No content | - |++[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)+# **write_filesystem_file**> write_filesystem_file(session_id, path, write_filesystem_file_request)diff --git a/api-service/playground_client/docs/UpdateDeploymentRequest.md b/api-service/playground_client/docs/UpdateDeploymentRequest.mdnew file mode 100644index 000000000..dd5213daf--- /dev/null+++ b/api-service/playground_client/docs/UpdateDeploymentRequest.md@@ -0,0 +1,29 @@+# UpdateDeploymentRequest+++## Properties+Name | Type | Description | Notes+------------ | ------------- | ------------- | -------------+**env_vars** | **Dict[str, str]** | | [optional]+**code** | **str** | | [optional]++## Example++```python+from playground_client.models.update_deployment_request import UpdateDeploymentRequest++# TODO update the JSON string below+json = "{}"+# create an instance of UpdateDeploymentRequest from a JSON string+update_deployment_request_instance = UpdateDeploymentRequest.from_json(json)+# print the JSON string representation of the object+print UpdateDeploymentRequest.to_json()++# convert the object into a dict+update_deployment_request_dict = update_deployment_request_instance.to_dict()+# create an instance of UpdateDeploymentRequest from a dict+update_deployment_request_form_dict = update_deployment_request.from_dict(update_deployment_request_dict)+```+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)++diff --git a/api-service/playground_client/models/__init__.py b/api-service/playground_client/models/__init__.pyindex 3ad99a2d0..9900e09fe 100644--- a/api-service/playground_client/models/__init__.py+++ b/api-service/playground_client/models/__init__.py@@ -31,5 +31,6 @@ from playground_client.models.process_response import ProcessResponsefrom playground_client.models.read_filesystem_file_response import ReadFilesystemFileResponsefrom playground_client.models.session_response import SessionResponsefrom playground_client.models.start_process_params import StartProcessParams+from playground_client.models.update_deployment_request import UpdateDeploymentRequestfrom playground_client.models.write_filesystem_file_request import WriteFilesystemFileRequestfrom playground_client.models.write_process_stdin_request import WriteProcessStdinRequestdiff --git a/api-service/playground_client/models/update_deployment_request.py b/api-service/playground_client/models/update_deployment_request.pynew file mode 100644index 000000000..cf9f028cf--- /dev/null+++ b/api-service/playground_client/models/update_deployment_request.py@@ -0,0 +1,77 @@+# coding: utf-8++"""+ playground++ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501++ The version of the OpenAPI document: 1.0.0+ Generated by: https://openapi-generator.tech+"""+++from __future__ import annotations+from inspect import getfullargspec+import pprint+import re # noqa: F401+import json+++from typing import Dict, Optional+from pydantic import BaseModel, Field, StrictStr++class UpdateDeploymentRequest(BaseModel):+ """NOTE: This class is auto generated by OpenAPI Generator.+ Ref: https://openapi-generator.tech++ Do not edit the class manually.+ """+ env_vars: Optional[Dict[str, StrictStr]] = Field(None, alias="envVars")+ code: Optional[StrictStr] = None+ __properties = ["envVars", "code"]++ class Config:+ allow_population_by_field_name = True+ validate_assignment = True++ def to_str(self) -> str:+ """Returns the string representation of the model using alias"""+ return pprint.pformat(self.dict(by_alias=True))++ def to_json(self) -> str:+ """Returns the JSON representation of the model using alias"""+ return json.dumps(self.to_dict())++ @classmethod+ def from_json(cls, json_str: str) -> UpdateDeploymentRequest:+ """Create an instance of UpdateDeploymentRequest from a JSON string"""+ return cls.from_dict(json.loads(json_str))++ def to_dict(self):+ """Returns the dictionary representation of the model using alias"""+ _dict = self.dict(by_alias=True,+ exclude={+ },+ exclude_none=True)+ return _dict++ @classmethod+ def from_dict(cls, obj: dict) -> UpdateDeploymentRequest:+ """Create an instance of UpdateDeploymentRequest from a dict"""+ if obj is None:+ return None++ if type(obj) is not dict:+ return UpdateDeploymentRequest.parse_obj(obj)++ # raise errors for additional fields in the input+ for _key in obj.keys():+ if _key not in cls.__properties:+ raise ValueError("Error due to additional fields (not defined in UpdateDeploymentRequest) in the input: " + obj)++ _obj = UpdateDeploymentRequest.parse_obj({+ "env_vars": obj.get("envVars"),+ "code": obj.get("code")+ })+ return _obj+diff --git a/api-service/playground_client/test/test_default_api.py b/api-service/playground_client/test/test_default_api.pyindex 1cf5e5a1f..44b442386 100644--- a/api-service/playground_client/test/test_default_api.py+++ b/api-service/playground_client/test/test_default_api.py@@ -100,6 +100,12 @@ class TestDefaultApi(unittest.TestCase):"""pass+ def test_update_deployment(self):+ """Test case for update_deployment++ """+ pass+def test_write_filesystem_file(self):"""Test case for write_filesystem_filediff --git a/api-service/playground_client/test/test_update_deployment_request.py b/api-service/playground_client/test/test_update_deployment_request.pynew file mode 100644index 000000000..602ab5079--- /dev/null+++ b/api-service/playground_client/test/test_update_deployment_request.py@@ -0,0 +1,57 @@+# coding: utf-8++"""+ playground++ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501++ The version of the OpenAPI document: 1.0.0+ Generated by: https://openapi-generator.tech+"""+++from __future__ import absolute_import++import unittest+import datetime++import playground_client+from playground_client.models.update_deployment_request import UpdateDeploymentRequest # noqa: E501+from playground_client.rest import ApiException++class TestUpdateDeploymentRequest(unittest.TestCase):+ """UpdateDeploymentRequest unit test stubs"""++ def setUp(self):+ pass++ def tearDown(self):+ pass++ def make_instance(self, include_optional):+ """Test UpdateDeploymentRequest+ include_option is a boolean, when False only required+ params are included, when True both required and+ optional params are included """+ # uncomment below to create an instance of `UpdateDeploymentRequest`+ """+ model = playground_client.models.update_deployment_request.UpdateDeploymentRequest() # noqa: E501+ if include_optional :+ return UpdateDeploymentRequest(+ env_vars = {+ 'key' : ''+ },+ code = ''+ )+ else :+ return UpdateDeploymentRequest(+ )+ """++ def testUpdateDeploymentRequest(self):+ """Test UpdateDeploymentRequest"""+ # inst_req_only = self.make_instance(include_optional=False)+ # inst_req_and_optional = self.make_instance(include_optional=True)++if __name__ == '__main__':+ unittest.main()diff --git a/api-service/playground_client_README.md b/api-service/playground_client_README.mdindex 6a55f7ba8..7a1e3632e 100644--- a/api-service/playground_client_README.md+++ b/api-service/playground_client_README.md@@ -50,10 +50,9 @@ with playground_client.ApiClient(configuration) as api_client:project_id = 'project_id_example' # str |session_id = 'session_id_example' # str | active session to use for deploymentcreate_deployment_request = playground_client.CreateDeploymentRequest() # CreateDeploymentRequest |- update = True # bool | (optional)try:- api_instance.create_deployment(project_id, session_id, create_deployment_request, update=update)+ api_instance.create_deployment(project_id, session_id, create_deployment_request)except ApiException as e:print("Exception when calling DefaultApi->create_deployment: %s\n" % e)@@ -77,6 +76,7 @@ Class | Method | HTTP request | Description*DefaultApi* | [**read_filesystem_file**](playground_client/docs/DefaultApi.md#read_filesystem_file) | **GET** /sessions/{sessionID}/filesystem/file |*DefaultApi* | [**start_process**](playground_client/docs/DefaultApi.md#start_process) | **POST** /sessions/{sessionID}/processes |*DefaultApi* | [**stop_process**](playground_client/docs/DefaultApi.md#stop_process) | **DELETE** /sessions/{sessionID}/processes/{processID} |+*DefaultApi* | [**update_deployment**](playground_client/docs/DefaultApi.md#update_deployment) | **PATCH** /deployments/{projectID} |*DefaultApi* | [**write_filesystem_file**](playground_client/docs/DefaultApi.md#write_filesystem_file) | **PUT** /sessions/{sessionID}/filesystem/file |*DefaultApi* | [**write_process_stdin**](playground_client/docs/DefaultApi.md#write_process_stdin) | **POST** /sessions/{sessionID}/processes/{processID}/stdin |@@ -100,6 +100,7 @@ Class | Method | HTTP request | Description- [ReadFilesystemFileResponse](playground_client/docs/ReadFilesystemFileResponse.md)- [SessionResponse](playground_client/docs/SessionResponse.md)- [StartProcessParams](playground_client/docs/StartProcessParams.md)+ - [UpdateDeploymentRequest](playground_client/docs/UpdateDeploymentRequest.md)- [WriteFilesystemFileRequest](playground_client/docs/WriteFilesystemFileRequest.md)- [WriteProcessStdinRequest](playground_client/docs/WriteProcessStdinRequest.md)diff --git a/api-service/session/deploy.py b/api-service/session/deploy.pyindex 853ff7e2a..2c2d121b0 100644--- a/api-service/session/deploy.py+++ b/api-service/session/deploy.py@@ -25,15 +25,14 @@ class Deployment(API):return code.replace("app.listen(", "; ({})?.listen?.(")- def update(self, project_id: str, code: str, env_vars: List[EnvVar]):- self.api.create_deployment(+ def update(self, project_id: str, code: str | None = None, env_vars: List[EnvVar] | None = None):+ self.api.update_deployment(project_id,session_id=self.session.id,- create_deployment_request=playground_client.CreateDeploymentRequest(- envVars=format_env_vars(env_vars),- code=Deployment.modify_code(code),+ update_deployment_request=playground_client.UpdateDeploymentRequest(+ envVars=format_env_vars(env_vars) if env_vars is not None else None,+ code=Deployment.modify_code(code) if code is not None else None,),- update=True,)def new(self, project_id: str, code: str, env_vars: List[EnvVar]):