Skip to content

Commit

Permalink
Merge pull request #221 from IOTechSystems/PS-579-branch
Browse files Browse the repository at this point in the history
PS-579 Add device update func with query parameter
  • Loading branch information
cloudxxx8 authored Dec 6, 2023
2 parents ac28bb1 + 95f6903 commit bac57c8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions clients/http/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ func (dc DeviceClient) Update(ctx context.Context, reqs []requests.UpdateDeviceR
return res, nil
}

func (dc DeviceClient) UpdateWithQueryParams(ctx context.Context, reqs []requests.UpdateDeviceRequest, queryParams map[string]string) (res []dtoCommon.BaseResponse, err errors.EdgeX) {
requestParams := url.Values{}
for k, v := range queryParams {
requestParams.Set(k, v)
}
err = utils.PatchRequest(ctx, &res, dc.baseUrl, common.ApiDeviceRoute, requestParams, reqs)
if err != nil {
return res, errors.NewCommonEdgeXWrapper(err)
}
return res, nil
}

func (dc DeviceClient) AllDevices(ctx context.Context, labels []string, offset int, limit int) (res responses.MultiDevicesResponse, err errors.EdgeX) {
requestParams := url.Values{}
if len(labels) > 0 {
Expand Down
2 changes: 2 additions & 0 deletions clients/interfaces/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type DeviceClient interface {
Add(ctx context.Context, reqs []requests.AddDeviceRequest) ([]common.BaseWithIdResponse, errors.EdgeX)
// Update updates devices.
Update(ctx context.Context, reqs []requests.UpdateDeviceRequest) ([]common.BaseResponse, errors.EdgeX)
// UpdateWithQueryParams updates devices with query parameters.
UpdateWithQueryParams(ctx context.Context, reqs []requests.UpdateDeviceRequest, queryParams map[string]string) ([]common.BaseResponse, errors.EdgeX)
// AllDevices returns all devices. Devices can also be filtered by labels.
// The result can be limited in a certain range by specifying the offset and limit parameters.
// offset: The number of items to skip before starting to collect the result set. Default is 0.
Expand Down
1 change: 1 addition & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ const (
KeyOnly = "keyOnly" //query string to specify if the response will only return the keys of the specified query key prefix, without values and metadata
Plaintext = "plaintext" //query string to specify if the response will return the stored plain text value of the key(s) without any encoding
Deregistered = "deregistered" //query string to specify if the response will return the registries of deregistered services
NoCallback = "nocallback" //query string to specify if the response will return the registries of deregistered services
)

// Constants related to the default value of query strings in the v2 service APIs
Expand Down

0 comments on commit bac57c8

Please sign in to comment.