Migration guide from [seampai](https://pypi.org/project/seamapi/) to [seam](https://pypi.org/project/seam/)
Learn how to migrate from the `seamapi` package to the `seam` package. This guide includes descriptions of all breaking changes.
The new SDK has fewer dependencies and is generated daily to ensure methods and types are always up-to-date with the latest API changes. It is mostly a drop-in replacement, however some method signatures and options have changed to improve overall consistency with the Seam API.
This guide includes descriptions of all breaking changes. Please refer to the [README](https://github.com/seamapi/python/blob/main/README.md) for updated usage instructions and a complete list of new features.
New Python package name
Changed the package name from `seamapi` to `seam`.
diff
- pip install seamapi
+ pip install seam
diff
- from seamapi import Seam
+ from seam import Seam
Updated API method signatures
Keyword arguments
API method signatures now only accept keyword arguments.
diff
- seam.access_codes.get("my_access_code_id")
+ seam.access_codes.get(access_code_id="my_access_code_id")
diff
- seam.thermostats.get("my_thermostat_device_id")
+ seam.thermostats.get(device_id="my_thermostat_device_id")
Standardized resource ID arguments
Changed from accepting both resource objects and resource ID strings to accepting only resource ID strings. Includes a renaming scheme for clarity.
diff
- def get(resource: Union[str, Resource]) -> Resource
+ def get(resource_id: str) -> Resource
Usage
diff
- seam.locks.get(device=my_device)
+ seam.locks.get(device_id=my_device.device_id)
Removed method arguments
Removed `wait_for_code` from `access_codes.create`. Use the newly-created `access_code_id` to poll or watch for events.
Return value changes
Changed the return types for some methods to enhance API consistency and reliability.
The following methods now return `void`:
- `access_codes.delete`: Instead, you should wait for the `access_code.deleted` event.
- `access_codes.unmanaged.delete`
- `access_codes.update`: Instead, you should watch for relevant `access_code.*` events or poll the resource as needed.
- `noise_sensors.noise_thresholds.delete`: Instead, you should wait for the `noise_threshold.deleted` event.
- `noise_sensors.noise_thresholds.update`: Instead, you should watch for relevant `noise_threshold.*` events or poll the resource as needed.
- `thermostats.climate_setting_schedules.update`: Instead, you should watch for relevant `climate_setting_schedule.*` events or poll the resource as needed.
- `access_codes.unmanaged.convert_to_managed`: Instead, you should wait for the `access_code.unmanaged.converted_to_managed` and `access_code.unmanaged.failed_to_convert_to_managed` events.
The following methods now return a `NoiseThreshold`:
- `noise_sensors.noise_thresholds.create`: Use the newly-created `noise_threshold_id` to poll or watch for events.
The following methods now return an `ActionAttempt`:
- `workspaces.reset_sandbox`: Instead, you should use the newly-created `action_attempt_id` to poll the status of the action attempt via the `/action_attempt/get` endpoint.
Action attempt resolution
Methods returning action attempts still wait for the action attempt to resolve by default. Further, you can now configure this behavior using the [`wait_for_action_attempt` option](https://github.com/seamapi/javascript-http#action-attempts) on a per-request basis. You can also set the default behavior for the client.
Set per request
py
Wait for the action attempt to be ready with a default timeout of 5.0 seconds and a default polling interval of 0.5 seconds.
seam.locks.lock_door(
device_id="my_device_id",
wait_for_action_attempt=True
)
Wait up to 10 seconds for the action attempt to be ready, checking every 2 seconds.
seam.locks.lock_door(
device_id="my_device_id",
wait_for_action_attempt={
"timeout": 10.0, Up to 10 seconds
"polling_interval": 2.0 Every 2 seconds
}
)
Set default behavior
py
seam = Seam(wait_for_action_attempt=True)
Environment variables
Added support for the `SEAM_ENDPOINT` environment variable.
Using Personal Access Tokens without a Workspace ID
Use `SeamMultiWorkspace` to call the subset of Seam API endpoints that allow authentication with a personal access token without a workspace ID.
diff
- const seam = new Seam({ personal_access_token: 'your-personal-access-token' })
- const workspace = seam.workspaces.create({ company_name: 'Example Inc.' })
+ const seam_multi_workspace = new SeamMultiWorkspace({ personal_access_token: 'your-personal-access-token' })
+ const workspace = seam_multi_workspace.workspaces.create({ company_name: 'Example Inc.' })
Third-party component support and version changes
- Updated the minimum supported Python version to 3.9.
- Updated the `dataclasses-json` version to 0.6.4.
- Removed Sentry support.
- Replaced `requests` with `niquests` version 3.6.4.