九游平台/ 代码托管 codearts repo/ api参考/ / / 修改租户ip白名单
更新时间:2025-01-22 gmt 08:00

修改租户ip白名单-九游平台

功能介绍

修改租户ip白名单

调试

您可以在中调试该接口,支持自动认证鉴权。api explorer可以自动生成sdk代码示例,并提供sdk代码示例调试功能。

uri

put /v4/tenant/trusted-ip-addresses/{ip_id}

表1 路径参数

参数

是否必选

参数类型

描述

ip_id

integer

参数解释:

ip白名单id。

取值范围:

1-2147483647

请求参数

表2 请求header参数

参数

是否必选

参数类型

描述

x-auth-token

string

参数解释:

用户token。 通过调用iam服务获取用户token接口获取(响应消息头中x-subject-token的值)。

约束限制:

必传。

取值范围:

字符串长度不少于1,不超过10万。

默认取值:

不涉及。

表3 请求body参数

参数

是否必选

参数类型

描述

ip_type

integer

参数解释:

格式类型。

  • 0,表示指定ip。

  • 1,表示ip范围。

  • 2,表示cidr。

默认取值:

0

枚举值:

  • 0

  • 1

  • 2

ip_start

string

参数解释:

起始ip。

ip_end

string

参数解释:

结束ip。

view_flag

integer

参数解释:

是否允许访问代码仓库。

  • 0,表示禁止访问。

  • 1,表示允许访问。

默认取值:

0

枚举值:

  • 0

  • 1

download_flag

integer

参数解释:

是否允许下载代码。

  • 0,表示禁止下载。

  • 1,表示允许下载。

默认取值:

0

枚举值:

  • 0

  • 1

upload_flag

integer

参数解释:

是否允许提交代码。

  • 0,表示禁止提交。

  • 1,表示允许提交。

默认取值:

0

枚举值:

  • 0

  • 1

remark

string

参数解释:

备注。

取值范围:

字符串长度不少于0,不超过200。

响应参数

状态码: 200

表4 响应body参数

参数

参数类型

描述

id

string

参数解释:

ip白名单id。

user_id

integer

参数解释:

用户id。

取值范围:

0-2147483647

domain_id

string

参数解释:

租户id。

ip_range

string

参数解释:

ip范围。

ip_type

integer

参数解释:

格式类型。

  • 0,表示指定ip。

  • 1,表示ip范围。

  • 2,表示cidr。

默认取值:

0

枚举值:

  • 0

  • 1

  • 2

ip_start

string

参数解释:

起始ip。

ip_end

string

参数解释:

结束ip。

view_flag

integer

参数解释:

是否允许访问代码仓库。

  • 0,表示禁止访问。

  • 1,表示允许访问。

默认取值:

0

枚举值:

  • 0

  • 1

download_flag

integer

参数解释:

是否允许下载代码。

  • 0,表示禁止下载。

  • 1,表示允许下载。

默认取值:

0

枚举值:

  • 0

  • 1

upload_flag

integer

参数解释:

是否允许提交代码。

  • 0,表示禁止提交。

  • 1,表示允许提交。

默认取值:

0

枚举值:

  • 0

  • 1

remark

string

参数解释:

备注。

取值范围:

字符串长度不少于0,不超过200。

created_at

string

参数解释:

创建时间。

参数解释:

mmm dd, yyyy hh:mm:ss a

updated_at

string

参数解释:

更新时间。

参数解释:

mmm dd, yyyy hh:mm:ss a

order_flag

integer

参数解释:

排序。

  • 0,表示默认规则。

  • 1,表示自定义规则。

枚举值:

  • 0

  • 1

状态码: 401

表5 响应body参数

参数

参数类型

描述

error_code

string

参数解释:

错误码。

error_msg

string

参数解释:

错误信息。

请求示例

put https://{endpoint}/v4/tenant/trusted-ip-addresses/1
{
  "ip_type" : 0,
  "ip_start" : "1.1.1.1",
  "ip_end" : "1.1.1.1",
  "view_flag" : 1,
  "download_flag" : 1,
  "upload_flag" : 1,
  "remark" : "xxx办公网"
}

响应示例

状态码: 200

ok

{
  "id" : 19326,
  "user_id" : 7574,
  "ip_range" : "1.1.1.1",
  "ip_start" : "1.1.1.1",
  "ip_end" : "1.1.1.1",
  "ip_type" : 0,
  "view_flag" : 1,
  "download_flag" : 1,
  "upload_flag" : 1,
  "order_flag" : 1,
  "domain_id" : "159b65b41ead484d8ddff250a4731781",
  "remark" : ""
}

状态码: 401

unauthorized

