-
-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathexport_term_store.py
More file actions
28 lines (19 loc) · 845 Bytes
/
Copy pathexport_term_store.py
File metadata and controls
28 lines (19 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Exports the term store groups and term sets to JSON.
https://learn.microsoft.com/en-us/sharepoint/dev/apis/rest-api/taxonomy
"""
import argparse
import json
from office365.sharepoint.client_context import ClientContext
from tests.settings import cert_path, cert_thumbprint, client_id, team_site_url, tenant
def main():
argparse.ArgumentParser(description="Export term store groups and term sets to JSON").parse_args()
ctx = ClientContext(team_site_url).with_client_certificate(
tenant, client_id=client_id, thumbprint=cert_thumbprint, cert_path=cert_path
)
term_groups = ctx.taxonomy.term_store.term_groups.get().execute_query()
for term_group in term_groups:
term_group.term_sets.get().execute_query()
print(json.dumps(term_groups.to_json(), indent=4))
if __name__ == "__main__":
main()