Skip to content

Commit f9d7133

Browse files
committed
add share link method to SharePoint service
1 parent 0b5bf48 commit f9d7133

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/office365_service/sharepoint_service.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from office365.sharepoint.client_context import ClientContext
88
from office365.sharepoint.files.file import File
99
from office365.sharepoint.folders.folder import Folder
10+
from office365.sharepoint.sharing.links.kind import SharingLinkKind
1011

1112

1213
def handle_sharepoint_errors(max_retries=5, delay_seconds=3):
@@ -250,6 +251,12 @@ def renomear_arquivo(self, arquivo: File, novo_nome: str) -> File:
250251
print("Arquivo renomeado com sucesso.")
251252
return novo_arquivo
252253

254+
@handle_sharepoint_errors()
255+
def compartilhar_item(self, item: File | Folder, tipo: int):
256+
resultado = item.share_link(tipo)
257+
resultado.execute_query()
258+
return resultado.value.sharingLinkInfo.Url
259+
253260
def obter_pasta_por_nome(self, pasta_raiz: Folder, nome):
254261
pastas = list(self.listar_pastas(pasta_raiz))
255262
pasta_encontrada = next((pasta for pasta in pastas if nome in pasta.name), None)

0 commit comments

Comments
 (0)