Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python: Replace OpenAPI generator http code with out own #1654

Merged
merged 41 commits into from
Jan 23, 2025
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
cbd1f89
python: Add new low-level http client
svix-mman Jan 20, 2025
cca4e24
python: Migrate `Application` to new HTTP client
svix-mman Jan 20, 2025
14e8d0f
python: Sort `dashboard_access` in the correct order
svix-mman Jan 20, 2025
97893a3
python: Rename query_params/header_params to an internal method
svix-mman Jan 20, 2025
8255e3a
python: Add `sanitize_field` and `str().lower()` in `*Options._query_…
svix-mman Jan 20, 2025
f4bb9c5
python: For now we only need 1 exception type for HTTP errors
svix-mman Jan 21, 2025
60750da
python: rename `_execute_request` to `_request`
svix-mman Jan 21, 2025
67155e6
python: Add `serialize_params` to `_query_params`/`_header_params`
svix-mman Jan 21, 2025
be34bba
python: Simplify path param url formatting
svix-mman Jan 21, 2025
f0c4a6c
python: Explicit boolean serialization
svix-mman Jan 21, 2025
7de109c
python: Don't generate `_query_params`/`_header_params` if there are …
svix-mman Jan 21, 2025
c93c0d1
python: Implement a default `_header_params` and `_query_params` for …
svix-mman Jan 21, 2025
04ec169
python: `_query_params` and `_header_params` need self (:
svix-mman Jan 21, 2025
ddc30ad
python: Switch `Authentication` to new HTTP client
svix-mman Jan 21, 2025
a4970e3
python: Switch `BackgroundTask` to new codegen
svix-mman Jan 21, 2025
072091f
python: Switch `Endpoint` resource to new HTTP client
svix-mman Jan 21, 2025
6e23c1f
python: Switch `EventType` resource to new HTTP client
svix-mman Jan 21, 2025
1d4c76a
python: Mark `Integration(A)sync`.`get_key` as deprecated
svix-mman Jan 21, 2025
e992a60
python: Switch the `Integration` resource to new HTTP client
svix-mman Jan 21, 2025
ec8092e
python(**Breaking change**): Remove `list` and `list_attempts_for_end…
svix-mman Jan 21, 2025
6374d5c
python: Add `list_by_msg_deprecated` and `list_by_endpoint_deprecated…
svix-mman Jan 21, 2025
743345e
python: (**breaking change**) Remove `MessageListAttemptsForEndpointO…
svix-mman Jan 21, 2025
35b36da
python: Switch `MessageAttempt` to new HTTP client
svix-mman Jan 21, 2025
3e0a99f
python: Switch `Message` resource to use new HTTP client
svix-mman Jan 21, 2025
cd36ffb
python: Switch `Statistics` to new HTTP client
svix-mman Jan 21, 2025
f9b9d16
python: remove `PostOptions` from `OperationalWebhook`
svix-mman Jan 21, 2025
da78242
python: Rename `operational_webhook` to `operational_webhook_endpoint`
svix-mman Jan 21, 2025
6b7ca26
python: (breaking change) Rename these arguments to be inline with th…
svix-mman Jan 21, 2025
2018317
python: Switch `OperationalWebhookEndpoint` to new HTTP client
svix-mman Jan 21, 2025
0071e10
python: Codegen is smart enough to not need to leave `noqa: F841` eve…
svix-mman Jan 22, 2025
03a6f7b
python: Better codegen does not need to ignore unused variable warnings
svix-mman Jan 23, 2025
ecb9202
python: This is the correct way to handel class properties doc comments
svix-mman Jan 23, 2025
1c05e65
python: Document breaking changes
svix-mman Jan 23, 2025
1b5545e
python: Remove these deprecated operations.
svix-mman Jan 23, 2025
ea02fe7
python: Update generated files to use correct doc string format
svix-mman Jan 23, 2025
10942df
This was not really a breaking change
svix-mman Jan 23, 2025
348fcc1
English: Correct syntax error...
svix-mman Jan 23, 2025
db7adbe
python: Move `OperationalWebhook` to new codegen (#1656)
svix-mman Jan 23, 2025
0277b9f
Merge branch 'main' into mendy/add-python-low-level-http-client
svix-mman Jan 23, 2025
f165777
python: Sort these method inline with the codegen
svix-mman Jan 23, 2025
8f204c7
python: Serialize list/set params as a comma separated list
svix-mman Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
python: Add list_by_msg_deprecated and `list_by_endpoint_deprecated…
…` methods to `MessageAttempt(A)sync`

Not sure why these _new_ methods have deprecated in their name
svix-mman committed Jan 21, 2025
commit 6374d5cf9e4c8e97311aa0197a2abedf6904bcc7
203 changes: 201 additions & 2 deletions python/svix/api/message_attempt.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

from deprecated import deprecated

from .common import ApiBase, BaseOptions
from .common import ApiBase, BaseOptions, serialize_params
from ..internal.openapi_client import models


@@ -16,7 +16,6 @@
v1_message_attempt_expunge_content,
v1_message_attempt_list_attempted_destinations,
v1_message_attempt_resend,
v1_message_attempt_list_by_endpoint_deprecated,
)

from ..internal.openapi_client.models.list_response_message_attempt_out import (
@@ -108,6 +107,46 @@ class MessageAttemptListAttemptedMessagesOptions(BaseOptions):
event_types: t.Optional[t.Set[str]] = None


@dataclass
class MessageAttemptListByMsgDeprecatedOptions(BaseOptions):
# Limit the number of returned items
limit: t.Optional[int] = None
# The iterator returned from a prior invocation
iterator: t.Optional[str] = None
# Filter the attempts based on the attempted endpoint
endpoint_id: t.Optional[str] = None
# Filter response based on the channel
channel: t.Optional[str] = None
# Filter response based on the tag
tag: t.Optional[str] = None
# Filter response based on the status of the attempt: Success (0), Pending (1), Failed (2), or Sending (3)
status: t.Optional[models.MessageStatus] = None
# Only include items created before a certain date
before: t.Optional[datetime] = None
# Only include items created after a certain date
after: t.Optional[datetime] = None
# Filter response based on the HTTP status code
status_code_class: t.Optional[models.StatusCodeClass] = None
# Filter response based on the event type
event_types: t.Optional[t.Set[str]] = None

def _query_params(self) -> t.Dict[str, str]:
return serialize_params(
{
"limit": self.limit,
"iterator": self.iterator,
"endpoint_id": self.endpoint_id,
"channel": self.channel,
"tag": self.tag,
"status": self.status,
"before": self.before,
"after": self.after,
"status_code_class": self.status_code_class,
"event_types": self.event_types,
}
)


@dataclass
class MessageAttemptListAttemptedDestinationsOptions(BaseOptions):
# Limit the number of returned items
@@ -116,6 +155,40 @@ class MessageAttemptListAttemptedDestinationsOptions(BaseOptions):
iterator: t.Optional[str] = None


@dataclass
class MessageAttemptListByEndpointDeprecatedOptions(BaseOptions):
# Limit the number of returned items
limit: t.Optional[int] = None
# The iterator returned from a prior invocation
iterator: t.Optional[str] = None
# Filter response based on the channel
channel: t.Optional[str] = None
# Filter response based on the tag
tag: t.Optional[str] = None
# Filter response based on the status of the attempt: Success (0), Pending (1), Failed (2), or Sending (3)
status: t.Optional[models.MessageStatus] = None
# Only include items created before a certain date
before: t.Optional[datetime] = None
# Only include items created after a certain date
after: t.Optional[datetime] = None
# Filter response based on the event type
event_types: t.Optional[t.Set[str]] = None

def _query_params(self) -> t.Dict[str, str]:
return serialize_params(
{
"limit": self.limit,
"iterator": self.iterator,
"channel": self.channel,
"tag": self.tag,
"status": self.status,
"before": self.before,
"after": self.after,
"event_types": self.event_types,
}
)


@dataclass
class MessageAttemptResendOptions(BaseOptions):
idempotency_key: t.Optional[str] = None
@@ -190,6 +263,34 @@ async def list_attempted_messages(
**options.to_dict(),
)

@deprecated
async def list_by_msg_deprecated(
self,
app_id: str,
msg_id: str,
options: MessageAttemptListByMsgDeprecatedOptions = MessageAttemptListByMsgDeprecatedOptions(),
) -> ListResponseMessageAttemptOut:
"""Deprecated: Please use "List Attempts by Endpoint" and "List Attempts by Msg" instead.
Note that by default this endpoint is limited to retrieving 90 days' worth of data
relative to now or, if an iterator is provided, 90 days before/after the time indicated
by the iterator ID. If you require data beyond those time ranges, you will need to explicitly
set the `before` or `after` parameter as appropriate.
`msg_id`: Use a message id or a message `eventId`"""
# ruff: noqa: F841
response = await self._request_asyncio(
method="get",
path="/api/v1/app/{app_id}/msg/{msg_id}/attempt",
path_params={
"app_id": app_id,
"msg_id": msg_id,
},
query_params=options._query_params(),
header_params=options._header_params(),
)
return ListResponseMessageAttemptOut.from_dict(response.json())

async def get(self, app_id: str, msg_id: str, attempt_id: str) -> MessageAttemptOut:
"""`msg_id`: Use a message id or a message `eventId`"""
return await v1_message_attempt_get.request_asyncio(
@@ -219,6 +320,41 @@ async def list_attempted_destinations(
client=self._client, app_id=app_id, msg_id=msg_id, **options.to_dict()
)

@deprecated
async def list_by_endpoint_deprecated(
self,
app_id: str,
msg_id: str,
endpoint_id: str,
options: MessageAttemptListByEndpointDeprecatedOptions = MessageAttemptListByEndpointDeprecatedOptions(),
) -> ListResponseMessageAttemptEndpointOut:
"""DEPRECATED: please use list_attempts with endpoint_id as a query parameter instead.
List the message attempts for a particular endpoint.
Returning the endpoint.
The `before` parameter lets you filter all items created before a certain date and is ignored if an iterator is passed.
Note that by default this endpoint is limited to retrieving 90 days' worth of data
relative to now or, if an iterator is provided, 90 days before/after the time indicated
by the iterator ID. If you require data beyond those time ranges, you will need to explicitly
set the `before` or `after` parameter as appropriate.
"""
# ruff: noqa: F841
response = await self._request_asyncio(
method="get",
path="/api/v1/app/{app_id}/msg/{msg_id}/endpoint/{endpoint_id}/attempt",
path_params={
"app_id": app_id,
"msg_id": msg_id,
"endpoint_id": endpoint_id,
},
query_params=options._query_params(),
header_params=options._header_params(),
)
return ListResponseMessageAttemptEndpointOut.from_dict(response.json())

async def resend(
self,
app_id: str,
@@ -295,6 +431,34 @@ def list_attempted_messages(
**options.to_dict(),
)

@deprecated
def list_by_msg_deprecated(
self,
app_id: str,
msg_id: str,
options: MessageAttemptListByMsgDeprecatedOptions = MessageAttemptListByMsgDeprecatedOptions(),
) -> ListResponseMessageAttemptOut:
"""Deprecated: Please use "List Attempts by Endpoint" and "List Attempts by Msg" instead.
Note that by default this endpoint is limited to retrieving 90 days' worth of data
relative to now or, if an iterator is provided, 90 days before/after the time indicated
by the iterator ID. If you require data beyond those time ranges, you will need to explicitly
set the `before` or `after` parameter as appropriate.
`msg_id`: Use a message id or a message `eventId`"""
# ruff: noqa: F841
response = self._request_sync(
method="get",
path="/api/v1/app/{app_id}/msg/{msg_id}/attempt",
path_params={
"app_id": app_id,
"msg_id": msg_id,
},
query_params=options._query_params(),
header_params=options._header_params(),
)
return ListResponseMessageAttemptOut.from_dict(response.json())

def get(self, app_id: str, msg_id: str, attempt_id: str) -> MessageAttemptOut:
"""`msg_id`: Use a message id or a message `eventId`"""
return v1_message_attempt_get.request_sync(
@@ -324,6 +488,41 @@ def list_attempted_destinations(
client=self._client, app_id=app_id, msg_id=msg_id, **options.to_dict()
)

@deprecated
def list_by_endpoint_deprecated(
self,
app_id: str,
msg_id: str,
endpoint_id: str,
options: MessageAttemptListByEndpointDeprecatedOptions = MessageAttemptListByEndpointDeprecatedOptions(),
) -> ListResponseMessageAttemptEndpointOut:
"""DEPRECATED: please use list_attempts with endpoint_id as a query parameter instead.
List the message attempts for a particular endpoint.
Returning the endpoint.
The `before` parameter lets you filter all items created before a certain date and is ignored if an iterator is passed.
Note that by default this endpoint is limited to retrieving 90 days' worth of data
relative to now or, if an iterator is provided, 90 days before/after the time indicated
by the iterator ID. If you require data beyond those time ranges, you will need to explicitly
set the `before` or `after` parameter as appropriate.
"""
# ruff: noqa: F841
response = self._request_sync(
method="get",
path="/api/v1/app/{app_id}/msg/{msg_id}/endpoint/{endpoint_id}/attempt",
path_params={
"app_id": app_id,
"msg_id": msg_id,
"endpoint_id": endpoint_id,
},
query_params=options._query_params(),
header_params=options._header_params(),
)
return ListResponseMessageAttemptEndpointOut.from_dict(response.json())

def resend(
self,
app_id: str,