@@ -166,7 +166,7 @@ def __getitem__(self, name):
166
166
167
167
return arr
168
168
169
- def get_attributes (self , pattern = None , limit = None , marker = None , use_cache = True ):
169
+ def get_attributes (self , names = None , pattern = None , limit = None , marker = None , use_cache = True ):
170
170
"""
171
171
Get all attributes or a subset of attributes from the target object.
172
172
If 'use_cache' is True, use the objdb cache if available.
@@ -179,6 +179,9 @@ def get_attributes(self, pattern=None, limit=None, marker=None, use_cache=True):
179
179
if use_cache and (pattern or limit or marker ):
180
180
raise ValueError ("use_cache cannot be used with pattern, limit, or marker parameters" )
181
181
182
+ if names and (pattern or limit or marker or use_cache ):
183
+ raise ValueError ("names cannot be used with pattern, limit, marker, or cache" )
184
+
182
185
if self ._objdb_attributes is not None :
183
186
# use the objdb cache
184
187
out = {}
@@ -189,8 +192,8 @@ def get_attributes(self, pattern=None, limit=None, marker=None, use_cache=True):
189
192
190
193
# Omit trailing slash
191
194
req = self ._req_prefix [:- 1 ]
192
-
193
195
req += "?IncludeData=1"
196
+ body = {}
194
197
195
198
if pattern :
196
199
req += "&pattern=" + pattern
@@ -199,7 +202,21 @@ def get_attributes(self, pattern=None, limit=None, marker=None, use_cache=True):
199
202
if marker :
200
203
req += "&Marker=" + marker
201
204
202
- rsp = self ._parent .GET (req )
205
+ if names :
206
+ if isinstance (names , list ):
207
+ names = [name .decode ('utf-8' ) if isinstance (name , bytes ) else name for name in names ]
208
+ else :
209
+ if isinstance (names , bytes ):
210
+ names = names .decode ("utf-8" )
211
+ names = [names ]
212
+
213
+ body ['attr_names' ] = names
214
+
215
+ if body :
216
+ rsp = self ._parent .POST (req , body = body )
217
+ else :
218
+ rsp = self ._parent .GET (req )
219
+
203
220
attrs_json = rsp ['attributes' ]
204
221
names = [attr ['name' ] for attr in attrs_json ]
205
222
values = [attr ['value' ] for attr in attrs_json ]
0 commit comments