diff --git a/CHANGELOG.md b/CHANGELOG.md index e0f8c17..dbe2b9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- `tilebox-datasets`: Added `delete_collection` method to `DatasetClient` to delete a collection by name. + ## [0.37.1] - 2025-06-10 ### Fixed diff --git a/tilebox-datasets/tests/test_timeseries.py b/tilebox-datasets/tests/test_timeseries.py index 629060b..656da10 100644 --- a/tilebox-datasets/tests/test_timeseries.py +++ b/tilebox-datasets/tests/test_timeseries.py @@ -6,7 +6,7 @@ import xarray as xr from attr import dataclass from hypothesis import assume, given, settings -from hypothesis.stateful import Bundle, RuleBasedStateMachine, invariant, rule +from hypothesis.stateful import Bundle, RuleBasedStateMachine, consumes, invariant, rule from hypothesis.strategies import lists from promise import Promise @@ -28,6 +28,7 @@ from tilebox.datasets.data.uuid import uuid_message_to_uuid, uuid_to_uuid_message from tilebox.datasets.datasetsv1.collections_pb2 import ( CreateCollectionRequest, + DeleteCollectionByNameRequest, GetCollectionByNameRequest, ListCollectionsRequest, ) @@ -291,6 +292,9 @@ def GetCollectionByName(self, req: GetCollectionByNameRequest) -> CollectionInfo return self.collections[req.collection_name] raise NotFoundError(f"Collection {req.collection_name} not found") + def DeleteCollectionByName(self, req: DeleteCollectionByNameRequest) -> None: # noqa: N802 + del self.collections[req.collection_name] + def ListCollections(self, req: ListCollectionsRequest) -> CollectionInfosMessage: # noqa: N802 _ = req return CollectionInfosMessage(data=list(self.collections.values())) @@ -346,6 +350,12 @@ def get_collection(self, collection: CollectionClient) -> None: got = self.dataset_client.collection(collection.name) assert got.info() == collection.info() + @rule(collection=consumes(inserted_collections)) # consumes -> remove from bundle afterwards + def delete_collection(self, collection: CollectionClient) -> None: + self.count_collections -= 1 + assert self.count_collections >= 0 + self.dataset_client.delete_collection(collection.name) + @invariant() def list_collections(self) -> None: collections = self.dataset_client.collections() diff --git a/tilebox-datasets/tilebox/datasets/aio/dataset.py b/tilebox-datasets/tilebox/datasets/aio/dataset.py index 9891713..e4a4bc4 100644 --- a/tilebox-datasets/tilebox/datasets/aio/dataset.py +++ b/tilebox-datasets/tilebox/datasets/aio/dataset.py @@ -127,6 +127,14 @@ async def collection(self, name: str) -> "CollectionClient": return CollectionClient(self, info) + async def delete_collection(self, name: str) -> None: + """Delete a collection by its name. + + Args: + name: The name of the collection to delete. + """ + await self._service.delete_collection_by_name(self._dataset.id, name) + def __repr__(self) -> str: return f"{self.name} [Timeseries Dataset]: {self._dataset.summary}" diff --git a/tilebox-datasets/tilebox/datasets/datasetsv1/collections_pb2.py b/tilebox-datasets/tilebox/datasets/datasetsv1/collections_pb2.py index 6d597a0..6ac74d3 100644 --- a/tilebox-datasets/tilebox/datasets/datasetsv1/collections_pb2.py +++ b/tilebox-datasets/tilebox/datasets/datasetsv1/collections_pb2.py @@ -25,7 +25,7 @@ from tilebox.datasets.datasetsv1 import core_pb2 as datasets_dot_v1_dot_core__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1d\x64\x61tasets/v1/collections.proto\x12\x0b\x64\x61tasets.v1\x1a\x16\x64\x61tasets/v1/core.proto\"]\n\x17\x43reateCollectionRequest\x12.\n\ndataset_id\x18\x01 \x01(\x0b\x32\x0f.datasets.v1.IDR\tdatasetId\x12\x12\n\x04name\x18\x02 \x01(\tR\x04name\"\xc1\x01\n\x1aGetCollectionByNameRequest\x12\'\n\x0f\x63ollection_name\x18\x01 \x01(\tR\x0e\x63ollectionName\x12+\n\x11with_availability\x18\x02 \x01(\x08R\x10withAvailability\x12\x1d\n\nwith_count\x18\x03 \x01(\x08R\twithCount\x12.\n\ndataset_id\x18\x04 \x01(\x0b\x32\x0f.datasets.v1.IDR\tdatasetId\"\x94\x01\n\x16ListCollectionsRequest\x12.\n\ndataset_id\x18\x01 \x01(\x0b\x32\x0f.datasets.v1.IDR\tdatasetId\x12+\n\x11with_availability\x18\x02 \x01(\x08R\x10withAvailability\x12\x1d\n\nwith_count\x18\x03 \x01(\x08R\twithCount2\xa3\x02\n\x11\x43ollectionService\x12W\n\x10\x43reateCollection\x12$.datasets.v1.CreateCollectionRequest\x1a\x1b.datasets.v1.CollectionInfo\"\x00\x12]\n\x13GetCollectionByName\x12\'.datasets.v1.GetCollectionByNameRequest\x1a\x1b.datasets.v1.CollectionInfo\"\x00\x12V\n\x0fListCollections\x12#.datasets.v1.ListCollectionsRequest\x1a\x1c.datasets.v1.CollectionInfos\"\x00\x42\xb2\x01\n\x0f\x63om.datasets.v1B\x10\x43ollectionsProtoP\x01Z@github.com/tilebox/tilebox-go/protogen/go/datasets/v1;datasetsv1\xa2\x02\x03\x44XX\xaa\x02\x0b\x44\x61tasets.V1\xca\x02\x0b\x44\x61tasets\\V1\xe2\x02\x17\x44\x61tasets\\V1\\GPBMetadata\xea\x02\x0c\x44\x61tasets::V1b\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1d\x64\x61tasets/v1/collections.proto\x12\x0b\x64\x61tasets.v1\x1a\x16\x64\x61tasets/v1/core.proto\"]\n\x17\x43reateCollectionRequest\x12.\n\ndataset_id\x18\x01 \x01(\x0b\x32\x0f.datasets.v1.IDR\tdatasetId\x12\x12\n\x04name\x18\x02 \x01(\tR\x04name\"\xc1\x01\n\x1aGetCollectionByNameRequest\x12\'\n\x0f\x63ollection_name\x18\x01 \x01(\tR\x0e\x63ollectionName\x12+\n\x11with_availability\x18\x02 \x01(\x08R\x10withAvailability\x12\x1d\n\nwith_count\x18\x03 \x01(\x08R\twithCount\x12.\n\ndataset_id\x18\x04 \x01(\x0b\x32\x0f.datasets.v1.IDR\tdatasetId\"x\n\x1d\x44\x65leteCollectionByNameRequest\x12\'\n\x0f\x63ollection_name\x18\x01 \x01(\tR\x0e\x63ollectionName\x12.\n\ndataset_id\x18\x02 \x01(\x0b\x32\x0f.datasets.v1.IDR\tdatasetId\" \n\x1e\x44\x65leteCollectionByNameResponse\"\x94\x01\n\x16ListCollectionsRequest\x12.\n\ndataset_id\x18\x01 \x01(\x0b\x32\x0f.datasets.v1.IDR\tdatasetId\x12+\n\x11with_availability\x18\x02 \x01(\x08R\x10withAvailability\x12\x1d\n\nwith_count\x18\x03 \x01(\x08R\twithCount2\x98\x03\n\x11\x43ollectionService\x12W\n\x10\x43reateCollection\x12$.datasets.v1.CreateCollectionRequest\x1a\x1b.datasets.v1.CollectionInfo\"\x00\x12]\n\x13GetCollectionByName\x12\'.datasets.v1.GetCollectionByNameRequest\x1a\x1b.datasets.v1.CollectionInfo\"\x00\x12s\n\x16\x44\x65leteCollectionByName\x12*.datasets.v1.DeleteCollectionByNameRequest\x1a+.datasets.v1.DeleteCollectionByNameResponse\"\x00\x12V\n\x0fListCollections\x12#.datasets.v1.ListCollectionsRequest\x1a\x1c.datasets.v1.CollectionInfos\"\x00\x42\xb2\x01\n\x0f\x63om.datasets.v1B\x10\x43ollectionsProtoP\x01Z@github.com/tilebox/tilebox-go/protogen/go/datasets/v1;datasetsv1\xa2\x02\x03\x44XX\xaa\x02\x0b\x44\x61tasets.V1\xca\x02\x0b\x44\x61tasets\\V1\xe2\x02\x17\x44\x61tasets\\V1\\GPBMetadata\xea\x02\x0c\x44\x61tasets::V1b\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) @@ -37,8 +37,12 @@ _globals['_CREATECOLLECTIONREQUEST']._serialized_end=163 _globals['_GETCOLLECTIONBYNAMEREQUEST']._serialized_start=166 _globals['_GETCOLLECTIONBYNAMEREQUEST']._serialized_end=359 - _globals['_LISTCOLLECTIONSREQUEST']._serialized_start=362 - _globals['_LISTCOLLECTIONSREQUEST']._serialized_end=510 - _globals['_COLLECTIONSERVICE']._serialized_start=513 - _globals['_COLLECTIONSERVICE']._serialized_end=804 + _globals['_DELETECOLLECTIONBYNAMEREQUEST']._serialized_start=361 + _globals['_DELETECOLLECTIONBYNAMEREQUEST']._serialized_end=481 + _globals['_DELETECOLLECTIONBYNAMERESPONSE']._serialized_start=483 + _globals['_DELETECOLLECTIONBYNAMERESPONSE']._serialized_end=515 + _globals['_LISTCOLLECTIONSREQUEST']._serialized_start=518 + _globals['_LISTCOLLECTIONSREQUEST']._serialized_end=666 + _globals['_COLLECTIONSERVICE']._serialized_start=669 + _globals['_COLLECTIONSERVICE']._serialized_end=1077 # @@protoc_insertion_point(module_scope) diff --git a/tilebox-datasets/tilebox/datasets/datasetsv1/collections_pb2.pyi b/tilebox-datasets/tilebox/datasets/datasetsv1/collections_pb2.pyi index 9a2ba34..518c96c 100644 --- a/tilebox-datasets/tilebox/datasets/datasetsv1/collections_pb2.pyi +++ b/tilebox-datasets/tilebox/datasets/datasetsv1/collections_pb2.pyi @@ -25,6 +25,18 @@ class GetCollectionByNameRequest(_message.Message): dataset_id: _core_pb2.ID def __init__(self, collection_name: _Optional[str] = ..., with_availability: bool = ..., with_count: bool = ..., dataset_id: _Optional[_Union[_core_pb2.ID, _Mapping]] = ...) -> None: ... +class DeleteCollectionByNameRequest(_message.Message): + __slots__ = ("collection_name", "dataset_id") + COLLECTION_NAME_FIELD_NUMBER: _ClassVar[int] + DATASET_ID_FIELD_NUMBER: _ClassVar[int] + collection_name: str + dataset_id: _core_pb2.ID + def __init__(self, collection_name: _Optional[str] = ..., dataset_id: _Optional[_Union[_core_pb2.ID, _Mapping]] = ...) -> None: ... + +class DeleteCollectionByNameResponse(_message.Message): + __slots__ = () + def __init__(self) -> None: ... + class ListCollectionsRequest(_message.Message): __slots__ = ("dataset_id", "with_availability", "with_count") DATASET_ID_FIELD_NUMBER: _ClassVar[int] diff --git a/tilebox-datasets/tilebox/datasets/datasetsv1/collections_pb2_grpc.py b/tilebox-datasets/tilebox/datasets/datasetsv1/collections_pb2_grpc.py index 0be6824..d95862b 100644 --- a/tilebox-datasets/tilebox/datasets/datasetsv1/collections_pb2_grpc.py +++ b/tilebox-datasets/tilebox/datasets/datasetsv1/collections_pb2_grpc.py @@ -26,6 +26,11 @@ def __init__(self, channel): request_serializer=datasets_dot_v1_dot_collections__pb2.GetCollectionByNameRequest.SerializeToString, response_deserializer=datasets_dot_v1_dot_core__pb2.CollectionInfo.FromString, _registered_method=True) + self.DeleteCollectionByName = channel.unary_unary( + '/datasets.v1.CollectionService/DeleteCollectionByName', + request_serializer=datasets_dot_v1_dot_collections__pb2.DeleteCollectionByNameRequest.SerializeToString, + response_deserializer=datasets_dot_v1_dot_collections__pb2.DeleteCollectionByNameResponse.FromString, + _registered_method=True) self.ListCollections = channel.unary_unary( '/datasets.v1.CollectionService/ListCollections', request_serializer=datasets_dot_v1_dot_collections__pb2.ListCollectionsRequest.SerializeToString, @@ -49,6 +54,12 @@ def GetCollectionByName(self, request, context): context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') + def DeleteCollectionByName(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + def ListCollections(self, request, context): """Missing associated documentation comment in .proto file.""" context.set_code(grpc.StatusCode.UNIMPLEMENTED) @@ -68,6 +79,11 @@ def add_CollectionServiceServicer_to_server(servicer, server): request_deserializer=datasets_dot_v1_dot_collections__pb2.GetCollectionByNameRequest.FromString, response_serializer=datasets_dot_v1_dot_core__pb2.CollectionInfo.SerializeToString, ), + 'DeleteCollectionByName': grpc.unary_unary_rpc_method_handler( + servicer.DeleteCollectionByName, + request_deserializer=datasets_dot_v1_dot_collections__pb2.DeleteCollectionByNameRequest.FromString, + response_serializer=datasets_dot_v1_dot_collections__pb2.DeleteCollectionByNameResponse.SerializeToString, + ), 'ListCollections': grpc.unary_unary_rpc_method_handler( servicer.ListCollections, request_deserializer=datasets_dot_v1_dot_collections__pb2.ListCollectionsRequest.FromString, @@ -139,6 +155,33 @@ def GetCollectionByName(request, metadata, _registered_method=True) + @staticmethod + def DeleteCollectionByName(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/datasets.v1.CollectionService/DeleteCollectionByName', + datasets_dot_v1_dot_collections__pb2.DeleteCollectionByNameRequest.SerializeToString, + datasets_dot_v1_dot_collections__pb2.DeleteCollectionByNameResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + @staticmethod def ListCollections(request, target, diff --git a/tilebox-datasets/tilebox/datasets/datasetsv1/core_pb2.py b/tilebox-datasets/tilebox/datasets/datasetsv1/core_pb2.py index 89ca213..2e4ad08 100644 --- a/tilebox-datasets/tilebox/datasets/datasetsv1/core_pb2.py +++ b/tilebox-datasets/tilebox/datasets/datasetsv1/core_pb2.py @@ -26,7 +26,7 @@ from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x16\x64\x61tasets/v1/core.proto\x12\x0b\x64\x61tasets.v1\x1a\x1e\x64\x61tasets/v1/dataset_type.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x18\n\x02ID\x12\x12\n\x04uuid\x18\x01 \x01(\x0cR\x04uuid\"\xce\x01\n\x0cTimeInterval\x12\x39\n\nstart_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.TimestampR\tstartTime\x12\x35\n\x08\x65nd_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.TimestampR\x07\x65ndTime\x12\'\n\x0fstart_exclusive\x18\x03 \x01(\x08R\x0estartExclusive\x12#\n\rend_inclusive\x18\x04 \x01(\x08R\x0c\x65ndInclusive\"\xb5\x01\n\x11\x44\x61tapointInterval\x12*\n\x08start_id\x18\x01 \x01(\x0b\x32\x0f.datasets.v1.IDR\x07startId\x12&\n\x06\x65nd_id\x18\x02 \x01(\x0b\x32\x0f.datasets.v1.IDR\x05\x65ndId\x12\'\n\x0fstart_exclusive\x18\x03 \x01(\x08R\x0estartExclusive\x12#\n\rend_inclusive\x18\x04 \x01(\x08R\x0c\x65ndInclusive\"v\n\x10LegacyPagination\x12\x19\n\x05limit\x18\x01 \x01(\x03H\x00R\x05limit\x88\x01\x01\x12*\n\x0estarting_after\x18\x02 \x01(\tH\x01R\rstartingAfter\x88\x01\x01\x42\x08\n\x06_limitB\x11\n\x0f_starting_after\"\x81\x01\n\nPagination\x12\x19\n\x05limit\x18\x01 \x01(\x03H\x00R\x05limit\x88\x01\x01\x12;\n\x0estarting_after\x18\x02 \x01(\x0b\x32\x0f.datasets.v1.IDH\x01R\rstartingAfter\x88\x01\x01\x42\x08\n\x06_limitB\x11\n\x0f_starting_after\"6\n\x03\x41ny\x12\x19\n\x08type_url\x18\x01 \x01(\tR\x07typeUrl\x12\x14\n\x05value\x18\x02 \x01(\x0cR\x05value\">\n\x0bRepeatedAny\x12\x19\n\x08type_url\x18\x01 \x01(\tR\x07typeUrl\x12\x14\n\x05value\x18\x02 \x03(\x0cR\x05value\"\xad\x01\n\x11\x44\x61tapointMetadata\x12\x39\n\nevent_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.TimestampR\teventTime\x12\x41\n\x0eingestion_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.TimestampR\ringestionTime\x12\x13\n\x02id\x18\x03 \x01(\tH\x00R\x02id\x88\x01\x01\x42\x05\n\x03_id\"n\n\nDatapoints\x12\x32\n\x04meta\x18\x01 \x03(\x0b\x32\x1e.datasets.v1.DatapointMetadataR\x04meta\x12,\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x18.datasets.v1.RepeatedAnyR\x04\x64\x61ta\"\xc0\x01\n\rDatapointPage\x12\x32\n\x04meta\x18\x01 \x03(\x0b\x32\x1e.datasets.v1.DatapointMetadataR\x04meta\x12,\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x18.datasets.v1.RepeatedAnyR\x04\x64\x61ta\x12?\n\tnext_page\x18\x03 \x01(\x0b\x32\x1d.datasets.v1.LegacyPaginationH\x00R\x08nextPage\x88\x01\x01\x42\x0c\n\n_next_page\"e\n\tDatapoint\x12\x32\n\x04meta\x18\x01 \x01(\x0b\x32\x1e.datasets.v1.DatapointMetadataR\x04meta\x12$\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x10.datasets.v1.AnyR\x04\x64\x61ta\"^\n\nCollection\x12\x1b\n\tlegacy_id\x18\x01 \x01(\tR\x08legacyId\x12\x12\n\x04name\x18\x02 \x01(\tR\x04name\x12\x1f\n\x02id\x18\x03 \x01(\x0b\x32\x0f.datasets.v1.IDR\x02id\"\xc3\x01\n\x0e\x43ollectionInfo\x12\x37\n\ncollection\x18\x01 \x01(\x0b\x32\x17.datasets.v1.CollectionR\ncollection\x12\x42\n\x0c\x61vailability\x18\x02 \x01(\x0b\x32\x19.datasets.v1.TimeIntervalH\x00R\x0c\x61vailability\x88\x01\x01\x12\x19\n\x05\x63ount\x18\x03 \x01(\x04H\x01R\x05\x63ount\x88\x01\x01\x42\x0f\n\r_availabilityB\x08\n\x06_count\"B\n\x0f\x43ollectionInfos\x12/\n\x04\x64\x61ta\x18\x01 \x03(\x0b\x32\x1b.datasets.v1.CollectionInfoR\x04\x64\x61ta\"\x96\x03\n\x07\x44\x61taset\x12\x1f\n\x02id\x18\x01 \x01(\x0b\x32\x0f.datasets.v1.IDR\x02id\x12*\n\x08group_id\x18\x02 \x01(\x0b\x32\x0f.datasets.v1.IDR\x07groupId\x12.\n\x04type\x18\x03 \x01(\x0b\x32\x1a.datasets.v1.AnnotatedTypeR\x04type\x12\x1b\n\tcode_name\x18\x04 \x01(\tR\x08\x63odeName\x12\x12\n\x04name\x18\x05 \x01(\tR\x04name\x12\x18\n\x07summary\x18\x06 \x01(\tR\x07summary\x12\x12\n\x04icon\x18\x07 \x01(\tR\x04icon\x12 \n\x0b\x64\x65scription\x18\x08 \x01(\tR\x0b\x64\x65scription\x12@\n\x0bpermissions\x18\n \x03(\x0e\x32\x1e.datasets.v1.DatasetPermissionR\x0bpermissions\x12\x37\n\nvisibility\x18\x0b \x01(\x0e\x32\x17.datasets.v1.VisibilityR\nvisibility\x12\x12\n\x04slug\x18\x0c \x01(\tR\x04slug\"\xa2\x01\n\x0c\x44\x61tasetGroup\x12\x1f\n\x02id\x18\x01 \x01(\x0b\x32\x0f.datasets.v1.IDR\x02id\x12,\n\tparent_id\x18\x02 \x01(\x0b\x32\x0f.datasets.v1.IDR\x08parentId\x12\x1b\n\tcode_name\x18\x03 \x01(\tR\x08\x63odeName\x12\x12\n\x04name\x18\x04 \x01(\tR\x04name\x12\x12\n\x04icon\x18\x05 \x01(\tR\x04icon*\x9b\x01\n\x11\x44\x61tasetPermission\x12\"\n\x1e\x44\x41TASET_PERMISSION_UNSPECIFIED\x10\x00\x12\"\n\x1e\x44\x41TASET_PERMISSION_ACCESS_DATA\x10\x01\x12!\n\x1d\x44\x41TASET_PERMISSION_WRITE_DATA\x10\x02\x12\x1b\n\x17\x44\x41TASET_PERMISSION_EDIT\x10\x03*v\n\nVisibility\x12\x1a\n\x16VISIBILITY_UNSPECIFIED\x10\x00\x12\x16\n\x12VISIBILITY_PRIVATE\x10\x01\x12\x1d\n\x19VISIBILITY_SHARED_WITH_ME\x10\x02\x12\x15\n\x11VISIBILITY_PUBLIC\x10\x03\x42\xab\x01\n\x0f\x63om.datasets.v1B\tCoreProtoP\x01Z@github.com/tilebox/tilebox-go/protogen/go/datasets/v1;datasetsv1\xa2\x02\x03\x44XX\xaa\x02\x0b\x44\x61tasets.V1\xca\x02\x0b\x44\x61tasets\\V1\xe2\x02\x17\x44\x61tasets\\V1\\GPBMetadata\xea\x02\x0c\x44\x61tasets::V1b\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x16\x64\x61tasets/v1/core.proto\x12\x0b\x64\x61tasets.v1\x1a\x1e\x64\x61tasets/v1/dataset_type.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x18\n\x02ID\x12\x12\n\x04uuid\x18\x01 \x01(\x0cR\x04uuid\"\xce\x01\n\x0cTimeInterval\x12\x39\n\nstart_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.TimestampR\tstartTime\x12\x35\n\x08\x65nd_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.TimestampR\x07\x65ndTime\x12\'\n\x0fstart_exclusive\x18\x03 \x01(\x08R\x0estartExclusive\x12#\n\rend_inclusive\x18\x04 \x01(\x08R\x0c\x65ndInclusive\"\xb5\x01\n\x11\x44\x61tapointInterval\x12*\n\x08start_id\x18\x01 \x01(\x0b\x32\x0f.datasets.v1.IDR\x07startId\x12&\n\x06\x65nd_id\x18\x02 \x01(\x0b\x32\x0f.datasets.v1.IDR\x05\x65ndId\x12\'\n\x0fstart_exclusive\x18\x03 \x01(\x08R\x0estartExclusive\x12#\n\rend_inclusive\x18\x04 \x01(\x08R\x0c\x65ndInclusive\"v\n\x10LegacyPagination\x12\x19\n\x05limit\x18\x01 \x01(\x03H\x00R\x05limit\x88\x01\x01\x12*\n\x0estarting_after\x18\x02 \x01(\tH\x01R\rstartingAfter\x88\x01\x01\x42\x08\n\x06_limitB\x11\n\x0f_starting_after\"\x81\x01\n\nPagination\x12\x19\n\x05limit\x18\x01 \x01(\x03H\x00R\x05limit\x88\x01\x01\x12;\n\x0estarting_after\x18\x02 \x01(\x0b\x32\x0f.datasets.v1.IDH\x01R\rstartingAfter\x88\x01\x01\x42\x08\n\x06_limitB\x11\n\x0f_starting_after\"6\n\x03\x41ny\x12\x19\n\x08type_url\x18\x01 \x01(\tR\x07typeUrl\x12\x14\n\x05value\x18\x02 \x01(\x0cR\x05value\">\n\x0bRepeatedAny\x12\x19\n\x08type_url\x18\x01 \x01(\tR\x07typeUrl\x12\x14\n\x05value\x18\x02 \x03(\x0cR\x05value\"\xad\x01\n\x11\x44\x61tapointMetadata\x12\x39\n\nevent_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.TimestampR\teventTime\x12\x41\n\x0eingestion_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.TimestampR\ringestionTime\x12\x13\n\x02id\x18\x03 \x01(\tH\x00R\x02id\x88\x01\x01\x42\x05\n\x03_id\"n\n\nDatapoints\x12\x32\n\x04meta\x18\x01 \x03(\x0b\x32\x1e.datasets.v1.DatapointMetadataR\x04meta\x12,\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x18.datasets.v1.RepeatedAnyR\x04\x64\x61ta\"\xc0\x01\n\rDatapointPage\x12\x32\n\x04meta\x18\x01 \x03(\x0b\x32\x1e.datasets.v1.DatapointMetadataR\x04meta\x12,\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x18.datasets.v1.RepeatedAnyR\x04\x64\x61ta\x12?\n\tnext_page\x18\x03 \x01(\x0b\x32\x1d.datasets.v1.LegacyPaginationH\x00R\x08nextPage\x88\x01\x01\x42\x0c\n\n_next_page\"e\n\tDatapoint\x12\x32\n\x04meta\x18\x01 \x01(\x0b\x32\x1e.datasets.v1.DatapointMetadataR\x04meta\x12$\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x10.datasets.v1.AnyR\x04\x64\x61ta\"^\n\nCollection\x12\x1b\n\tlegacy_id\x18\x01 \x01(\tR\x08legacyId\x12\x12\n\x04name\x18\x02 \x01(\tR\x04name\x12\x1f\n\x02id\x18\x03 \x01(\x0b\x32\x0f.datasets.v1.IDR\x02id\"\xc3\x01\n\x0e\x43ollectionInfo\x12\x37\n\ncollection\x18\x01 \x01(\x0b\x32\x17.datasets.v1.CollectionR\ncollection\x12\x42\n\x0c\x61vailability\x18\x02 \x01(\x0b\x32\x19.datasets.v1.TimeIntervalH\x00R\x0c\x61vailability\x88\x01\x01\x12\x19\n\x05\x63ount\x18\x03 \x01(\x04H\x01R\x05\x63ount\x88\x01\x01\x42\x0f\n\r_availabilityB\x08\n\x06_count\"B\n\x0f\x43ollectionInfos\x12/\n\x04\x64\x61ta\x18\x01 \x03(\x0b\x32\x1b.datasets.v1.CollectionInfoR\x04\x64\x61ta\"\xbb\x03\n\x07\x44\x61taset\x12\x1f\n\x02id\x18\x01 \x01(\x0b\x32\x0f.datasets.v1.IDR\x02id\x12*\n\x08group_id\x18\x02 \x01(\x0b\x32\x0f.datasets.v1.IDR\x07groupId\x12.\n\x04type\x18\x03 \x01(\x0b\x32\x1a.datasets.v1.AnnotatedTypeR\x04type\x12\x1b\n\tcode_name\x18\x04 \x01(\tR\x08\x63odeName\x12\x12\n\x04name\x18\x05 \x01(\tR\x04name\x12\x18\n\x07summary\x18\x06 \x01(\tR\x07summary\x12\x12\n\x04icon\x18\x07 \x01(\tR\x04icon\x12 \n\x0b\x64\x65scription\x18\x08 \x01(\tR\x0b\x64\x65scription\x12@\n\x0bpermissions\x18\n \x03(\x0e\x32\x1e.datasets.v1.DatasetPermissionR\x0bpermissions\x12\x37\n\nvisibility\x18\x0b \x01(\x0e\x32\x17.datasets.v1.VisibilityR\nvisibility\x12\x12\n\x04slug\x18\x0c \x01(\tR\x04slug\x12#\n\rtype_editable\x18\r \x01(\x08R\x0ctypeEditable\"\xa2\x01\n\x0c\x44\x61tasetGroup\x12\x1f\n\x02id\x18\x01 \x01(\x0b\x32\x0f.datasets.v1.IDR\x02id\x12,\n\tparent_id\x18\x02 \x01(\x0b\x32\x0f.datasets.v1.IDR\x08parentId\x12\x1b\n\tcode_name\x18\x03 \x01(\tR\x08\x63odeName\x12\x12\n\x04name\x18\x04 \x01(\tR\x04name\x12\x12\n\x04icon\x18\x05 \x01(\tR\x04icon*\x9b\x01\n\x11\x44\x61tasetPermission\x12\"\n\x1e\x44\x41TASET_PERMISSION_UNSPECIFIED\x10\x00\x12\"\n\x1e\x44\x41TASET_PERMISSION_ACCESS_DATA\x10\x01\x12!\n\x1d\x44\x41TASET_PERMISSION_WRITE_DATA\x10\x02\x12\x1b\n\x17\x44\x41TASET_PERMISSION_EDIT\x10\x03*v\n\nVisibility\x12\x1a\n\x16VISIBILITY_UNSPECIFIED\x10\x00\x12\x16\n\x12VISIBILITY_PRIVATE\x10\x01\x12\x1d\n\x19VISIBILITY_SHARED_WITH_ME\x10\x02\x12\x15\n\x11VISIBILITY_PUBLIC\x10\x03\x42\xab\x01\n\x0f\x63om.datasets.v1B\tCoreProtoP\x01Z@github.com/tilebox/tilebox-go/protogen/go/datasets/v1;datasetsv1\xa2\x02\x03\x44XX\xaa\x02\x0b\x44\x61tasets.V1\xca\x02\x0b\x44\x61tasets\\V1\xe2\x02\x17\x44\x61tasets\\V1\\GPBMetadata\xea\x02\x0c\x44\x61tasets::V1b\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) @@ -34,10 +34,10 @@ if not _descriptor._USE_C_DESCRIPTORS: _globals['DESCRIPTOR']._loaded_options = None _globals['DESCRIPTOR']._serialized_options = b'\n\017com.datasets.v1B\tCoreProtoP\001Z@github.com/tilebox/tilebox-go/protogen/go/datasets/v1;datasetsv1\242\002\003DXX\252\002\013Datasets.V1\312\002\013Datasets\\V1\342\002\027Datasets\\V1\\GPBMetadata\352\002\014Datasets::V1' - _globals['_DATASETPERMISSION']._serialized_start=2418 - _globals['_DATASETPERMISSION']._serialized_end=2573 - _globals['_VISIBILITY']._serialized_start=2575 - _globals['_VISIBILITY']._serialized_end=2693 + _globals['_DATASETPERMISSION']._serialized_start=2455 + _globals['_DATASETPERMISSION']._serialized_end=2610 + _globals['_VISIBILITY']._serialized_start=2612 + _globals['_VISIBILITY']._serialized_end=2730 _globals['_ID']._serialized_start=104 _globals['_ID']._serialized_end=128 _globals['_TIMEINTERVAL']._serialized_start=131 @@ -67,7 +67,7 @@ _globals['_COLLECTIONINFOS']._serialized_start=1775 _globals['_COLLECTIONINFOS']._serialized_end=1841 _globals['_DATASET']._serialized_start=1844 - _globals['_DATASET']._serialized_end=2250 - _globals['_DATASETGROUP']._serialized_start=2253 - _globals['_DATASETGROUP']._serialized_end=2415 + _globals['_DATASET']._serialized_end=2287 + _globals['_DATASETGROUP']._serialized_start=2290 + _globals['_DATASETGROUP']._serialized_end=2452 # @@protoc_insertion_point(module_scope) diff --git a/tilebox-datasets/tilebox/datasets/datasetsv1/core_pb2.pyi b/tilebox-datasets/tilebox/datasets/datasetsv1/core_pb2.pyi index 523e21b..c59fc50 100644 --- a/tilebox-datasets/tilebox/datasets/datasetsv1/core_pb2.pyi +++ b/tilebox-datasets/tilebox/datasets/datasetsv1/core_pb2.pyi @@ -155,7 +155,7 @@ class CollectionInfos(_message.Message): def __init__(self, data: _Optional[_Iterable[_Union[CollectionInfo, _Mapping]]] = ...) -> None: ... class Dataset(_message.Message): - __slots__ = ("id", "group_id", "type", "code_name", "name", "summary", "icon", "description", "permissions", "visibility", "slug") + __slots__ = ("id", "group_id", "type", "code_name", "name", "summary", "icon", "description", "permissions", "visibility", "slug", "type_editable") ID_FIELD_NUMBER: _ClassVar[int] GROUP_ID_FIELD_NUMBER: _ClassVar[int] TYPE_FIELD_NUMBER: _ClassVar[int] @@ -167,6 +167,7 @@ class Dataset(_message.Message): PERMISSIONS_FIELD_NUMBER: _ClassVar[int] VISIBILITY_FIELD_NUMBER: _ClassVar[int] SLUG_FIELD_NUMBER: _ClassVar[int] + TYPE_EDITABLE_FIELD_NUMBER: _ClassVar[int] id: ID group_id: ID type: _dataset_type_pb2.AnnotatedType @@ -178,7 +179,8 @@ class Dataset(_message.Message): permissions: _containers.RepeatedScalarFieldContainer[DatasetPermission] visibility: Visibility slug: str - def __init__(self, id: _Optional[_Union[ID, _Mapping]] = ..., group_id: _Optional[_Union[ID, _Mapping]] = ..., type: _Optional[_Union[_dataset_type_pb2.AnnotatedType, _Mapping]] = ..., code_name: _Optional[str] = ..., name: _Optional[str] = ..., summary: _Optional[str] = ..., icon: _Optional[str] = ..., description: _Optional[str] = ..., permissions: _Optional[_Iterable[_Union[DatasetPermission, str]]] = ..., visibility: _Optional[_Union[Visibility, str]] = ..., slug: _Optional[str] = ...) -> None: ... + type_editable: bool + def __init__(self, id: _Optional[_Union[ID, _Mapping]] = ..., group_id: _Optional[_Union[ID, _Mapping]] = ..., type: _Optional[_Union[_dataset_type_pb2.AnnotatedType, _Mapping]] = ..., code_name: _Optional[str] = ..., name: _Optional[str] = ..., summary: _Optional[str] = ..., icon: _Optional[str] = ..., description: _Optional[str] = ..., permissions: _Optional[_Iterable[_Union[DatasetPermission, str]]] = ..., visibility: _Optional[_Union[Visibility, str]] = ..., slug: _Optional[str] = ..., type_editable: bool = ...) -> None: ... class DatasetGroup(_message.Message): __slots__ = ("id", "parent_id", "code_name", "name", "icon") diff --git a/tilebox-datasets/tilebox/datasets/service.py b/tilebox-datasets/tilebox/datasets/service.py index 6ce5008..599269a 100644 --- a/tilebox-datasets/tilebox/datasets/service.py +++ b/tilebox-datasets/tilebox/datasets/service.py @@ -18,6 +18,7 @@ from tilebox.datasets.datasetsv1 import core_pb2 from tilebox.datasets.datasetsv1.collections_pb2 import ( CreateCollectionRequest, + DeleteCollectionByNameRequest, GetCollectionByNameRequest, ListCollectionsRequest, ) @@ -83,6 +84,16 @@ def create_collection(self, dataset_id: UUID, name: str) -> Promise[CollectionIn req = CreateCollectionRequest(dataset_id=uuid_to_uuid_message(dataset_id), name=name) return Promise.resolve(self._collection_service.CreateCollection(req)).then(CollectionInfo.from_message) + def delete_collection_by_name(self, dataset_id: UUID, name: str) -> Promise[None]: + """Delete a collection in a dataset by name. + + Args: + dataset_id: The id of the dataset to delete the collection from. + name: The name of the collection to delete. + """ + req = DeleteCollectionByNameRequest(dataset_id=uuid_to_uuid_message(dataset_id), collection_name=name) + return Promise.resolve(self._collection_service.DeleteCollectionByName(req)) + def get_collections( self, dataset_id: UUID, with_availability: bool = True, with_count: bool = False ) -> Promise[list[CollectionInfo]]: diff --git a/tilebox-datasets/tilebox/datasets/sync/dataset.py b/tilebox-datasets/tilebox/datasets/sync/dataset.py index e39979f..968c85f 100644 --- a/tilebox-datasets/tilebox/datasets/sync/dataset.py +++ b/tilebox-datasets/tilebox/datasets/sync/dataset.py @@ -124,6 +124,14 @@ def collection(self, name: str) -> "CollectionClient": return CollectionClient(self, info) + def delete_collection(self, name: str) -> None: + """Delete a collection by its name. + + Args: + name: The name of the collection to delete. + """ + self._service.delete_collection_by_name(self._dataset.id, name).get() + def __repr__(self) -> str: return f"{self.name} [Timeseries Dataset]: {self._dataset.summary}"