|
16 | 16 | from volcengine.ServiceInfo import ServiceInfo |
17 | 17 | from volcengine.base.Request import Request |
18 | 18 | from volcengine.base.Service import Service |
| 19 | +import requests |
19 | 20 |
|
20 | | -from .auth import Auth |
| 21 | +from .auth import Auth, IAM, APIKey |
21 | 22 | from .exceptions import ( |
22 | 23 | DEFAULT_UNKNOWN_ERROR_CODE, |
23 | 24 | VikingAPIException, |
@@ -52,7 +53,13 @@ def __init__( |
52 | 53 | timeout=timeout, |
53 | 54 | ) |
54 | 55 | self.api_info = self._build_api_info() |
55 | | - super().__init__(self.service_info, self.api_info) |
| 56 | + # 判断auth是不是IAM 还是 APIKey类型 |
| 57 | + if isinstance(auth, IAM): |
| 58 | + super().__init__(self.service_info, self.api_info) |
| 59 | + elif isinstance(auth, APIKey): |
| 60 | + self.session = requests.session() |
| 61 | + else: |
| 62 | + raise ValueError("auth must be IAM or APIKey type") |
56 | 63 |
|
57 | 64 | if sts_token: |
58 | 65 | self.set_session_token(session_token=sts_token) |
@@ -81,7 +88,7 @@ def _build_service_info( |
81 | 88 | def prepare_request(self, api_info: ApiInfo, params: Optional[Mapping[str, Any]], doseq: int = 0): |
82 | 89 | """Prepare a volcengine request without adding implicit headers.""" |
83 | 90 | request = Request() |
84 | | - request.set_schema(self.service_info.scheme) |
| 91 | + request.set_shema(self.service_info.scheme) |
85 | 92 | request.set_method(api_info.method) |
86 | 93 | request.set_host(self.service_info.host) |
87 | 94 | request.set_path(api_info.path) |
|
0 commit comments