Skip to content

Commit

Permalink
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.198.1
Browse files Browse the repository at this point in the history
  • Loading branch information
speakeasybot committed Mar 1, 2024
1 parent 4ca7901 commit 5ee9010
Show file tree
Hide file tree
Showing 12 changed files with 277 additions and 30 deletions.
11 changes: 7 additions & 4 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ management:
docChecksum: 2516596125ef223fbbef6c434d22eaac
docVersion: 1.0.0
speakeasyVersion: internal
generationVersion: 2.258.2
releaseVersion: 0.13.1
configChecksum: a0520f518d0ee53a5190269296d9a625
generationVersion: 2.275.4
releaseVersion: 0.14.0
configChecksum: 3094cf1ed617220ed856b216803e40c9
repoURL: https://github.com/speakeasy-sdks/test-repo-test2.git
repoSubDirectory: .
installationURL: https://github.com/speakeasy-sdks/test-repo-test2.git
features:
python:
core: 4.4.6
core: 4.5.0
globalServerURLs: 2.82.1
generatedFiles:
- src/test/sdkconfiguration.py
Expand Down Expand Up @@ -46,3 +46,6 @@ generatedFiles:
- docs/sdks/pets/README.md
- USAGE.md
- .gitattributes
- src/test/_hooks/sdkhooks.py
- src/test/_hooks/types.py
- src/test/_hooks/__init__.py
10 changes: 9 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,12 @@ Based on:
- OpenAPI Doc 1.0.0
- Speakeasy CLI 1.180.1 (2.258.2) https://github.com/speakeasy-api/speakeasy
### Generated
- [python v0.13.1] .
- [python v0.13.1] .

## 2024-03-01 00:56:19
### Changes
Based on:
- OpenAPI Doc 1.0.0
- Speakeasy CLI 1.198.1 (2.275.4) https://github.com/speakeasy-api/speakeasy
### Generated
- [python v0.14.0] .
8 changes: 7 additions & 1 deletion gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ generation:
nameResolutionDec2023: false
parameterOrderingFeb2024: false
requestResponseComponentNamesFeb2024: false
auth:
oAuth2ClientCredentialsEnabled: false
python:
version: 0.13.1
version: 0.14.0
additionalDependencies:
dependencies: {}
extraDependencies:
dev: {}
author: my-test
clientServerStatusCodesAsErrors: true
description: Python Client SDK Generated by Speakeasy
Expand Down
1 change: 1 addition & 0 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ good-names=i,
ex,
Run,
_,
e,
id

