@@ -308,7 +308,12 @@ class DataClient {
308308 /// ```
309309 ///
310310 /// For more information, see [Data Client API] (https://docs.viam.com/dev/reference/apis/data-client/).
311- Future <List <Map <String , dynamic >>> tabularDataByMql (String organizationId, dynamic query, {bool useRecentData = false }) async {
311+ Future <List <Map <String , dynamic >>> tabularDataByMql (
312+ String organizationId,
313+ dynamic query, {
314+ bool useRecentData = false ,
315+ String ? queryPrefixName,
316+ }) async {
312317 List <Uint8List > binary;
313318 if (query is List <Map <String , dynamic >>) {
314319 binary = query.map ((q) => BsonCodec .serialize (q).byteList).toList ();
@@ -321,6 +326,9 @@ class DataClient {
321326 ..organizationId = organizationId
322327 ..mqlBinary.addAll (binary)
323328 ..useRecentData = useRecentData;
329+ if (queryPrefixName != null ) {
330+ request.queryPrefixName = queryPrefixName;
331+ }
324332 final response = await _dataClient.tabularDataByMQL (request);
325333 return response.rawData.map ((e) => BsonCodec .deserialize (BsonBinary .from (e))).toList ();
326334 }
@@ -1620,6 +1628,110 @@ class DataClient {
16201628 payload: response.payload.toMap (),
16211629 );
16221630 }
1631+
1632+ /// CreateIndex starts a custom index build
1633+ ///
1634+ /// ```
1635+ /// _viam = await Viam.withApiKey(
1636+ /// dotenv.env['API_KEY_ID'] ?? '',
1637+ /// dotenv.env['API_KEY'] ?? ''
1638+ /// );
1639+ /// final dataClient = _viam.dataClient;
1640+ ///
1641+ /// try {
1642+ /// // Create index
1643+ /// await this.createIndex(
1644+ /// "<YOUR-ORG-ID>",
1645+ /// IndexableCollection.INDEXABLE_COLLECTION_PIPELINE_SINK,
1646+ /// {
1647+ /// 'keys': {'field1': 1}
1648+ /// }
1649+ /// );
1650+ /// print('Successfully created index');
1651+ /// } catch (e) {
1652+ /// print('Error creating index: $e');
1653+ /// }
1654+ /// ```
1655+ ///
1656+ /// For more information, see [Data Client API] (https://docs.viam.com/dev/reference/apis/data-client/).
1657+ Future <void > createIndex (String organizationId, IndexableCollection collectionType, Map <String , dynamic > indexSpec,
1658+ {String ? pipelineName}) async {
1659+ final request = CreateIndexRequest ()
1660+ ..organizationId = organizationId
1661+ ..collectionType = collectionType
1662+ ..indexSpec.add (BsonCodec .serialize (indexSpec).byteList);
1663+ if (pipelineName != null ) {
1664+ request.pipelineName = pipelineName;
1665+ }
1666+ await _dataClient.createIndex (request);
1667+ }
1668+
1669+ /// ListIndexes returns all the indexes for a given collection.
1670+ ///
1671+ /// ```
1672+ /// _viam = await Viam.withApiKey(
1673+ /// dotenv.env['API_KEY_ID'] ?? '',
1674+ /// dotenv.env['API_KEY'] ?? ''
1675+ /// );
1676+ /// final dataClient = _viam.dataClient;
1677+ ///
1678+ /// try {
1679+ /// // List indexes
1680+ /// final indexes = await this.listIndexes(
1681+ /// "<YOUR-ORG-ID>",
1682+ /// IndexableCollection.INDEXABLE_COLLECTION_PIPELINE_SINK,
1683+ /// );
1684+ /// print('Successfully retrieved indexes: $indexes');
1685+ /// } catch (e) {
1686+ /// print('Error retrieving indexes: $e');
1687+ /// }
1688+ /// ```
1689+ ///
1690+ /// For more information, see [Data Client API] (https://docs.viam.com/dev/reference/apis/data-client/).
1691+ Future <List <Index >> listIndexes (String organizationId, IndexableCollection collectionType, {String ? pipelineName}) async {
1692+ final request = ListIndexesRequest ()
1693+ ..organizationId = organizationId
1694+ ..collectionType = collectionType;
1695+ if (pipelineName != null ) {
1696+ request.pipelineName = pipelineName;
1697+ }
1698+ final resp = await _dataClient.listIndexes (request);
1699+ return resp.indexes;
1700+ }
1701+
1702+ /// DeleteIndex drops the specified custom index from a collection.
1703+ ///
1704+ /// ```
1705+ /// _viam = await Viam.withApiKey(
1706+ /// dotenv.env['API_KEY_ID'] ?? '',
1707+ /// dotenv.env['API_KEY'] ?? ''
1708+ /// );
1709+ /// final dataClient = _viam.dataClient;
1710+ ///
1711+ /// try {
1712+ /// // Delete index
1713+ /// await this.deleteIndex(
1714+ /// "<YOUR-ORG-ID>",
1715+ /// IndexableCollection.INDEXABLE_COLLECTION_PIPELINE_SINK,
1716+ /// "<YOUR-INDEX-NAME>"
1717+ /// );
1718+ /// print('Successfully deleted index');
1719+ /// } catch (e) {
1720+ /// print('Error deleting index: $e');
1721+ /// }
1722+ /// ```
1723+ ///
1724+ /// For more information, see [Data Client API] (https://docs.viam.com/dev/reference/apis/data-client/).
1725+ Future <void > deleteIndex (String organizationId, IndexableCollection collectionType, String indexName, {String ? pipelineName}) async {
1726+ final request = DeleteIndexRequest ()
1727+ ..organizationId = organizationId
1728+ ..collectionType = collectionType
1729+ ..indexName = indexName;
1730+ if (pipelineName != null ) {
1731+ request.pipelineName = pipelineName;
1732+ }
1733+ await _dataClient.deleteIndex (request);
1734+ }
16231735}
16241736
16251737/// {@category App}
0 commit comments