-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: 🐝 Update SDK - Generate (#46)
# SDK update Based on: - OpenAPI Doc 0.0.1 - Speakeasy CLI 1.200.0 (2.277.0) https://github.com/speakeasy-api/speakeasy ## PYTHON CHANGELOG ## unions: 2.82.6 - 2024-02-29 ### 🐛 Bug Fixes - null-enums are treated as switch a oneOf field to nullable *(commit by [@disintegrator](https://github.com/disintegrator))* ## core: 4.5.0 - 2024-02-19 ### 🐝 New Features - add sdk hooks support to python *(commit by [@TristanSpeakEasy](https://github.com/TristanSpeakeasy))* ## globalSecurity: 2.83.4 - 2024-02-26 ### 🔧 Chores - add no-security testcase *(commit by [@2ynn](https://github.com/2ynn))* ## globalSecurity: 2.83.3 - 2024-02-23 ### 🐛 Bug Fixes - allow security to be disabled at the operation level *(commit by [@TristanSpeakEasy](https://github.com/TristanSpeakeasy))* --------- Co-authored-by: speakeasybot <[email protected]>
- Loading branch information
1 parent
3961bb0
commit 4afad44
Showing
15 changed files
with
279 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" | ||
|
||
from .sdkhooks import * | ||
from .types import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" | ||
|
||
import requests | ||
from .types import SDKInitHook, BeforeRequestContext, BeforeRequestHook, AfterSuccessContext, AfterSuccessHook, AfterErrorContext, AfterErrorHook, Hooks | ||
from typing import List, Optional, Tuple, Union | ||
|
||
|
||
class SDKHooks(Hooks): | ||
sdk_init_hooks: List[SDKInitHook] = [] | ||
before_request_hooks: List[BeforeRequestHook] = [] | ||
after_success_hooks: List[AfterSuccessHook] = [] | ||
after_error_hooks: List[AfterErrorHook] = [] | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def register_sdk_init_hook(self, hook: SDKInitHook) -> None: | ||
self.sdk_init_hooks.append(hook) | ||
|
||
def register_before_request_hook(self, hook: BeforeRequestHook) -> None: | ||
self.before_request_hooks.append(hook) | ||
|
||
def register_after_success_hook(self, hook: AfterSuccessHook) -> None: | ||
self.after_success_hooks.append(hook) | ||
|
||
def register_after_error_hook(self, hook: AfterErrorHook) -> None: | ||
self.after_error_hooks.append(hook) | ||
|
||
def sdk_init(self, base_url: str, client: requests.Session) -> Tuple[str, requests.Session]: | ||
for hook in self.sdk_init_hooks: | ||
base_url, client = hook.sdk_init(base_url, client) | ||
return base_url, client | ||
|
||
def before_request(self, hook_ctx: BeforeRequestContext, request: requests.PreparedRequest) -> Union[requests.PreparedRequest, Exception]: | ||
for hook in self.before_request_hooks: | ||
request = hook.before_request(hook_ctx, request) | ||
if isinstance(request, Exception): | ||
raise request | ||
|
||
return request | ||
|
||
def after_success(self, hook_ctx: AfterSuccessContext, response: requests.Response) -> requests.Response: | ||
for hook in self.after_success_hooks: | ||
response = hook.after_success(hook_ctx, response) | ||
if isinstance(response, Exception): | ||
raise response | ||
return response | ||
|
||
def after_error(self, hook_ctx: AfterErrorContext, response: Optional[requests.Response], error: Optional[Exception]) -> Tuple[Optional[requests.Response], Optional[Exception]]: | ||
for hook in self.after_error_hooks: | ||
result = hook.after_error(hook_ctx, response, error) | ||
if isinstance(result, Exception): | ||
raise result | ||
response, error = result | ||
return response, error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" | ||
|
||
import requests as requests_http | ||
from abc import ABC, abstractmethod | ||
from typing import Any, Callable, List, Optional, Tuple, Union | ||
|
||
|
||
class HookContext: | ||
operation_id: str | ||
oauth2_scopes: Optional[List[str]] = None | ||
security_source: Optional[Union[Any, Callable[[], Any]]] = None | ||
|
||
def __init__(self, operation_id: str, oauth2_scopes: Optional[List[str]], security_source: Optional[Union[Any, Callable[[], Any]]]): | ||
self.operation_id = operation_id | ||
self.oauth2_scopes = oauth2_scopes | ||
self.security_source = security_source | ||
|
||
|
||
class BeforeRequestContext(HookContext): | ||
pass | ||
|
||
|
||
class AfterSuccessContext(HookContext): | ||
pass | ||
|
||
|
||
class AfterErrorContext(HookContext): | ||
pass | ||
|
||
|
||
class SDKInitHook(ABC): | ||
@abstractmethod | ||
def sdk_init(self, base_url: str, client: requests_http.Session) -> Tuple[str, requests_http.Session]: | ||
pass | ||
|
||
|
||
class BeforeRequestHook(ABC): | ||
@abstractmethod | ||
def before_request(self, hook_ctx: BeforeRequestContext, request: requests_http.PreparedRequest) -> Union[requests_http.PreparedRequest, Exception]: | ||
pass | ||
|
||
|
||
class AfterSuccessHook(ABC): | ||
@abstractmethod | ||
def after_success(self, hook_ctx: AfterSuccessContext, response: requests_http.Response) -> Union[requests_http.PreparedRequest, Exception]: | ||
pass | ||
|
||
|
||
class AfterErrorHook(ABC): | ||
@abstractmethod | ||
def after_error(self, hook_ctx: AfterErrorContext, response: Optional[requests_http.Response], error: Optional[Exception]) -> Union[Tuple[Optional[requests_http.PreparedRequest], Optional[Exception]], Exception]: | ||
pass | ||
|
||
|
||
class Hooks(ABC): | ||
@abstractmethod | ||
def register_sdk_init_hook(self, hook: SDKInitHook): | ||
pass | ||
|
||
@abstractmethod | ||
def register_before_request_hook(self, hook: BeforeRequestHook): | ||
pass | ||
|
||
@abstractmethod | ||
def register_after_success_hook(self, hook: AfterSuccessHook): | ||
pass | ||
|
||
@abstractmethod | ||
def register_after_error_hook(self, hook: AfterErrorHook): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.