Skip to content

Commit

Permalink
This Branch can be merged now
Browse files Browse the repository at this point in the history
 - Using AdditionalFields instead of the "c8y_RelayArray" JSON Tag
 - Using the generic.JsonFromObject Method instead of the json.Marshal Method
  • Loading branch information
jrasko committed Oct 26, 2020
1 parent f71db6b commit 40af04e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions devicecontrol/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const (

type OperationCollection struct {
Self string `json:"self"`
Operations []Operation `json:"operations"`
Operations []Operation `json:"operations" jsonc:"collection"`
Statistics *generic.PagingStatistics `json:"statistics"`
Prev string `json:"prev"`
Next string `json:"next"`
Expand All @@ -30,7 +30,6 @@ type Operation struct {
Status string `json:"status"`
FailureReason string `json:"failureReason"`
Description string `json:"description"`
RelayArray []string `json:"c8y_RelayArray"`
Delivery struct {
Time time.Time `json:"time"`
Status string `json:"status"`
Expand Down
3 changes: 2 additions & 1 deletion inventory/inventoryApi.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ func (inventoryApi *inventoryApi) Update(managedObjectId string, managedObject *
if len(managedObjectId) == 0 {
return nil, generic.ClientError("Updating managedObject without an id is not allowed", "UpdateManagedObject")
}
bytes, err := json.Marshal(managedObject)

bytes, err := generic.JsonFromObject(managedObject)
if err != nil {
return nil, generic.ClientError(fmt.Sprintf("Error while marshalling the update managedObject: %s", err.Error()), "UpdateManagedObject")
}
Expand Down
8 changes: 3 additions & 5 deletions inventory/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ type NewManagedObject struct {
}

type ManagedObjectUpdate struct {
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
RelayArray []string `json:"c8y_RelayArray"`
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
AdditionalFields map[string]interface{} `jsonc:"flat"`
}

type (
Expand Down Expand Up @@ -50,8 +50,6 @@ type (

C8YSupportedOperations *[]string `json:"c8y_SupportedOperations,omitempty"`
AdditionalFields map[string]interface{} `jsonc:"flat"`

RelayArray []string `json:"c8y_RelayArray"`
}

AssetParents struct {
Expand Down

0 comments on commit 40af04e

Please sign in to comment.