# Good variable names regexes, separated by a comma. If names match any regex,
Expand Down
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setuptools.setup(
name="test",
version="0.13.1",
version="0.14.0",
author="my-test",
description="Python Client SDK Generated by Speakeasy",
long_description=long_description,
Expand All @@ -19,9 +19,9 @@
install_requires=[
"certifi>=2023.7.22",
"charset-normalizer>=3.2.0",
"dataclasses-json-speakeasy>=0.5.11",
"dataclasses-json>=0.6.4",
"idna>=3.4",
"jsonpath-python>=1.0.6 ",
"jsonpath-python>=1.0.6",
"marshmallow>=3.19.0",
"mypy-extensions>=1.0.0",
"packaging>=23.1",
Expand All @@ -33,7 +33,9 @@
"urllib3>=1.26.18",
],
extras_require={
"dev":["pylint==2.16.2"]
"dev": [
"pylint==2.16.2",
],
},
package_dir={'': 'src'},
python_requires='>=3.8',
Expand Down
4 changes: 4 additions & 0 deletions src/test/_hooks/__init__.py
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 *
55 changes: 55 additions & 0 deletions src/test/_hooks/sdkhooks.py
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
70 changes: 70 additions & 0 deletions src/test/_hooks/types.py
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
71 changes: 68 additions & 3 deletions src/test/pets.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""

import requests as requests_http
from .sdkconfiguration import SDKConfiguration
from test import utils
from test._hooks import HookContext
from test.models import errors, operations, shared
from typing import List, Optional

Expand All @@ -15,6 +17,7 @@ def __init__(self, sdk_config: SDKConfiguration) -> None:

def create_pets(self) -> operations.CreatePetsResponse:
r"""Create a pet"""
hook_ctx = HookContext(operation_id='createPets', oauth2_scopes=[], security_source=None)
base_url = utils.template_url(*self.sdk_configuration.get_server_details())

url = base_url + '/pets'
Expand All @@ -24,7 +27,27 @@ def create_pets(self) -> operations.CreatePetsResponse:

client = self.sdk_configuration.client

http_res = client.request('POST', url, headers=headers)

try:
req = self.sdk_configuration.get_hooks().before_request(
hook_ctx,
requests_http.Request('POST', url, headers=headers).prepare(),
)
http_res = client.send(req)
except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
raise e

if utils.match_status_codes(['4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
if e:
raise e
else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
if isinstance(result, Exception):
raise result
http_res = result

content_type = http_res.headers.get('Content-Type')

res = operations.CreatePetsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
Expand All @@ -46,6 +69,7 @@ def create_pets(self) -> operations.CreatePetsResponse:

def list_pets(self, request: operations.ListPetsRequest) -> operations.ListPetsResponse:
r"""List all pets"""
hook_ctx = HookContext(operation_id='listPets', oauth2_scopes=[], security_source=None)
base_url = utils.template_url(*self.sdk_configuration.get_server_details())

url = base_url + '/pets'
Expand All @@ -56,7 +80,27 @@ def list_pets(self, request: operations.ListPetsRequest) -> operations.ListPetsR

client = self.sdk_configuration.client

http_res = client.request('GET', url, params=query_params, headers=headers)

try:
req = self.sdk_configuration.get_hooks().before_request(
hook_ctx,
requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
)
http_res = client.send(req)
except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
raise e

if utils.match_status_codes(['4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
if e:
raise e
else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
if isinstance(result, Exception):
raise result
http_res = result

content_type = http_res.headers.get('Content-Type')

res = operations.ListPetsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res, headers=None)
Expand Down Expand Up @@ -84,6 +128,7 @@ def list_pets(self, request: operations.ListPetsRequest) -> operations.ListPetsR

def show_pet_by_id(self, request: operations.ShowPetByIDRequest) -> operations.ShowPetByIDResponse:
r"""Info for a specific pet"""
hook_ctx = HookContext(operation_id='showPetById', oauth2_scopes=[], security_source=None)
base_url = utils.template_url(*self.sdk_configuration.get_server_details())

url = utils.generate_url(operations.ShowPetByIDRequest, base_url, '/pets/{petId}', request)
Expand All @@ -93,7 +138,27 @@ def show_pet_by_id(self, request: operations.ShowPetByIDRequest) -> operations.S

client = self.sdk_configuration.client

http_res = client.request('GET', url, headers=headers)

try:
req = self.sdk_configuration.get_hooks().before_request(
hook_ctx,
requests_http.Request('GET', url, headers=headers).prepare(),
)
http_res = client.send(req)
except Exception as e:
_, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
raise e

if utils.match_status_codes(['4XX','5XX'], http_res.status_code):
http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
if e:
raise e
else:
result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
if isinstance(result, Exception):
raise result
http_res = result

content_type = http_res.headers.get('Content-Type')

res = operations.ShowPetByIDResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
Expand Down
11 changes: 11 additions & 0 deletions src/test/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .pets import Pets
from .sdkconfiguration import SDKConfiguration
from test import utils
from test._hooks import SDKHooks
from typing import Dict

class Test:
Expand Down Expand Up @@ -39,6 +40,16 @@ def __init__(self,
server_url = utils.template_url(server_url, url_params)

self.sdk_configuration = SDKConfiguration(client, None, server_url, server_idx, retry_config=retry_config)

hooks = SDKHooks()

current_server_url, *_ = self.sdk_configuration.get_server_details()
server_url, self.sdk_configuration.client = hooks.sdk_init(current_server_url, self.sdk_configuration.client)
if current_server_url != server_url:
self.sdk_configuration.server_url = server_url

# pylint: disable=protected-access
self.sdk_configuration._hooks=hooks

self._init_sdks()

Expand Down
Loading

0 comments on commit 5ee9010

Please sign in to comment.