You need to enable JavaScript to run this app.
弹性文件存储

弹性文件存储

复制全文
Python SDK
代码示例
复制全文
代码示例

本文介绍文件存储 NAS Python SDK 的代码示例供您参考。

前提条件

  1. 下载安装 SDK
  2. 初始化客户端

请求超时时间设置

使用 Python SDK 调用文件存储 NAS 接口时,默认无超时时间限制。
您可以在发起接口调用请求时,在代码的最后加上 _request_timeout 参数来指定请求的超时时间(单位:秒),若未在该时间内完成,请求即会终止并报超时错误。

例如,您可以在调用 DescribeFileSystems 接口时,通过如下代码将超时时间设置为 10 秒。

resp = api_instance.describe_file_systems(volcenginesdkfilenas.DescribeFileSystemsRequest(), _request_timeout=10)

创建文件系统

说明

关于下述 SDK 代码中所使用参数的定义、取值范围等信息,请参见 CreateFileSystem

import volcenginesdkfilenas
import volcenginesdkcore
from volcenginesdkcore.rest import ApiException
from pprint import pprint

if __name__ == "__main__":
    try:
        # api_instance 详见初始化客户端部分
        resp = api_instance.create_file_system(volcenginesdkfilenas.CreateFileSystemRequest(
            zone_id="cn-beijing-a",
            file_system_name="python_sdk_test",
            file_system_type="Extreme",
            protocol_type="NFS",
            charge_type="PayAsYouGo",
            capacity=100,
        ))
        pprint(resp)
    except ApiException as e:
        print("Exception when calling FILENASApi->create_file_system: %s\n" % e)

列举文件系统

说明

关于下述 SDK 请求中所使用参数的定义、取值范围等信息,请参见 DescribeFileSystems

import volcenginesdkfilenas
import volcenginesdkcore
from volcenginesdkcore.rest import ApiException
from pprint import pprint

if __name__ == "__main__":
    try:
        # api_instance 详见初始化客户端部分
        resp = api_instance.describe_file_systems(volcenginesdkfilenas.DescribeFileSystemsRequest())
        pprint(resp)
    except ApiException as e:
        print("Exception when calling FILENASApi->describe_file_systems: %s\n" % e)
最近更新时间:2023.12.19 16:19:24
这个页面对您有帮助吗?
有用
有用
无用
无用