Creating a Permission Rule

Updated on 2025-04-28 GMT+08:00

Function

This API is used to create a permission rule.

Constraints

A maximum of 64 permission rules can be configured for a file system.

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

The project ID.

share_id

Yes

String

The file system ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

The account token.

Content-Type

Yes

String

The MIME type.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

rules

Yes

Array of OnePermRuleRequestInfo objects

The permission rule details. You can add a maximum of five rules at a time.

Table 4 OnePermRuleRequestInfo

Parameter

Mandatory

Type

Description

ip_cidr

No

String

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

rw_type

No

String

The read/write permission of the object to be authorized.

  • rw: read and write permission, which is the default option

  • ro: read-only permission

  • none: no permission

user_type

No

String

The file system access permission granted to the user of the object to be authorized. The value can be:

  • no_root_squash: allows any user including root on the client to access the file system as who they are, instead of mapping them to another user.

  • root_squash: allows root on the client to access the file system as nfsnobody. Client access using a non-root user will be retained as who they are, instead of being mapped to another user.

  • all_squash: allows any user on the client to access the file system as nfsnobody.

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

rules

Array of OnePermRuleResponseInfo objects

The permission rule information.

Table 6 OnePermRuleResponseInfo

Parameter

Type

Description

id

String

The permission rule ID.

ip_cidr

String

The IP address or IP address range of the authorized object.

rw_type

String

The read/write permission of the authorized object.

  • rw: read and write permission, which is the default option

  • ro: read-only permission

  • none: no permission

user_type

String

The file system access permission granted to the user of the authorized object. The value can be:

  • no_root_squash: allows root on the client to access the file system as root.

  • root_squash: allows root on the client to access the file system as nfsnobody.

  • all_squash: allows any user on the client to access the file system as nfsnobody. This is the default value.

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

errCode

String

The error code.

errMsg

String

The error message.

Status code: 500

Table 8 Response body parameters

Parameter

Type

Description

errCode

String

The error code.

errMsg

String

The error message.

Example Requests

{
  "rules" : [ {
    "ip_cidr" : "192.168.xx.xx/16",
    "rw_type" : "rw",
    "user_type" : "no_root_squash"
  }, {
    "ip_cidr" : "192.32.xx.xx/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.

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback