Creating a Workspace
Function
This API is used to create a workspace. The name of the created workspace cannot be default, which is the name of the default workspace reserved by the system.
This API applies to the following scenarios: When you need to create independent workspaces for different service objectives, teams, or projects, you can use this API to create new workspaces. Before using this API, ensure that you have the permission to create a workspace and the workspace name is not in use and is not default. After the workspace is created, the system allocates a default access control policy to the workspace. You can develop, manage, and deploy models in the workspace. If the workspace name already exists, the workspace name is default, or you do not have the operation permission, the API returns an error message.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
URI
POST /v1/{project_id}/workspaces
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Definition: Project ID. For details, see Obtaining a Project ID and Name. Constraints: The value can contain 1 to 64 characters. Letters, digits, and hyphens (-) are allowed. Range: N/A Default Value: N/A |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Definition: Requests for calling an API can be authenticated using either a token or AK/SK. If token-based authentication is used, this parameter is mandatory and must be set to a user token. For details, see Obtaining a User Token. Constraints: N/A Range: N/A Default Value: N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
grants |
No |
Array of grants objects |
Definition: list of authorized users. Constraints: This parameter is valid only when auth_type is set to INTERNAL. The value contains a maximum of 500 characters. |
auth_type |
No |
String |
Definition: authorization type. Constraints: N/A Range:
Default Value: PUBLIC |
enterprise_project_id |
No |
String |
Definition: Enterprise project ID. If this parameter is specified, only the workspaces of the enterprise project are returned. By default, all workspaces are displayed. Constraints: N/A Range: ID of an enabled enterprise project. The value contains 36 characters. Letters, digits, and hyphens (-) are allowed. Default Value: N/A |
name |
Yes |
String |
Definition: Workspace name. Constraints: You are not allowed to create a workspace named default. default is the name of the default workspace reserved by the system. Range: The value can contain 4 to 64 characters. Letters, digits, hyphens (-), and underscores (_) are allowed. Default Value: N/A |
description |
No |
String |
Definition: Workspace description. Constraints: N/A Range: The value can contain 0 to 256 characters. It cannot contain the following special characters: < > = & " ' /. Default Value: It is left blank by default. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
user_id |
No |
String |
Definition: IAM user ID. For details, see Obtaining a Username and ID. Constraints: Either this parameter or user_name must be configured. If both of them are available, user_id will be used preferentially. Range: N/A Default Value: N/A |
user_name |
No |
String |
Definition: IAM username. Constraints: Either this parameter or user_name must be configured. If both of them are available, user_id will be used preferentially. Range: N/A Default Value: N/A |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
owner |
String |
Definition: Creator name. Range: N/A |
auth_type |
String |
Definition: Authorization type. Range: |
enterprise_project_id |
String |
Definition: Enterprise project ID. Range: ID of an enabled enterprise project. The value contains 36 characters. Letters, digits, and hyphens (-) are allowed. |
update_time |
Integer |
Definition: Last modification time, in UTC format Range: N/A |
create_time |
Integer |
Definition: Creation time, in UTC format. Range: N/A |
enterprise_project_name |
String |
Definition: Enterprise project name. Range: Name of the enterprise project corresponding to the response parameter enterprise_project_id |
name |
String |
Definition: Workspace name. Range: The value can contain 4 to 64 characters. Letters, digits, hyphens (-), and underscores (_) are allowed. |
description |
String |
Definition: Workspace description. Range: The value can contain 0 to 256 characters. It cannot contain the following special characters: < > = & " ' /. |
id |
String |
Definition: Workspace ID. If no workspaces are available, the default value is 0. If a workspace is created and used, use the actual value. Range: The value is a 32-bit UUID generated by the system without hyphens (-). |
status |
String |
Definition: Workspace status. Range: |
status_info |
String |
Definition: Status description. By default, this parameter is left blank. This parameter is used to show detailed information about a status. If a deletion failed, you can use this parameter to obtain the failure cause. Range: N/A |
grants |
Array of grants objects |
Definition: List of authorized users. By default, this parameter is left blank. This parameter must be used with auth_type and takes effect only when auth_type is set to INTERNAL. |
Parameter |
Type |
Description |
---|---|---|
user_id |
String |
Definition: IAM user ID. For details, see Obtaining a Username and ID. Range: N/A |
user_name |
String |
Definition: IAM username. Range: N/A |
Example Requests
The following is an example of how to create a workspace whose name is test-workspace, authorization type is internal, and authorized IAM user is test.
POST https://{endpoint}/v1/{project_id}/workspaces { "name" : "test-workspace", "description" : "It is a test project", "enterprise_project_id" : "***b0091-887f-4839-9929-cbc884f1e***", "auth_type" : "internal", "grants" : [ { "user_name" : "test" } ] }
Example Responses
Status code: 200
Response parameter indicating that a workspace is created
{ "id" : "**d05d1a553b4e188ea878e7dcb85e**", "name" : "test-workspace", "description" : "It is a test project'", "owner" : "testUser", "create_time" : 1470000020000, "update_time" : 1470000030000, "enterprise_project_id" : "***b0091-887f-4839-9929-cbc884f1e***", "enterprise_project_name" : "test-eps", "auth_type" : "internal", "status" : "NORMAL", "status_info" : "" }
Status Codes
Status Code |
Description |
---|---|
200 |
Response parameter indicating that a workspace is created |
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