|
| 1 | +from __future__ import annotations |
| 2 | + |
1 | 3 | import logging |
2 | 4 | import os |
3 | 5 | import tempfile |
@@ -130,14 +132,14 @@ def __init__(self, results: T, cursor: Mapping): |
130 | 132 |
|
131 | 133 |
|
132 | 134 | class RsConnectApi: |
133 | | - api_key: "str | None" |
134 | | - server_url: "str" |
| 135 | + api_key: str | None |
| 136 | + server_url: str |
135 | 137 |
|
136 | 138 | def __init__( |
137 | 139 | self, |
138 | | - server_url: "str | None", |
139 | | - api_key: "str | None" = None, |
140 | | - session: "requests.Session | None" = None, |
| 140 | + server_url: str | None, |
| 141 | + api_key: str | None = None, |
| 142 | + session: requests.Session | None = None, |
141 | 143 | ): |
142 | 144 | self.server_url = server_url |
143 | 145 | self.api_key = api_key |
@@ -182,7 +184,7 @@ def _get_headers(self): |
182 | 184 |
|
183 | 185 | return {**d_key, **d_rsc} |
184 | 186 |
|
185 | | - def _validate_json_response(self, data: "dict | list"): |
| 187 | + def _validate_json_response(self, data: dict | list): |
186 | 188 | if isinstance(data, list): |
187 | 189 | return |
188 | 190 |
|
@@ -257,23 +259,23 @@ def walk_paginated_offsets(self, f_query, endpoint, method, params=None, **kwarg |
257 | 259 |
|
258 | 260 | # users ---- |
259 | 261 |
|
260 | | - def get_user(self, guid: str = None) -> User: |
| 262 | + def get_user(self, guid: str | None = None) -> User: |
261 | 263 | if guid is None: |
262 | 264 | return User(self.query_v1("user")) |
263 | 265 |
|
264 | | - result = self.query_v1(f"user/{guid}") |
| 266 | + result = self.query_v1(f"users/{guid}") |
265 | 267 | return User(result) |
266 | 268 |
|
267 | 269 | def get_users( |
268 | 270 | self, |
269 | | - prefix: "str | None" = None, |
270 | | - user_role: "str | None" = None, |
271 | | - account_status: "str | None" = None, |
272 | | - page_number: "int | None" = None, |
273 | | - page_size: "int | None" = None, |
274 | | - asc_order: "bool | None" = None, |
| 271 | + prefix: str | None = None, |
| 272 | + user_role: str | None = None, |
| 273 | + account_status: str | None = None, |
| 274 | + page_number: int | None = None, |
| 275 | + page_size: int | None = None, |
| 276 | + asc_order: bool | None = None, |
275 | 277 | walk_pages=True, |
276 | | - ) -> "Sequence[User] | Sequence[dict]": |
| 278 | + ) -> Sequence[User] | Sequence[dict]: |
277 | 279 | params = {k: v for k, v in locals().items() if k != "self" if v is not None} |
278 | 280 |
|
279 | 281 | if walk_pages: |
@@ -303,7 +305,7 @@ def post_content_item( |
303 | 305 |
|
304 | 306 | return Content(result) |
305 | 307 |
|
306 | | - def post_content_item_deploy(self, guid: str, bundle_id: "str | None" = None): |
| 308 | + def post_content_item_deploy(self, guid: str, bundle_id: str | None = None): |
307 | 309 | json = {"bundle_id": bundle_id} if bundle_id is not None else {} |
308 | 310 | return self.query_v1(f"content/{guid}/deploy", "POST", json=json) |
309 | 311 |
|
@@ -345,9 +347,7 @@ def get_content_bundle(self, guid: str, id: int) -> Bundle: |
345 | 347 | result = self.query_v1(f"content/{guid}/bundles/{id}") |
346 | 348 | return Bundle(result) |
347 | 349 |
|
348 | | - def get_content_bundle_archive( |
349 | | - self, guid: str, id: str, f_obj: "str | IOBase" |
350 | | - ) -> None: |
| 350 | + def get_content_bundle_archive(self, guid: str, id: str, f_obj: str | IOBase) -> None: |
351 | 351 | r = self.query_v1( |
352 | 352 | f"content/{guid}/bundles/{id}/download", stream=True, return_request=True |
353 | 353 | ) |
@@ -399,7 +399,7 @@ def misc_ping(self): |
399 | 399 | return self._raw_query(f"{self.server_url}/__ping__") |
400 | 400 |
|
401 | 401 | def misc_get_content_bundle_file( |
402 | | - self, guid: str, id: str, fname: str, f_obj: "str | IOBase | None" = None |
| 402 | + self, guid: str, id: str, fname: str, f_obj: str | IOBase | None = None |
403 | 403 | ): |
404 | 404 | if f_obj is None: |
405 | 405 | f_obj = fname |
|
0 commit comments