diff --git a/app/data_client.go b/app/data_client.go index 6fc201aaf76..80162ca8857 100644 --- a/app/data_client.go +++ b/app/data_client.go @@ -235,8 +235,23 @@ type FileData struct { Data []byte } -// BinaryOptions represents optional parameters for the BinaryDataCaptureUpload method. -type BinaryOptions struct { +// DataByFilterOptions contains optional parameters for TabularDataByFilter and BinaryDataByFilter. +type DataByFilterOptions struct { + // No Filter implies all data. + Filter *Filter + // Limit is the maximum number of entries to include in a page. Limit defaults to 50 if unspecified. + Limit int + // Last indicates the object identifier of the Last-returned data. + // This is returned by calls to TabularDataByFilter and BinaryDataByFilter as the `Last` value. + // If provided, the server will return the next data entries after the last object identifier. + Last string + SortOrder Order + CountOnly bool + IncludeInternalData bool +} + +// BinaryDataCaptureUploadOptions represents optional parameters for the BinaryDataCaptureUpload method. +type BinaryDataCaptureUploadOptions struct { Type *DataType FileName *string MethodParameters map[string]interface{} @@ -244,8 +259,8 @@ type BinaryOptions struct { DataRequestTimes *[2]time.Time } -// TabularOptions represents optional parameters for the TabularDataCaptureUpload method. -type TabularOptions struct { +// TabularDataCaptureUploadOptions represents optional parameters for the TabularDataCaptureUpload method. +type TabularDataCaptureUploadOptions struct { Type *DataType FileName *string MethodParameters map[string]interface{} @@ -253,8 +268,8 @@ type TabularOptions struct { Tags []string } -// StreamingOptions represents optional parameters for the StreamingDataCaptureUpload method. -type StreamingOptions struct { +// StreamingDataCaptureUploadOptions represents optional parameters for the StreamingDataCaptureUpload method. +type StreamingDataCaptureUploadOptions struct { ComponentType *string ComponentName *string MethodName *string @@ -276,6 +291,17 @@ type FileUploadOptions struct { Tags []string } +// UpdateBoundingBoxOptions contains optional parameters for UpdateBoundingBox. +type UpdateBoundingBoxOptions struct { + Label *string + + // Normalized coordinates where all coordinates must be in the range [0, 1]. + XMinNormalized *float64 + YMinNormalized *float64 + XMaxNormalized *float64 + YMaxNormalized *float64 +} + // Dataset contains the information of a dataset. type Dataset struct { ID string @@ -320,22 +346,23 @@ func BsonToGo(rawData [][]byte) ([]map[string]interface{}, error) { } // TabularDataByFilter queries tabular data and metadata based on given filters. -func (d *DataClient) TabularDataByFilter( - ctx context.Context, - filter Filter, - limit int, - last string, - sortOrder Order, - countOnly bool, - includeInternalData bool, -) (TabularDataReturn, error) { +func (d *DataClient) TabularDataByFilter(ctx context.Context, opts *DataByFilterOptions) (TabularDataReturn, error) { + dataReq := pb.DataRequest{} + var countOnly, includeInternalData bool + if opts != nil { + dataReq.Filter = filterToProto(opts.Filter) + if opts.Limit != 0 { + dataReq.Limit = uint64(opts.Limit) + } + if opts.Last != "" { + dataReq.Last = opts.Last + } + dataReq.SortOrder = orderToProto(opts.SortOrder) + countOnly = opts.CountOnly + includeInternalData = opts.IncludeInternalData + } resp, err := d.dataClient.TabularDataByFilter(ctx, &pb.TabularDataByFilterRequest{ - DataRequest: &pb.DataRequest{ - Filter: filterToProto(filter), - Limit: uint64(limit), - Last: last, - SortOrder: orderToProto(sortOrder), - }, + DataRequest: &dataReq, CountOnly: countOnly, IncludeInternalData: includeInternalData, }) @@ -396,22 +423,24 @@ func (d *DataClient) TabularDataByMQL(ctx context.Context, organizationID string // BinaryDataByFilter queries binary data and metadata based on given filters. func (d *DataClient) BinaryDataByFilter( - ctx context.Context, - filter Filter, - limit int, - sortOrder Order, - last string, - includeBinary bool, - countOnly bool, - includeInternalData bool, + ctx context.Context, includeBinary bool, opts *DataByFilterOptions, ) (BinaryDataReturn, error) { + dataReq := pb.DataRequest{} + var countOnly, includeInternalData bool + if opts != nil { + dataReq.Filter = filterToProto(opts.Filter) + if opts.Limit != 0 { + dataReq.Limit = uint64(opts.Limit) + } + if opts.Last != "" { + dataReq.Last = opts.Last + } + dataReq.SortOrder = orderToProto(opts.SortOrder) + countOnly = opts.CountOnly + includeInternalData = opts.IncludeInternalData + } resp, err := d.dataClient.BinaryDataByFilter(ctx, &pb.BinaryDataByFilterRequest{ - DataRequest: &pb.DataRequest{ - Filter: filterToProto(filter), - Limit: uint64(limit), - Last: last, - SortOrder: orderToProto(sortOrder), - }, + DataRequest: &dataReq, IncludeBinary: includeBinary, CountOnly: countOnly, IncludeInternalData: includeInternalData, @@ -431,7 +460,7 @@ func (d *DataClient) BinaryDataByFilter( } // BinaryDataByIDs queries binary data and metadata based on given IDs. -func (d *DataClient) BinaryDataByIDs(ctx context.Context, binaryIDs []BinaryID) ([]BinaryData, error) { +func (d *DataClient) BinaryDataByIDs(ctx context.Context, binaryIDs []*BinaryID) ([]BinaryData, error) { resp, err := d.dataClient.BinaryDataByIDs(ctx, &pb.BinaryDataByIDsRequest{ IncludeBinary: true, BinaryIds: binaryIDsToProto(binaryIDs), @@ -459,9 +488,9 @@ func (d *DataClient) DeleteTabularData(ctx context.Context, organizationID strin return int(resp.DeletedCount), nil } -// DeleteBinaryDataByFilter deletes binary data based on given filters. +// DeleteBinaryDataByFilter deletes binary data based on given filters. If filter is empty, delete all data. // It returns the number of binary datapoints deleted. -func (d *DataClient) DeleteBinaryDataByFilter(ctx context.Context, filter Filter) (int, error) { +func (d *DataClient) DeleteBinaryDataByFilter(ctx context.Context, filter *Filter) (int, error) { resp, err := d.dataClient.DeleteBinaryDataByFilter(ctx, &pb.DeleteBinaryDataByFilterRequest{ Filter: filterToProto(filter), IncludeInternalData: true, @@ -474,7 +503,7 @@ func (d *DataClient) DeleteBinaryDataByFilter(ctx context.Context, filter Filter // DeleteBinaryDataByIDs deletes binary data based on given IDs. // It returns the number of binary datapoints deleted. -func (d *DataClient) DeleteBinaryDataByIDs(ctx context.Context, binaryIDs []BinaryID) (int, error) { +func (d *DataClient) DeleteBinaryDataByIDs(ctx context.Context, binaryIDs []*BinaryID) (int, error) { resp, err := d.dataClient.DeleteBinaryDataByIDs(ctx, &pb.DeleteBinaryDataByIDsRequest{ BinaryIds: binaryIDsToProto(binaryIDs), }) @@ -485,7 +514,7 @@ func (d *DataClient) DeleteBinaryDataByIDs(ctx context.Context, binaryIDs []Bina } // AddTagsToBinaryDataByIDs adds string tags, unless the tags are already present, to binary data based on given IDs. -func (d *DataClient) AddTagsToBinaryDataByIDs(ctx context.Context, tags []string, binaryIDs []BinaryID) error { +func (d *DataClient) AddTagsToBinaryDataByIDs(ctx context.Context, tags []string, binaryIDs []*BinaryID) error { _, err := d.dataClient.AddTagsToBinaryDataByIDs(ctx, &pb.AddTagsToBinaryDataByIDsRequest{ BinaryIds: binaryIDsToProto(binaryIDs), Tags: tags, @@ -494,7 +523,8 @@ func (d *DataClient) AddTagsToBinaryDataByIDs(ctx context.Context, tags []string } // AddTagsToBinaryDataByFilter adds string tags, unless the tags are already present, to binary data based on the given filter. -func (d *DataClient) AddTagsToBinaryDataByFilter(ctx context.Context, tags []string, filter Filter) error { +// If no filter is given, all data will be tagged. +func (d *DataClient) AddTagsToBinaryDataByFilter(ctx context.Context, tags []string, filter *Filter) error { _, err := d.dataClient.AddTagsToBinaryDataByFilter(ctx, &pb.AddTagsToBinaryDataByFilterRequest{ Filter: filterToProto(filter), Tags: tags, @@ -505,7 +535,7 @@ func (d *DataClient) AddTagsToBinaryDataByFilter(ctx context.Context, tags []str // RemoveTagsFromBinaryDataByIDs removes string tags from binary data based on given IDs. // It returns the number of binary files which had tags removed. func (d *DataClient) RemoveTagsFromBinaryDataByIDs(ctx context.Context, - tags []string, binaryIDs []BinaryID, + tags []string, binaryIDs []*BinaryID, ) (int, error) { resp, err := d.dataClient.RemoveTagsFromBinaryDataByIDs(ctx, &pb.RemoveTagsFromBinaryDataByIDsRequest{ BinaryIds: binaryIDsToProto(binaryIDs), @@ -518,9 +548,10 @@ func (d *DataClient) RemoveTagsFromBinaryDataByIDs(ctx context.Context, } // RemoveTagsFromBinaryDataByFilter removes the specified string tags from binary data that match the given filter. +// If no filter is given, all data will be untagged. // It returns the number of binary files from which tags were removed. func (d *DataClient) RemoveTagsFromBinaryDataByFilter(ctx context.Context, - tags []string, filter Filter, + tags []string, filter *Filter, ) (int, error) { resp, err := d.dataClient.RemoveTagsFromBinaryDataByFilter(ctx, &pb.RemoveTagsFromBinaryDataByFilterRequest{ Filter: filterToProto(filter), @@ -533,8 +564,8 @@ func (d *DataClient) RemoveTagsFromBinaryDataByFilter(ctx context.Context, } // TagsByFilter retrieves all unique tags associated with the data that match the specified filter. -// It returns the list of these unique tags. -func (d *DataClient) TagsByFilter(ctx context.Context, filter Filter) ([]string, error) { +// It returns the list of these unique tags. If no filter is given, all data tags are returned. +func (d *DataClient) TagsByFilter(ctx context.Context, filter *Filter) ([]string, error) { resp, err := d.dataClient.TagsByFilter(ctx, &pb.TagsByFilterRequest{ Filter: filterToProto(filter), }) @@ -549,7 +580,7 @@ func (d *DataClient) TagsByFilter(ctx context.Context, filter Filter) ([]string, // All normalized coordinates (xMin, yMin, xMax, yMax) must be float values in the range [0, 1]. func (d *DataClient) AddBoundingBoxToImageByID( ctx context.Context, - binaryID BinaryID, + binaryID *BinaryID, label string, xMinNormalized float64, yMinNormalized float64, @@ -574,7 +605,7 @@ func (d *DataClient) AddBoundingBoxToImageByID( func (d *DataClient) RemoveBoundingBoxFromImageByID( ctx context.Context, bboxID string, - binaryID BinaryID, + binaryID *BinaryID, ) error { _, err := d.dataClient.RemoveBoundingBoxFromImageByID(ctx, &pb.RemoveBoundingBoxFromImageByIDRequest{ BinaryId: binaryIDToProto(binaryID), @@ -584,8 +615,8 @@ func (d *DataClient) RemoveBoundingBoxFromImageByID( } // BoundingBoxLabelsByFilter retrieves all unique string labels for bounding boxes that match the specified filter. -// It returns a list of these labels. -func (d *DataClient) BoundingBoxLabelsByFilter(ctx context.Context, filter Filter) ([]string, error) { +// It returns a list of these labels. If no filter is given, all labels are returned. +func (d *DataClient) BoundingBoxLabelsByFilter(ctx context.Context, filter *Filter) ([]string, error) { resp, err := d.dataClient.BoundingBoxLabelsByFilter(ctx, &pb.BoundingBoxLabelsByFilterRequest{ Filter: filterToProto(filter), }) @@ -595,18 +626,18 @@ func (d *DataClient) BoundingBoxLabelsByFilter(ctx context.Context, filter Filte return resp.Labels, nil } -// UpdateBoundingBox updates the bounding box for a given bbox ID for the file represented by the binary ID, -// modifying its label and position using optional normalized coordinates (xMin, yMin, xMax, yMax), -// where all coordinates must be in the range [0, 1]. -func (d *DataClient) UpdateBoundingBox(ctx context.Context, - binaryID BinaryID, - bboxID string, - label *string, // optional - xMinNormalized *float64, // optional - yMinNormalized *float64, // optional - xMaxNormalized *float64, // optional - yMaxNormalized *float64, // optional -) error { +// UpdateBoundingBox updates the bounding box for a given bbox ID for the file represented by the binary ID. +func (d *DataClient) UpdateBoundingBox(ctx context.Context, binaryID *BinaryID, bboxID string, opts *UpdateBoundingBoxOptions) error { + var label *string + var xMinNormalized, yMinNormalized, xMaxNormalized, yMaxNormalized *float64 + if opts != nil { + label = opts.Label + xMinNormalized = opts.XMinNormalized + yMinNormalized = opts.YMinNormalized + xMaxNormalized = opts.XMaxNormalized + yMaxNormalized = opts.YMaxNormalized + } + _, err := d.dataClient.UpdateBoundingBox(ctx, &pb.UpdateBoundingBoxRequest{ BinaryId: binaryIDToProto(binaryID), BboxId: bboxID, @@ -652,7 +683,7 @@ func (d *DataClient) ConfigureDatabaseUser( // AddBinaryDataToDatasetByIDs adds the binary data with the given binary IDs to the dataset. func (d *DataClient) AddBinaryDataToDatasetByIDs( ctx context.Context, - binaryIDs []BinaryID, + binaryIDs []*BinaryID, datasetID string, ) error { _, err := d.dataClient.AddBinaryDataToDatasetByIDs(ctx, &pb.AddBinaryDataToDatasetByIDsRequest{ @@ -665,7 +696,7 @@ func (d *DataClient) AddBinaryDataToDatasetByIDs( // RemoveBinaryDataFromDatasetByIDs removes the binary data with the given binary IDs from the dataset. func (d *DataClient) RemoveBinaryDataFromDatasetByIDs( ctx context.Context, - binaryIDs []BinaryID, + binaryIDs []*BinaryID, datasetID string, ) error { _, err := d.dataClient.RemoveBinaryDataFromDatasetByIDs(ctx, &pb.RemoveBinaryDataFromDatasetByIDsRequest{ @@ -684,7 +715,7 @@ func (d *DataClient) BinaryDataCaptureUpload( componentName string, methodName string, fileExtension string, - options *BinaryOptions, + options *BinaryDataCaptureUploadOptions, ) (string, error) { var sensorMetadata SensorMetadata if options.DataRequestTimes != nil && len(options.DataRequestTimes) == 2 { @@ -732,7 +763,7 @@ func (d *DataClient) TabularDataCaptureUpload( componentName string, methodName string, dataRequestTimes [][2]time.Time, - options *TabularOptions, + options *TabularDataCaptureUploadOptions, ) (string, error) { if len(dataRequestTimes) != len(tabularData) { return "", errors.New("dataRequestTimes and tabularData lengths must be equal") @@ -802,7 +833,7 @@ func (d *DataClient) StreamingDataCaptureUpload( data []byte, partID string, fileExt string, - options *StreamingOptions, + options *StreamingDataCaptureUploadOptions, ) (string, error) { uploadMetadata := UploadMetadata{ PartID: partID, @@ -1158,7 +1189,10 @@ func tabularDataFromProto(proto *pb.TabularData, metadata *pb.CaptureMetadata) T } } -func binaryIDToProto(binaryID BinaryID) *pb.BinaryID { +func binaryIDToProto(binaryID *BinaryID) *pb.BinaryID { + if binaryID == nil { + return nil + } return &pb.BinaryID{ FileId: binaryID.FileID, OrganizationId: binaryID.OrganizationID, @@ -1166,7 +1200,7 @@ func binaryIDToProto(binaryID BinaryID) *pb.BinaryID { } } -func binaryIDsToProto(binaryIDs []BinaryID) []*pb.BinaryID { +func binaryIDsToProto(binaryIDs []*BinaryID) []*pb.BinaryID { var protoBinaryIDs []*pb.BinaryID for _, binaryID := range binaryIDs { protoBinaryIDs = append(protoBinaryIDs, binaryIDToProto(binaryID)) @@ -1174,7 +1208,10 @@ func binaryIDsToProto(binaryIDs []BinaryID) []*pb.BinaryID { return protoBinaryIDs } -func filterToProto(filter Filter) *pb.Filter { +func filterToProto(filter *Filter) *pb.Filter { + if filter == nil { + return nil + } return &pb.Filter{ ComponentName: filter.ComponentName, ComponentType: filter.ComponentType, diff --git a/app/data_client_test.go b/app/data_client_test.go index 260e5b88ed7..6d985b6dcd0 100644 --- a/app/data_client_test.go +++ b/app/data_client_test.go @@ -77,7 +77,8 @@ var ( OrganizationID: organizationID, LocationID: locationID, } - binaryIDs = []BinaryID{binaryID} + pbBinaryID = binaryIDToProto(&binaryID) + binaryIDs = []*BinaryID{&binaryID} binaryDataByte = []byte("BYTE") sqlQuery = "SELECT * FROM readings WHERE organization_id='e76d1b3b-0468-4efd-bb7f-fb1d2b352fcb' LIMIT 1" rawData = []map[string]interface{}{ @@ -182,7 +183,7 @@ func binaryMetadataToProto(binaryMetadata BinaryMetadata) *pb.BinaryMetadata { func dataRequestToProto(dataRequest DataRequest) *pb.DataRequest { return &pb.DataRequest{ - Filter: filterToProto(dataRequest.Filter), + Filter: filterToProto(&dataRequest.Filter), Limit: uint64(dataRequest.Limit), Last: dataRequest.Last, SortOrder: orderToProto(dataRequest.SortOrder), @@ -230,6 +231,7 @@ func TestDataClient(t *testing.T) { BboxLabels: bboxLabels, DatasetID: datasetID, } + pbFilter := filterToProto(&filter) binaryMetadata := BinaryMetadata{ ID: binaryMetaID, @@ -278,9 +280,9 @@ func TestDataClient(t *testing.T) { Metadata: []*pb.CaptureMetadata{captureMetadataToProto(tabularMetadata)}, }, nil } - resp, _ := client.TabularDataByFilter( - context.Background(), filter, limit, last, - dataRequest.SortOrder, countOnly, includeInternalData) + resp, _ := client.TabularDataByFilter(context.Background(), &DataByFilterOptions{ + &filter, limit, last, dataRequest.SortOrder, countOnly, includeInternalData, + }) test.That(t, resp.TabularData[0], test.ShouldResemble, tabularData) test.That(t, resp.Count, test.ShouldEqual, count) test.That(t, resp.Last, test.ShouldEqual, last) @@ -354,8 +356,9 @@ func TestDataClient(t *testing.T) { }, nil } resp, _ := client.BinaryDataByFilter( - context.Background(), filter, limit, dataRequest.SortOrder, - last, includeBinary, countOnly, includeInternalData) + context.Background(), includeBinary, &DataByFilterOptions{ + &filter, limit, last, dataRequest.SortOrder, countOnly, includeInternalData, + }) test.That(t, resp.BinaryData[0], test.ShouldResemble, binaryData) test.That(t, resp.Count, test.ShouldEqual, count) test.That(t, resp.Last, test.ShouldEqual, last) @@ -395,13 +398,13 @@ func TestDataClient(t *testing.T) { grpcClient.DeleteBinaryDataByFilterFunc = func(ctx context.Context, in *pb.DeleteBinaryDataByFilterRequest, opts ...grpc.CallOption, ) (*pb.DeleteBinaryDataByFilterResponse, error) { - test.That(t, in.Filter, test.ShouldResemble, filterToProto(filter)) + test.That(t, in.Filter, test.ShouldResemble, pbFilter) test.That(t, in.IncludeInternalData, test.ShouldBeTrue) return &pb.DeleteBinaryDataByFilterResponse{ DeletedCount: pbCount, }, nil } - resp, _ := client.DeleteBinaryDataByFilter(context.Background(), filter) + resp, _ := client.DeleteBinaryDataByFilter(context.Background(), &filter) test.That(t, resp, test.ShouldEqual, count) }) @@ -433,11 +436,11 @@ func TestDataClient(t *testing.T) { grpcClient.AddTagsToBinaryDataByFilterFunc = func(ctx context.Context, in *pb.AddTagsToBinaryDataByFilterRequest, opts ...grpc.CallOption, ) (*pb.AddTagsToBinaryDataByFilterResponse, error) { - test.That(t, in.Filter, test.ShouldResemble, filterToProto(filter)) + test.That(t, in.Filter, test.ShouldResemble, pbFilter) test.That(t, in.Tags, test.ShouldResemble, tags) return &pb.AddTagsToBinaryDataByFilterResponse{}, nil } - client.AddTagsToBinaryDataByFilter(context.Background(), tags, filter) + client.AddTagsToBinaryDataByFilter(context.Background(), tags, &filter) }) t.Run("RemoveTagsFromBinaryDataByIDs", func(t *testing.T) { @@ -458,13 +461,13 @@ func TestDataClient(t *testing.T) { grpcClient.RemoveTagsFromBinaryDataByFilterFunc = func(ctx context.Context, in *pb.RemoveTagsFromBinaryDataByFilterRequest, opts ...grpc.CallOption, ) (*pb.RemoveTagsFromBinaryDataByFilterResponse, error) { - test.That(t, in.Filter, test.ShouldResemble, filterToProto(filter)) + test.That(t, in.Filter, test.ShouldResemble, pbFilter) test.That(t, in.Tags, test.ShouldResemble, tags) return &pb.RemoveTagsFromBinaryDataByFilterResponse{ DeletedCount: pbCount, }, nil } - resp, _ := client.RemoveTagsFromBinaryDataByFilter(context.Background(), tags, filter) + resp, _ := client.RemoveTagsFromBinaryDataByFilter(context.Background(), tags, &filter) test.That(t, resp, test.ShouldEqual, count) }) @@ -472,12 +475,12 @@ func TestDataClient(t *testing.T) { grpcClient.TagsByFilterFunc = func(ctx context.Context, in *pb.TagsByFilterRequest, opts ...grpc.CallOption, ) (*pb.TagsByFilterResponse, error) { - test.That(t, in.Filter, test.ShouldResemble, filterToProto(filter)) + test.That(t, in.Filter, test.ShouldResemble, pbFilter) return &pb.TagsByFilterResponse{ Tags: tags, }, nil } - resp, _ := client.TagsByFilter(context.Background(), filter) + resp, _ := client.TagsByFilter(context.Background(), &filter) test.That(t, resp, test.ShouldResemble, tags) }) @@ -486,7 +489,7 @@ func TestDataClient(t *testing.T) { in *pb.AddBoundingBoxToImageByIDRequest, opts ...grpc.CallOption, ) (*pb.AddBoundingBoxToImageByIDResponse, error) { - test.That(t, in.BinaryId, test.ShouldResemble, binaryIDToProto(binaryID)) + test.That(t, in.BinaryId, test.ShouldResemble, pbBinaryID) test.That(t, in.Label, test.ShouldEqual, bboxLabel) test.That(t, in.XMinNormalized, test.ShouldEqual, annotations.Bboxes[0].XMinNormalized) test.That(t, in.YMinNormalized, test.ShouldEqual, annotations.Bboxes[0].YMinNormalized) @@ -498,7 +501,7 @@ func TestDataClient(t *testing.T) { }, nil } resp, _ := client.AddBoundingBoxToImageByID( - context.Background(), binaryID, bboxLabel, annotations.Bboxes[0].XMinNormalized, + context.Background(), &binaryID, bboxLabel, annotations.Bboxes[0].XMinNormalized, annotations.Bboxes[0].YMinNormalized, annotations.Bboxes[0].XMaxNormalized, annotations.Bboxes[0].YMaxNormalized) test.That(t, resp, test.ShouldResemble, annotations.Bboxes[0].ID) }) @@ -507,12 +510,12 @@ func TestDataClient(t *testing.T) { grpcClient.RemoveBoundingBoxFromImageByIDFunc = func(ctx context.Context, in *pb.RemoveBoundingBoxFromImageByIDRequest, opts ...grpc.CallOption, ) (*pb.RemoveBoundingBoxFromImageByIDResponse, error) { - test.That(t, in.BinaryId, test.ShouldResemble, binaryIDToProto(binaryID)) + test.That(t, in.BinaryId, test.ShouldResemble, pbBinaryID) test.That(t, in.BboxId, test.ShouldEqual, annotations.Bboxes[0].ID) return &pb.RemoveBoundingBoxFromImageByIDResponse{}, nil } - client.RemoveBoundingBoxFromImageByID(context.Background(), annotations.Bboxes[0].ID, binaryID) + client.RemoveBoundingBoxFromImageByID(context.Background(), annotations.Bboxes[0].ID, &binaryID) }) t.Run("BoundingBoxLabelsByFilter", func(t *testing.T) { @@ -527,12 +530,12 @@ func TestDataClient(t *testing.T) { grpcClient.BoundingBoxLabelsByFilterFunc = func(ctx context.Context, in *pb.BoundingBoxLabelsByFilterRequest, opts ...grpc.CallOption, ) (*pb.BoundingBoxLabelsByFilterResponse, error) { - test.That(t, in.Filter, test.ShouldResemble, filterToProto(filter)) + test.That(t, in.Filter, test.ShouldResemble, pbFilter) return &pb.BoundingBoxLabelsByFilterResponse{ Labels: expectedBBoxLabelsPb, }, nil } - resp, _ := client.BoundingBoxLabelsByFilter(context.Background(), filter) + resp, _ := client.BoundingBoxLabelsByFilter(context.Background(), &filter) test.That(t, resp, test.ShouldResemble, expectedBBoxLabels) }) t.Run("UpdateBoundingBox", func(t *testing.T) { @@ -540,7 +543,7 @@ func TestDataClient(t *testing.T) { grpcClient.UpdateBoundingBoxFunc = func(ctx context.Context, in *pb.UpdateBoundingBoxRequest, opts ...grpc.CallOption, ) (*pb.UpdateBoundingBoxResponse, error) { - test.That(t, in.BinaryId, test.ShouldResemble, binaryIDToProto(binaryID)) + test.That(t, in.BinaryId, test.ShouldResemble, pbBinaryID) test.That(t, in.BboxId, test.ShouldResemble, annotationsPb.Bboxes[0].Id) test.That(t, *in.Label, test.ShouldEqual, annotationsPb.Bboxes[0].Label) test.That(t, *in.XMinNormalized, test.ShouldEqual, annotationsPb.Bboxes[0].XMinNormalized) @@ -549,9 +552,13 @@ func TestDataClient(t *testing.T) { test.That(t, *in.YMaxNormalized, test.ShouldEqual, annotationsPb.Bboxes[0].YMaxNormalized) return &pb.UpdateBoundingBoxResponse{}, nil } - client.UpdateBoundingBox(context.Background(), binaryID, annotations.Bboxes[0].ID, &annotationsPb.Bboxes[0].Label, - &annotationsPb.Bboxes[0].XMinNormalized, &annotationsPb.Bboxes[0].YMinNormalized, - &annotationsPb.Bboxes[0].XMaxNormalized, &annotationsPb.Bboxes[0].YMaxNormalized) + client.UpdateBoundingBox(context.Background(), &binaryID, annotations.Bboxes[0].ID, &UpdateBoundingBoxOptions{ + &annotationsPb.Bboxes[0].Label, + &annotationsPb.Bboxes[0].XMinNormalized, + &annotationsPb.Bboxes[0].YMinNormalized, + &annotationsPb.Bboxes[0].XMaxNormalized, + &annotationsPb.Bboxes[0].YMaxNormalized, + }) }) t.Run("GetDatabaseConnection", func(t *testing.T) { @@ -623,7 +630,7 @@ func TestDataSyncClient(t *testing.T) { t.Run("BinaryDataCaptureUpload", func(t *testing.T) { uploadMetadata.Type = DataTypeBinarySensor - options := BinaryOptions{ + options := BinaryDataCaptureUploadOptions{ Type: &binaryDataType, FileName: &fileName, MethodParameters: methodParameters, @@ -669,7 +676,7 @@ func TestDataSyncClient(t *testing.T) { TimeRequested: timestamppb.New(start), TimeReceived: timestamppb.New(end), } - options := TabularOptions{ + options := TabularDataCaptureUploadOptions{ Type: &binaryDataType, FileName: &fileName, MethodParameters: methodParameters, @@ -711,7 +718,7 @@ func TestDataSyncClient(t *testing.T) { }) t.Run("StreamingDataCaptureUpload", func(t *testing.T) { - options := StreamingOptions{ + options := StreamingDataCaptureUploadOptions{ ComponentType: &componentType, ComponentName: &componentName, MethodName: &method,