skillforge-client 0.3.0__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.
Files changed (147) hide show
  1. skillforge_client/__init__.py +8 -0
  2. skillforge_client/api/__init__.py +1 -0
  3. skillforge_client/api/auth/__init__.py +1 -0
  4. skillforge_client/api/auth/create_application_client_endpoint_api_v1_auth_clients_post.py +166 -0
  5. skillforge_client/api/auth/create_application_client_secret_endpoint_api_v1_auth_clients_client_id_secrets_post.py +182 -0
  6. skillforge_client/api/auth/create_token_api_v1_auth_token_post.py +165 -0
  7. skillforge_client/api/auth/grant_application_client_scopes_endpoint_api_v1_auth_clients_client_id_scopes_post.py +182 -0
  8. skillforge_client/api/auth/read_application_client_api_v1_auth_clients_client_id_get.py +161 -0
  9. skillforge_client/api/auth/read_application_clients_api_v1_auth_clients_get.py +133 -0
  10. skillforge_client/api/auth/revoke_application_client_scope_endpoint_api_v1_auth_clients_client_id_scopes_scope_key_delete.py +173 -0
  11. skillforge_client/api/auth/revoke_application_client_secret_endpoint_api_v1_auth_clients_client_id_secrets_secret_id_delete.py +174 -0
  12. skillforge_client/api/auth/update_application_client_endpoint_api_v1_auth_clients_client_id_patch.py +182 -0
  13. skillforge_client/api/bot/__init__.py +1 -0
  14. skillforge_client/api/bot/add_user_to_group_endpoint_api_v1_bot_users_discord_id_groups_group_key_put.py +199 -0
  15. skillforge_client/api/bot/cancel_operation_endpoint_api_v1_bot_operations_operation_id_cancel_post.py +203 -0
  16. skillforge_client/api/bot/check_authorization_endpoint_api_v1_bot_authz_check_post.py +206 -0
  17. skillforge_client/api/bot/claim_jobs_endpoint_api_v1_bot_jobs_claim_post.py +210 -0
  18. skillforge_client/api/bot/commit_student_activation_endpoint_api_v1_bot_students_activations_operation_id_commit_post.py +204 -0
  19. skillforge_client/api/bot/commit_student_deactivation_endpoint_api_v1_bot_students_guild_id_student_discord_id_deactivate_operation_id_commit_post.py +211 -0
  20. skillforge_client/api/bot/commit_student_pop_endpoint_api_v1_bot_students_guild_id_student_discord_id_pop_operation_id_commit_post.py +211 -0
  21. skillforge_client/api/bot/commit_student_stash_endpoint_api_v1_bot_students_guild_id_student_discord_id_stash_operation_id_commit_post.py +211 -0
  22. skillforge_client/api/bot/commit_tutor_activation_endpoint_api_v1_bot_tutors_activations_operation_id_commit_post.py +204 -0
  23. skillforge_client/api/bot/commit_tutor_deactivation_endpoint_api_v1_bot_tutors_guild_id_tutor_discord_id_deactivate_operation_id_commit_post.py +211 -0
  24. skillforge_client/api/bot/complete_job_endpoint_api_v1_bot_jobs_job_id_complete_post.py +183 -0
  25. skillforge_client/api/bot/deactivate_discord_account_endpoint_api_v1_bot_users_discord_id_account_delete.py +197 -0
  26. skillforge_client/api/bot/delete_command_env_endpoint_api_v1_bot_command_envs_guild_id_channel_id_kind_delete.py +204 -0
  27. skillforge_client/api/bot/fail_job_endpoint_api_v1_bot_jobs_job_id_fail_post.py +228 -0
  28. skillforge_client/api/bot/job_queue_summary_endpoint_api_v1_bot_jobs_summary_get.py +202 -0
  29. skillforge_client/api/bot/link_discord_account_endpoint_api_v1_bot_users_discord_id_account_put.py +227 -0
  30. skillforge_client/api/bot/list_jobs_endpoint_api_v1_bot_jobs_get.py +243 -0
  31. skillforge_client/api/bot/list_operations_endpoint_api_v1_bot_operations_get.py +302 -0
  32. skillforge_client/api/bot/prepare_student_activation_endpoint_api_v1_bot_students_activations_prepare_post.py +181 -0
  33. skillforge_client/api/bot/prepare_student_deactivation_endpoint_api_v1_bot_students_guild_id_student_discord_id_deactivate_prepare_post.py +190 -0
  34. skillforge_client/api/bot/prepare_student_pop_endpoint_api_v1_bot_students_guild_id_student_discord_id_pop_prepare_post.py +190 -0
  35. skillforge_client/api/bot/prepare_student_stash_endpoint_api_v1_bot_students_guild_id_student_discord_id_stash_prepare_post.py +190 -0
  36. skillforge_client/api/bot/prepare_tutor_activation_endpoint_api_v1_bot_tutors_activations_prepare_post.py +181 -0
  37. skillforge_client/api/bot/prepare_tutor_deactivation_endpoint_api_v1_bot_tutors_guild_id_tutor_discord_id_deactivate_prepare_post.py +190 -0
  38. skillforge_client/api/bot/read_job_api_v1_bot_jobs_job_id_get.py +186 -0
  39. skillforge_client/api/bot/read_operation_api_v1_bot_operations_operation_id_get.py +186 -0
  40. skillforge_client/api/bot/read_principal_api_v1_bot_runtime_principals_discord_id_get.py +177 -0
  41. skillforge_client/api/bot/read_principals_batch_api_v1_bot_runtime_principals_batch_post.py +189 -0
  42. skillforge_client/api/bot/read_student_context_api_v1_bot_runtime_students_guild_id_discord_id_get.py +191 -0
  43. skillforge_client/api/bot/read_student_contexts_batch_api_v1_bot_runtime_students_guild_id_batch_post.py +205 -0
  44. skillforge_client/api/bot/read_tutor_context_api_v1_bot_runtime_tutors_guild_id_discord_id_get.py +191 -0
  45. skillforge_client/api/bot/read_tutor_contexts_batch_api_v1_bot_runtime_tutors_guild_id_batch_post.py +205 -0
  46. skillforge_client/api/bot/remove_user_from_group_endpoint_api_v1_bot_users_discord_id_groups_group_key_delete.py +197 -0
  47. skillforge_client/api/bot/resolve_command_env_endpoint_api_v1_bot_runtime_command_envs_resolve_get.py +234 -0
  48. skillforge_client/api/bot/upsert_command_env_endpoint_api_v1_bot_command_envs_put.py +181 -0
  49. skillforge_client/api/bot/upsert_discord_user_endpoint_api_v1_bot_users_discord_id_put.py +213 -0
  50. skillforge_client/api/default/__init__.py +1 -0
  51. skillforge_client/api/default/root_get.py +81 -0
  52. skillforge_client/api/system/__init__.py +1 -0
  53. skillforge_client/api/system/dependencies_health_check_health_dependencies_get.py +136 -0
  54. skillforge_client/api/system/dependency_health_check_health_dependencies_dependency_name_get.py +170 -0
  55. skillforge_client/api/system/liveness_check_health_live_get.py +132 -0
  56. skillforge_client/api/system/system_health_check_health_get.py +136 -0
  57. skillforge_client/api/system/worker_health_check_health_workers_worker_name_get.py +170 -0
  58. skillforge_client/api/system/workers_health_check_health_workers_get.py +136 -0
  59. skillforge_client/client.py +268 -0
  60. skillforge_client/errors.py +16 -0
  61. skillforge_client/models/__init__.py +167 -0
  62. skillforge_client/models/access_token_response.py +85 -0
  63. skillforge_client/models/application_client_create_request.py +91 -0
  64. skillforge_client/models/application_client_response.py +149 -0
  65. skillforge_client/models/application_client_scope_grant_request.py +61 -0
  66. skillforge_client/models/application_client_secret_create_request.py +104 -0
  67. skillforge_client/models/application_client_secret_response.py +160 -0
  68. skillforge_client/models/application_client_status.py +9 -0
  69. skillforge_client/models/application_client_update_request.py +124 -0
  70. skillforge_client/models/authorization_check_request.py +78 -0
  71. skillforge_client/models/authorization_check_response.py +61 -0
  72. skillforge_client/models/body_create_token_api_v1_auth_token_post.py +123 -0
  73. skillforge_client/models/bot_job.py +119 -0
  74. skillforge_client/models/bot_job_payload.py +47 -0
  75. skillforge_client/models/bot_principal.py +148 -0
  76. skillforge_client/models/command_env_channel_response.py +100 -0
  77. skillforge_client/models/command_env_kind.py +9 -0
  78. skillforge_client/models/command_env_upsert_request.py +100 -0
  79. skillforge_client/models/contact_info_profile.py +92 -0
  80. skillforge_client/models/contact_info_type.py +9 -0
  81. skillforge_client/models/created_client_secret_response.py +75 -0
  82. skillforge_client/models/dependencies_health_check_response.py +77 -0
  83. skillforge_client/models/dependencies_health_check_response_checks.py +56 -0
  84. skillforge_client/models/dependency_health_check_response.py +72 -0
  85. skillforge_client/models/dependency_name.py +8 -0
  86. skillforge_client/models/discord_account_link_request.py +82 -0
  87. skillforge_client/models/discord_account_link_response.py +86 -0
  88. skillforge_client/models/discord_account_profile.py +77 -0
  89. skillforge_client/models/discord_id_batch_request.py +62 -0
  90. skillforge_client/models/discord_user_response.py +87 -0
  91. skillforge_client/models/discord_user_upsert_request.py +81 -0
  92. skillforge_client/models/error_response.py +61 -0
  93. skillforge_client/models/external_accounts_profile.py +124 -0
  94. skillforge_client/models/group_membership_response.py +69 -0
  95. skillforge_client/models/health_check_response.py +63 -0
  96. skillforge_client/models/health_status.py +10 -0
  97. skillforge_client/models/http_validation_error.py +79 -0
  98. skillforge_client/models/job_claim_request.py +113 -0
  99. skillforge_client/models/job_detail.py +239 -0
  100. skillforge_client/models/job_detail_payload.py +47 -0
  101. skillforge_client/models/job_fail_request.py +82 -0
  102. skillforge_client/models/job_kind_counts.py +92 -0
  103. skillforge_client/models/job_list_item.py +225 -0
  104. skillforge_client/models/job_page.py +100 -0
  105. skillforge_client/models/job_queue_summary.py +106 -0
  106. skillforge_client/models/job_response.py +187 -0
  107. skillforge_client/models/job_status.py +11 -0
  108. skillforge_client/models/job_status_counts.py +86 -0
  109. skillforge_client/models/member_role.py +10 -0
  110. skillforge_client/models/microsoft_account_profile.py +61 -0
  111. skillforge_client/models/operation_cancel_response.py +108 -0
  112. skillforge_client/models/operation_kind.py +13 -0
  113. skillforge_client/models/operation_page.py +100 -0
  114. skillforge_client/models/operation_response.py +257 -0
  115. skillforge_client/models/operation_response_plan.py +47 -0
  116. skillforge_client/models/operation_status.py +12 -0
  117. skillforge_client/models/operation_summary.py +243 -0
  118. skillforge_client/models/operational_profile.py +178 -0
  119. skillforge_client/models/party_relation_type.py +10 -0
  120. skillforge_client/models/person_profile.py +69 -0
  121. skillforge_client/models/principal_batch.py +84 -0
  122. skillforge_client/models/relation_profile.py +81 -0
  123. skillforge_client/models/relation_profile_direction.py +9 -0
  124. skillforge_client/models/student_activation_commit_request.py +61 -0
  125. skillforge_client/models/student_activation_prepare_request.py +77 -0
  126. skillforge_client/models/student_channel_state.py +9 -0
  127. skillforge_client/models/student_context.py +140 -0
  128. skillforge_client/models/student_context_batch.py +83 -0
  129. skillforge_client/models/system_health_check_response.py +87 -0
  130. skillforge_client/models/transition_commit_response.py +108 -0
  131. skillforge_client/models/transition_prepare_response.py +95 -0
  132. skillforge_client/models/transition_prepare_response_plan.py +47 -0
  133. skillforge_client/models/tutor_activation_commit_request.py +69 -0
  134. skillforge_client/models/tutor_activation_prepare_request.py +69 -0
  135. skillforge_client/models/tutor_context.py +99 -0
  136. skillforge_client/models/tutor_context_batch.py +83 -0
  137. skillforge_client/models/validation_error.py +123 -0
  138. skillforge_client/models/validation_error_context.py +47 -0
  139. skillforge_client/models/worker_health_check_response.py +72 -0
  140. skillforge_client/models/worker_name.py +8 -0
  141. skillforge_client/models/workers_health_check_response.py +77 -0
  142. skillforge_client/models/workers_health_check_response_checks.py +56 -0
  143. skillforge_client/py.typed +1 -0
  144. skillforge_client/types.py +54 -0
  145. skillforge_client-0.3.0.dist-info/METADATA +83 -0
  146. skillforge_client-0.3.0.dist-info/RECORD +147 -0
  147. skillforge_client-0.3.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,206 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.authorization_check_request import AuthorizationCheckRequest
