UpdateOperationUtility Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.service.digitaltwin.UpdateOperationUtility

public class UpdateOperationUtility

A utility to create the JSON patch payload required for update operations such as update digital twin

Method Summary

Modifier and Type Method and Description
UpdateOperationUtility appendAddComponentOperation(String path, Map<String, Object> properties)

Include an add operation for a component.

UpdateOperationUtility appendAddPropertyOperation(String path, Object value)

Include an add operation for a property.

UpdateOperationUtility appendRemoveComponentOperation(String path)

Include a remove operation for a component.

UpdateOperationUtility appendRemovePropertyOperation(String path)

Include a remove operation for a property.

UpdateOperationUtility appendReplaceComponentOperation(String path, Map<String, Object> properties)

Include a replace operation for a component.

UpdateOperationUtility appendReplacePropertyOperation(String path, Object value)

Include a replace operation for a property.

List<Object> getUpdateOperations()

Gets the JSON patch payload required for update operations.

Method Details

appendAddComponentOperation

public UpdateOperationUtility appendAddComponentOperation(String path, Map properties)

Include an add operation for a component.

Parameters:

path - The path to the component to be added.
properties - A collection of properties and their values in the component.

Returns:

The UpdateOperationUtility object itself.
The component patch should be in the following format:

{

     "op": "add",

     "path": "/sampleComponentName",

     "value": {

        "samplePropertyName": 20,

        "$metadata": {}

        }

}

appendAddPropertyOperation

public UpdateOperationUtility appendAddPropertyOperation(String path, Object value)

Include an add operation for a property.

Parameters:

path - The path to the property to be added.
value - The value to update to.

Returns:

The UpdateOperationUtility object itself.
The root-level property patch should be in the following format:

{

     "op": "add",

     "path": "/samplePropertyName",

     "value": 20

}

The component-level property patch should be in the following format:

{

     "op": "add",

     "path": "/sampleComponentName/samplePropertyName",

     "value": 20

}

appendRemoveComponentOperation

public UpdateOperationUtility appendRemoveComponentOperation(String path)

Include a remove operation for a component.

Parameters:

path - The path to the component to be removed.

Returns:

The UpdateOperationUtility object itself.
The patch for removing a component should be in the following format:

{

     "op": "remove",

     "path": "/sampleComponentName",

}

appendRemovePropertyOperation

public UpdateOperationUtility appendRemovePropertyOperation(String path)

Include a remove operation for a property.

Parameters:

path - The path to the property to be added.

Returns:

The UpdateOperationUtility object itself.
The patch for removing a root-level property should be in the following format:

{

     "op": "remove",

     "path": "/samplePropertyName",

}

The patch for removing a component-level property should be in the following format:

{

     "op": "remove",

     "path": "/sampleComponentName/samplePropertyName",

}

appendReplaceComponentOperation

public UpdateOperationUtility appendReplaceComponentOperation(String path, Map properties)

Include a replace operation for a component.

Parameters:

path - The path to the component to be updated.
properties - A collection of properties and their values in the component.

Returns:

The UpdateOperationUtility object itself.
The component patch should be in the following format:

{

     "op": "replace",

     "path": "/sampleComponentName",

     "value": {

        "samplePropertyName": 20,

        "$metadata": {}

        }

}

appendReplacePropertyOperation

public UpdateOperationUtility appendReplacePropertyOperation(String path, Object value)

Include a replace operation for a property.

Parameters:

path - The path to the property to be updated.
value - The value to update to.

Returns:

The UpdateOperationUtility object itself.
The root-level property patch should be in the following format:

{

     "op": "replace",

     "path": "/samplePropertyName",

     "value": 20

}

The root-level property patch should be in the following format:

{

     "op": "replace",

     "path": "/sampleComponentName/samplePropertyName",

     "value": 20

}

getUpdateOperations

public List getUpdateOperations()

Gets the JSON patch payload required for update operations.

Returns:

The JSON patch payload required for update operations.

Applies to