Switching a Deployment to a Specified Version
Function
This API is used to switch a deployment to a specified version. It is applicable to scenarios where the deployment needs to be switched between different versions for testing or rollback. If the request contains a valid service ID, deployment ID, and target version number, the version number must be a valid version that has been released. You must have the permission to manage the target service deployment, and the deployment must be in the Running state. After the switch, the new version is used immediately. If the service ID or deployment ID is invalid, the version number does not exist, or the user does not have the permission, "400 Bad Request" or "403 Forbidden" is returned. If the deployment status cannot be switched, "400 Bad Request" is returned.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
modelarts:service:switchDeploymentVersion
Read
service *
-
-
-
URI
POST /v2/{project_id}/services/{service_id}/deployments/{deployment_id}/versions/{version}/switch
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition Project ID. For details, see Obtaining a Project ID and Name. Constraints N/A Range N/A Default Value N/A |
| service_id | Yes | String | Definition Service ID, which can be obtained from the response body during service creation or by obtaining the services owned by the current user. The service_id field is the service ID. Constraints N/A Range N/A Default Value N/A |
| deployment_id | Yes | String | Definition Deployment ID, which you can obtain from the response body when adding the deployment or by obtaining service deployments. The deployment_id field indicates the deployment ID. Constraints N/A Range Deployment ID. Default Value N/A |
| version | Yes | String | Definition Target version. |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| service_id | No | String | Definition Service ID. Constraints N/A Range N/A Default Value N/A |
| target_deployment_version | No | String | Definition Target version. Constraints N/A Range N/A Default Value N/A |
| infer_name | Yes | String | Definition Deployment ID. |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| id | String | Definition Service deployment ID. Range N/A |
Example Requests
Switch a deployment to a specified version (target_version).
POST https://{end_point}/v2/{project_id}/services/{service_id}/deployments/{deployment_id}/versions/switch Example Responses
Status code: 200
Version switched.
{
"id" : "deployment_idxxxxxxxxxxxx"
} Status Codes
| Status Code | Description |
|---|---|
| 200 | Version switched. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot