Skip to content

Commit 63adeb8

Browse files
feat(api): add list_notifications method to routing_strategies
1 parent ea30dd6 commit 63adeb8

7 files changed

Lines changed: 266 additions & 4 deletions

File tree

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 102
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-c22b0f83f2edb9cc171977928b3e630e57a9b607a12c7ebaaee4bf2915ad0686.yml
3-
openapi_spec_hash: 9ebc6453998e155b12fb35c40c7d5249
4-
config_hash: cecef6fb68feaa0bda820cd86fa4f045
1+
configured_endpoints: 103
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-d891c800ffe6b7eddce179c225367cedcb49dab758ebc03e352d945240918d96.yml
3+
openapi_spec_hash: 852d55192b8d7ad96c1f85cd9070ef64
4+
config_hash: a730d0e598dc108e89c016802008c9b3

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ Types:
399399

400400
```python
401401
from courier.types import (
402+
AssociatedNotificationListResponse,
402403
RoutingStrategyCreateRequest,
403404
RoutingStrategyGetResponse,
404405
RoutingStrategyListResponse,
@@ -414,6 +415,7 @@ Methods:
414415
- <code title="get /routing-strategies/{id}">client.routing_strategies.<a href="./src/courier/resources/routing_strategies.py">retrieve</a>(id) -> <a href="./src/courier/types/routing_strategy_get_response.py">RoutingStrategyGetResponse</a></code>
415416
- <code title="get /routing-strategies">client.routing_strategies.<a href="./src/courier/resources/routing_strategies.py">list</a>(\*\*<a href="src/courier/types/routing_strategy_list_params.py">params</a>) -> <a href="./src/courier/types/routing_strategy_list_response.py">RoutingStrategyListResponse</a></code>
416417
- <code title="delete /routing-strategies/{id}">client.routing_strategies.<a href="./src/courier/resources/routing_strategies.py">archive</a>(id) -> None</code>
418+
- <code title="get /routing-strategies/{id}/notifications">client.routing_strategies.<a href="./src/courier/resources/routing_strategies.py">list_notifications</a>(id, \*\*<a href="src/courier/types/routing_strategy_list_notifications_params.py">params</a>) -> <a href="./src/courier/types/associated_notification_list_response.py">AssociatedNotificationListResponse</a></code>
417419
- <code title="put /routing-strategies/{id}">client.routing_strategies.<a href="./src/courier/resources/routing_strategies.py">replace</a>(id, \*\*<a href="src/courier/types/routing_strategy_replace_params.py">params</a>) -> <a href="./src/courier/types/routing_strategy_mutation_response.py">RoutingStrategyMutationResponse</a></code>
418420

419421
# Profiles

src/courier/resources/routing_strategies.py

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
routing_strategy_list_params,
1111
routing_strategy_create_params,
1212
routing_strategy_replace_params,
13+
routing_strategy_list_notifications_params,
1314
)
1415
from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, SequenceNotStr, omit, not_given
1516
from .._utils import path_template, maybe_transform, async_maybe_transform
@@ -28,6 +29,7 @@
2829
from ..types.shared_params.message_channels import MessageChannels
2930
from ..types.shared_params.message_providers import MessageProviders
3031
from ..types.routing_strategy_mutation_response import RoutingStrategyMutationResponse
32+
from ..types.associated_notification_list_response import AssociatedNotificationListResponse
3133

3234
__all__ = ["RoutingStrategiesResource", "AsyncRoutingStrategiesResource"]
3335

@@ -233,6 +235,57 @@ def archive(
233235
cast_to=NoneType,
234236
)
235237

238+
def list_notifications(
239+
self,
240+
id: str,
241+
*,
242+
cursor: Optional[str] | Omit = omit,
243+
limit: int | Omit = omit,
244+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
245+
# The extra values given here take precedence over values defined on the client or passed to this method.
246+
extra_headers: Headers | None = None,
247+
extra_query: Query | None = None,
248+
extra_body: Body | None = None,
249+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
250+
) -> AssociatedNotificationListResponse:
251+
"""List notification templates associated with a routing strategy.
252+
253+
Includes
254+
template metadata only, not full content.
255+
256+
Args:
257+
cursor: Opaque pagination cursor from a previous response. Omit for the first page.
258+
259+
limit: Maximum number of results per page. Default 20, max 100.
260+
261+
extra_headers: Send extra headers
262+
263+
extra_query: Add additional query parameters to the request
264+
265+
extra_body: Add additional JSON properties to the request
266+
267+
timeout: Override the client-level default timeout for this request, in seconds
268+
"""
269+
if not id:
270+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
271+
return self._get(
272+
path_template("/routing-strategies/{id}/notifications", id=id),
273+
options=make_request_options(
274+
extra_headers=extra_headers,
275+
extra_query=extra_query,
276+
extra_body=extra_body,
277+
timeout=timeout,
278+
query=maybe_transform(
279+
{
280+
"cursor": cursor,
281+
"limit": limit,
282+
},
283+
routing_strategy_list_notifications_params.RoutingStrategyListNotificationsParams,
284+
),
285+
),
286+
cast_to=AssociatedNotificationListResponse,
287+
)
288+
236289
def replace(
237290
self,
238291
id: str,
@@ -499,6 +552,57 @@ async def archive(
499552
cast_to=NoneType,
500553
)
501554

555+
async def list_notifications(
556+
self,
557+
id: str,
558+
*,
559+
cursor: Optional[str] | Omit = omit,
560+
limit: int | Omit = omit,
561+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
562+
# The extra values given here take precedence over values defined on the client or passed to this method.
563+
extra_headers: Headers | None = None,
564+
extra_query: Query | None = None,
565+
extra_body: Body | None = None,
566+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
567+
) -> AssociatedNotificationListResponse:
568+
"""List notification templates associated with a routing strategy.
569+
570+
Includes
571+
template metadata only, not full content.
572+
573+
Args:
574+
cursor: Opaque pagination cursor from a previous response. Omit for the first page.
575+
576+
limit: Maximum number of results per page. Default 20, max 100.
577+
578+
extra_headers: Send extra headers
579+
580+
extra_query: Add additional query parameters to the request
581+
582+
extra_body: Add additional JSON properties to the request
583+
584+
timeout: Override the client-level default timeout for this request, in seconds
585+
"""
586+
if not id:
587+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
588+
return await self._get(
589+
path_template("/routing-strategies/{id}/notifications", id=id),
590+
options=make_request_options(
591+
extra_headers=extra_headers,
592+
extra_query=extra_query,
593+
extra_body=extra_body,
594+
timeout=timeout,
595+
query=await async_maybe_transform(
596+
{
597+
"cursor": cursor,
598+
"limit": limit,
599+
},
600+
routing_strategy_list_notifications_params.RoutingStrategyListNotificationsParams,
601+
),
602+
),
603+
cast_to=AssociatedNotificationListResponse,
604+
)
605+
502606
async def replace(
503607
self,
504608
id: str,
@@ -580,6 +684,9 @@ def __init__(self, routing_strategies: RoutingStrategiesResource) -> None:
580684
self.archive = to_raw_response_wrapper(
581685
routing_strategies.archive,
582686
)
687+
self.list_notifications = to_raw_response_wrapper(
688+
routing_strategies.list_notifications,
689+
)
583690
self.replace = to_raw_response_wrapper(
584691
routing_strategies.replace,
585692
)
@@ -601,6 +708,9 @@ def __init__(self, routing_strategies: AsyncRoutingStrategiesResource) -> None:
601708
self.archive = async_to_raw_response_wrapper(
602709
routing_strategies.archive,
603710
)
711+
self.list_notifications = async_to_raw_response_wrapper(
712+
routing_strategies.list_notifications,
713+
)
604714
self.replace = async_to_raw_response_wrapper(
605715
routing_strategies.replace,
606716
)
@@ -622,6 +732,9 @@ def __init__(self, routing_strategies: RoutingStrategiesResource) -> None:
622732
self.archive = to_streamed_response_wrapper(
623733
routing_strategies.archive,
624734
)
735+
self.list_notifications = to_streamed_response_wrapper(
736+
routing_strategies.list_notifications,
737+
)
625738
self.replace = to_streamed_response_wrapper(
626739
routing_strategies.replace,
627740
)
@@ -643,6 +756,9 @@ def __init__(self, routing_strategies: AsyncRoutingStrategiesResource) -> None:
643756
self.archive = async_to_streamed_response_wrapper(
644757
routing_strategies.archive,
645758
)
759+
self.list_notifications = async_to_streamed_response_wrapper(
760+
routing_strategies.list_notifications,
761+
)
646762
self.replace = async_to_streamed_response_wrapper(
647763
routing_strategies.replace,
648764
)

src/courier/types/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@
230230
from .routing_strategy_mutation_response import RoutingStrategyMutationResponse as RoutingStrategyMutationResponse
231231
from .notification_template_payload_param import NotificationTemplatePayloadParam as NotificationTemplatePayloadParam
232232
from .notification_retrieve_content_params import NotificationRetrieveContentParams as NotificationRetrieveContentParams
233+
from .associated_notification_list_response import (
234+
AssociatedNotificationListResponse as AssociatedNotificationListResponse,
235+
)
233236
from .post_tenant_template_publish_response import (
234237
PostTenantTemplatePublishResponse as PostTenantTemplatePublishResponse,
235238
)
@@ -243,6 +246,9 @@
243246
from .notification_template_mutation_response import (
244247
NotificationTemplateMutationResponse as NotificationTemplateMutationResponse,
245248
)
249+
from .routing_strategy_list_notifications_params import (
250+
RoutingStrategyListNotificationsParams as RoutingStrategyListNotificationsParams,
251+
)
246252
from .notification_template_version_list_response import (
247253
NotificationTemplateVersionListResponse as NotificationTemplateVersionListResponse,
248254
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List
4+
5+
from .._models import BaseModel
6+
from .shared.paging import Paging
7+
from .notification_template_summary import NotificationTemplateSummary
8+
9+
__all__ = ["AssociatedNotificationListResponse"]
10+
11+
12+
class AssociatedNotificationListResponse(BaseModel):
13+
"""Paginated list of notification templates associated with a routing strategy."""
14+
15+
paging: Paging
16+
17+
results: List[NotificationTemplateSummary]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Optional
6+
from typing_extensions import TypedDict
7+
8+
__all__ = ["RoutingStrategyListNotificationsParams"]
9+
10+
11+
class RoutingStrategyListNotificationsParams(TypedDict, total=False):
12+
cursor: Optional[str]
13+
"""Opaque pagination cursor from a previous response. Omit for the first page."""
14+
15+
limit: int
16+
"""Maximum number of results per page. Default 20, max 100."""

tests/api_resources/test_routing_strategies.py

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
RoutingStrategyGetResponse,
1414
RoutingStrategyListResponse,
1515
RoutingStrategyMutationResponse,
16+
AssociatedNotificationListResponse,
1617
)
1718

1819
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -240,6 +241,58 @@ def test_path_params_archive(self, client: Courier) -> None:
240241
"",
241242
)
242243

244+
@pytest.mark.skip(reason="Mock server tests are disabled")
245+
@parametrize
246+
def test_method_list_notifications(self, client: Courier) -> None:
247+
routing_strategy = client.routing_strategies.list_notifications(
248+
id="id",
249+
)
250+
assert_matches_type(AssociatedNotificationListResponse, routing_strategy, path=["response"])
251+
252+
@pytest.mark.skip(reason="Mock server tests are disabled")
253+
@parametrize
254+
def test_method_list_notifications_with_all_params(self, client: Courier) -> None:
255+
routing_strategy = client.routing_strategies.list_notifications(
256+
id="id",
257+
cursor="cursor",
258+
limit=1,
259+
)
260+
assert_matches_type(AssociatedNotificationListResponse, routing_strategy, path=["response"])
261+
262+
@pytest.mark.skip(reason="Mock server tests are disabled")
263+
@parametrize
264+
def test_raw_response_list_notifications(self, client: Courier) -> None:
265+
response = client.routing_strategies.with_raw_response.list_notifications(
266+
id="id",
267+
)
268+
269+
assert response.is_closed is True
270+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
271+
routing_strategy = response.parse()
272+
assert_matches_type(AssociatedNotificationListResponse, routing_strategy, path=["response"])
273+
274+
@pytest.mark.skip(reason="Mock server tests are disabled")
275+
@parametrize
276+
def test_streaming_response_list_notifications(self, client: Courier) -> None:
277+
with client.routing_strategies.with_streaming_response.list_notifications(
278+
id="id",
279+
) as response:
280+
assert not response.is_closed
281+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
282+
283+
routing_strategy = response.parse()
284+
assert_matches_type(AssociatedNotificationListResponse, routing_strategy, path=["response"])
285+
286+
assert cast(Any, response.is_closed) is True
287+
288+
@pytest.mark.skip(reason="Mock server tests are disabled")
289+
@parametrize
290+
def test_path_params_list_notifications(self, client: Courier) -> None:
291+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
292+
client.routing_strategies.with_raw_response.list_notifications(
293+
id="",
294+
)
295+
243296
@pytest.mark.skip(reason="Mock server tests are disabled")
244297
@parametrize
245298
def test_method_replace(self, client: Courier) -> None:
@@ -580,6 +633,58 @@ async def test_path_params_archive(self, async_client: AsyncCourier) -> None:
580633
"",
581634
)
582635

636+
@pytest.mark.skip(reason="Mock server tests are disabled")
637+
@parametrize
638+
async def test_method_list_notifications(self, async_client: AsyncCourier) -> None:
639+
routing_strategy = await async_client.routing_strategies.list_notifications(
640+
id="id",
641+
)
642+
assert_matches_type(AssociatedNotificationListResponse, routing_strategy, path=["response"])
643+
644+
@pytest.mark.skip(reason="Mock server tests are disabled")
645+
@parametrize
646+
async def test_method_list_notifications_with_all_params(self, async_client: AsyncCourier) -> None:
647+
routing_strategy = await async_client.routing_strategies.list_notifications(
648+
id="id",
649+
cursor="cursor",
650+
limit=1,
651+
)
652+
assert_matches_type(AssociatedNotificationListResponse, routing_strategy, path=["response"])
653+
654+
@pytest.mark.skip(reason="Mock server tests are disabled")
655+
@parametrize
656+
async def test_raw_response_list_notifications(self, async_client: AsyncCourier) -> None:
657+
response = await async_client.routing_strategies.with_raw_response.list_notifications(
658+
id="id",
659+
)
660+
661+
assert response.is_closed is True
662+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
663+
routing_strategy = await response.parse()
664+
assert_matches_type(AssociatedNotificationListResponse, routing_strategy, path=["response"])
665+
666+
@pytest.mark.skip(reason="Mock server tests are disabled")
667+
@parametrize
668+
async def test_streaming_response_list_notifications(self, async_client: AsyncCourier) -> None:
669+
async with async_client.routing_strategies.with_streaming_response.list_notifications(
670+
id="id",
671+
) as response:
672+
assert not response.is_closed
673+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
674+
675+
routing_strategy = await response.parse()
676+
assert_matches_type(AssociatedNotificationListResponse, routing_strategy, path=["response"])
677+
678+
assert cast(Any, response.is_closed) is True
679+
680+
@pytest.mark.skip(reason="Mock server tests are disabled")
681+
@parametrize
682+
async def test_path_params_list_notifications(self, async_client: AsyncCourier) -> None:
683+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
684+
await async_client.routing_strategies.with_raw_response.list_notifications(
685+
id="",
686+
)
687+
583688
@pytest.mark.skip(reason="Mock server tests are disabled")
584689
@parametrize
585690
async def test_method_replace(self, async_client: AsyncCourier) -> None:

0 commit comments

Comments
 (0)