-
-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathactivate_site.py
More file actions
27 lines (19 loc) · 1.02 KB
/
Copy pathactivate_site.py
File metadata and controls
27 lines (19 loc) · 1.02 KB
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
"""Demonstrates how to activate a site feature.
Official documentation: https://learn.microsoft.com/en-us/sharepoint/dev/apis/rest-api/csom/features
"""
import argparse
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.features.definitions.scope import FeatureDefinitionScope
from office365.sharepoint.features.known_list import KnownFeaturesList
from tests.settings import cert_path, cert_thumbprint, client_id, team_site_url, tenant
def main():
parser = argparse.ArgumentParser(description="Activate a site feature")
parser.add_argument("--site-url", default=team_site_url, help="target site URL")
args = parser.parse_args()
ctx = ClientContext(args.site_url).with_client_certificate(
tenant, client_id=client_id, thumbprint=cert_thumbprint, cert_path=cert_path
)
f = ctx.site.features.add(KnownFeaturesList.DocId, False, FeatureDefinitionScope.Farm).execute_query()
print(f"Feature {f.display_name} has been activated.")
if __name__ == "__main__":
main()