clerk_rs/
endpoints.rs

1use std::fmt;
2
3#[derive(Debug)]
4pub enum ClerkEndpoint {
5	Get(ClerkGetEndpoint),
6	Post(ClerkPostEndpoint),
7	Delete(ClerkDeleteEndpoint),
8	Put(ClerkPutEndpoint),
9	Patch(ClerkPatchEndpoint),
10	DynamicGet(ClerkDynamicGetEndpoint),
11	DynamicPost(ClerkDynamicPostEndpoint),
12	DynamicDelete(ClerkDynamicDeleteEndpoint),
13	DynamicPut(ClerkDynamicPutEndpoint),
14	DynamicPatch(ClerkDynamicPatchEndpoint),
15}
16
17#[derive(Debug)]
18#[allow(dead_code)]
19pub enum ClerkDynamicGetEndpoint {
20	GetClient,
21	GetClientLastActiveSession,
22	GetEmailAddress,
23	GetTemplate,
24	GetTemplateList,
25	GetJwks,
26	GetJwtTemplate,
27	ListPendingOrganizationInvitations,
28	ListOrganizationMemberships,
29	GetOrganization,
30	GetPhoneNumber,
31	GetRedirectUrl,
32	GetSession,
33	GetOAuthAccessToken,
34	GetUser,
35	UsersGetOrganizationMemberships,
36}
37
38#[derive(Debug)]
39#[allow(dead_code)]
40pub enum ClerkDynamicPostEndpoint {
41	RevokeActorToken,
42	DeleteBlocklistIdentifier,
43	PreviewTemplate,
44	RevertTemplate,
45	RevokeInvitation,
46	CreateOrganizationInvitation,
47	RevokeOrganizationInvitation,
48	CreateOrganizationMembership,
49	CreateSessionTokenFromTemplate,
50	RevokeSession,
51	VerifySession,
52	RevokeSignInToken,
53	BanUser,
54	UnbanUser,
55	VerifyPassword,
56	VerifyTotp,
57}
58
59#[derive(Debug)]
60#[allow(dead_code)]
61pub enum ClerkDynamicDeleteEndpoint {
62	DeleteAllowlistIdentifier,
63	DeleteEmailAddress,
64	DeleteJwtTemplate,
65	DeleteOrganizationMembership,
66	DeleteOrganization,
67	DeletePhoneNumber,
68	DeleteRedirectUrl,
69	DeleteUser,
70	DisableMfa,
71}
72
73#[derive(Debug)]
74#[allow(dead_code)]
75pub enum ClerkDynamicPutEndpoint {
76	UpsertTemplate,
77	UploadOrganizationLogo,
78}
79
80#[derive(Debug)]
81#[allow(dead_code)]
82pub enum ClerkDynamicPatchEndpoint {
83	UpdateEmailAddress,
84	UpdateJwtTemplate,
85	UpdateOrganizationMembershipMetadata,
86	MergeOrganizationMetadata,
87	UpdateOrganizationMembership,
88	UpdateOrganization,
89	UpdatePhoneNumber,
90	UpdateSignUp,
91	UpdateUser,
92	UpdateUserMetadata,
93}
94
95#[derive(Debug)]
96#[allow(dead_code)]
97pub enum ClerkGetEndpoint {
98	ListAllowlistIdentifiers,
99	ListBlocklistIdentifiers,
100	GetClientList,
101	ListInvitations,
102	ListJwtTemplates,
103	GetPublicInterstitial,
104	ListOrganizations,
105	ListRedirectUrls,
106	GetSessionList,
107	GetUserList,
108	GetUsersCount,
109}
110
111#[derive(Debug)]
112#[allow(dead_code)]
113pub enum ClerkPostEndpoint {
114	CreateActorToken,
115	CreateAllowlistIdentifier,
116	CreateBlocklistIdentifier,
117	VerifyClient,
118	CreateEmailAddress,
119	CreateEmail,
120	CreateInvitation,
121	CreateJwtTemplate,
122	CreateDemoInstance,
123	CreateOrganization,
124	CreatePhoneNumber,
125	CreateRedirectUrl,
126	CreateSignInToken,
127	CreateUser,
128	CreateSvixApp,
129	GenerateSvixAuthUrl,
130}
131
132#[derive(Debug)]
133#[allow(dead_code)]
134pub enum ClerkDeleteEndpoint {
135	DeleteSvixApp,
136}
137
138#[derive(Debug)]
139#[allow(dead_code)]
140pub enum ClerkPatchEndpoint {
141	UpdateInstanceAuthConfig,
142	UpdateInstance,
143	UpdateInstanceOrganizationSettings,
144	UpdateInstanceRestrictions,
145}
146
147#[derive(Debug)]
148#[allow(dead_code)]
149pub enum ClerkPutEndpoint {
150	UpdateProductionInstanceDomain,
151}
152
153impl ClerkGetEndpoint {
154	/// Convert a clerk endpoint enum to a string value
155	pub fn as_str(&self) -> &str {
156		match self {
157			ClerkGetEndpoint::ListAllowlistIdentifiers => "/allowlist_identifiers",
158			ClerkGetEndpoint::ListBlocklistIdentifiers => "/blocklist_identifiers",
159			ClerkGetEndpoint::GetClientList => "/clients",
160			ClerkGetEndpoint::ListInvitations => "/invitations",
161			ClerkGetEndpoint::ListJwtTemplates => "/jwt_templates",
162			ClerkGetEndpoint::GetPublicInterstitial => "/public/interstitial",
163			ClerkGetEndpoint::ListOrganizations => "/organizations",
164			ClerkGetEndpoint::ListRedirectUrls => "/redirect_urls",
165			ClerkGetEndpoint::GetSessionList => "/sessions",
166			ClerkGetEndpoint::GetUserList => "/users",
167			ClerkGetEndpoint::GetUsersCount => "/users/count",
168		}
169	}
170}
171
172impl ClerkPostEndpoint {
173	/// Convert a clerk endpoint enum to a string value
174	pub fn as_str(&self) -> &str {
175		match self {
176			ClerkPostEndpoint::CreateActorToken => "/actor_tokens",
177			ClerkPostEndpoint::CreateAllowlistIdentifier => "/allowlist_identifiers",
178			ClerkPostEndpoint::CreateBlocklistIdentifier => "/blocklist_identifiers",
179			ClerkPostEndpoint::VerifyClient => "/clients/verify",
180			ClerkPostEndpoint::CreateEmailAddress => "/email_addresses",
181			ClerkPostEndpoint::CreateEmail => "/emails",
182			ClerkPostEndpoint::CreateInvitation => "/invitations",
183			ClerkPostEndpoint::CreateJwtTemplate => "/jwt_templates",
184			ClerkPostEndpoint::CreateDemoInstance => "/public/demo_instance",
185			ClerkPostEndpoint::CreateOrganization => "/organizations",
186			ClerkPostEndpoint::CreatePhoneNumber => "/phone_numbers",
187			ClerkPostEndpoint::CreateRedirectUrl => "/redirect_urls",
188			ClerkPostEndpoint::CreateSignInToken => "/sign_in_tokens",
189			ClerkPostEndpoint::CreateUser => "/users",
190			ClerkPostEndpoint::CreateSvixApp => "/webhooks/svix",
191			ClerkPostEndpoint::GenerateSvixAuthUrl => "/webhooks/svix_url",
192		}
193	}
194}
195
196impl ClerkDeleteEndpoint {
197	/// Convert a clerk endpoint enum to a string value
198	pub fn as_str(&self) -> &str {
199		match self {
200			ClerkDeleteEndpoint::DeleteSvixApp => "/webhooks/svix",
201		}
202	}
203}
204
205impl ClerkPutEndpoint {
206	/// Convert a clerk endpoint enum to a string value
207	pub fn as_str(&self) -> &str {
208		match self {
209			ClerkPutEndpoint::UpdateProductionInstanceDomain => "/beta_features/domain",
210		}
211	}
212}
213
214impl ClerkPatchEndpoint {
215	/// Convert a clerk endpoint enum to a string value
216	pub fn as_str(&self) -> &str {
217		match self {
218			ClerkPatchEndpoint::UpdateInstanceAuthConfig => "/beta_features/instance_settings",
219			ClerkPatchEndpoint::UpdateInstance => "/instance",
220			ClerkPatchEndpoint::UpdateInstanceOrganizationSettings => "/instance/organization_settings",
221			ClerkPatchEndpoint::UpdateInstanceRestrictions => "/instance/restrictions",
222		}
223	}
224}
225
226impl ClerkDynamicGetEndpoint {
227	/// Convert a clerk endpoint enum to a string value
228	pub fn as_str(&self) -> &str {
229		match self {
230			ClerkDynamicGetEndpoint::GetOrganization => "/organizations/{organization_id}",
231			ClerkDynamicGetEndpoint::GetPhoneNumber => "/phone_numbers/{phone_number_id}",
232			ClerkDynamicGetEndpoint::GetRedirectUrl => "/redirect_urls/{id}",
233			ClerkDynamicGetEndpoint::GetSession => "/sessions/{session_id}",
234			ClerkDynamicGetEndpoint::GetUser => "/users/{user_id}",
235			ClerkDynamicGetEndpoint::GetClient => "/clients/{client_id}",
236			ClerkDynamicGetEndpoint::GetJwks => "/jwks",
237			ClerkDynamicGetEndpoint::ListOrganizationMemberships => "/organizations/{organization_id}/memberships",
238			ClerkDynamicGetEndpoint::ListPendingOrganizationInvitations => "/organizations/{organization_id}/invitations/pending",
239			ClerkDynamicGetEndpoint::GetClientLastActiveSession => "/clients/{client_id}/last_active_session",
240			ClerkDynamicGetEndpoint::GetEmailAddress => "/email_addresses/{email_address_id}",
241			ClerkDynamicGetEndpoint::GetTemplate => "/templates/{template_type}/{slug}",
242			ClerkDynamicGetEndpoint::GetTemplateList => "/templates/{template_type}",
243			ClerkDynamicGetEndpoint::GetJwtTemplate => "/jwt_templates/{jwt_template_id}",
244			ClerkDynamicGetEndpoint::GetOAuthAccessToken => "/users/{user_id}/oauth_access_tokens/{provider}",
245			ClerkDynamicGetEndpoint::UsersGetOrganizationMemberships => "/users/{user_id}/organization_memberships",
246		}
247	}
248}
249
250impl ClerkDynamicPostEndpoint {
251	/// Convert a clerk endpoint enum to a string value
252	pub fn as_str(&self) -> &str {
253		match self {
254			ClerkDynamicPostEndpoint::CreateOrganizationMembership => "/organizations/{organization_id}/memberships",
255			ClerkDynamicPostEndpoint::CreateOrganizationInvitation => "/organizations/{organization_id}/invitations",
256			ClerkDynamicPostEndpoint::RevokeActorToken => "/actor_tokens/{actor_token_id}/revoke",
257			ClerkDynamicPostEndpoint::DeleteBlocklistIdentifier => "/blocklist_identifiers/{identifier_id}",
258			ClerkDynamicPostEndpoint::PreviewTemplate => "/templates/{template_type}/{slug}/preview",
259			ClerkDynamicPostEndpoint::RevertTemplate => "/templates/{template_type}/{slug}/revert",
260			ClerkDynamicPostEndpoint::RevokeInvitation => "/invitations/{invitation_id}/revoke",
261			ClerkDynamicPostEndpoint::RevokeOrganizationInvitation => "/organizations/{organization_id}/invitations/{invitation_id}/revoke",
262			ClerkDynamicPostEndpoint::CreateSessionTokenFromTemplate => "/sessions/{session_id}/tokens/{template_name}",
263			ClerkDynamicPostEndpoint::RevokeSession => "/sessions/{session_id}/revoke",
264			ClerkDynamicPostEndpoint::VerifySession => "/sessions/{session_id}/verify",
265			ClerkDynamicPostEndpoint::RevokeSignInToken => "/sign_in_tokens/{sign_in_token_id}/revoke",
266			ClerkDynamicPostEndpoint::BanUser => "/users/{user_id}/ban",
267			ClerkDynamicPostEndpoint::UnbanUser => "/users/{user_id}/unban",
268			ClerkDynamicPostEndpoint::VerifyPassword => "/users/{user_id}/verify_password",
269			ClerkDynamicPostEndpoint::VerifyTotp => "/users/{user_id}/verify_totp",
270		}
271	}
272}
273
274impl ClerkDynamicDeleteEndpoint {
275	/// Convert a clerk endpoint enum to a string value
276	pub fn as_str(&self) -> &str {
277		match self {
278			ClerkDynamicDeleteEndpoint::DeleteOrganization => "/organizations/{organization_id}",
279			ClerkDynamicDeleteEndpoint::DeleteOrganizationMembership => "/organizations/{organization_id}/memberships/{user_id}",
280			ClerkDynamicDeleteEndpoint::DeletePhoneNumber => "/phone_numbers/{phone_number_id}",
281			ClerkDynamicDeleteEndpoint::DeleteRedirectUrl => "/redirect_urls/{id}",
282			ClerkDynamicDeleteEndpoint::DeleteUser => "/users/{user_id}",
283			ClerkDynamicDeleteEndpoint::DeleteEmailAddress => "/email_addresses/{email_address_id}",
284			ClerkDynamicDeleteEndpoint::DeleteJwtTemplate => "/jwt_templates/{jwt_template_id}",
285			ClerkDynamicDeleteEndpoint::DeleteAllowlistIdentifier => "/allowlist_identifiers/{identifier_id}",
286			ClerkDynamicDeleteEndpoint::DisableMfa => "/users/{user_id}/disable_mfa",
287		}
288	}
289}
290
291impl ClerkDynamicPutEndpoint {
292	/// Convert a clerk endpoint enum to a string value
293	pub fn as_str(&self) -> &str {
294		match self {
295			ClerkDynamicPutEndpoint::UploadOrganizationLogo => "/organizations/{organization_id}/logo",
296			ClerkDynamicPutEndpoint::UpsertTemplate => "/templates/{template_type}/{slug}",
297		}
298	}
299}
300
301impl ClerkDynamicPatchEndpoint {
302	/// Convert a clerk endpoint enum to a string value
303	pub fn as_str(&self) -> &str {
304		match self {
305			ClerkDynamicPatchEndpoint::UpdateOrganization => "/organizations/{organization_id}",
306			ClerkDynamicPatchEndpoint::UpdateOrganizationMembership => "/organizations/{organization_id}/memberships/{user_id}",
307			ClerkDynamicPatchEndpoint::UpdatePhoneNumber => "/phone_numbers/{phone_number_id}",
308			ClerkDynamicPatchEndpoint::UpdateUser => "/users/{user_id}",
309			ClerkDynamicPatchEndpoint::UpdateEmailAddress => "/email_addresses/{email_address_id}",
310			ClerkDynamicPatchEndpoint::UpdateJwtTemplate => "/jwt_templates/{jwt_template_id}",
311			ClerkDynamicPatchEndpoint::MergeOrganizationMetadata => "/organizations/{organization_id}/metadata",
312			ClerkDynamicPatchEndpoint::UpdateOrganizationMembershipMetadata => "/organizations/{organization_id}/memberships/{user_id}/metadata",
313			ClerkDynamicPatchEndpoint::UpdateSignUp => "/sign_ups/{id}",
314			ClerkDynamicPatchEndpoint::UpdateUserMetadata => "/users/{user_id}/metadata",
315		}
316	}
317}
318
319impl fmt::Display for ClerkGetEndpoint {
320	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
321		write!(f, "{:?}", self)
322	}
323}
324
325impl fmt::Display for ClerkPostEndpoint {
326	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
327		write!(f, "{:?}", self)
328	}
329}
330
331impl fmt::Display for ClerkDeleteEndpoint {
332	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
333		write!(f, "{:?}", self)
334	}
335}
336
337impl fmt::Display for ClerkPutEndpoint {
338	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
339		write!(f, "{:?}", self)
340	}
341}
342
343impl fmt::Display for ClerkPatchEndpoint {
344	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
345		write!(f, "{:?}", self)
346	}
347}
348
349impl fmt::Display for ClerkDynamicGetEndpoint {
350	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
351		write!(f, "{:?}", self)
352	}
353}
354
355impl fmt::Display for ClerkDynamicPostEndpoint {
356	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
357		write!(f, "{:?}", self)
358	}
359}
360
361impl fmt::Display for ClerkDynamicDeleteEndpoint {
362	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
363		write!(f, "{:?}", self)
364	}
365}
366
367impl fmt::Display for ClerkDynamicPutEndpoint {
368	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
369		write!(f, "{:?}", self)
370	}
371}
372
373impl fmt::Display for ClerkDynamicPatchEndpoint {
374	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
375		write!(f, "{:?}", self)
376	}
377}