File system
Create file system
Use the following code to create a CFS file system and retrieve its corresponding file system ID.
1args := &cfs.CreateFSArgs{
2 ClientToken: "be31b98c-5e41-4838-9830-9be700de5a20",
3 Name: "sdkCFS", // Set the instance name
4 VpcID: vpcId, // Set the vpc to which the instance belongs
5 Protocol: protocol, // Set the instance protocol type: 1.nfs 2.smb
6 Zone: zone, // Set the availability zone of the instance
7}
8result, err := cfsClient.CreateFS(args)
9if err != nil {
10 fmt.Println("create cfs failed:", err)
11} else {
12 fmt.Println("create cfs success: ", result)
13}
Note: For detailed parameter configurations and constraints, refer to the CFS API document Create File System.
Update file system
Use the following code to update the configuration details of a CFS file system, such as its name.
1args := &cfs.UpdateFSArgs{
2 FSID: "cfs-xxxxx", // Instance ID
3 FSName: "testSdk",
4}
5err := cfsClient.UpdateFS(args)
6if err != nil {
7 fmt.Println("update cfs failed:", err)
8} else {
9 fmt.Println("update cfs success")
10}
Note: For detailed parameter configurations and constraints, refer to the CFS API document Update File System.
Query existing file system
The following code can be used to query all CFS file system information under the user account
1args := &cfs.DescribeFSArgs{}
2 // Support filtering by fsId and userId, with matching rules allowing partial matches (do not support regular expressions)
3args.FSID = cfsId
4args.UserId = userId
5result, err := cfsClient.DescribeFS(args)
6if err != nil {
7 fmt.Println("list all cfs failed:", err)
8} else {
9 fmt.Println("list all cfs success: ", result)
10}
Note: For detailed parameter configurations and constraints, refer to the CFS API document Query File System.
Drop file system
Use the following code to delete a specific CFS file system. Be aware that a released CFS file system cannot be recovered (you must delete mount targets first; otherwise, the instance cannot be deleted).
1args := &cfs.DropFSArgs{}
2args.FSID = cfsId
3err := client.DropFS(args)
4if err != nil {
5 fmt.Println("delete cfs failed:", err)
6} else {
7 fmt.Println("delete cfs success")
8}
Note: For detailed parameter configurations and constraints, refer to the CFS API document Drop File System.
