|
2 | 2 | from typing import Any, Dict, Optional, Union |
3 | 3 |
|
4 | 4 | from .calls import make_request |
5 | | -from .data import BugoutResource, BugoutResources, Method |
| 5 | +from .data import ( |
| 6 | + BugoutResource, |
| 7 | + BugoutResources, |
| 8 | + Method, |
| 9 | + BugoutResourceHolder, |
| 10 | + BugoutResourceHolders, |
| 11 | +) |
6 | 12 | from .exceptions import InvalidUrlSpec |
7 | 13 | from .settings import REQUESTS_TIMEOUT |
8 | 14 |
|
@@ -99,3 +105,45 @@ def delete_resource( |
99 | 105 | } |
100 | 106 | result = self._call(method=Method.delete, path=resources_path, headers=headers) |
101 | 107 | return BugoutResource(**result) |
| 108 | + |
| 109 | + def get_resource_holders( |
| 110 | + self, |
| 111 | + token: Union[str, uuid.UUID], |
| 112 | + resource_id: Union[str, uuid.UUID], |
| 113 | + ) -> BugoutResourceHolders: |
| 114 | + path = f"resources/{resource_id}/holders" |
| 115 | + headers = { |
| 116 | + "Authorization": f"Bearer {token}", |
| 117 | + } |
| 118 | + result = self._call(method=Method.get, path=path, headers=headers) |
| 119 | + return BugoutResourceHolders(**result) |
| 120 | + |
| 121 | + def add_resource_holder_permissions( |
| 122 | + self, |
| 123 | + token: Union[str, uuid.UUID], |
| 124 | + resource_id: Union[str, uuid.UUID], |
| 125 | + holder_permissions: BugoutResourceHolder, |
| 126 | + ) -> BugoutResourceHolders: |
| 127 | + path = f"resources/{resource_id}/holders" |
| 128 | + headers = { |
| 129 | + "Authorization": f"Bearer {token}", |
| 130 | + } |
| 131 | + result = self._call( |
| 132 | + method=Method.post, path=path, headers=headers, json=holder_permissions |
| 133 | + ) |
| 134 | + return BugoutResourceHolders(**result) |
| 135 | + |
| 136 | + def delete_resource_holder_permissions( |
| 137 | + self, |
| 138 | + token: Union[str, uuid.UUID], |
| 139 | + resource_id: Union[str, uuid.UUID], |
| 140 | + holder_permissions: BugoutResourceHolder, |
| 141 | + ) -> BugoutResourceHolders: |
| 142 | + path = f"resources/{resource_id}/holders" |
| 143 | + headers = { |
| 144 | + "Authorization": f"Bearer {token}", |
| 145 | + } |
| 146 | + result = self._call( |
| 147 | + method=Method.delete, path=path, headers=headers, json=holder_permissions |
| 148 | + ) |
| 149 | + return BugoutResourceHolders(**result) |
0 commit comments