Creating and Modifying a Workspace
This section describes how to create and modify a workspace by calling ModelArts APIs.
Overview
The process of creating and modifying a workspace is as follows:
- Call the authentication API to obtain the user token, which will be added in the request header for authentication.
- Call the API for creating a workspace to create a workspace.
- Call the API for obtaining workspace details to obtain workspace details based on the workspace ID.
- Call the API for modifying a workspace to modify the workspace information including its name, description, and authorization based on the workspace ID.
- Call the API for deleting a workspace to delete the workspace if it is not needed.
Prerequisites
- You have obtained the endpoints of IAM and ModelArts.
- The following information is available: region where ModelArts is deployed, project name and ID, account name and ID, and username and ID.
Procedure
- Call the API for authentication to obtain a user token.
- Request body:
URI: POST https://{iam_endpoint}/v3/auth/tokens
Request header: Content-Type → application/json
Request body:{ "auth": { "identity": { "methods": ["password"], "password": { "user": { "name": "user_name", "password": "user_password", "domain": { "name": "domain_name" } } } }, "scope": { "project": { "name": "ap-southeast-1" } } } }Set the following parameters based on site requirements:- iam_endpoint: IAM endpoint
- user_name: IAM username
- user_password: login password of the user
- domain_name: account to which the user belongs
- ap-southeast-1: Project name, which is the region where ModelArts is deployed
- Status code 201 Created is returned. The X-Subject-Token value in the response header is the token.
x-subject-token →MIIZmgYJKoZIhvcNAQcCoIIZizCCGYcCAQExDTALBglghkgBZQMEAgEwgXXXXXX...
- Request body:
- Call the API for creating a workspace to create a workspace.
- Request body:
URI: POST https://{endpoint}/v1/{project_id}/workspaces
Request header:
- X-auth-Token →MIIZmgYJKoZIhvcNAQcCoIIZizCCGYcCAQExDTALBglghkgBZQMEAgEwgXXXXXX...
- Content-Type →application/json
Request body:
{ "name": "test_workspace", "description": "It is my workspace", "enterprise_project_id": "0", "auth_type": "PUBLIC", "grants": [ { "user_id": "aa7efa8801024da08a7fa92dc0******", "user_name": "" } ] }Set the following parameters based on site requirements:- endpoint: ModelArts endpoint
- project_id: your project ID
- X-auth-Token: token obtained in the previous step
- user_id: user ID
- Status code 200 OK is returned. The response body is as follows:
{ "id": "f3deca1406da4910a50f3919940b9bda", "name": "test_workspace", "description": "It is my workspace", "owner": "test166", "create_time": 1625453558000, "update_time": 1625453558000, "enterprise_project_id": "0", "enterprise_project_name": "default", "auth_type": "public", "status": "NORMAL", "status_info": "" }Set id to the ID of the created workspace. Record the value for subsequent operations.
- Request body:
- Call the API for obtaining workspace details to obtain workspace details based on the workspace ID.
- Request body:
URI: GET https://{endpoint}/v1/{project_id}/workspaces/{workspaces_id}
Request header: X-auth-Token →MIIZmgYJKoZIhvcNAQcCoIIZizCCGYcCAQExDTALBglghkgBZQMEAgEwgXXXXXX...
Set the italic parameters based on site requirements. Set workspace_id to the workspace ID obtained in 2.
- Status code 200 OK is returned. The response body is as follows:
{ "id": "f3deca1406da4910a50f3919940b9bda", "name": "test_workspace", "description": "It is my workspace", "owner": "test166", "create_time": 1625453558000, "update_time": 1625453558000, "enterprise_project_id": "0", "enterprise_project_name": "default", "auth_type": "public", "status": "NORMAL", "status_info": "" }Obtain the detailed information about the workspace based on the response. status value NORMAL indicates the workspace is running properly.
- Request body:
- Call the API for modifying a workspace to modify the workspace information including its name, description, and authorization based on the workspace ID.
- Request body:
URI: PUT https://{endpoint}/v1/{project_id}/workspaces/{workspaces_id}
Request header:- X-auth-Token →MIIZmgYJKoZIhvcNAQcCoIIZizCCGYcCAQExDTALBglghkgBZQMEAgEwgXXXXXX...
- Content-Type →application/json
Request body:
{ "name": "new_name", "description": "update description", "auth_type":"INTERNAL", "grants": [ {"user_id": "aa7efa8801024da08a7fa92dc0******"} ] }Set the italic parameters based on site requirements. Set name and description to the modified name and description, respectively.
- Response body with status code 200 OK returned (indicating that the workspace has been modified):
{ "workspace_id": "f3deca1406da4910a50f3919940b9bda" }
- Request body:
- Call the API for deleting a workspace to delete the workspace if it is not needed.
- Request body:
URI: DELETE https://{endpoint}/v1/{project_id}/workspaces/{workspaces_id}
Request header: X-auth-Token →MIIZmgYJKoZIhvcNAQcCoIIZizCCGYcCAQExDTALBglghkgBZQMEAgEwgXXXXXX...
Set the italic parameters based on site requirements.
- Response body with status code 200 OK returned (indicating that the authorization has been deleted):
{ "workspace_id": "f3deca1406da4910a50f3919940b9bda" }
- Request body:
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