|
20 | 20 | AccessPolicyTemplate, |
21 | 21 | Column, |
22 | 22 | ColumnConsentedPurposes, |
| 23 | + ColumnDataType, |
23 | 24 | ColumnRetentionDurationResponse, |
24 | 25 | ColumnRetentionDurationsResponse, |
25 | 26 | Edge, |
@@ -185,9 +186,59 @@ async def CreateUserWithMutatorAsync( |
185 | 186 | } |
186 | 187 | return await self._post_async("/userstore/api/users", json_data=body) |
187 | 188 |
|
| 189 | + # ColumnDataType Operations |
| 190 | + |
| 191 | + async def CreateColumnDataTypeAsync( |
| 192 | + self, dataType: ColumnDataType, if_not_exists: bool = False |
| 193 | + ) -> ColumnDataType: |
| 194 | + try: |
| 195 | + resp_json = await self._post_async( |
| 196 | + "/userstore/config/datatypes", |
| 197 | + json_data={"data_type": dataType.__dict__}, |
| 198 | + ) |
| 199 | + return ColumnDataType.from_json(resp_json) |
| 200 | + except UserCloudsSDKError as err: |
| 201 | + if if_not_exists: |
| 202 | + dataType.id = _id_from_identical_conflict(err) |
| 203 | + return dataType |
| 204 | + raise err |
| 205 | + |
| 206 | + async def DeleteColumnDataTypeAsync(self, id: uuid.UUID) -> bool: |
| 207 | + return await self._delete_async(f"/userstore/config/datatypes/{id}") |
| 208 | + |
| 209 | + async def GetColumnDataTypeAsync(self, id: uuid.UUID) -> ColumnDataType: |
| 210 | + resp_json = await self._get_async(f"/userstore/config/datatypes/{id}") |
| 211 | + return ColumnDataType.from_json(resp_json) |
| 212 | + |
| 213 | + async def ListColumnDataTypesAsync( |
| 214 | + self, limit: int = 0, starting_after: uuid.UUID | None = None |
| 215 | + ) -> list[ColumnDataType]: |
| 216 | + params: dict[str, int | str] = {} |
| 217 | + if limit > 0: |
| 218 | + params["limit"] = limit |
| 219 | + if starting_after is not None: |
| 220 | + params["starting_after"] = f"id:{starting_after}" |
| 221 | + params["version"] = "3" |
| 222 | + resp_json = await self._get_async("/userstore/config/datatypes", params=params) |
| 223 | + dataTypes = [ |
| 224 | + ColumnDataType.from_json(dataType) for dataType in resp_json["data"] |
| 225 | + ] |
| 226 | + return dataTypes |
| 227 | + |
| 228 | + async def UpdateColumnDataTypeAsync( |
| 229 | + self, dataType: ColumnDataType |
| 230 | + ) -> ColumnDataType: |
| 231 | + resp_json = await self._put_async( |
| 232 | + f"/userstore/config/datatypes/{dataType.id}", |
| 233 | + json_data={"data_type": dataType.__dict__}, |
| 234 | + ) |
| 235 | + return ColumnDataType.from_json(resp_json) |
| 236 | + |
188 | 237 | # Column Operations |
189 | 238 |
|
190 | | - async def CreateColumnAsync(self, column: Column, if_not_exists=False) -> Column: |
| 239 | + async def CreateColumnAsync( |
| 240 | + self, column: Column, if_not_exists: bool = False |
| 241 | + ) -> Column: |
191 | 242 | try: |
192 | 243 | resp_json = await self._post_async( |
193 | 244 | "/userstore/config/columns", json_data={"column": column.__dict__} |
@@ -229,7 +280,7 @@ async def UpdateColumnAsync(self, column: Column) -> Column: |
229 | 280 | # Purpose Operations |
230 | 281 |
|
231 | 282 | async def CreatePurposeAsync( |
232 | | - self, purpose: Purpose, if_not_exists=False |
| 283 | + self, purpose: Purpose, if_not_exists: bool = False |
233 | 284 | ) -> Purpose: |
234 | 285 | try: |
235 | 286 | resp_json = await self._post_async( |
@@ -438,7 +489,7 @@ async def UpdateSoftDeletedRetentionDurationsOnColumnAsync( |
438 | 489 | # Access Policy Templates |
439 | 490 |
|
440 | 491 | async def CreateAccessPolicyTemplateAsync( |
441 | | - self, access_policy_template: AccessPolicyTemplate, if_not_exists=False |
| 492 | + self, access_policy_template: AccessPolicyTemplate, if_not_exists: bool = False |
442 | 493 | ) -> AccessPolicyTemplate | UserCloudsSDKError: |
443 | 494 | try: |
444 | 495 | resp_json = await self._post_async( |
@@ -498,7 +549,7 @@ async def DeleteAccessPolicyTemplateAsync(self, id: uuid.UUID, version: int): |
498 | 549 | # Access Policies |
499 | 550 |
|
500 | 551 | async def CreateAccessPolicyAsync( |
501 | | - self, access_policy: AccessPolicy, if_not_exists=False |
| 552 | + self, access_policy: AccessPolicy, if_not_exists: bool = False |
502 | 553 | ) -> AccessPolicy | UserCloudsSDKError: |
503 | 554 | try: |
504 | 555 | resp_json = await self._post_async( |
@@ -552,7 +603,7 @@ async def DeleteAccessPolicyAsync(self, id: uuid.UUID, version: int): |
552 | 603 | # Transformers |
553 | 604 |
|
554 | 605 | async def CreateTransformerAsync( |
555 | | - self, transformer: Transformer, if_not_exists=False |
| 606 | + self, transformer: Transformer, if_not_exists: bool = False |
556 | 607 | ): |
557 | 608 | try: |
558 | 609 | resp_json = await self._post_async( |
@@ -589,7 +640,7 @@ async def DeleteTransformerAsync(self, id: uuid.UUID): |
589 | 640 | # Accessor Operations |
590 | 641 |
|
591 | 642 | async def CreateAccessorAsync( |
592 | | - self, accessor: Accessor, if_not_exists=False |
| 643 | + self, accessor: Accessor, if_not_exists: bool = False |
593 | 644 | ) -> Accessor: |
594 | 645 | try: |
595 | 646 | resp_json = await self._post_async( |
@@ -643,7 +694,7 @@ async def ExecuteAccessorAsync( |
643 | 694 | # Mutator Operations |
644 | 695 |
|
645 | 696 | async def CreateMutatorAsync( |
646 | | - self, mutator: Mutator, if_not_exists=False |
| 697 | + self, mutator: Mutator, if_not_exists: bool = False |
647 | 698 | ) -> Mutator: |
648 | 699 | try: |
649 | 700 | resp_json = await self._post_async( |
@@ -783,7 +834,9 @@ async def ListObjectsAsync( |
783 | 834 | objects = [Object.from_json(o) for o in j["data"]] |
784 | 835 | return objects |
785 | 836 |
|
786 | | - async def CreateObjectAsync(self, object: Object, if_not_exists=False) -> Object: |
| 837 | + async def CreateObjectAsync( |
| 838 | + self, object: Object, if_not_exists: bool = False |
| 839 | + ) -> Object: |
787 | 840 | try: |
788 | 841 | j = await self._post_async( |
789 | 842 | "/authz/objects", json_data={"object": object.__dict__} |
@@ -816,7 +869,7 @@ async def ListEdgesAsync( |
816 | 869 | edges = [Edge.from_json(e) for e in j["data"]] |
817 | 870 | return edges |
818 | 871 |
|
819 | | - async def CreateEdgeAsync(self, edge: Edge, if_not_exists=False) -> Edge: |
| 872 | + async def CreateEdgeAsync(self, edge: Edge, if_not_exists: bool = False) -> Edge: |
820 | 873 | try: |
821 | 874 | j = await self._post_async( |
822 | 875 | "/authz/edges", json_data={"edge": edge.__dict__} |
@@ -850,7 +903,7 @@ async def ListObjectTypesAsync( |
850 | 903 | return object_types |
851 | 904 |
|
852 | 905 | async def CreateObjectTypeAsync( |
853 | | - self, object_type: ObjectType, if_not_exists=False |
| 906 | + self, object_type: ObjectType, if_not_exists: bool = False |
854 | 907 | ) -> ObjectType: |
855 | 908 | try: |
856 | 909 | j = await self._post_async( |
@@ -885,7 +938,7 @@ async def ListEdgeTypesAsync( |
885 | 938 | return edge_types |
886 | 939 |
|
887 | 940 | async def CreateEdgeTypeAsync( |
888 | | - self, edge_type: EdgeType, if_not_exists=False |
| 941 | + self, edge_type: EdgeType, if_not_exists: bool = False |
889 | 942 | ) -> EdgeType: |
890 | 943 | try: |
891 | 944 | j = await self._post_async( |
@@ -920,7 +973,7 @@ async def ListOrganizationsAsync( |
920 | 973 | return organizations |
921 | 974 |
|
922 | 975 | async def CreateOrganizationAsync( |
923 | | - self, organization: Organization, if_not_exists=False |
| 976 | + self, organization: Organization, if_not_exists: bool = False |
924 | 977 | ) -> Organization: |
925 | 978 | try: |
926 | 979 | json_data = await self._post_async( |
|
0 commit comments