1+ import enum
2+ import typing
3+
4+ T_Result = typing .TypeVar ("T_Result" )
5+
6+
7+ class OauthScope (str , enum .Enum ):
8+ AUTHORIZED_USER_READ = "authorized_user:read"
9+ """
10+ read details about the authorized user
11+ """
12+
13+ ASSETS_READ = "assets:read"
14+ """
15+ read assets on the site
16+ """
17+
18+ ASSETS_WRITE = "assets:write"
19+ """
20+ write assets on a site
21+ """
22+
23+ CMS_READ = "cms:read"
24+ """
25+ read collections and items for a site
26+ """
27+
28+ CMS_WRITE = "cms:write"
29+ """
30+ write to collections and items for a site
31+ """
32+
33+ CUSTOM_CODE_READ = "custom_code:read"
34+ """
35+ read custom code on the site
36+ """
37+
38+ CUSTOM_CODE_WRITE = "custom_code:write"
39+ """
40+ modify custom code on the site
41+ """
42+
43+ ECOMMERCE_READ = "ecommerce:read"
44+ """
45+ read ecommerce data
46+ """
47+
48+ ECOMMERCE_WRITE = "ecommerce:write"
49+ """
50+ edit ecommerce data
51+ """
52+
53+ FORMS_READ = "forms:read"
54+ """
55+ read form data
56+ """
57+
58+ FORMS_WRITE = "forms:write"
59+ """
60+ write form data
61+ """
62+
63+ PAGES_READ = "pages:read"
64+ """
65+ read pages on the site
66+ """
67+
68+ PAGES_WRITE = "pages:write"
69+ """
70+ write to pages on the site
71+ """
72+
73+ SITES_READ = "sites:read"
74+ """
75+ read sites on the site
76+ """
77+
78+ SITES_WRITE = "sites:write"
79+ """
80+ modify pages on the site
81+ """
82+
83+ USERS_READ = "users:read"
84+ """
85+ read users on the site
86+ """
87+
88+ SITE_ACTIVITY_READ = "site_activity:read"
89+ """
90+ read site activity logs
91+ """
92+
93+ USERS_WRITE = "users:write"
94+ """
95+ modify users on the site
96+ """
97+
98+ WORKSPACE_READ = "workspace:read"
99+ """
100+ read workspace resource data
101+ """
102+
103+ WORKSPACE_WRITE = "workspace:write"
104+ """
105+ write workspace resource data
106+ """
107+
108+ SITE_CONFIG_READ = "site_config:read"
109+ """
110+ read site configuration data
111+ """
112+
113+ SITE_CONFIG_WRITE = "site_config:write"
114+ """
115+ write site configuration data
116+ """
117+
118+ def visit (
119+ self ,
120+ authorized_user_read : typing .Callable [[], T_Result ],
121+ assets_read : typing .Callable [[], T_Result ],
122+ assets_write : typing .Callable [[], T_Result ],
123+ cms_read : typing .Callable [[], T_Result ],
124+ cms_write : typing .Callable [[], T_Result ],
125+ custom_code_read : typing .Callable [[], T_Result ],
126+ custom_code_write : typing .Callable [[], T_Result ],
127+ ecommerce_read : typing .Callable [[], T_Result ],
128+ ecommerce_write : typing .Callable [[], T_Result ],
129+ forms_read : typing .Callable [[], T_Result ],
130+ forms_write : typing .Callable [[], T_Result ],
131+ pages_read : typing .Callable [[], T_Result ],
132+ pages_write : typing .Callable [[], T_Result ],
133+ sites_read : typing .Callable [[], T_Result ],
134+ sites_write : typing .Callable [[], T_Result ],
135+ users_read : typing .Callable [[], T_Result ],
136+ site_activity_read : typing .Callable [[], T_Result ],
137+ users_write : typing .Callable [[], T_Result ],
138+ workspace_read : typing .Callable [[], T_Result ],
139+ workspace_write : typing .Callable [[], T_Result ],
140+ site_config_read : typing .Callable [[], T_Result ],
141+ site_config_write : typing .Callable [[], T_Result ],
142+ ) -> T_Result :
143+ if self is OauthScope .AUTHORIZED_USER_READ :
144+ return authorized_user_read ()
145+ if self is OauthScope .ASSETS_READ :
146+ return assets_read ()
147+ if self is OauthScope .ASSETS_WRITE :
148+ return assets_write ()
149+ if self is OauthScope .CMS_READ :
150+ return cms_read ()
151+ if self is OauthScope .CMS_WRITE :
152+ return cms_write ()
153+ if self is OauthScope .CUSTOM_CODE_READ :
154+ return custom_code_read ()
155+ if self is OauthScope .CUSTOM_CODE_WRITE :
156+ return custom_code_write ()
157+ if self is OauthScope .ECOMMERCE_READ :
158+ return ecommerce_read ()
159+ if self is OauthScope .ECOMMERCE_WRITE :
160+ return ecommerce_write ()
161+ if self is OauthScope .FORMS_READ :
162+ return forms_read ()
163+ if self is OauthScope .FORMS_WRITE :
164+ return forms_write ()
165+ if self is OauthScope .PAGES_READ :
166+ return pages_read ()
167+ if self is OauthScope .PAGES_WRITE :
168+ return pages_write ()
169+ if self is OauthScope .SITES_READ :
170+ return sites_read ()
171+ if self is OauthScope .SITES_WRITE :
172+ return sites_write ()
173+ if self is OauthScope .USERS_READ :
174+ return users_read ()
175+ if self is OauthScope .SITE_ACTIVITY_READ :
176+ return site_activity_read ()
177+ if self is OauthScope .USERS_WRITE :
178+ return users_write ()
179+ if self is OauthScope .WORKSPACE_READ :
180+ return workspace_read ()
181+ if self is OauthScope .WORKSPACE_WRITE :
182+ return workspace_write ()
183+ if self is OauthScope .SITE_CONFIG_READ :
184+ return site_config_read ()
185+ if self is OauthScope .SITE_CONFIG_WRITE :
186+ return site_config_write ()
0 commit comments