Skip to content

Commit 9e84da9

Browse files
authored
Merge pull request #32 from bugout-dev/add-resource-update
Add resource update and black formating.
2 parents e0584c3 + 828f0e2 commit 9e84da9

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

bugout/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
__email__ = "engineering@bugout.dev"
99
__license__ = "MIT"
10-
__version__ = "0.1.15"
10+
__version__ = "0.1.16"
1111

1212
__all__ = (
1313
"__author__",

bugout/app.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,18 @@ def list_resources(
372372
self.resource.timeout = timeout
373373
return self.resource.list_resources(token=token, params=params)
374374

375+
def update_resource(
376+
self,
377+
token: Union[str, uuid.UUID],
378+
resource_id: Union[str, uuid.UUID],
379+
resource_data: Dict[str, Any],
380+
timeout: float = REQUESTS_TIMEOUT,
381+
) -> data.BugoutResource:
382+
self.resource.timeout = timeout
383+
return self.resource.update_resource(
384+
token=token, resource_id=resource_id, resource_data_update=resource_data
385+
)
386+
375387
def delete_resource(
376388
self,
377389
token: Union[str, uuid.UUID],

bugout/resource.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,24 @@ def list_resources(
7070
)
7171
return BugoutResources(**result)
7272

73+
def update_resource(
74+
self,
75+
token: Union[str, uuid.UUID],
76+
resource_id: Union[str, uuid.UUID],
77+
resource_data_update: Dict[str, Any],
78+
) -> BugoutResource:
79+
resources_path = f"resources/{resource_id}"
80+
headers = {
81+
"Authorization": f"Bearer {token}",
82+
}
83+
result = self._call(
84+
method=Method.put,
85+
path=resources_path,
86+
headers=headers,
87+
json=resource_data_update,
88+
)
89+
return BugoutResource(**result)
90+
7391
def delete_resource(
7492
self,
7593
token: Union[str, uuid.UUID],

0 commit comments

Comments
 (0)