def resource_path(self): orig_path = ClientObject.resource_path.fget(self) if self.is_property_available("Id") and orig_path is None: return ResourcePathEntry(self.context, self.context.web.lists.resource_path, ODataPathParser.from_method("GetById", [self.properties["Id"]])) elif self.is_property_available("Title") and orig_path is None: path = ResourcePathEntry(self.context, ResourcePathEntry(self.context, None, "Web"), ODataPathParser.from_method("GetByTitle", [self.properties["Title"]])) return path return orig_path
def set_property(self, name, value, serializable=True): super(Principal, self).set_property(name, value, serializable) # fallback: create a new resource path if self._resource_path is None: if name == "Id": self._resource_path = ResourcePathEntity( self.context, self._parent_collection.resourcePath, ODataPathParser.from_method("GetById", [value])) elif name == "LoginName": self._resource_path = ResourcePathEntity( self.context, self._parent_collection.resourcePath, ODataPathParser.from_method("GetByName", [value]))
def resource_path(self): orig_path = ClientObject.resource_path.fget(self) if self.is_property_available("Id") and orig_path is None: return ResourcePathEntry( self.context, self.context.web.site_groups.resource_path, ODataPathParser.from_method("GetById", [self.properties["Id"]])) if self.is_property_available("LoginName") and orig_path is None: return ResourcePathEntry( self.context, self.context.web.site_groups.resource_path, ODataPathParser.from_method("GetByName", [self.properties["LoginName"]])) return orig_path
def set_property(self, name, value, serializable=True): super(File, self).set_property(name, value, serializable) # fallback: create a new resource path if self._resource_path is None: if name == "ServerRelativeUrl": self._resource_path = ResourcePathEntity( self.context, ResourcePathEntity(self.context, None, "Web"), ODataPathParser.from_method("GetFileByServerRelativeUrl", [value])) elif name == "UniqueId": self._resource_path = ResourcePathEntity( self.context, ResourcePathEntity(self.context, None, "Web"), ODataPathParser.from_method("GetFileById", [value]))
def __init__(self, web, file_url, file_object): """ A download file content query :type file_url: str :type web: office365.sharepoint.webs.web.Web :type file_object: typing.IO """ def _construct_download_query(request): request.method = HttpMethod.Get self.context.after_execute(_process_response) def _process_response(response): """ :type response: RequestOptions """ file_object.write(response.content) # Sharepoint Endpoint bug: https://github.com/SharePoint/sp-dev-docs/issues/2630 file_url = ODataPathParser.encode_method_value(file_url) super(DownloadFileQuery, self).__init__( web, r"getFileByServerRelativePath(decodedurl={0})/$value".format( file_url)) self.context.before_execute(_construct_download_query)
def resource_path(self): resource_path = super(Principal, self).resource_path if resource_path: return resource_path # fallback: create a new resource path if self.is_property_available("Id"): self._resource_path = ResourcePathEntity( self.context, self._parent_collection.resource_path, ODataPathParser.from_method("GetById", [self.properties["Id"]])) elif self.is_property_available("LoginName"): self._resource_path = ResourcePathEntity( self.context, self._parent_collection.resource_path, ODataPathParser.from_method("GetByName", [self.properties["LoginName"]]))
def resource_path(self): orig_path = ClientObject.resource_path.fget(self) if self.is_property_available( "ServerRelativeUrl") and orig_path is None: return ResourcePathEntry( self.context, self.context.web.resource_path, ODataPathParser.from_method( "GetFolderByServerRelativeUrl", [self.properties["ServerRelativeUrl"]])) elif self.is_property_available("UniqueId") and orig_path is None: return ResourcePathEntry( self.context, self.context.web.resource_path, ODataPathParser.from_method( "GetFolderById", [{ 'guid': self.properties["UniqueId"] }])) return orig_path
def set_property(self, name, value, serializable=True): super(ListItem, self).set_property(name, value, serializable) # fallback: create a new resource path if name == "Id": self._resource_path = ResourcePathEntity( self.context, self._parent_collection.resourcePath, ODataPathParser.from_method("getItemById", [value]))
def service_operation_query(client_object, action_type, method_name, method_params=None, payload=None): url = client_object.url + "/" + ODataPathParser.from_method( method_name, method_params) qry = ClientQuery(url, action_type, payload) return qry
def __init__(self, method_name, method_parameters=None, parent=None): """ :type method_parameters: list or dict or office365.runtime.client_value.ClientValue or None :type method_name: str """ super(ResourcePathServiceOperation, self).__init__(ODataPathParser.from_method(method_name, method_parameters), parent)
def resource_path(self): resource_path = super(Folder, self).resource_path if resource_path: return resource_path # fallback: create a new resource path if self.is_property_available("ServerRelativeUrl"): self._resource_path = ResourcePathEntity( self.context, ResourcePathEntity.from_uri("Web", self.context), ODataPathParser.from_method( "GetFolderByServerRelativeUrl", [self.properties["ServerRelativeUrl"]])) elif self.is_property_available("UniqueId"): self._resource_path = ResourcePathEntity( self.context, ResourcePathEntity.from_uri("Web", self.context), ODataPathParser.from_method( "GetFolderById", [{ 'guid': self.properties["UniqueId"] }])) return self._resource_path
def resourcePath(self): resource_path = super(ListItem, self).resourcePath if resource_path: return resource_path # fallback: create a new resource path if self.is_property_available("Id"): self._resource_path = ResourcePathEntity( self.context, self._parent_collection.resourcePath, ODataPathParser.from_method("getItemById", [self.properties["Id"]])) return self._resource_path
def resource_path(self): orig_path = ClientObject.resource_path.fget(self) if self.is_property_available("Id") and "ParentList" in self.properties and orig_path is None: parent_list = self.properties["ParentList"] if '__deferred' in parent_list: list_resource_path = ResourcePathEntry.from_uri(self.properties["ParentList"]['__deferred']['uri'], self.context) else: list_resource_path = parent_list.resource_path return ResourcePathEntry(self.context, list_resource_path, ODataPathParser.from_method("getItemById", [self.properties["Id"]])) return orig_path
def resourcePath(self): resource_path = super(AttachmentFile, self).resourcePath if resource_path: return resource_path # fallback: create a new resource path if self.is_property_available("ServerRelativeUrl"): self._resource_path = ResourcePathEntity( self.context, ResourcePathEntity(self.context, None, "Web"), ODataPathParser.from_method( "GetFileByServerRelativeUrl", [self.properties["ServerRelativeUrl"]])) return self._resource_path
def segment(self): return ODataPathParser.from_method(self._method_name, self._method_parameters)
def __init__(self, resource, method, method_name, method_params=None, payload=None): url = resource.resourceUrl + "/" + ODataPathParser.from_method(method_name, method_params) super(ServiceOperationQuery, self).__init__(url, method, payload)
def __init__(self, method_name, method_parameters=None, parent=None): super(ResourcePathServiceOperation, self).__init__(ODataPathParser.from_method(method_name, method_parameters), parent)