Artem Goncharov 10a5d8856a
Reimport api with latest import script (#23)
Reimport api with latest import script

fix various links

Reviewed-by: Beibei <None>
Reviewed-by: kucerakk <kucerakk@gmail.com>
2022-04-20 08:30:45 +00:00

26 KiB

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.

URI

POST /v1/{project_id}/workspaces

Table 1 Path parameters
Parameter Mandatory Type Description
project_id Yes String Project ID. For details about how to obtain the project ID, see Obtaining a Project ID <modelarts_03_0147>.

Request Parameters

Table 2 Request body parameters
Parameter Mandatory Type Description
name Yes String Workspace name, encoded using UTF-8. Enter 4 to 64 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed. In addition, default is the name of the default workspace reserved by the system. You are not allowed to create a workspace named default.
description No String Workspace description. By default, this parameter is left blank. Enter 0 to 256 characters.
enterprise_project_id No String

Enterprise project ID. The method of obtaining an enterprise project ID is the same as that of obtaining a project ID.

Default: 0

auth_type No String

Authorization type. Options:

  • PUBLIC: public access of tenants (default value)
  • PRIVATE: accessible only to the creator and primary account
  • INTERNAL: accessible to the creator, primary account, and specified IAM users. This parameter must be used together with grants.
grants No Array of grants <createworkspace__request_grants> objects List of authorized users, which is left blank by default. This parameter must be used together with auth_type and takes effect only when auth_type is set to INTERNAL.
Table 3 grants
Parameter Mandatory Type Description
user_id No String User ID. For details about how to obtain a user ID, see Obtaining a User ID <modelarts_03_0006>. Either this parameter or user_name must be set. If both of them are set, user_id is used preferentially.
user_name No String IAM username. Either this parameter or user_id must be set.

Response Parameters

Status code: 200

Table 4 Response body parameters
Parameter Type Description
id String Workspace ID, which is a 32-bit UUID generated by the system without hyphens (-). The ID of the default workspace is 0.
name String Workspace name
description String Workspace description. Enter 0 to 256 characters.
owner String Creator name. Enter 0 to 64 characters.
create_time Number Time when a workspace was created, in UTC format
update_time Number Last modification time, in UTC format
auth_type String

Authorization type. Options:

  • PUBLIC: public access of tenants (default value)
  • PRIVATE: accessible only to the creator and primary account
  • INTERNAL: accessible to the creator, primary account, and specified IAM users. This parameter must be used together with grants.
enterprise_project_id String Enterprise project ID
enterprise_project_name String Name of an enterprise project
status String

Workspace status. Options:

  • CREATE_FAILED: Creating the workspace failed.
  • NORMAL: The workspace is running properly.
  • DELETING: The workspace is being deleted.
  • DELETE_FAILED: Deleting the workspace failed.
status_info String 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.
grants Array of grants <createworkspace__response_grants> objects List of authorized users, which is left blank by default. This parameter must be used together with auth_type and takes effect only when auth_type is set to INTERNAL.
Table 5 grants
Parameter Type Description
user_id String User ID. Either this parameter or user_name must be set. If both of them are set, user_id is used preferentially.
user_name String IAM username. Either this parameter or user_id must be set.

Example Requests

Creating a Workspace

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

OK

{
  "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" : "public",
  "status" : "NORMAL",
  "status_info" : ""
}

Status Codes

Status Code Description
200 OK
400 BadRequest
403 Forbidden
500 InternalServerError

Error Codes

See Error Codes <modelarts_03_0095>.