Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

Commit e8648de

Browse files
authored
Merge branch 'main' into fix-docker-reference
2 parents 5fcf5ed + 8db1c04 commit e8648de

File tree

7 files changed

+117
-7
lines changed

7 files changed

+117
-7
lines changed

.github/workflows/test.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,27 @@ on:
2323
jobs:
2424
test:
2525
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
packages: write
2629
env:
27-
CONTAINER_REGISTRY: "registry.digitalocean.com"
30+
CONTAINER_REGISTRY: "ghcr.io"
2831
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
2932
steps:
3033
- name: Checkout
3134
uses: actions/checkout@v2
3235
with:
3336
ref: ${{ github.event.inputs.sdkSha }}
34-
- name: Login to DO container registry
35-
uses: docker/login-action@v1
37+
- name: Login to container registry
38+
uses: docker/login-action@v2
3639
with:
3740
registry: ${{ env.CONTAINER_REGISTRY }}
38-
username: ${{ secrets.DIGITAL_OCEAN_TOKEN }}
39-
password: ${{ secrets.DIGITAL_OCEAN_TOKEN }}
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.BOT_GH_TOKEN }}
4043
- name: Pre-pull Seam Connect image
41-
run: docker pull ${{ env.CONTAINER_REGISTRY }}/seam/seam-connect:${{ github.event.inputs.connectSha || 'latest' }}
44+
run: |
45+
docker pull ${{ env.CONTAINER_REGISTRY }}/seamapi/seam-connect:${{ github.event.inputs.connectSha || 'latest' }}
46+
docker tag ${{ env.CONTAINER_REGISTRY }}/seamapi/seam-connect:${{ github.event.inputs.connectSha || 'latest' }} seamapi/seam-connect
4247
- uses: actions/setup-python@v2
4348
with:
4449
python-version: 3.8

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
All notable changes to this project will be documented in this file. See
44
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [1.3.0](https://github.com/seamapi/python/compare/v1.2.0...v1.3.0) (2022-09-19)
7+
8+
9+
### Features
10+
11+
* Merge pull request [#42](https://github.com/seamapi/python/issues/42) from seamapi/implement-delete-connected-account ([c4b55b5](https://github.com/seamapi/python/commit/c4b55b5722774f6dc700679ecd03fbc12028eda0)), closes [#27](https://github.com/seamapi/python/issues/27)
12+
13+
## [1.2.0](https://github.com/seamapi/python/compare/v1.1.5...v1.2.0) (2022-09-16)
14+
15+
16+
### Features
17+
18+
* Merge pull request [#41](https://github.com/seamapi/python/issues/41) from seamapi/implement-device-update ([bd94e17](https://github.com/seamapi/python/commit/bd94e17bab7657d31e2f58049deb136b5d2a58a2)), closes [#29](https://github.com/seamapi/python/issues/29)
19+
620
### [1.1.5](https://github.com/seamapi/python/compare/v1.1.4...v1.1.5) (2022-09-13)
721

822

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "seamapi"
3-
version = "1.1.5"
3+
version = "1.3.0"
44
description = "A Python Library for Seam's API https://getseam.com"
55
authors = ["Severin Ibarluzea <[email protected]>"]
66
license = "MIT"

seamapi/connected_accounts.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,35 @@ def get(
110110
account_type=json_account["account_type"],
111111
errors=json_account.get("errors", []),
112112
)
113+
114+
def delete(
115+
self,
116+
connected_account: Union[ConnectedAccountId, ConnectedAccount],
117+
) -> bool:
118+
"""Deletes a connected account.
119+
120+
Parameters
121+
----------
122+
connected_account : ConnectedAccountId or ConnectedAccount
123+
Connected account id or ConnectedAccount to delete
124+
125+
Raises
126+
------
127+
Exception
128+
If the API request wasn't successful.
129+
130+
Returns
131+
Boolean indicating if the connected account was deleted
132+
"""
133+
134+
connected_account_id = to_connected_account_id(connected_account)
135+
136+
res = requests.delete(
137+
f"{self.seam.api_url}/connected_accounts/delete",
138+
headers={"Authorization": f"Bearer {self.seam.api_key}"},
139+
data={"connected_account_id": connected_account_id},
140+
)
141+
if not res.ok:
142+
raise Exception(res.text)
143+
144+
return True

seamapi/devices.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class Devices(AbstractDevices):
3636
Gets a list of devices
3737
get(device=None, name=None)
3838
Gets a device
39+
update(device, name=None, properties=None, location=None)
40+
Updates a device
3941
"""
4042

4143
seam: Seam
@@ -136,3 +138,53 @@ def get(
136138
raise Exception(res.text)
137139
json_device = res.json()["device"]
138140
return Device.from_dict(json_device)
141+
142+
def update(
143+
self,
144+
device: Union[DeviceId, Device],
145+
name: Optional[str] = None,
146+
properties: Optional[dict] = None,
147+
location: Optional[dict] = None,
148+
) -> Device:
149+
"""Updates a device.
150+
151+
Parameters
152+
----------
153+
device : DeviceId or Device
154+
Device id or Device to update
155+
name : str, optional
156+
New device name
157+
properties : dict, optional
158+
New device properties
159+
location : str, optional
160+
New device location
161+
162+
Raises
163+
------
164+
Exception
165+
If the API request wasn't successful.
166+
167+
Returns
168+
------
169+
Boolean
170+
"""
171+
172+
if not device:
173+
raise Exception("device is required")
174+
175+
params = {
176+
"device_id": to_device_id(device),
177+
"name": name,
178+
"properties": properties,
179+
"location": location,
180+
}
181+
182+
res = requests.post(
183+
f"{self.seam.api_url}/devices/update",
184+
headers={"Authorization": f"Bearer {self.seam.api_key}"},
185+
params=params,
186+
)
187+
if not res.ok:
188+
raise Exception(res.text)
189+
190+
return True

tests/connected_accounts/test_connected_accounts.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ def test_connected_accounts(seam: Seam):
1111
connected_account_id = connected_accounts[0].connected_account_id
1212
connected_account = seam.connected_accounts.get(connected_account_id)
1313
assert connected_account.connected_account_id == connected_account_id
14+
15+
seam.connected_accounts.delete(connected_account)
16+
assert len(seam.connected_accounts.list()) == 0

tests/devices/test_devices.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ def test_devices(seam: Seam):
2727
seam.locks.lock_door(device=(some_device))
2828
some_locked_lock = seam.locks.get(device=(some_device))
2929
assert some_locked_lock.properties.locked == True
30+
31+
seam.devices.update(device=(some_device), name="Updated lock")
32+
some_updated_lock = seam.locks.get(device=(some_device))
33+
assert some_updated_lock.properties.name == "Updated lock"

0 commit comments

Comments
 (0)