sharepoint-v1-api 0.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sharepoint_api/SharePointAPI.py +1101 -0
- sharepoint_api/SharePointList.py +202 -0
- sharepoint_api/SharePointListItem.py +196 -0
- sharepoint_api/SharePointLists.py +59 -0
- sharepoint_api/SharePointTimeRegistration.py +53 -0
- sharepoint_api/SharePointUser.py +33 -0
- sharepoint_api/SharePointUserList.py +36 -0
- sharepoint_api/__init__.py +21 -0
- sharepoint_v1_api-0.2.2.dist-info/METADATA +187 -0
- sharepoint_v1_api-0.2.2.dist-info/RECORD +13 -0
- sharepoint_v1_api-0.2.2.dist-info/WHEEL +5 -0
- sharepoint_v1_api-0.2.2.dist-info/licenses/LICENSE +19 -0
- sharepoint_v1_api-0.2.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sharepoint_v1_api
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Author: Aske Bluhme Klok
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: Sharepoint
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: requests>=2.32.2
|
|
16
|
+
Requires-Dist: requests-ntlm>=1.3.0
|
|
17
|
+
Dynamic: author
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: description-content-type
|
|
21
|
+
Dynamic: keywords
|
|
22
|
+
Dynamic: license
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
Dynamic: requires-dist
|
|
25
|
+
Dynamic: requires-python
|
|
26
|
+
|
|
27
|
+
# SharePoint API Python Client – Documentation
|
|
28
|
+
|
|
29
|
+
This repository provides a lightweight Python client for interacting with SharePoint sites via SharePoint's REST API. The library handles NTLM authentication, list operations, file management, and time registration while abstracting SharePoint-specific implementation details.
|
|
30
|
+
|
|
31
|
+
## Dependencies
|
|
32
|
+
- Python ≥3.9
|
|
33
|
+
- requests ≥2.32.2
|
|
34
|
+
- requests-ntlm ≥1.3.0
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install sharepoint-api
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Or install from source:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
git clone https://github.com/your-org/nc-devops-sharepoint-v1-api.git
|
|
46
|
+
cd nc-devops-sharepoint-v1-api
|
|
47
|
+
pip install -e .
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Authentication & Initialization
|
|
51
|
+
The client uses NTLM authentication via `requests-ntlm`. Choose between two initialization methods:
|
|
52
|
+
|
|
53
|
+
### Quick Initialization
|
|
54
|
+
```python
|
|
55
|
+
from sharepoint_api.SharePointAPI import SharePointAPI
|
|
56
|
+
|
|
57
|
+
creds = {
|
|
58
|
+
"username": "your_user",
|
|
59
|
+
"password": "your_password",
|
|
60
|
+
"sharepoint_url": "https://your.sharepoint.com",
|
|
61
|
+
"proxies": {}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# Recommended compact initialization (bypasses normal constructor)
|
|
65
|
+
sp: SharePointAPI = SharePointAPI._compact_init(creds)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Full Initialization
|
|
69
|
+
```python
|
|
70
|
+
from requests_ntlm import HttpNtlmAuth
|
|
71
|
+
from sharepoint_api.SharePointAPI import SharePointAPI
|
|
72
|
+
|
|
73
|
+
sp = SharePointAPI(
|
|
74
|
+
sharepoint_url="https://your.sharepoint.com",
|
|
75
|
+
auth=HttpNtlmAuth("your_user", "your_password"),
|
|
76
|
+
proxies={}
|
|
77
|
+
)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Core Operations
|
|
81
|
+
|
|
82
|
+
### List Operations
|
|
83
|
+
```python
|
|
84
|
+
from sharepoint_api.SharePointList import SharePointList
|
|
85
|
+
|
|
86
|
+
# Get all lists in a site
|
|
87
|
+
site = "YOUR_SITE"
|
|
88
|
+
lists: list[SharePointList] = sp.get_lists(site)
|
|
89
|
+
|
|
90
|
+
# Access specific list
|
|
91
|
+
cases: SharePointList = sp.get_list_by_name(site, "Sager")
|
|
92
|
+
print(cases.Title)
|
|
93
|
+
|
|
94
|
+
# Filter items with CAML queries
|
|
95
|
+
filters = ' and '.join([
|
|
96
|
+
"(TeamId == '3')",
|
|
97
|
+
"(Status == '11 - Modtaget')",
|
|
98
|
+
"((Status != '90 - Lukket') and (Status != '91 - Afvist'))"
|
|
99
|
+
])
|
|
100
|
+
filtered_items = sp.get_list_by_name(site, "Sager", filters).all_items
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### File Operations
|
|
104
|
+
```python
|
|
105
|
+
from sharepoint_api.SharePointList import SharePointListItem
|
|
106
|
+
|
|
107
|
+
# Upload file
|
|
108
|
+
item: SharePointListItem = sp.upload_file(
|
|
109
|
+
site="cases",
|
|
110
|
+
folder="Documents",
|
|
111
|
+
file_name="report.pdf",
|
|
112
|
+
file_path="/local/path/report.pdf"
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
# Download file
|
|
116
|
+
sp.download_file(
|
|
117
|
+
site="cases",
|
|
118
|
+
file_url=item.FileRef,
|
|
119
|
+
download_path="./downloads/report.pdf"
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
# Copy file
|
|
123
|
+
copy_result = sp.copy_file(
|
|
124
|
+
site="cases",
|
|
125
|
+
source_url=item.FileRef,
|
|
126
|
+
target_folder="Archive",
|
|
127
|
+
new_name="report_2023.pdf"
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
# Delete file
|
|
131
|
+
sp.delete_file(site="cases", file_url=item.FileRef)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Folder Management
|
|
135
|
+
```python
|
|
136
|
+
# Check folder existence
|
|
137
|
+
if not sp.folder_exists(site="cases", folder_path="Documents/Archived"):
|
|
138
|
+
sp.create_new_folder(site="cases", folder_path="Documents/Archived")
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Time Registration
|
|
142
|
+
```python
|
|
143
|
+
time_list = sp.get_time_registration_list_by_name(site="HR", list_name="TimeRegistrations")
|
|
144
|
+
entries = time_list.get_items(select=["Title", "Hours", "Date"])
|
|
145
|
+
for entry in entries:
|
|
146
|
+
print(f"{entry.Date}: {entry.Hours} hours - {entry.Title}")
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Version History
|
|
150
|
+
```python
|
|
151
|
+
item = sp.get_list_by_name(site="Legal", list_name="Contracts").get_item_by_id(42)
|
|
152
|
+
versions = sp.get_item_versions(item)
|
|
153
|
+
print(f"Item has {len(versions)} versions:")
|
|
154
|
+
for v in versions:
|
|
155
|
+
print(f"Version {v.VersionLabel} by {v.CreatedBy}")
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
## 0.2.2 – 2025-11-28
|
|
160
|
+
|
|
161
|
+
### Added
|
|
162
|
+
|
|
163
|
+
- `SharePointList.fields` property to retrieve list field definitions
|
|
164
|
+
|
|
165
|
+
## 0.2.1 – 2025‑11‑06
|
|
166
|
+
|
|
167
|
+
### Added
|
|
168
|
+
|
|
169
|
+
- Optional `select_fields` parameters to list retrieval methods for more efficient queries.
|
|
170
|
+
- New public API methods:
|
|
171
|
+
- `SharePointAPI.get_group_users` – fetch users of a SharePoint group.
|
|
172
|
+
- Improved error handling with explicit `TypeError` exceptions.
|
|
173
|
+
- Detailed docstrings for core classes and methods (enhances IDE support).
|
|
174
|
+
|
|
175
|
+
### Changed
|
|
176
|
+
|
|
177
|
+
- HTTP header handling unified; corrected `X‑HTTP‑Method: PUT` for full updates.
|
|
178
|
+
- Error handling improved: generic `sys.exit(1)` replaced with explicit `TypeError`/`ConnectionError` exceptions.
|
|
179
|
+
|
|
180
|
+
### Fixed
|
|
181
|
+
|
|
182
|
+
- Fixed incorrect PUT header that previously sent a MERGE header.
|
|
183
|
+
- Minor docstring formatting issues.
|
|
184
|
+
|
|
185
|
+
### Security
|
|
186
|
+
|
|
187
|
+
- Enforced NTLM authentication across all request helpers.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
sharepoint_api/SharePointAPI.py,sha256=Jht8HHslbnCV_iXKOMjgr0KwnggweLgYtDsevFadN2Q,43437
|
|
2
|
+
sharepoint_api/SharePointList.py,sha256=rkrrMBuCBiHaaL6PUtwmhjsVlOyNlC0-Fv8YmOxRypY,5947
|
|
3
|
+
sharepoint_api/SharePointListItem.py,sha256=9yGuytUbW-g4nca0OeJHAKYinE_w65kE2fmxe9-Wl44,6223
|
|
4
|
+
sharepoint_api/SharePointLists.py,sha256=vzX61w9rykHfj4hION3Qrff1BakR4wBb-OCOcyvDCXI,1605
|
|
5
|
+
sharepoint_api/SharePointTimeRegistration.py,sha256=O5t0hyO6-HP1W7QY1LIaHKk9F45zQ5FpYB_RqHE1EPs,1564
|
|
6
|
+
sharepoint_api/SharePointUser.py,sha256=w2UsEIiy-DpdJg5jEm0uVpfAjfALPsG9Uc7Wbm0_OeE,721
|
|
7
|
+
sharepoint_api/SharePointUserList.py,sha256=YTBnUqoXHZSdK6Djg-xyc6TYhhGglJ4PzXFVI05wkyk,981
|
|
8
|
+
sharepoint_api/__init__.py,sha256=vjtZtd4uyPWTV4ctA7H3m5x7oyWVwa39zlNDT3iR3iY,505
|
|
9
|
+
sharepoint_v1_api-0.2.2.dist-info/licenses/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
|
|
10
|
+
sharepoint_v1_api-0.2.2.dist-info/METADATA,sha256=BcV8Ent9r-hPEpBfIHmvJJ3RKGPx65CJkB2GzSAhzSk,4914
|
|
11
|
+
sharepoint_v1_api-0.2.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
12
|
+
sharepoint_v1_api-0.2.2.dist-info/top_level.txt,sha256=2aqHFFcN4A1cPWj5EeXIvIwzC9yra2lI7BS3FdQlLW4,15
|
|
13
|
+
sharepoint_v1_api-0.2.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2018 The Python Packaging Authority
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sharepoint_api
|