9
+ from ...models.authorization_check_response import AuthorizationCheckResponse
10
+ from ...models.error_response import ErrorResponse
11
+ from ...models.http_validation_error import HTTPValidationError
12
+ from ...types import Response
13
+
14
+
15
+ def _get_kwargs(
16
+ *,
17
+ body: AuthorizationCheckRequest,
18
+ ) -> dict[str, Any]:
19
+ headers: dict[str, Any] = {}
20
+
21
+ _kwargs: dict[str, Any] = {
22
+ "method": "post",
23
+ "url": "/api/v1/bot/authz/check",
24
+ }
25
+
26
+ _kwargs["json"] = body.to_dict()
27
+
28
+ headers["Content-Type"] = "application/json"
29
+
30
+ _kwargs["headers"] = headers
31
+ return _kwargs
32
+
33
+
34
+ def _parse_response(
35
+ *, client: AuthenticatedClient | Client, response: httpx.Response
36
+ ) -> AuthorizationCheckResponse | ErrorResponse | HTTPValidationError | None:
37
+ if response.status_code == 200:
38
+ response_200 = AuthorizationCheckResponse.from_dict(response.json())
39
+
40
+ return response_200
41
+
42
+ if response.status_code == 401:
43
+ response_401 = ErrorResponse.from_dict(response.json())
44
+
45
+ return response_401
46
+
47
+ if response.status_code == 403:
48
+ response_403 = ErrorResponse.from_dict(response.json())
49
+
50
+ return response_403
51
+
52
+ if response.status_code == 404:
53
+ response_404 = ErrorResponse.from_dict(response.json())
54
+
55
+ return response_404
56
+
57
+ if response.status_code == 422:
58
+ response_422 = HTTPValidationError.from_dict(response.json())
59
+
60
+ return response_422
61
+
62
+ if client.raise_on_unexpected_status:
63
+ raise errors.UnexpectedStatus(response.status_code, response.content)
64
+ else:
65
+ return None
66
+
67
+
68
+ def _build_response(
69
+ *, client: AuthenticatedClient | Client, response: httpx.Response
70
+ ) -> Response[AuthorizationCheckResponse | ErrorResponse | HTTPValidationError]:
71
+ return Response(
72
+ status_code=HTTPStatus(response.status_code),
73
+ content=response.content,
74
+ headers=response.headers,
75
+ parsed=_parse_response(client=client, response=response),
76
+ )
77
+
78
+
79
+ def sync_detailed(
80
+ *,
81
+ client: AuthenticatedClient,
82
+ body: AuthorizationCheckRequest,
83
+ ) -> Response[AuthorizationCheckResponse | ErrorResponse | HTTPValidationError]:
84
+ """Check Authorization Endpoint
85
+
86
+ Check whether an actor may perform an action on a target party (direct or delegated).
87
+
88
+ Combines the grant engine (*whether* the actor may run `action_key`) with the delegation set
89
+ derived from `PartyRelation` (*on whose behalf* -- own party plus `PARENT_OF` / `PAYS_FOR`
90
+ targets). An inactive actor is denied; an unknown actor returns 404.
91
+
92
+ Args:
93
+ body (AuthorizationCheckRequest):
94
+
95
+ Raises:
96
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
97
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
98
+
99
+ Returns:
100
+ Response[AuthorizationCheckResponse | ErrorResponse | HTTPValidationError]
101
+ """
102
+
103
+ kwargs = _get_kwargs(
104
+ body=body,
105
+ )
106
+
107
+ response = client.get_httpx_client().request(
108
+ **kwargs,
109
+ )
110
+
111
+ return _build_response(client=client, response=response)
112
+
113
+
114
+ def sync(
115
+ *,
116
+ client: AuthenticatedClient,
117
+ body: AuthorizationCheckRequest,
118
+ ) -> AuthorizationCheckResponse | ErrorResponse | HTTPValidationError | None:
119
+ """Check Authorization Endpoint
120
+
121
+ Check whether an actor may perform an action on a target party (direct or delegated).
122
+
123
+ Combines the grant engine (*whether* the actor may run `action_key`) with the delegation set
124
+ derived from `PartyRelation` (*on whose behalf* -- own party plus `PARENT_OF` / `PAYS_FOR`
125
+ targets). An inactive actor is denied; an unknown actor returns 404.
126
+
127
+ Args:
128
+ body (AuthorizationCheckRequest):
129
+
130
+ Raises:
131
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
132
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
133
+
134
+ Returns:
135
+ AuthorizationCheckResponse | ErrorResponse | HTTPValidationError
136
+ """
137
+
138
+ return sync_detailed(
139
+ client=client,
140
+ body=body,
141
+ ).parsed
142
+
143
+
144
+ async def asyncio_detailed(
145
+ *,
146
+ client: AuthenticatedClient,
147
+ body: AuthorizationCheckRequest,
148
+ ) -> Response[AuthorizationCheckResponse | ErrorResponse | HTTPValidationError]:
149
+ """Check Authorization Endpoint
150
+
151
+ Check whether an actor may perform an action on a target party (direct or delegated).
152
+
153
+ Combines the grant engine (*whether* the actor may run `action_key`) with the delegation set
154
+ derived from `PartyRelation` (*on whose behalf* -- own party plus `PARENT_OF` / `PAYS_FOR`
155
+ targets). An inactive actor is denied; an unknown actor returns 404.
156
+
157
+ Args:
158
+ body (AuthorizationCheckRequest):
159
+
160
+ Raises:
161
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
162
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
163
+
164
+ Returns:
165
+ Response[AuthorizationCheckResponse | ErrorResponse | HTTPValidationError]
166
+ """
167
+
168
+ kwargs = _get_kwargs(
169
+ body=body,
170
+ )
171
+
172
+ response = await client.get_async_httpx_client().request(**kwargs)
173
+
174
+ return _build_response(client=client, response=response)
175
+
176
+
177
+ async def asyncio(
178
+ *,
179
+ client: AuthenticatedClient,
180
+ body: AuthorizationCheckRequest,
181
+ ) -> AuthorizationCheckResponse | ErrorResponse | HTTPValidationError | None:
182
+ """Check Authorization Endpoint
183
+
184
+ Check whether an actor may perform an action on a target party (direct or delegated).
185
+
186
+ Combines the grant engine (*whether* the actor may run `action_key`) with the delegation set
187
+ derived from `PartyRelation` (*on whose behalf* -- own party plus `PARENT_OF` / `PAYS_FOR`
188
+ targets). An inactive actor is denied; an unknown actor returns 404.
189
+
190
+ Args:
191
+ body (AuthorizationCheckRequest):
192
+
193
+ Raises:
194
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
195
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
196
+
197
+ Returns:
198
+ AuthorizationCheckResponse | ErrorResponse | HTTPValidationError
199
+ """
200
+
201
+ return (
202
+ await asyncio_detailed(
203
+ client=client,
204
+ body=body,
205
+ )
206
+ ).parsed
@@ -0,0 +1,210 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.bot_job import BotJob
9
+ from ...models.error_response import ErrorResponse
10
+ from ...models.http_validation_error import HTTPValidationError
11
+ from ...models.job_claim_request import JobClaimRequest
12
+ from ...types import Response
13
+
14
+
15
+ def _get_kwargs(
16
+ *,
17
+ body: JobClaimRequest,
18
+ ) -> dict[str, Any]:
19
+ headers: dict[str, Any] = {}
20
+
21
+ _kwargs: dict[str, Any] = {
22
+ "method": "post",
23
+ "url": "/api/v1/bot/jobs/claim",
24
+ }
25
+
26
+ _kwargs["json"] = body.to_dict()
27
+
28
+ headers["Content-Type"] = "application/json"
29
+
30
+ _kwargs["headers"] = headers
31
+ return _kwargs
32
+
33
+
34
+ def _parse_response(
35
+ *, client: AuthenticatedClient | Client, response: httpx.Response
36
+ ) -> ErrorResponse | HTTPValidationError | list[BotJob] | None:
37
+ if response.status_code == 200:
38
+ response_200 = []
39
+ _response_200 = response.json()
40
+ for response_200_item_data in _response_200:
41
+ response_200_item = BotJob.from_dict(response_200_item_data)
42
+
43
+ response_200.append(response_200_item)
44
+
45
+ return response_200
46
+
47
+ if response.status_code == 401:
48
+ response_401 = ErrorResponse.from_dict(response.json())
49
+
50
+ return response_401
51
+
52
+ if response.status_code == 403:
53
+ response_403 = ErrorResponse.from_dict(response.json())
54
+
55
+ return response_403
56
+
57
+ if response.status_code == 422:
58
+ response_422 = HTTPValidationError.from_dict(response.json())
59
+
60
+ return response_422
61
+
62
+ if client.raise_on_unexpected_status:
63
+ raise errors.UnexpectedStatus(response.status_code, response.content)
64
+ else:
65
+ return None
66
+
67
+
68
+ def _build_response(
69
+ *, client: AuthenticatedClient | Client, response: httpx.Response
70
+ ) -> Response[ErrorResponse | HTTPValidationError | list[BotJob]]:
71
+ return Response(
72
+ status_code=HTTPStatus(response.status_code),
73
+ content=response.content,
74
+ headers=response.headers,
75
+ parsed=_parse_response(client=client, response=response),
76
+ )
77
+
78
+
79
+ def sync_detailed(
80
+ *,
81
+ client: AuthenticatedClient,
82
+ body: JobClaimRequest,
83
+ ) -> Response[ErrorResponse | HTTPValidationError | list[BotJob]]:
84
+ """Claim Jobs Endpoint
85
+
86
+ Claim up to `limit` due jobs for processing.
87
+
88
+ **Delivery is at-least-once.** A claimed job whose worker dies is reclaimed once its lease
89
+ (5 minutes) expires and handed out again, so the same job can be delivered more than once.
90
+ Re-delivery is real, not hypothetical -- handlers **must be idempotent** and must not
91
+ trigger a duplicate side effect on a job they have already processed.
92
+
93
+ Args:
94
+ body (JobClaimRequest):
95
+
96
+ Raises:
97
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
98
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
99
+
100
+ Returns:
101
+ Response[ErrorResponse | HTTPValidationError | list[BotJob]]
102
+ """
103
+
104
+ kwargs = _get_kwargs(
105
+ body=body,
106
+ )
107
+
108
+ response = client.get_httpx_client().request(
109
+ **kwargs,
110
+ )
111
+
112
+ return _build_response(client=client, response=response)
113
+
114
+
115
+ def sync(
116
+ *,
117
+ client: AuthenticatedClient,
118
+ body: JobClaimRequest,
119
+ ) -> ErrorResponse | HTTPValidationError | list[BotJob] | None:
120
+ """Claim Jobs Endpoint
121
+
122
+ Claim up to `limit` due jobs for processing.
123
+
124
+ **Delivery is at-least-once.** A claimed job whose worker dies is reclaimed once its lease
125
+ (5 minutes) expires and handed out again, so the same job can be delivered more than once.
126
+ Re-delivery is real, not hypothetical -- handlers **must be idempotent** and must not
127
+ trigger a duplicate side effect on a job they have already processed.
128
+
129
+ Args:
130
+ body (JobClaimRequest):
131
+
132
+ Raises:
133
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
134
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
135
+
136
+ Returns:
137
+ ErrorResponse | HTTPValidationError | list[BotJob]
138
+ """
139
+
140
+ return sync_detailed(
141
+ client=client,
142
+ body=body,
143
+ ).parsed
144
+
145
+
146
+ async def asyncio_detailed(
147
+ *,
148
+ client: AuthenticatedClient,
149
+ body: JobClaimRequest,
150
+ ) -> Response[ErrorResponse | HTTPValidationError | list[BotJob]]:
151
+ """Claim Jobs Endpoint
152
+
153
+ Claim up to `limit` due jobs for processing.
154
+
155
+ **Delivery is at-least-once.** A claimed job whose worker dies is reclaimed once its lease
156
+ (5 minutes) expires and handed out again, so the same job can be delivered more than once.
157
+ Re-delivery is real, not hypothetical -- handlers **must be idempotent** and must not
158
+ trigger a duplicate side effect on a job they have already processed.
159
+
160
+ Args:
161
+ body (JobClaimRequest):
162
+
163
+ Raises:
164
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
165
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
166
+
167
+ Returns:
168
+ Response[ErrorResponse | HTTPValidationError | list[BotJob]]
169
+ """
170
+
171
+ kwargs = _get_kwargs(
172
+ body=body,
173
+ )
174
+
175
+ response = await client.get_async_httpx_client().request(**kwargs)
176
+
177
+ return _build_response(client=client, response=response)
178
+
179
+
180
+ async def asyncio(
181
+ *,
182
+ client: AuthenticatedClient,
183
+ body: JobClaimRequest,
184
+ ) -> ErrorResponse | HTTPValidationError | list[BotJob] | None:
185
+ """Claim Jobs Endpoint
186
+
187
+ Claim up to `limit` due jobs for processing.
188
+
189
+ **Delivery is at-least-once.** A claimed job whose worker dies is reclaimed once its lease
190
+ (5 minutes) expires and handed out again, so the same job can be delivered more than once.
191
+ Re-delivery is real, not hypothetical -- handlers **must be idempotent** and must not
192
+ trigger a duplicate side effect on a job they have already processed.
193
+
194
+ Args:
195
+ body (JobClaimRequest):
196
+
197
+ Raises:
198
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
199
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
200
+
201
+ Returns:
202
+ ErrorResponse | HTTPValidationError | list[BotJob]
203
+ """
204
+
205
+ return (
206
+ await asyncio_detailed(
207
+ client=client,
208
+ body=body,
209
+ )
210
+ ).parsed
@@ -0,0 +1,204 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+ from urllib.parse import quote
4
+ from uuid import UUID
5
+
6
+ import httpx
7
+
8
+ from ... import errors
9
+ from ...client import AuthenticatedClient, Client
10
+ from ...models.error_response import ErrorResponse
11
+ from ...models.http_validation_error import HTTPValidationError
12
+ from ...models.student_activation_commit_request import StudentActivationCommitRequest
13
+ from ...models.transition_commit_response import TransitionCommitResponse
14
+ from ...types import Response
15
+
16
+
17
+ def _get_kwargs(
18
+ operation_id: UUID,
19
+ *,
20
+ body: StudentActivationCommitRequest,
21
+ ) -> dict[str, Any]:
22
+ headers: dict[str, Any] = {}
23
+
24
+ _kwargs: dict[str, Any] = {
25
+ "method": "post",
26
+ "url": "/api/v1/bot/students/activations/{operation_id}/commit".format(
27
+ operation_id=quote(str(operation_id), safe=""),
28
+ ),
29
+ }
30
+
31
+ _kwargs["json"] = body.to_dict()
32
+
33
+ headers["Content-Type"] = "application/json"
34
+
35
+ _kwargs["headers"] = headers
36
+ return _kwargs
37
+
38
+
39
+ def _parse_response(
40
+ *, client: AuthenticatedClient | Client, response: httpx.Response
41
+ ) -> ErrorResponse | HTTPValidationError | TransitionCommitResponse | None:
42
+ if response.status_code == 200:
43
+ response_200 = TransitionCommitResponse.from_dict(response.json())
44
+
45
+ return response_200
46
+
47
+ if response.status_code == 401:
48
+ response_401 = ErrorResponse.from_dict(response.json())
49
+
50
+ return response_401
51
+
52
+ if response.status_code == 403:
53
+ response_403 = ErrorResponse.from_dict(response.json())
54
+
55
+ return response_403
56
+
57
+ if response.status_code == 404:
58
+ response_404 = ErrorResponse.from_dict(response.json())
59
+
60
+ return response_404
61
+
62
+ if response.status_code == 409:
63
+ response_409 = ErrorResponse.from_dict(response.json())
64
+
65
+ return response_409
66
+
67
+ if response.status_code == 422:
68
+ response_422 = HTTPValidationError.from_dict(response.json())
69
+
70
+ return response_422
71
+
72
+ if client.raise_on_unexpected_status:
73
+ raise errors.UnexpectedStatus(response.status_code, response.content)
74
+ else:
75
+ return None
76
+
77
+
78
+ def _build_response(
79
+ *, client: AuthenticatedClient | Client, response: httpx.Response
80
+ ) -> Response[ErrorResponse | HTTPValidationError | TransitionCommitResponse]:
81
+ return Response(
82
+ status_code=HTTPStatus(response.status_code),
83
+ content=response.content,
84
+ headers=response.headers,
85
+ parsed=_parse_response(client=client, response=response),
86
+ )
87
+
88
+
89
+ def sync_detailed(
90
+ operation_id: UUID,
91
+ *,
92
+ client: AuthenticatedClient,
93
+ body: StudentActivationCommitRequest,
94
+ ) -> Response[ErrorResponse | HTTPValidationError | TransitionCommitResponse]:
95
+ """Commit Student Activation Endpoint
96
+
97
+ Args:
98
+ operation_id (UUID):
99
+ body (StudentActivationCommitRequest):
100
+
101
+ Raises:
102
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
103
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
104
+
105
+ Returns:
106
+ Response[ErrorResponse | HTTPValidationError | TransitionCommitResponse]
107
+ """
108
+
109
+ kwargs = _get_kwargs(
110
+ operation_id=operation_id,
111
+ body=body,
112
+ )
113
+
114
+ response = client.get_httpx_client().request(
115
+ **kwargs,
116
+ )
117
+
118
+ return _build_response(client=client, response=response)
119
+
120
+
121
+ def sync(
122
+ operation_id: UUID,
123
+ *,
124
+ client: AuthenticatedClient,
125
+ body: StudentActivationCommitRequest,
126
+ ) -> ErrorResponse | HTTPValidationError | TransitionCommitResponse | None:
127
+ """Commit Student Activation Endpoint
128
+
129
+ Args:
130
+ operation_id (UUID):
131
+ body (StudentActivationCommitRequest):
132
+
133
+ Raises:
134
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
135
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
136
+
137
+ Returns:
138
+ ErrorResponse | HTTPValidationError | TransitionCommitResponse
139
+ """
140
+
141
+ return sync_detailed(
142
+ operation_id=operation_id,
143
+ client=client,
144
+ body=body,
145
+ ).parsed
146
+
147
+
148
+ async def asyncio_detailed(
149
+ operation_id: UUID,
150
+ *,
151
+ client: AuthenticatedClient,
152
+ body: StudentActivationCommitRequest,
153
+ ) -> Response[ErrorResponse | HTTPValidationError | TransitionCommitResponse]:
154
+ """Commit Student Activation Endpoint
155
+
156
+ Args:
157
+ operation_id (UUID):
158
+ body (StudentActivationCommitRequest):
159
+
160
+ Raises:
161
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
162
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
163
+
164
+ Returns:
165
+ Response[ErrorResponse | HTTPValidationError | TransitionCommitResponse]
166
+ """
167
+
168
+ kwargs = _get_kwargs(
169
+ operation_id=operation_id,
170
+ body=body,
171
+ )
172
+
173
+ response = await client.get_async_httpx_client().request(**kwargs)
174
+
175
+ return _build_response(client=client, response=response)
176
+
177
+
178
+ async def asyncio(
179
+ operation_id: UUID,
180
+ *,
181
+ client: AuthenticatedClient,
182
+ body: StudentActivationCommitRequest,
183
+ ) -> ErrorResponse | HTTPValidationError | TransitionCommitResponse | None:
184
+ """Commit Student Activation Endpoint
185
+
186
+ Args:
187
+ operation_id (UUID):
188
+ body (StudentActivationCommitRequest):
189
+
190
+ Raises:
191
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
192
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
193
+
194
+ Returns:
195
+ ErrorResponse | HTTPValidationError | TransitionCommitResponse
196
+ """
197
+
198
+ return (
199
+ await asyncio_detailed(
200
+ operation_id=operation_id,
201
+ client=client,
202
+ body=body,
203
+ )
204
+ ).parsed