工作空间列表查询
功能介绍
工作空间列表查询:可通过工作空间名称、工作空间描述、创建时间等条件对租户的工作空间进行筛选。
调用方法
请参见如何调用API。
URI
GET /v1/{project_id}/workspaces
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目id |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
offset |
是 |
Number |
偏移量 指定返回记录的开始位置,必须为数字,取值范围为大于或等于0, |
limit |
是 |
Number |
每页显示个数 |
region_id |
否 |
String |
区域id |
name |
否 |
String |
名称查询 |
description |
否 |
String |
描述查询 |
view_bind_id |
否 |
String |
视图绑定的空间id |
view_bind_name |
否 |
String |
视图绑定的空间名称 |
create_time_start |
否 |
String |
创建时间开始,例如2024-04-26T16:08:09Z+0800 |
create_time_end |
否 |
String |
创建时间结束,例如2024-04-2T16:08:09Z+0800 |
is_view |
否 |
Boolean |
是否查询视图 true or false |
ids |
否 |
String |
工作空间id数组,英文逗号分隔 |
normal_project_id |
否 |
String |
普通项目的项目id |
enterprise_project_id |
否 |
String |
企业项目的项目id |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
content-type |
是 |
String |
application/json;charset=UTF-8 |
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
workspaces |
Array of CreateWorkspaceResponseBody objects |
空间信息 |
count |
Number |
数据总量 |
参数 |
参数类型 |
描述 |
---|---|---|
id |
String |
工作空间id |
create_time |
String |
创建时间 |
update_time |
String |
更新时间 |
name |
String |
工作空间名称 |
description |
String |
工作空间描述 |
creator_id |
String |
创建人id |
creator_name |
String |
创建人名称 |
modifier_id |
String |
修改人id |
modifier_name |
String |
修改人名称 |
project_id |
String |
所属项目id |
project_name |
String |
所属项目名称 |
domain_id |
String |
所属租户id |
domain_name |
String |
所属租户名称 |
enterprise_project_id |
String |
企业项目id |
enterprise_project_name |
String |
企业项目名称 |
is_view |
Boolean |
是否是视图 |
region_id |
String |
区域id |
view_bind_id |
String |
视图绑定的空间id |
view_bind_name |
String |
视图绑定的空间名称 |
workspace_agency_list |
Array of workspace_agency_list objects |
仅用于视图场景,列出了该视图纳管的空间列表 |
参数 |
参数类型 |
描述 |
---|---|---|
project_id |
String |
委托空间所属项目id |
id |
String |
空间委托id |
name |
String |
空间委托名称 |
region_id |
String |
委托空间所属region id |
workspace_attribution |
String |
THIS_ACCOUNT:本账号空间,CROSS_ACCOUNT:跨账号空间 |
agency_version |
String |
用户创建托管空间时使用的IAM委托版本,V3或者V5 |
domain_id |
String |
委托租户id |
domain_name |
String |
委托租户名称 |
iam_agency_id |
String |
iam委托id |
iam_agency_name |
String |
iam委托名称 |
resource_spec_code |
Array of strings |
委托空间购买版本 |
selected |
Boolean |
是否被视图选中 |
状态码: 400
参数 |
参数类型 |
描述 |
---|---|---|
code |
String |
错误码 |
message |
String |
错误消息 |
状态码: 500
参数 |
参数类型 |
描述 |
---|---|---|
code |
String |
错误码 |
message |
String |
错误消息 |
请求示例
无
响应示例
状态码: 200
请求成功
{ "count" : 1, "workspaces" : [ { "create_time" : "2024-07-02T09:25:17Z+0800", "creator_id" : "b4*****************************46a", "creator_name" : "l00644738", "description" : "我的工作空间", "domain_id" : "ac*****************************bf4", "domain_name" : "scc****09", "enterprise_project_id" : "", "enterprise_project_name" : "", "id" : "39*************bf", "is_view" : false, "modifier_id" : "", "modifier_name" : "", "name" : "我的工作空间", "project_id" : "15**************************da6", "project_name" : "cn-north-4", "region_id" : "cn-north-4", "update_time" : "2024-07-02T09:25:17Z+0800", "view_bind_id" : "", "view_bind_name" : "", "workspace_agency_list" : [ ] } ] }
SDK代码示例
SDK代码示例如下。
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.secmaster.v2.region.SecMasterRegion; import com.huaweicloud.sdk.secmaster.v2.*; import com.huaweicloud.sdk.secmaster.v2.model.*; public class ListWorkspacesSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); SecMasterClient client = SecMasterClient.newBuilder() .withCredential(auth) .withRegion(SecMasterRegion.valueOf("<YOUR REGION>")) .build(); ListWorkspacesRequest request = new ListWorkspacesRequest(); try { ListWorkspacesResponse response = client.listWorkspaces(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdksecmaster.v2.region.secmaster_region import SecMasterRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdksecmaster.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = SecMasterClient.new_builder() \ .with_credentials(credentials) \ .with_region(SecMasterRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListWorkspacesRequest() response = client.list_workspaces(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := secmaster.NewSecMasterClient( secmaster.SecMasterClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListWorkspacesRequest{} response, err := client.ListWorkspaces(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
请求成功 |
400 |
请求参数有误 |
500 |
请求失败 |
错误码
请参见错误码。