Skip to content

Commit

Permalink
release: 0.1.0-beta.0 (#42)
Browse files Browse the repository at this point in the history
Automated Release PR
---


## 0.1.0-beta.0 (2024-08-22)

Full Changelog:
[v0.1.0-alpha.4...v0.1.0-beta.0](v0.1.0-alpha.4...v0.1.0-beta.0)

### Features

* **api:** OpenAPI spec update via Stainless API
([#46](#46))
([40b3e77](40b3e77))
* **api:** OpenAPI spec update via Stainless API
([#47](#47))
([dc0a486](dc0a486))
* **api:** OpenAPI spec update via Stainless API
([#51](#51))
([32b51b7](32b51b7))
* **api:** OpenAPI spec update via Stainless API
([#52](#52))
([19e0b68](19e0b68))
* **api:** OpenAPI spec update via Stainless API
([#54](#54))
([f82e637](f82e637))
* **api:** OpenAPI spec update via Stainless API
([#57](#57))
([768bb4c](768bb4c))
* **api:** OpenAPI spec update via Stainless API
([#59](#59))
([99508ad](99508ad))
* **api:** OpenAPI spec update via Stainless API
([#60](#60))
([1bdc085](1bdc085))
* **api:** OpenAPI spec update via Stainless API
([#61](#61))
([8a58b5c](8a58b5c))
* **api:** OpenAPI spec update via Stainless API
([#62](#62))
([6fd1a9f](6fd1a9f))
* **api:** OpenAPI spec update via Stainless API
([#63](#63))
([289a809](289a809))
* **api:** OpenAPI spec update via Stainless API
([#70](#70))
([b4ff212](b4ff212))
* **api:** OpenAPI spec update via Stainless API
([#71](#71))
([8ed8ccb](8ed8ccb))
* **api:** OpenAPI spec update via Stainless API
([#72](#72))
([b5e6b00](b5e6b00))
* **api:** OpenAPI spec update via Stainless API
([#73](#73))
([92000b7](92000b7))
* **client:** add `retry_count` to raw response class
([#44](#44))
([aa7658d](aa7658d))


### Bug Fixes

* **client:** correctly serialise array body params
([#50](#50))
([88156f9](88156f9))


### Chores

* **ci:** also run pydantic v1 tests
([#69](#69))
([84f5669](84f5669))
* **ci:** bump prism mock server version
([#55](#55))
([1bd186d](1bd186d))
* **client:** fix parsing union responses when non-json is returned
([#66](#66))
([51d2a84](51d2a84))
* **examples:** minor formatting changes
([#58](#58))
([a518d00](a518d00))
* **internal:** bump pyright
([#43](#43))
([19e30f3](19e30f3))
* **internal:** bump ruff version
([#48](#48))
([b91ea15](b91ea15))
* **internal:** ensure package is importable in lint cmd
([#56](#56))
([1a99c7e](1a99c7e))
* **internal:** remove deprecated ruff config
([#53](#53))
([36a843f](36a843f))
* **internal:** test updates
([#45](#45))
([d0c9e05](d0c9e05))
* **internal:** update pydantic compat helper function
([#49](#49))
([c057767](c057767))
* **internal:** use `TypeAlias` marker for type assignments
([#41](#41))
([46f909b](46f909b))
* **internal:** use different 32bit detection method
([#64](#64))
([bec41c2](bec41c2))
* update SDK settings
([#65](#65))
([4ac3a29](4ac3a29))

---
This pull request is managed by Stainless's [GitHub
App](https://github.com/apps/stainless-app).

The [semver version
number](https://semver.org/#semantic-versioning-specification-semver) is
based on included [commit
messages](https://www.conventionalcommits.org/en/v1.0.0/).
Alternatively, you can manually set the version number in the title of
this pull request.

For a better experience, it is recommended to use either rebase-merge or
squash-merge when merging this pull request.

🔗 Stainless [website](https://www.stainlessapi.com)
📚 Read the [docs](https://app.stainlessapi.com/docs)
🙋 [Reach out](mailto:[email protected]) for help or questions

---------

Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
Co-authored-by: Jay Kim <[email protected]>
  • Loading branch information
stainless-app[bot] and keyworks authored Aug 23, 2024
1 parent c847795 commit 23089c9
Show file tree
Hide file tree
Showing 320 changed files with 19,715 additions and 918 deletions.
Empty file modified .devcontainer/Dockerfile
100644 → 100755
Empty file.
Empty file modified .devcontainer/devcontainer.json
100644 → 100755
Empty file.
Empty file modified .github/workflows/ci.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/publish-pypi.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/release-doctor.yml
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .python-version
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.4"
".": "0.1.0-beta.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 48
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-115e754ed55ead15816eea022ce7352fbdd0bd0cff851d13ec173f4557e45ec2.yml
configured_endpoints: 87
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-085bb8699d222fd7950750078c4ea00fb8728477809a8ebc74521a7ad5f32038.yml
Empty file modified Brewfile
100644 → 100755
Empty file.
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
# Changelog

## 0.1.0-beta.0 (2024-08-22)

Full Changelog: [v0.1.0-alpha.4...v0.1.0-beta.0](https://github.com/Metronome-Industries/metronome-python/compare/v0.1.0-alpha.4...v0.1.0-beta.0)

### Features

* **api:** OpenAPI spec update via Stainless API ([#46](https://github.com/Metronome-Industries/metronome-python/issues/46)) ([40b3e77](https://github.com/Metronome-Industries/metronome-python/commit/40b3e77f0beadf35974462d3f899caf1c98bdb09))
* **api:** OpenAPI spec update via Stainless API ([#47](https://github.com/Metronome-Industries/metronome-python/issues/47)) ([dc0a486](https://github.com/Metronome-Industries/metronome-python/commit/dc0a486b80eae244d6a0d8ee28eb720330bf45ce))
* **api:** OpenAPI spec update via Stainless API ([#51](https://github.com/Metronome-Industries/metronome-python/issues/51)) ([32b51b7](https://github.com/Metronome-Industries/metronome-python/commit/32b51b7355f3e043ee55620dba227b65ec21dc01))
* **api:** OpenAPI spec update via Stainless API ([#52](https://github.com/Metronome-Industries/metronome-python/issues/52)) ([19e0b68](https://github.com/Metronome-Industries/metronome-python/commit/19e0b68dbb8fd8709a19c983fd70bcc290259306))
* **api:** OpenAPI spec update via Stainless API ([#54](https://github.com/Metronome-Industries/metronome-python/issues/54)) ([f82e637](https://github.com/Metronome-Industries/metronome-python/commit/f82e6376a839f3d7e469f49e7d3a5f8914d1f940))
* **api:** OpenAPI spec update via Stainless API ([#57](https://github.com/Metronome-Industries/metronome-python/issues/57)) ([768bb4c](https://github.com/Metronome-Industries/metronome-python/commit/768bb4cdf7d6160b8658aea7a0ae09383c85cc96))
* **api:** OpenAPI spec update via Stainless API ([#59](https://github.com/Metronome-Industries/metronome-python/issues/59)) ([99508ad](https://github.com/Metronome-Industries/metronome-python/commit/99508adaf24ca2c3701119536e2bfb5eb0d170c4))
* **api:** OpenAPI spec update via Stainless API ([#60](https://github.com/Metronome-Industries/metronome-python/issues/60)) ([1bdc085](https://github.com/Metronome-Industries/metronome-python/commit/1bdc085afe19ed8ce2749f097f44962539cf15c9))
* **api:** OpenAPI spec update via Stainless API ([#61](https://github.com/Metronome-Industries/metronome-python/issues/61)) ([8a58b5c](https://github.com/Metronome-Industries/metronome-python/commit/8a58b5c27f2e7a8b3cf7948b2f5f008ae12fecf4))
* **api:** OpenAPI spec update via Stainless API ([#62](https://github.com/Metronome-Industries/metronome-python/issues/62)) ([6fd1a9f](https://github.com/Metronome-Industries/metronome-python/commit/6fd1a9f64baf1e8b26593265f67b0e53bc95b39b))
* **api:** OpenAPI spec update via Stainless API ([#63](https://github.com/Metronome-Industries/metronome-python/issues/63)) ([289a809](https://github.com/Metronome-Industries/metronome-python/commit/289a809b37fefe0739554154b8c63841b778ce4e))
* **api:** OpenAPI spec update via Stainless API ([#70](https://github.com/Metronome-Industries/metronome-python/issues/70)) ([b4ff212](https://github.com/Metronome-Industries/metronome-python/commit/b4ff212e9afc96cebecde3a1633b46b1f29ad834))
* **api:** OpenAPI spec update via Stainless API ([#71](https://github.com/Metronome-Industries/metronome-python/issues/71)) ([8ed8ccb](https://github.com/Metronome-Industries/metronome-python/commit/8ed8ccbca9e3909953e53580180fd3716093f61b))
* **api:** OpenAPI spec update via Stainless API ([#72](https://github.com/Metronome-Industries/metronome-python/issues/72)) ([b5e6b00](https://github.com/Metronome-Industries/metronome-python/commit/b5e6b006ae618267e682b3b4ef7be0c573bd7e37))
* **api:** OpenAPI spec update via Stainless API ([#73](https://github.com/Metronome-Industries/metronome-python/issues/73)) ([92000b7](https://github.com/Metronome-Industries/metronome-python/commit/92000b7395e73424e95cc5dbbc3662a2cd98fe07))
* **client:** add `retry_count` to raw response class ([#44](https://github.com/Metronome-Industries/metronome-python/issues/44)) ([aa7658d](https://github.com/Metronome-Industries/metronome-python/commit/aa7658d30aa75c374a16451607ebfe403a8bbd96))


### Bug Fixes

* **client:** correctly serialise array body params ([#50](https://github.com/Metronome-Industries/metronome-python/issues/50)) ([88156f9](https://github.com/Metronome-Industries/metronome-python/commit/88156f93aaf54cd5936f8a2229e03ebf1c55fd45))


### Chores

* **ci:** also run pydantic v1 tests ([#69](https://github.com/Metronome-Industries/metronome-python/issues/69)) ([84f5669](https://github.com/Metronome-Industries/metronome-python/commit/84f566900dce00002c8d737ee2c759f0ffe54c9d))
* **ci:** bump prism mock server version ([#55](https://github.com/Metronome-Industries/metronome-python/issues/55)) ([1bd186d](https://github.com/Metronome-Industries/metronome-python/commit/1bd186d700e211d9ad9c866b2d03b29034dd57e6))
* **client:** fix parsing union responses when non-json is returned ([#66](https://github.com/Metronome-Industries/metronome-python/issues/66)) ([51d2a84](https://github.com/Metronome-Industries/metronome-python/commit/51d2a841772bc332199bb9153836248f0e01744e))
* **examples:** minor formatting changes ([#58](https://github.com/Metronome-Industries/metronome-python/issues/58)) ([a518d00](https://github.com/Metronome-Industries/metronome-python/commit/a518d00c9a090dd582be30b3e1fe7ddc9e1bbd8c))
* **internal:** bump pyright ([#43](https://github.com/Metronome-Industries/metronome-python/issues/43)) ([19e30f3](https://github.com/Metronome-Industries/metronome-python/commit/19e30f3be4baf1018bf549f3ec232b3fb1b4a890))
* **internal:** bump ruff version ([#48](https://github.com/Metronome-Industries/metronome-python/issues/48)) ([b91ea15](https://github.com/Metronome-Industries/metronome-python/commit/b91ea1500f3e6d22762d7aaa674aea5ab3ecc52a))
* **internal:** ensure package is importable in lint cmd ([#56](https://github.com/Metronome-Industries/metronome-python/issues/56)) ([1a99c7e](https://github.com/Metronome-Industries/metronome-python/commit/1a99c7ef8f534cfdbe80bdf21f600cf322bd4a38))
* **internal:** remove deprecated ruff config ([#53](https://github.com/Metronome-Industries/metronome-python/issues/53)) ([36a843f](https://github.com/Metronome-Industries/metronome-python/commit/36a843f1be4ec852c6a5eaf9017bfe98e65fd4ab))
* **internal:** test updates ([#45](https://github.com/Metronome-Industries/metronome-python/issues/45)) ([d0c9e05](https://github.com/Metronome-Industries/metronome-python/commit/d0c9e051545b7da62a87877e1a46fd182afd52cc))
* **internal:** update pydantic compat helper function ([#49](https://github.com/Metronome-Industries/metronome-python/issues/49)) ([c057767](https://github.com/Metronome-Industries/metronome-python/commit/c057767494cd610adf91243c208720c37acb145d))
* **internal:** use `TypeAlias` marker for type assignments ([#41](https://github.com/Metronome-Industries/metronome-python/issues/41)) ([46f909b](https://github.com/Metronome-Industries/metronome-python/commit/46f909b46a53da1565274c81e8ab0e8bbfc7e8df))
* **internal:** use different 32bit detection method ([#64](https://github.com/Metronome-Industries/metronome-python/issues/64)) ([bec41c2](https://github.com/Metronome-Industries/metronome-python/commit/bec41c2ec4e038e0ecefd84ba655d6595118937e))
* update SDK settings ([#65](https://github.com/Metronome-Industries/metronome-python/issues/65)) ([4ac3a29](https://github.com/Metronome-Industries/metronome-python/commit/4ac3a29beb076bd1dca61b8ab882058620af4357))

## 0.1.0-alpha.4 (2024-08-01)

Full Changelog: [v0.1.0-alpha.3...v0.1.0-alpha.4](https://github.com/Metronome-Industries/metronome-python/compare/v0.1.0-alpha.3...v0.1.0-alpha.4)
Expand Down
Empty file modified CONTRIBUTING.md
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
112 changes: 88 additions & 24 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ client = Metronome(
response = client.usage.ingest(
usage=[
{
"transaction_id": "2021-01-01T00:00:00Z_cluster42",
"customer_id": "[email protected]",
"event_type": "heartbeat",
"timestamp": "2021-01-01T00:00:00Z",
"transaction_id": "2021-01-01T00:00:00Z_cluster42",
}
],
)
Expand Down Expand Up @@ -70,10 +70,10 @@ async def main() -> None:
response = await client.usage.ingest(
usage=[
{
"transaction_id": "2021-01-01T00:00:00Z_cluster42",
"customer_id": "[email protected]",
"event_type": "heartbeat",
"timestamp": "2021-01-01T00:00:00Z",
"transaction_id": "2021-01-01T00:00:00Z_cluster42",
}
],
)
Expand All @@ -93,6 +93,69 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ

Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.

## Pagination

List methods in the Metronome API are paginated.

This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:

```python
from metronome import Metronome

client = Metronome()

all_products = []
# Automatically fetches more pages as needed.
for product in client.contracts.products.list():
# Do something with product here
all_products.append(product)
print(all_products)
```

Or, asynchronously:

```python
import asyncio
from metronome import AsyncMetronome

client = AsyncMetronome()


async def main() -> None:
all_products = []
# Iterate through items across all pages, issuing requests as needed.
async for product in client.contracts.products.list():
all_products.append(product)
print(all_products)


asyncio.run(main())
```

Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:

```python
first_page = await client.contracts.products.list()
if first_page.has_next_page():
print(f"will fetch next page using these details: {first_page.next_page_info()}")
next_page = await first_page.get_next_page()
print(f"number of items we just fetched: {len(next_page.data)}")

# Remove `await` for non-async usage.
```

Or just work directly with the returned data:

```python
first_page = await client.contracts.products.list()

print(f"next page cursor: {first_page.next_page}") # => "next page cursor: ..."
for product in first_page.data:
print(product.id)

# Remove `await` for non-async usage.
```

## Handling errors

When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `metronome.APIConnectionError` is raised.
Expand All @@ -103,16 +166,17 @@ response), a subclass of `metronome.APIStatusError` is raised, containing `statu
All errors inherit from `metronome.APIError`.

```python
from metronome._utils import parse_datetime

import metronome
from metronome import Metronome

client = Metronome()

try:
client.alerts.create(
alert_type="spend_threshold_reached",
name="$100 spend threshold reached",
threshold=10000,
client.contracts.create(
customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",
starting_at=parse_datetime("2020-01-01T00:00:00.000Z"),
)
except metronome.APIConnectionError as e:
print("The server could not be reached")
Expand Down Expand Up @@ -147,6 +211,8 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
You can use the `max_retries` option to configure or disable retry settings:

```python
from metronome._utils import parse_datetime

from metronome import Metronome

# Configure the default for all requests:
Expand All @@ -156,10 +222,9 @@ client = Metronome(
)

# Or, configure per-request:
client.with_options(max_retries=5).alerts.create(
alert_type="spend_threshold_reached",
name="$100 spend threshold reached",
threshold=10000,
client.with_options(max_retries=5).contracts.create(
customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",
starting_at=parse_datetime("2020-01-01T00:00:00.000Z"),
)
```

Expand All @@ -169,6 +234,8 @@ By default requests time out after 1 minute. You can configure this with a `time
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:

```python
from metronome._utils import parse_datetime

from metronome import Metronome

# Configure the default for all requests:
Expand All @@ -183,10 +250,9 @@ client = Metronome(
)

# Override per-request:
client.with_options(timeout=5.0).alerts.create(
alert_type="spend_threshold_reached",
name="$100 spend threshold reached",
threshold=10000,
client.with_options(timeout=5.0).contracts.create(
customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",
starting_at=parse_datetime("2020-01-01T00:00:00.000Z"),
)
```

Expand Down Expand Up @@ -226,15 +292,14 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
from metronome import Metronome

client = Metronome()
response = client.alerts.with_raw_response.create(
alert_type="spend_threshold_reached",
name="$100 spend threshold reached",
threshold=10000,
response = client.contracts.with_raw_response.create(
customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",
starting_at=parse_datetime("2020-01-01T00:00:00.000Z"),
)
print(response.headers.get('X-My-Header'))

alert = response.parse() # get the object that `alerts.create()` would have returned
print(alert.data)
contract = response.parse() # get the object that `contracts.create()` would have returned
print(contract.data)
```

These methods return an [`APIResponse`](https://github.com/Metronome-Industries/metronome-python/tree/main/src/metronome/_response.py) object.
Expand All @@ -248,10 +313,9 @@ The above interface eagerly reads the full response body when you make the reque
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.

```python
with client.alerts.with_streaming_response.create(
alert_type="spend_threshold_reached",
name="$100 spend threshold reached",
threshold=10000,
with client.contracts.with_streaming_response.create(
customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",
starting_at=parse_datetime("2020-01-01T00:00:00.000Z"),
) as response:
print(response.headers.get("X-My-Header"))

Expand Down
Empty file modified SECURITY.md
100644 → 100755
Empty file.
Loading

0 comments on commit 23089c9

Please sign in to comment.