Softlayer对象存储Python API搜索

时间:2016-05-12 20:15:51

标签: api ibm-cloud-infrastructure

我关注了softlayer-object-storage-python,以便返回符合特定条件的对象列表。

无论我在搜索中添加什么内容,此代码似乎只返回容器中的所有内容

^=icm10restapi-qa.zip

我希望只能找回以icm10restapi-qa.zip开头的东西。

我也尝试使用OPTIONS (SKIP=0) load data infile 'C:\*' APPEND into table Table1 FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS ( FNAME NULLIF NAME=BLANKS, LNAME NULLIF LNAME=BLANKS, SUFFIX NULLIF SUFFIX=BLANKS, HNAME NULLIF HNAME=BLANKS, ADDRESS1 NULLIF ADDRESS1=BLANKS, ADDRESS2 NULLIF ADDRESS2=BLANKS, CITY NULLIF CITY=BLANKS, HSTATE NULLIF HSTATE=BLANKS, ZIP NULLIF ZIP=BLANKS, EXTENDED_ZIP NULLIF EXTENDED_ZIP=BLANKS, COUNTRY NULLIF COUNTRY=BLANKS, ) ,但也没有运气。

1 个答案:

答案 0 :(得分:1)

检查方法时,似乎无法按照您的意愿过滤对象:

https://github.com/softlayer/softlayer-object-storage-python/blob/master/object_storage/client.py#L147

API Operations for Search Services

我为不便之处道歉,我建议您尝试在代码中过滤这些内容。

  

更新

此脚本将帮助使用以特定字符串

开头的名称过滤对象
import object_storage
import pprint

# Declare username, apikey and datacenter
USERNAME = 'set me'
API_KEY = 'set me'
DATACENTER = 'https://dal05.objectstorage.softlayer.net/auth/v1.0/'
# Creating object storage connection
sl_storage = object_storage.get_httplib2_client(USERNAME, API_KEY, auth_url=DATACENTER)
# Declare name to filter
name = 'icm10restapi-qa.zip'

# Filtering
containers = sl_storage.search(name)
for container in containers['results']:
    if container.__dict__['name'].startswith(name):
        print(container)
相关问题