{
  "error_code" : "dev.00000003",
  "error_msg" : "认证信息过期"
}

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
48
49
50
51
52
53
54
55
packagecom.huaweicloud.sdk.test;
importcom.huaweicloud.sdk.core.auth.icredential;
importcom.huaweicloud.sdk.core.auth.basiccredentials;
importcom.huaweicloud.sdk.core.exception.connectionexception;
importcom.huaweicloud.sdk.core.exception.requesttimeoutexception;
importcom.huaweicloud.sdk.core.exception.serviceresponseexception;
importcom.huaweicloud.sdk.codehub.v4.region.codehubregion;
importcom.huaweicloud.sdk.codehub.v4.*;
importcom.huaweicloud.sdk.codehub.v4.model.*;
publicclass updatetenanttrustedipaddresssolution{
publicstaticvoidmain(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
stringak=system.getenv("cloud_sdk_ak");
stringsk=system.getenv("cloud_sdk_sk");
icredentialauth=newbasiccredentials()
.withak(ak)
.withsk(sk);
codehubclientclient=codehubclient.newbuilder()
.withcredential(auth)
.withregion(codehubregion.valueof(""))
.build();
updatetenanttrustedipaddressrequestrequest=newupdatetenanttrustedipaddressrequest();
request.withipid({ip_id});
addtrustedipaddressrequestbodybody=newaddtrustedipaddressrequestbody();
body.withremark("xxx办公网");
body.withuploadflag(1);
body.withdownloadflag(1);
body.withviewflag(1);
body.withipend("1.1.1.1");
body.withipstart("1.1.1.1");
body.withiptype(0);
request.withbody(body);
try{
updatetenanttrustedipaddressresponseresponse=client.updatetenanttrustedipaddress(request);
system.out.println(response.tostring());
}catch(connectionexceptione){
e.printstacktrace();
}catch(requesttimeoutexceptione){
e.printstacktrace();
}catch(serviceresponseexceptione){
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
32
33
34
35
36
37
38
39
40
# coding: utf-8
import os
from huaweicloudsdkcore.auth.credentials import basiccredentials
from huaweicloudsdkcodehub.v4.region.codehub_region import codehubregion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcodehub.v4 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"]
    credentials = basiccredentials(ak, sk)
    client = codehubclient.new_builder() \
        .with_credentials(credentials) \
        .with_region(codehubregion.value_of("")) \
        .build()
    try:
        request = updatetenanttrustedipaddressrequest()
        request.ip_id = {ip_id}
        request.body = addtrustedipaddressrequestbody(
            remark="xxx办公网",
            upload_flag=1,
            download_flag=1,
            view_flag=1,
            ip_end="1.1.1.1",
            ip_start="1.1.1.1",
            ip_type=0
        )
        response = client.update_tenant_trusted_ip_address(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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
packagemain
import(
"fmt"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
codehub"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codehub/v4"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codehub/v4/model"
region"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codehub/v4/region"
)
funcmain(){
// 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")
auth:=basic.newcredentialsbuilder().
withak(ak).
withsk(sk).
build()
client:=codehub.newcodehubclient(
codehub.codehubclientbuilder().
withregion(region.valueof("")).
withcredential(auth).
build())
request:=&model.updatetenanttrustedipaddressrequest{}
request.ipid=int32({ip_id})
remarkaddtrustedipaddressrequestbody:="xxx办公网"
uploadflagaddtrustedipaddressrequestbody:=int32(1)
downloadflagaddtrustedipaddressrequestbody:=int32(1)
viewflagaddtrustedipaddressrequestbody:=int32(1)
ipendaddtrustedipaddressrequestbody:="1.1.1.1"
ipstartaddtrustedipaddressrequestbody:="1.1.1.1"
iptypeaddtrustedipaddressrequestbody:=int32(0)
request.body=&model.addtrustedipaddressrequestbody{
remark:&remarkaddtrustedipaddressrequestbody,
uploadflag:&uploadflagaddtrustedipaddressrequestbody,
downloadflag:&downloadflagaddtrustedipaddressrequestbody,
viewflag:&viewflagaddtrustedipaddressrequestbody,
ipend:&ipendaddtrustedipaddressrequestbody,
ipstart:&ipstartaddtrustedipaddressrequestbody,
iptype:&iptypeaddtrustedipaddressrequestbody,
}
response,err:=client.updatetenanttrustedipaddress(request)
iferr==nil{
fmt.printf("% v\n",response)
}else{
fmt.println(err)
}
}

更多

更多编程语言的sdk代码示例,请参见的代码示例页签,可生成自动对应的sdk代码示例。

状态码

状态码

描述

200

ok

401

unauthorized

错误码

请参见错误码

相关文档

网站地图