Python SDK

更新时间:

快速安装

通过pip安装

  1. pip install oassdk

快速开发

使用 Python SDK 的高级接口可实现快速的功能开发,以下展示几个常用的操作

创建Vault

  1. from oas.oas_api import OASAPI
  2. from oas.ease.vault import Vault
  3. # 创建OASAPI对象
  4. api = OASAPI('[Server Host]', '[Access Key ID]', '[Access Key Secret]')
  5. # 创建Vault
  6. vault = Vault.create_vault(api, '[Vault Name]')

查找Vault

  1. # 创建OASAPI对象
  2. api = OASAPI('[Server Host]', '[Access Key ID]', '[Access Key Secret]')
  3. # 根据名称获取Vault
  4. vault = Vault.get_vault_by_name(api, '[Vault Name]')
  5. # 根据ID获取Vault
  6. vault = Vault.get_vault_by_id(api, '[Vault ID]')

上传文件

  1. archive_id = vault.upload_archive('[File Path]')

删除Archive

  1. vault.delete_archive('[Archive ID]')

续传Multipart Upload任务

  1. uploader = vault.recover_uploader('[Upload ID]')
  2. uploader.resume('[File Path]')

获取Archive列表

  1. job = vault.retrieve_inventory()
  2. job.download_to_file('[File Path]')

下载Archive

  1. job = vault.retrieve_archive('[Archive ID]')
  2. job.download_to_file('[File Path]')