Updated on 2024-01-03 GMT+08:00

Creating a Permission Rule

Function

This API is used to create a permission rule.

URI

POST /v1/{project_id}/sfs-turbo/shares/{share_id}/fs/perm-rules

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID

share_id

Yes

String

File system ID

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Account token

Content-Type

Yes

String

MIME type

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

rules

Yes

Array of OnePermRuleRequestInfo objects

Permission rule details. A maximum of five rules can be created at a time.

Table 4 OnePermRuleRequestInfo

Parameter

Mandatory

Type

Description

ip_cidr

No

String

IP address or IP address range of the object to be authorized. Once configured, this parameter cannot be modified.

rw_type

No

String

Read/write permission of the object to be authorized. The value can be rw (read and write permission) or ro (read only permission). The default value is rw.

user_type

No

String

File system access permission granted to the user of the object to be authorized. The value can be no_root_squash, root_squash, or all_squash. Value no_root_squash allows the root user on the client to access the file system as root. Value root_squash allows the root user on the client to access the file system as nfsnobody. Value all_squash allows any user on the client to access the file system as nfsnobody. The default value is all_squash.

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

rules

Array of OnePermRuleResponseInfo objects

Permission rule details

Table 6 OnePermRuleResponseInfo

Parameter

Type

Description

id

String

Permission rule ID

ip_cidr

String

IP address or IP address range of the authorized object

rw_type

String

Read/write permission of the authorized object. The value can be rw (read and write permission) or ro (read only permission). The default value is rw.

user_type

String

File system access permission granted to the user of the authorized object. The value can be no_root_squash, root_squash, or all_squash. Value no_root_squash allows the root user on the client to access the file system as root. Value root_squash allows the root user on the client to access the file system as nfsnobody. Value all_squash allows any user on the client to access the file system as nfsnobody. The default value is all_squash.

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

errCode

String

Error code

Minimum: 8

Maximum: 36

errMsg

String

Error description

Minimum: 2

Maximum: 512

Status code: 500

Table 8 Response body parameters

Parameter

Type

Description

errCode

String

Error code

Minimum: 8

Maximum: 36

errMsg

String

Error description

Minimum: 2

Maximum: 512

Example Requests

{
  "rules" : [ {
    "ip_cidr" : "192.168.0.0/16",
    "rw_type" : "rw",
    "user_type" : "no_root_squash"
  }, {
    "ip_cidr" : "192.32.0.0/16",
    "rw_type" : "rw",
    "user_type" : "no_root_squash"
  } ]
}

Example Responses

Status code: 200

Successful creation

{
  "rules" : [ {
    "id" : "1131ed520xxxxxxebedb6e57xxxxxxxx",
    "ip_cidr" : "192.32.0.0/16",
    "rw_type" : "rw",
    "user_type" : "no_root_squash"
  }, {
    "id" : "1131ed520xxxxxxebedb6e57xxxxxxxx",
    "ip_cidr" : "192.32.0.1",
    "rw_type" : "rw",
    "user_type" : "no_root_squash"
  } ]
}

Status code: 400

Error response

{
  "errCode" : "SFS.TURBO.0001",
  "errMsg" : "Rules not allowed empty"
}

Status code: 500

Error response

{
  "errCode" : "SFS.TURBO.0005",
  "errMsg" : "Internal server error"
}

Status Codes

Status Code

Description

200

Successful creation

400

Error response

500

Error response

Error Codes

See Error Codes.