Creating a Workspace

Function

This API is used to create a workspace.

URI

POST /v1/{project_id}/workspaces

Table 1 describes the required parameters.
Table 1 Parameter description

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Request Body

Table 2 describes the request parameters.
Table 2 Parameter description

Parameter

Mandatory

Type

Description

name

Yes

String

Workspace name, encoded using UTF-8.

The value is a string of 4 to 64 characters consisting of Chinese characters, uppercase and lowercase letters, digits, hyphens (-), and underscores (_). In addition, default is the default workspace name reserved by the system. You cannot create a workspace named default.

description

No

String

Workspace description. By default, this parameter is left blank. The value is a string of 0 to 256 characters.

enterprise_project_id

No

String

Enterprise project ID

NOTE:

For details about how to obtain enterprise project IDs and features, see the Enterprise Management Service User Guide.

If this parameter is not specified or is set to 0, resources will be bound to the default enterprise project.

auth_type

No

String

Authorization type. Possible values are PUBLIC, PRIVATE, and INTERNAL. Default value: PUBLIC

  • PUBLIC: public access of tenants
  • PRIVATE: accessible only to the creator and primary account
  • INTERNAL: accessible to the creator, main account, and specified IAM users. This parameter must be used together with grants.

grants

No

grant array

List of authorized users. By default, this parameter is left blank. This parameter must be used together with auth_type and takes effect only when auth_type is set to INTERNAL.

Table 3 grants parameters

Parameter

Mandatory

Type

Description

user_id

No

String

IAM user ID. Configure either this parameter or user_name. If both of them are available, user_id is preferred.

user_name

No

String

IAM username. Configure either this parameter or user_id.

Response Body

Table 2 describes the response parameters.

Table 4 Parameter description

Parameter

Type

Description

error_msg

String

Error message of a failed API call.

This parameter is not included when the API call succeeds.

error_code

String

Error code of a failed API call. For details, see Error Code.

This parameter is not included when the API call succeeds.

request_id

String

request_id information of a failed API call.

This parameter is not included when the API call succeeds.

id

String

Workspace ID, which is a 32-bit UUID generated by the system without hyphens (-)

name

String

Workspace name

description

String

Workspace description

owner

String

Name of the user who creates a workspace

create_time

Long

Time when a workspace is created, in UTC format

update_time

Long

Last modification time, in UTC format

enterprise_project_id

String

Enterprise project ID

enterprise_project_name

String

Name of an enterprise project

auth_type

String

Authorization type. Default value: PUBLIC

  • PUBLIC: public access of tenants
  • PRIVATE: accessible only to the creator and primary account
  • INTERNAL: accessible to the creator, main account, and specified IAM users. This parameter must be used together with grants.

status

String

Workspace status. Possible values are as follows:

  • CREATE_FAILED: The workspace failed to be created.
  • NORMAL: The workspace is normal.
  • DELETING: The workspace is being deleted.
  • DELETE_FAILED: The workspace failed to be deleted.

grants

grant array

List of authorized users

Table 5 grants parameters

Parameter

Type

Description

user_id

String

IAM user ID

user_name

String

IAM username

Samples

  • Sample request
    POST https://{endpoint}/v1/{project_id}/workspaces
    {
        "name": "test-workspace",
        "description": "It's a test project",
        "enterprise_project_id": "10eb0091-887f-4839-9929-cbc884f1e20e",
        "auth_type": "internal",
        "grants": [
            {
                "user_name": "test"
            }
        ]
    }
  • Successful sample response
    { 
      "id": "cfedf4a550124446a0c781c2deababe0",
      "name": "test-workspace",
      "description": "It's a test project", 
      "owner": "testUser", 
      "create_time": 1470000020000, 
      "update_time": 1470000020000, 
      "enterprise_project_id":"10eb0091-887f-4839-9929-cbc884f1e20e",
      "enterprise_project_name": "test-eps",
      "auth_type": "public",
      "status": "NORMAL"
    }
  • Failed sample response
    {
      "error_msg": "Error message.",
      "error_code": "ModelArts.0104",
      "request_id": "21b81005261c4da5a627b4e9b9d58d50"
    }

Status Code

For details about the status code, see Table 1.