codecraftai-restclient-gitlab 1.2.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 (70) hide show
  1. ccai/gitlab/py.typed +0 -0
  2. ccai/gitlab/rest/aspectsrest.py +120 -0
  3. ccai/gitlab/rest/clients/__init__.py +0 -0
  4. ccai/gitlab/rest/clients/gitlabrestclient.py +118 -0
  5. ccai/gitlab/rest/clients/groups/__init__.py +0 -0
  6. ccai/gitlab/rest/clients/groups/accessrequests.py +230 -0
  7. ccai/gitlab/rest/clients/groups/admin.py +41 -0
  8. ccai/gitlab/rest/clients/groups/alertmanagement.py +149 -0
  9. ccai/gitlab/rest/clients/groups/application.py +68 -0
  10. ccai/gitlab/rest/clients/groups/applications.py +95 -0
  11. ccai/gitlab/rest/clients/groups/avatar.py +41 -0
  12. ccai/gitlab/rest/clients/groups/badges.py +338 -0
  13. ccai/gitlab/rest/clients/groups/batchedbackgroundmigrations.py +122 -0
  14. ccai/gitlab/rest/clients/groups/branches.py +230 -0
  15. ccai/gitlab/rest/clients/groups/broadcastmessages.py +149 -0
  16. ccai/gitlab/rest/clients/groups/bulkimports.py +176 -0
  17. ccai/gitlab/rest/clients/groups/clusters.py +149 -0
  18. ccai/gitlab/rest/clients/groups/jobs.py +95 -0
  19. ccai/gitlab/rest/clients/groups/metadata.py +68 -0
  20. ccai/gitlab/rest/clients/groups/migrations.py +41 -0
  21. ccai/gitlab/rest/clients/groups/pipelinecomposition.py +146 -0
  22. ccai/gitlab/rest/clients/groups/planlimits.py +68 -0
  23. ccai/gitlab/rest/clients/parameters/__init__.py +0 -0
  24. ccai/gitlab/rest/clients/parameters/accessrequests.py +222 -0
  25. ccai/gitlab/rest/clients/parameters/admin.py +31 -0
  26. ccai/gitlab/rest/clients/parameters/alertmanagement.py +147 -0
  27. ccai/gitlab/rest/clients/parameters/application.py +27 -0
  28. ccai/gitlab/rest/clients/parameters/applications.py +51 -0
  29. ccai/gitlab/rest/clients/parameters/avatar.py +31 -0
  30. ccai/gitlab/rest/clients/parameters/badges.py +344 -0
  31. ccai/gitlab/rest/clients/parameters/batchedbackgroundmigrations.py +105 -0
  32. ccai/gitlab/rest/clients/parameters/branches.py +236 -0
  33. ccai/gitlab/rest/clients/parameters/broadcastmessages.py +123 -0
  34. ccai/gitlab/rest/clients/parameters/bulkimports.py +173 -0
  35. ccai/gitlab/rest/clients/parameters/clusters.py +100 -0
  36. ccai/gitlab/rest/clients/parameters/jobs.py +88 -0
  37. ccai/gitlab/rest/clients/parameters/metadata.py +11 -0
  38. ccai/gitlab/rest/clients/parameters/migrations.py +29 -0
  39. ccai/gitlab/rest/clients/parameters/pipelinecomposition.py +123 -0
  40. ccai/gitlab/rest/clients/parameters/planlimits.py +47 -0
  41. ccai/gitlab/rest/clients/responses/__init__.py +0 -0
  42. ccai/gitlab/rest/clients/responses/accessrequests.py +157 -0
  43. ccai/gitlab/rest/clients/responses/admin.py +24 -0
  44. ccai/gitlab/rest/clients/responses/alertmanagement.py +100 -0
  45. ccai/gitlab/rest/clients/responses/application.py +43 -0
  46. ccai/gitlab/rest/clients/responses/applications.py +62 -0
  47. ccai/gitlab/rest/clients/responses/avatar.py +24 -0
  48. ccai/gitlab/rest/clients/responses/badges.py +233 -0
  49. ccai/gitlab/rest/clients/responses/batchedbackgroundmigrations.py +81 -0
  50. ccai/gitlab/rest/clients/responses/branches.py +157 -0
  51. ccai/gitlab/rest/clients/responses/broadcastmessages.py +100 -0
  52. ccai/gitlab/rest/clients/responses/bulkimports.py +119 -0
  53. ccai/gitlab/rest/clients/responses/clusters.py +100 -0
  54. ccai/gitlab/rest/clients/responses/jobs.py +62 -0
  55. ccai/gitlab/rest/clients/responses/metadata.py +43 -0
  56. ccai/gitlab/rest/clients/responses/migrations.py +24 -0
  57. ccai/gitlab/rest/clients/responses/pipelinecomposition.py +100 -0
  58. ccai/gitlab/rest/clients/responses/planlimits.py +43 -0
  59. ccai/gitlab/rest/descriptions/gitlab-openapi-hints.yaml +195 -0
  60. ccai/gitlab/rest/descriptions/gitlab-openapi-spec.yaml +3635 -0
  61. ccai/gitlab/rest/generation/__init__.py +0 -0
  62. ccai/gitlab/rest/generation/restclientgenerator.py +581 -0
  63. ccai/gitlab/rest/itemsresult.py +274 -0
  64. ccai/gitlab/rest/restapigroup.py +17 -0
  65. ccai/gitlab/rest/restclientbase.py +676 -0
  66. ccai/gitlab/rest/restclientutils.py +0 -0
  67. codecraftai_restclient_gitlab-1.2.0.dist-info/METADATA +90 -0
  68. codecraftai_restclient_gitlab-1.2.0.dist-info/RECORD +70 -0
  69. codecraftai_restclient_gitlab-1.2.0.dist-info/WHEEL +4 -0
  70. codecraftai_restclient_gitlab-1.2.0.dist-info/licenses/LICENSE.md +204 -0
