def content_get_properties( self, account=None, reference=None, path=None, properties=None, cid=None, content=None, version=None, params=None, **kwargs): """ Get a description of the content along with its user properties. """ obj_meta, _ = get_cached_object_metadata( account=account, reference=reference, path=path, cid=cid, version=version, properties=True, **kwargs) if obj_meta is not None: return obj_meta uri = self._make_uri('content/get_properties') data = json.dumps(properties) if properties else None resp, body = self._direct_request( 'POST', uri, data=data, params=params, **kwargs) obj_meta = extract_content_headers_meta(resp.headers) obj_meta.update(body) set_cached_object_metadata( obj_meta, None, account=account, reference=reference, path=path, cid=cid, version=version, properties=True, **kwargs) return obj_meta
def content_locate(self, account=None, reference=None, path=None, cid=None, content=None, version=None, properties=True, params=None, **kwargs): """ Get a description of the content along with the list of its chunks. :param cid: container id that can be used in place of `account` and `reference` :type cid: hexadecimal `str` :param content: content id that can be used in place of `path` :type content: hexadecimal `str` :param properties: should the request return object properties along with content description :type properties: `bool` :returns: a tuple with content metadata `dict` as first element and chunk `list` as second element """ content_meta, chunks = get_cached_object_metadata( account=account, reference=reference, path=path, cid=cid, version=version, properties=properties, **kwargs) if content_meta is not None and chunks is not None: # Refresh asynchronously so as not to slow down the current request eventlet.spawn_n(self._maybe_refresh_rawx_scores, **kwargs) for chunk in chunks: chunk['score'] = self.rawx_scores.get( chunk['url'].split('/')[2], 0) return content_meta, chunks uri = self._make_uri('content/locate') params['properties'] = properties try: resp, chunks = self._direct_request( 'GET', uri, params=params, **kwargs) content_meta = extract_content_headers_meta(resp.headers) except exceptions.OioNetworkException as exc: # TODO(FVE): this special behavior can be removed when # the 'content/locate' protocol is changed to include # object properties in the response body instead of headers. if properties and 'got more than ' in str(exc): params['properties'] = False _resp, chunks = self._direct_request( 'GET', uri, params=params, **kwargs) content_meta = self.content_get_properties( account, reference, path, cid=cid, content=content, version=version, **kwargs) else: raise set_cached_object_metadata( content_meta, chunks, account=account, reference=reference, path=path, cid=cid, version=version, properties=properties, **kwargs) return content_meta, chunks