Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.17.0"
".": "1.18.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 89
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/knock%2Fknock-092c2b568690b68f1683b668b1d14db02854ef1a6e70d9f96efcd5f6e3e95ed7.yml
openapi_spec_hash: 0ddb0d27c5cb719cddddbf204394d9fa
config_hash: 658c551418df454aa40794f8ac679c18
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/knock%2Fknock-1584eaacf779edacf947595928550c8914bd5f39e68c9ef7d8af8dd65e36187a.yml
openapi_spec_hash: 1e56a42e6985e71dfe1a58ff352b57cd
config_hash: 1470ae08f436e4d00dd096cb585b41fd
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 1.18.0 (2025-11-07)

Full Changelog: [v1.17.0...v1.18.0](https://github.com/knocklabs/knock-python/compare/v1.17.0...v1.18.0)

### Features

* **api:** api update ([be33019](https://github.com/knocklabs/knock-python/commit/be33019381cfb5ee35be3960c8ea28a7078b234a))
* **api:** support specifying a branch ([cbed5ed](https://github.com/knocklabs/knock-python/commit/cbed5ed3d3a8995d6167008addadec5e138e63e5))
* correct channel data schemas ([fadc24d](https://github.com/knocklabs/knock-python/commit/fadc24d9363b9cf33377e696cd6863dff8e38e55))


### Chores

* **internal:** grammar fix (it's -> its) ([49b5e48](https://github.com/knocklabs/knock-python/commit/49b5e48c10abe112361fd92f4c7a74fc7543706a))

## 1.17.0 (2025-10-30)

Full Changelog: [v1.16.0...v1.17.0](https://github.com/knocklabs/knock-python/compare/v1.16.0...v1.17.0)
Expand Down
6 changes: 6 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Types:
from knockapi.types.recipients import (
InlinePreferenceSetRequest,
PreferenceSet,
PreferenceSetChannelSetting,
PreferenceSetChannelTypeSetting,
PreferenceSetChannelTypes,
PreferenceSetRequest,
Expand All @@ -40,11 +41,16 @@ Types:

```python
from knockapi.types.recipients import (
AwsSnsPushChannelDataDevicesOnly,
AwsSnsPushChannelDataTargetArnsOnly,
ChannelData,
ChannelDataRequest,
DiscordChannelData,
InlineChannelDataRequest,
MsTeamsChannelData,
OneSignalChannelDataPlayerIDsOnly,
PushChannelDataDevicesOnly,
PushChannelDataTokensOnly,
SlackChannelData,
)
```
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "knockapi"
version = "1.17.0"
version = "1.18.0"
description = "The official Python library for the knock API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
26 changes: 24 additions & 2 deletions src/knockapi/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ class Knock(SyncAPIClient):

# client options
api_key: str
branch: str | None

def __init__(
self,
*,
api_key: str | None = None,
branch: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = not_given,
max_retries: int = DEFAULT_MAX_RETRIES,
Expand All @@ -84,7 +86,9 @@ def __init__(
) -> None:
"""Construct a new synchronous Knock client instance.

This automatically infers the `api_key` argument from the `KNOCK_API_KEY` environment variable if it is not provided.
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
- `api_key` from `KNOCK_API_KEY`
- `branch` from `KNOCK_BRANCH`
"""
if api_key is None:
api_key = os.environ.get("KNOCK_API_KEY")
Expand All @@ -94,6 +98,10 @@ def __init__(
)
self.api_key = api_key

if branch is None:
branch = os.environ.get("KNOCK_BRANCH")
self.branch = branch

if base_url is None:
base_url = os.environ.get("KNOCK_BASE_URL")
if base_url is None:
Expand Down Expand Up @@ -143,13 +151,15 @@ def default_headers(self) -> dict[str, str | Omit]:
return {
**super().default_headers,
"X-Stainless-Async": "false",
"X-Knock-Branch": self.branch if self.branch is not None else Omit(),
**self._custom_headers,
}

def copy(
self,
*,
api_key: str | None = None,
branch: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = not_given,
http_client: httpx.Client | None = None,
Expand Down Expand Up @@ -184,6 +194,7 @@ def copy(
http_client = http_client or self._client
return self.__class__(
api_key=api_key or self.api_key,
branch=branch or self.branch,
base_url=base_url or self.base_url,
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
http_client=http_client,
Expand Down Expand Up @@ -248,11 +259,13 @@ class AsyncKnock(AsyncAPIClient):

# client options
api_key: str
branch: str | None

def __init__(
self,
*,
api_key: str | None = None,
branch: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = not_given,
max_retries: int = DEFAULT_MAX_RETRIES,
Expand All @@ -274,7 +287,9 @@ def __init__(
) -> None:
"""Construct a new async AsyncKnock client instance.

This automatically infers the `api_key` argument from the `KNOCK_API_KEY` environment variable if it is not provided.
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
- `api_key` from `KNOCK_API_KEY`
- `branch` from `KNOCK_BRANCH`
"""
if api_key is None:
api_key = os.environ.get("KNOCK_API_KEY")
Expand All @@ -284,6 +299,10 @@ def __init__(
)
self.api_key = api_key

if branch is None:
branch = os.environ.get("KNOCK_BRANCH")
self.branch = branch

if base_url is None:
base_url = os.environ.get("KNOCK_BASE_URL")
if base_url is None:
Expand Down Expand Up @@ -333,13 +352,15 @@ def default_headers(self) -> dict[str, str | Omit]:
return {
**super().default_headers,
"X-Stainless-Async": f"async:{get_async_library()}",
"X-Knock-Branch": self.branch if self.branch is not None else Omit(),
**self._custom_headers,
}

def copy(
self,
*,
api_key: str | None = None,
branch: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = not_given,
http_client: httpx.AsyncClient | None = None,
Expand Down Expand Up @@ -374,6 +395,7 @@ def copy(
http_client = http_client or self._client
return self.__class__(
api_key=api_key or self.api_key,
branch=branch or self.branch,
base_url=base_url or self.base_url,
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
http_client=http_client,
Expand Down
2 changes: 1 addition & 1 deletion src/knockapi/_utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def is_given(obj: _T | NotGiven | Omit) -> TypeGuard[_T]:
# Type safe methods for narrowing types with TypeVars.
# The default narrowing for isinstance(obj, dict) is dict[unknown, unknown],
# however this cause Pyright to rightfully report errors. As we know we don't
# care about the contained types we can safely use `object` in it's place.
# care about the contained types we can safely use `object` in its place.
#
# There are two separate functions defined, `is_*` and `is_*_t` for different use cases.
# `is_*` is for when you're dealing with an unknown input
Expand Down
2 changes: 1 addition & 1 deletion src/knockapi/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "knockapi"
__version__ = "1.17.0" # x-release-please-version
__version__ = "1.18.0" # x-release-please-version
8 changes: 8 additions & 0 deletions src/knockapi/resources/objects/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ def set(
*,
channel_data: InlineChannelDataRequestParam | Omit = omit,
locale: Optional[str] | Omit = omit,
name: Optional[str] | Omit = omit,
preferences: InlinePreferenceSetRequestParam | Omit = omit,
timezone: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -731,6 +732,8 @@ def set(
locale: The locale of the object. Used for
[message localization](/concepts/translations).

name: An optional name for the object.

preferences: Inline set preferences for a recipient, where the key is the preference set id.
Preferences that are set inline will be merged into any existing preferences
rather than replacing them.
Expand Down Expand Up @@ -760,6 +763,7 @@ def set(
{
"channel_data": channel_data,
"locale": locale,
"name": name,
"preferences": preferences,
"timezone": timezone,
},
Expand Down Expand Up @@ -1617,6 +1621,7 @@ async def set(
*,
channel_data: InlineChannelDataRequestParam | Omit = omit,
locale: Optional[str] | Omit = omit,
name: Optional[str] | Omit = omit,
preferences: InlinePreferenceSetRequestParam | Omit = omit,
timezone: Optional[str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -1638,6 +1643,8 @@ async def set(
locale: The locale of the object. Used for
[message localization](/concepts/translations).

name: An optional name for the object.

preferences: Inline set preferences for a recipient, where the key is the preference set id.
Preferences that are set inline will be merged into any existing preferences
rather than replacing them.
Expand Down Expand Up @@ -1667,6 +1674,7 @@ async def set(
{
"channel_data": channel_data,
"locale": locale,
"name": name,
"preferences": preferences,
"timezone": timezone,
},
Expand Down
8 changes: 8 additions & 0 deletions src/knockapi/resources/tenants/tenants.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def set(
id: str,
*,
channel_data: Optional[InlineChannelDataRequestParam] | Omit = omit,
name: Optional[str] | Omit = omit,
settings: tenant_set_params.Settings | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -213,6 +214,8 @@ def set(
Args:
channel_data: A request to set channel data for a type of channel inline.

name: An optional name for the tenant.

settings: The settings for the tenant. Includes branding and preference set.

extra_headers: Send extra headers
Expand All @@ -232,6 +235,7 @@ def set(
body=maybe_transform(
{
"channel_data": channel_data,
"name": name,
"settings": settings,
},
tenant_set_params.TenantSetParams,
Expand Down Expand Up @@ -410,6 +414,7 @@ async def set(
id: str,
*,
channel_data: Optional[InlineChannelDataRequestParam] | Omit = omit,
name: Optional[str] | Omit = omit,
settings: tenant_set_params.Settings | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -427,6 +432,8 @@ async def set(
Args:
channel_data: A request to set channel data for a type of channel inline.

name: An optional name for the tenant.

settings: The settings for the tenant. Includes branding and preference set.

extra_headers: Send extra headers
Expand All @@ -446,6 +453,7 @@ async def set(
body=await async_maybe_transform(
{
"channel_data": channel_data,
"name": name,
"settings": settings,
},
tenant_set_params.TenantSetParams,
Expand Down
14 changes: 14 additions & 0 deletions src/knockapi/resources/users/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def list_items(
archived: Literal["exclude", "include", "only"] | Omit = omit,
before: str | Omit = omit,
has_tenant: bool | Omit = omit,
locale: str | Omit = omit,
page_size: int | Omit = omit,
source: str | Omit = omit,
status: Literal["unread", "read", "unseen", "seen", "all"] | Omit = omit,
Expand Down Expand Up @@ -128,6 +129,11 @@ def list_items(

has_tenant: Whether the feed items have a tenant.

locale: The locale to render the feed items in. Must be in the IETF 5646 format (e.g.
`en-US`). When not provided, will default to the locale that the feed items were
rendered in. Only available for enterprise plan customers using custom
translations.

page_size: The number of items per page (defaults to 50).

source: The workflow key associated with the message in the feed.
Expand Down Expand Up @@ -166,6 +172,7 @@ def list_items(
"archived": archived,
"before": before,
"has_tenant": has_tenant,
"locale": locale,
"page_size": page_size,
"source": source,
"status": status,
Expand Down Expand Up @@ -245,6 +252,7 @@ def list_items(
archived: Literal["exclude", "include", "only"] | Omit = omit,
before: str | Omit = omit,
has_tenant: bool | Omit = omit,
locale: str | Omit = omit,
page_size: int | Omit = omit,
source: str | Omit = omit,
status: Literal["unread", "read", "unseen", "seen", "all"] | Omit = omit,
Expand Down Expand Up @@ -283,6 +291,11 @@ def list_items(

has_tenant: Whether the feed items have a tenant.

locale: The locale to render the feed items in. Must be in the IETF 5646 format (e.g.
`en-US`). When not provided, will default to the locale that the feed items were
rendered in. Only available for enterprise plan customers using custom
translations.

page_size: The number of items per page (defaults to 50).

source: The workflow key associated with the message in the feed.
Expand Down Expand Up @@ -321,6 +334,7 @@ def list_items(
"archived": archived,
"before": before,
"has_tenant": has_tenant,
"locale": locale,
"page_size": page_size,
"source": source,
"status": status,
Expand Down
3 changes: 3 additions & 0 deletions src/knockapi/types/inline_object_request_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class InlineObjectRequestParamTyped(TypedDict, total=False):
created_at: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
"""Timestamp when the resource was created."""

name: Optional[str]
"""An optional name for the object."""

preferences: Optional[InlinePreferenceSetRequestParam]
"""Inline set preferences for a recipient, where the key is the preference set id.

Expand Down
Loading
Loading