Skip to content

Commit aa83ff0

Browse files
authored
✨ Feature: add deprecated decorator to endpoints (#257)
1 parent 2767a43 commit aa83ff0

File tree

17 files changed

+533
-1
lines changed

17 files changed

+533
-1
lines changed

codegen/templates/rest/_request.py.jinja

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,9 @@ error_models={
113113
},
114114
{% endif %}
115115
{% endmacro %}
116+
117+
{% macro build_request_deprecated_decorator(endpoint) %}
118+
{% if endpoint.deprecated -%}
119+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
120+
{% endif %}
121+
{% endmacro%}

codegen/templates/rest/client.py.jinja

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
{% from "rest/_param.py.jinja" import endpoint_params, endpoint_raw_params, endpoint_model_params %}
66
{% from "rest/_response.py.jinja" import build_response_type %}
7-
{% from "rest/_request.py.jinja" import build_request, build_request_params %}
7+
{% from "rest/_request.py.jinja" import build_request, build_request_params, build_request_deprecated_decorator %}
88
{% from "rest/_docstring.py.jinja" import build_docstring %}
99

1010
from __future__ import annotations
1111

1212
from collections.abc import Mapping
1313
from weakref import ref
1414
from typing import TYPE_CHECKING, Literal, Optional, Annotated, overload
15+
from typing_extensions import deprecated
1516

1617
from pydantic import BaseModel, Field
1718

@@ -78,6 +79,7 @@ class {{ pascal_case(tag) }}Client:
7879
{% if endpoint.request_body and endpoint.request_body.allowed_models %}
7980
{# generate raw data overload #}
8081
@overload
82+
{{ build_request_deprecated_decorator(endpoint) }}
8183
def {{ endpoint.name }}(
8284
self,
8385
{{ endpoint_raw_params(endpoint) | indent(8) }}
@@ -87,6 +89,7 @@ class {{ pascal_case(tag) }}Client:
8789
{# generate model data overload #}
8890
{% for model in endpoint.request_body.allowed_models %}
8991
@overload
92+
{{ build_request_deprecated_decorator(endpoint) }}
9093
def {{ endpoint.name }}(
9194
self,
9295
{{ endpoint_model_params(endpoint, model) | indent(8) }}
@@ -95,6 +98,7 @@ class {{ pascal_case(tag) }}Client:
9598

9699
{% endfor %}
97100
{% endif %}
101+
{{ build_request_deprecated_decorator(endpoint) }}
98102
def {{ endpoint.name }}(
99103
self,
100104
{{ endpoint_params(endpoint) | indent(8) }}
@@ -109,6 +113,7 @@ class {{ pascal_case(tag) }}Client:
109113
{% if endpoint.request_body and endpoint.request_body.allowed_models %}
110114
{# generate raw data overload #}
111115
@overload
116+
{{ build_request_deprecated_decorator(endpoint) }}
112117
async def async_{{ endpoint.name }}(
113118
self,
114119
{{ endpoint_raw_params(endpoint) | indent(8) }}
@@ -118,6 +123,7 @@ class {{ pascal_case(tag) }}Client:
118123
{# generate model data overload #}
119124
{% for model in endpoint.request_body.allowed_models %}
120125
@overload
126+
{{ build_request_deprecated_decorator(endpoint) }}
121127
async def async_{{ endpoint.name }}(
122128
self,
123129
{{ endpoint_model_params(endpoint, model) | indent(8) }}
@@ -126,6 +132,7 @@ class {{ pascal_case(tag) }}Client:
126132

127133
{% endfor %}
128134
{% endif %}
135+
{{ build_request_deprecated_decorator(endpoint) }}
129136
async def async_{{ endpoint.name }}(
130137
self,
131138
{{ endpoint_params(endpoint) | indent(8) }}

githubkit/versions/ghec_v2022_11_28/rest/codespaces.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from collections.abc import Mapping
1313
from typing import TYPE_CHECKING, Literal, Optional, overload
14+
from typing_extensions import deprecated
1415
from weakref import ref
1516

1617
from pydantic import BaseModel
@@ -208,6 +209,7 @@ async def async_list_in_organization(
208209
)
209210

210211
@overload
212+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
211213
def set_codespaces_access(
212214
self,
213215
org: str,
@@ -218,6 +220,7 @@ def set_codespaces_access(
218220
) -> Response: ...
219221

220222
@overload
223+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
221224
def set_codespaces_access(
222225
self,
223226
org: str,
@@ -234,6 +237,7 @@ def set_codespaces_access(
234237
selected_usernames: Missing[list[str]] = UNSET,
235238
) -> Response: ...
236239

240+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
237241
def set_codespaces_access(
238242
self,
239243
org: str,
@@ -282,6 +286,7 @@ def set_codespaces_access(
282286
)
283287

284288
@overload
289+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
285290
async def async_set_codespaces_access(
286291
self,
287292
org: str,
@@ -292,6 +297,7 @@ async def async_set_codespaces_access(
292297
) -> Response: ...
293298

294299
@overload
300+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
295301
async def async_set_codespaces_access(
296302
self,
297303
org: str,
@@ -308,6 +314,7 @@ async def async_set_codespaces_access(
308314
selected_usernames: Missing[list[str]] = UNSET,
309315
) -> Response: ...
310316

317+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
311318
async def async_set_codespaces_access(
312319
self,
313320
org: str,
@@ -356,6 +363,7 @@ async def async_set_codespaces_access(
356363
)
357364

358365
@overload
366+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
359367
def set_codespaces_access_users(
360368
self,
361369
org: str,
@@ -366,6 +374,7 @@ def set_codespaces_access_users(
366374
) -> Response: ...
367375

368376
@overload
377+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
369378
def set_codespaces_access_users(
370379
self,
371380
org: str,
@@ -376,6 +385,7 @@ def set_codespaces_access_users(
376385
selected_usernames: list[str],
377386
) -> Response: ...
378387

388+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
379389
def set_codespaces_access_users(
380390
self,
381391
org: str,
@@ -434,6 +444,7 @@ def set_codespaces_access_users(
434444
)
435445

436446
@overload
447+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
437448
async def async_set_codespaces_access_users(
438449
self,
439450
org: str,
@@ -444,6 +455,7 @@ async def async_set_codespaces_access_users(
444455
) -> Response: ...
445456

446457
@overload
458+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
447459
async def async_set_codespaces_access_users(
448460
self,
449461
org: str,
@@ -454,6 +466,7 @@ async def async_set_codespaces_access_users(
454466
selected_usernames: list[str],
455467
) -> Response: ...
456468

469+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
457470
async def async_set_codespaces_access_users(
458471
self,
459472
org: str,
@@ -512,6 +525,7 @@ async def async_set_codespaces_access_users(
512525
)
513526

514527
@overload
528+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
515529
def delete_codespaces_access_users(
516530
self,
517531
org: str,
@@ -522,6 +536,7 @@ def delete_codespaces_access_users(
522536
) -> Response: ...
523537

524538
@overload
539+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
525540
def delete_codespaces_access_users(
526541
self,
527542
org: str,
@@ -532,6 +547,7 @@ def delete_codespaces_access_users(
532547
selected_usernames: list[str],
533548
) -> Response: ...
534549

550+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
535551
def delete_codespaces_access_users(
536552
self,
537553
org: str,
@@ -590,6 +606,7 @@ def delete_codespaces_access_users(
590606
)
591607

592608
@overload
609+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
593610
async def async_delete_codespaces_access_users(
594611
self,
595612
org: str,
@@ -600,6 +617,7 @@ async def async_delete_codespaces_access_users(
600617
) -> Response: ...
601618

602619
@overload
620+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
603621
async def async_delete_codespaces_access_users(
604622
self,
605623
org: str,
@@ -610,6 +628,7 @@ async def async_delete_codespaces_access_users(
610628
selected_usernames: list[str],
611629
) -> Response: ...
612630

631+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
613632
async def async_delete_codespaces_access_users(
614633
self,
615634
org: str,

githubkit/versions/ghec_v2022_11_28/rest/enterprise_admin.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from collections.abc import Mapping
1313
from typing import TYPE_CHECKING, Literal, Optional, overload
14+
from typing_extensions import deprecated
1415
from weakref import ref
1516

1617
from pydantic import BaseModel
@@ -5418,6 +5419,7 @@ async def async_list_push_bypass_requests(
54185419
},
54195420
)
54205421

5422+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
54215423
def get_security_analysis_settings_for_enterprise(
54225424
self,
54235425
enterprise: str,
@@ -5461,6 +5463,7 @@ def get_security_analysis_settings_for_enterprise(
54615463
},
54625464
)
54635465

5466+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
54645467
async def async_get_security_analysis_settings_for_enterprise(
54655468
self,
54665469
enterprise: str,
@@ -5505,6 +5508,7 @@ async def async_get_security_analysis_settings_for_enterprise(
55055508
)
55065509

55075510
@overload
5511+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
55085512
def patch_security_analysis_settings_for_enterprise(
55095513
self,
55105514
enterprise: str,
@@ -5517,6 +5521,7 @@ def patch_security_analysis_settings_for_enterprise(
55175521
) -> Response: ...
55185522

55195523
@overload
5524+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
55205525
def patch_security_analysis_settings_for_enterprise(
55215526
self,
55225527
enterprise: str,
@@ -5537,6 +5542,7 @@ def patch_security_analysis_settings_for_enterprise(
55375542
] = UNSET,
55385543
) -> Response: ...
55395544

5545+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
55405546
def patch_security_analysis_settings_for_enterprise(
55415547
self,
55425548
enterprise: str,
@@ -5596,6 +5602,7 @@ def patch_security_analysis_settings_for_enterprise(
55965602
)
55975603

55985604
@overload
5605+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
55995606
async def async_patch_security_analysis_settings_for_enterprise(
56005607
self,
56015608
enterprise: str,
@@ -5608,6 +5615,7 @@ async def async_patch_security_analysis_settings_for_enterprise(
56085615
) -> Response: ...
56095616

56105617
@overload
5618+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
56115619
async def async_patch_security_analysis_settings_for_enterprise(
56125620
self,
56135621
enterprise: str,
@@ -5628,6 +5636,7 @@ async def async_patch_security_analysis_settings_for_enterprise(
56285636
] = UNSET,
56295637
) -> Response: ...
56305638

5639+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
56315640
async def async_patch_security_analysis_settings_for_enterprise(
56325641
self,
56335642
enterprise: str,
@@ -8928,6 +8937,7 @@ async def async_get_enterprise_ruleset_version(
89288937
},
89298938
)
89308939

8940+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
89318941
def post_security_product_enablement_for_enterprise(
89328942
self,
89338943
enterprise: str,
@@ -8976,6 +8986,7 @@ def post_security_product_enablement_for_enterprise(
89768986
},
89778987
)
89788988

8989+
@deprecated("Deprecated API endpoint. See the docstring for more details.")
89798990
async def async_post_security_product_enablement_for_enterprise(
89808991
self,
89818992
enterprise: str,

0 commit comments

Comments
 (0)