SaveWorkspaceCode

Updated at:

Saves workspace code. If the file does not exist, a new file is automatically created.

Operation description

发布工作空间的代码

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

dms:SaveWorkspaceCode

update

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

WorkspaceId

string

Yes

The workspace ID (numeric ID).

12345678

Path

string

Yes

The file path to save.

{"repos":[{"repo":"git@xxxx.git", "branch":"master"}], "exclude":["/.dms", "/username"]}

Content

string

Yes

The code content.

Description: 'Example template, describe instances in some status'nFormatVersion: OOS-2019-06-01nTasks:n - Name: SleepTaskn Action: ACS::Sleepn Properties:n Duration: PT1Mn

Force

boolean

No

Specifies whether to forcibly overwrite the file. If set to true, the file is overwritten regardless of whether it has been modified by others.

True

Repo

string

No

The repository information. Specify this parameter when creating a git repository directory during the save operation.

computing/ecs

Mtime

string

No

The file modification time. The GetWorkspaceCode operation returns this mtime value. When you call SaveWorkspaceCode, include this mtime value to check whether the file has been changed on the server. If the mtime values do not match, the save operation fails, which indicates that the server-side version has been modified.

2026-01-01T10:11:12Z

Iac

boolean

No

Specifies whether the file is an infrastructure as code template file. Set this parameter to true for YAML configuration files that are edited in the visual editor.

false

Response elements

Element

Type

Description

Example

object

Schema of Response

Data

string

返回数据

1

Message

string

错误信息,在接口失败时,返回具体错误信息,成功时则为空

Failed to publish,repo branch empty

RequestId

string

请求 ID

67E910F2-4B62-5B0C-ACA3-7547695C****

HttpStatusCode

integer

http 状态码

200

ErrorCode

string

错误码

InvalidTid

Success

boolean

是否调用成功。

  • true:调用成功。

  • false:调用失败。

true

Examples

Success response

JSON format

{
  "Data": "1",
  "Message": "Failed to publish,repo branch empty",
  "RequestId": "67E910F2-4B62-5B0C-ACA3-7547695C****",
  "HttpStatusCode": 200,
  "ErrorCode": "InvalidTid",
  "Success": true
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.