@@ -0,0 +1,274 @@
1
+ """
2
+ .. module:: itemsresult
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: itemsresult module.
5
+
6
+ .. moduleauthor:: Myron Walker <myron.walker@gmail.com>
7
+ """
8
+
9
+ __author__ = "Myron Walker"
10
+ __copyright__ = "Copyright 2025, Code Craft AI LLC"
11
+ __credits__ = []
12
+
13
+
14
+ from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union
15
+
16
+ from requests import Response
17
+
18
+ from ccai.gitlab.rest.aspectsrest import AspectsRest
19
+
20
+
21
+ CT = TypeVar("CT")
22
+
23
+
24
+ class PreCannedRequest(Generic[CT]):
25
+ """
26
+ Container for REST call details used to generate an :class:`ItemsResult` later.
27
+ """
28
+
29
+ def __init__(
30
+ self,
31
+ *,
32
+ leaf: str,
33
+ method: str,
34
+ params: Union[Dict[str, str], None],
35
+ body: Union[Dict[str, Any], None],
36
+ exp_status: Union[int, List[int]],
37
+ aspects: Union[AspectsRest, None],
38
+ perform_call: Callable,
39
+ package_result: Callable
40
+ ):
41
+ """
42
+ Stores call details for later execution.
43
+
44
+ :param leaf: API leaf path.
45
+ :param method: HTTP method name.
46
+ :param params: Query parameters for the call.
47
+ :param body: Body payload for the call.
48
+ :param exp_status: Expected HTTP status codes.
49
+ :param aspects: Optional call aspects.
50
+ :param perform_call: Callable used to perform the call.
51
+ :param package_result: Callable used to package the response.
52
+
53
+ :returns: None
54
+ """
55
+
56
+ self._leaf = leaf
57
+ self._method = method
58
+ self._params = params
59
+ self._body = body
60
+ self._exp_status = exp_status
61
+ self._aspects = aspects
62
+ self._perform_call = perform_call
63
+ self._package_result = package_result
64
+ return
65
+
66
+ def perform_call(self) -> "ItemsResult[CT]":
67
+ """
68
+ Perform the pre-canned REST call stored on this instance and
69
+ package the result into an :class:`ItemsResult` object.
70
+
71
+ :returns: The result object created from the REST call.
72
+ """
73
+
74
+ resp: Response = self._perform_call(
75
+ leaf=self.leaf,
76
+ method=self._method,
77
+ params=self._params,
78
+ body=self._body,
79
+ exp_status=self._exp_status,
80
+ aspects=self._aspects,
81
+ )
82
+ result = self._package_result(resp)
83
+
84
+ return result
85
+
86
+ @property
87
+ def leaf(self) -> str:
88
+ """
89
+ API leaf path for the stored call.
90
+
91
+ :returns: Leaf path string.
92
+ """
93
+ return self._leaf
94
+
95
+
96
+ class Paging:
97
+ """
98
+ The :class:`Paging` object combines a the collection of parameters that are necessary to preform paging opertions
99
+ on the results of a REST API call for a collection.
100
+ """
101
+
102
+ def __init__(
103
+ self,
104
+ *,
105
+ page: int,
106
+ count: int,
107
+ total_count: int,
108
+ per_page: int,
109
+ first_page: int,
110
+ last_page: int,
111
+ request_next: Optional[PreCannedRequest] = None,
112
+ request_prev: Optional[PreCannedRequest] = None
113
+ ):
114
+ """
115
+ Construct a paging descriptor for REST collection results.
116
+
117
+ :param page: Current page number.
118
+ :param count: Number of items in this page.
119
+ :param total_count: Total items across all pages.
120
+ :param per_page: Maximum items per page.
121
+ :param first_page: First page index available.
122
+ :param last_page: Last page index available.
123
+ :param request_next: Callable request for the next page.
124
+ :param request_prev: Callable request for the previous page.
125
+ """
126
+ self._page = page
127
+ self._count = count
128
+ self._total_count = total_count
129
+ self._per_page = per_page
130
+ self._first_page = first_page
131
+ self._last_page = last_page
132
+
133
+ self._request_next = request_next
134
+ self._request_prev = request_prev
135
+ return
136
+
137
+ @property
138
+ def count(self) -> int:
139
+ """
140
+ Number of items returned in the current result.
141
+
142
+ :returns: Count of items in this page.
143
+ """
144
+ return self._count
145
+
146
+ @property
147
+ def first_page(self) -> int:
148
+ """
149
+ First page number available in the result set.
150
+
151
+ :returns: Integer index of the first page.
152
+ """
153
+ return self._first_page
154
+
155
+ @property
156
+ def last_page(self) -> int:
157
+ """
158
+ Last page number available in the result set.
159
+
160
+ :returns: Integer index of the last page.
161
+ """
162
+ return self._last_page
163
+
164
+ @property
165
+ def page(self) -> int:
166
+ """
167
+ Current page number of the results.
168
+
169
+ :returns: Page index beginning at ``1``.
170
+ """
171
+ return self._page
172
+
173
+ @property
174
+ def per_page(self) -> int:
175
+ """
176
+ Maximum number of items returned per page.
177
+
178
+ :returns: Items per page value.
179
+ """
180
+ return self._per_page
181
+
182
+ @property
183
+ def request_next(self) -> Union[PreCannedRequest, None]:
184
+ """
185
+ Stored callable to retrieve the next page of results.
186
+
187
+ :returns: A :class:`PreCannedRequest` for the next page or ``None``.
188
+ """
189
+ return self._request_next
190
+
191
+ @property
192
+ def request_prev(self) -> Union[PreCannedRequest, None]:
193
+ """
194
+ Stored callable to retrieve the previous page of results.
195
+
196
+ :returns: A :class:`PreCannedRequest` for the previous page or ``None``.
197
+ """
198
+ return self._request_prev
199
+
200
+ @property
201
+ def total_count(self) -> int:
202
+ """
203
+ Total number of items available across all pages.
204
+
205
+ :returns: Overall item count.
206
+ """
207
+ return self._total_count
208
+
209
+
210
+ class ItemsResult(Generic[CT]):
211
+ """
212
+ Holds a list of returned items and optional paging information.
213
+ """
214
+
215
+ def __init__(self, items: List[CT], paging: Optional[Paging] = None):
216
+ """
217
+ Container object for paged or unpaged collections.
218
+ """
219
+ self._items = items
220
+ self._paging = paging
221
+ return
222
+
223
+ @property
224
+ def is_paged(self):
225
+ """
226
+ Returns a value indicating if this items result is paged.
227
+
228
+ :returns: ``True`` if paging information is present.
229
+ """
230
+ rtnval = True if self._paging is not None else False
231
+ return rtnval
232
+
233
+ @property
234
+ def items(self) -> List[CT]:
235
+ """
236
+ Returns a list of items. This could be a complete list of items or the items from a page depending
237
+ on the results of the API call.
238
+
239
+ :returns: The list of items for this result.
240
+ """
241
+ return self._items
242
+
243
+ @property
244
+ def paging(self) -> Union[Paging, None]:
245
+ """
246
+ Returns the paging details for this result.
247
+
248
+ :returns: A :class:`Paging` object or ``None`` if the result is unpaged.
249
+ """
250
+ return self._paging
251
+
252
+ def next_page_result(self) -> "ItemsResult[CT]":
253
+ """
254
+ Retrieve the next page of results if there is one.
255
+ """
256
+
257
+ result = None
258
+
259
+ if self._paging.request_next is not None:
260
+ result = self._paging.request_next.perform_call()
261
+
262
+ return result
263
+
264
+ def prev_page_result(self) -> "ItemsResult[CT]":
265
+ """
266
+ Retrieve the next page of results if there is one.
267
+ """
268
+
269
+ result = None
270
+
271
+ if self._paging.request_prev is not None:
272
+ result = self._paging.request_prev.perform_call()
273
+
274
+ return result
@@ -0,0 +1,17 @@
1
+ from typing import TYPE_CHECKING
2
+
3
+ import weakref
4
+
5
+ if TYPE_CHECKING:
6
+ from ccai.gitlab.rest.restclientbase import RestClientBase
7
+
8
+
9
+ class RestApiGroup:
10
+
11
+ def __init__(self, client: "RestClientBase"):
12
+ self._client_ref = weakref.ref(client)
13
+ return
14
+
15
+ @property
16
+ def client(self) -> "RestClientBase":
17
+ return self._client_ref()