Update virtual device mirrors
    • PDF

    Update virtual device mirrors

    • PDF

    Article Summary

    Summary

    Update virtual device mirror.
    A new virtual device mirror is created when none exists. When one already exists, it is modified.

    Request

    Request URL

    POST {CLOUD_IOT_CORE_API_URL}/devices/{deviceName}/mirror
    
    Content-Type: application/json; charset=utf-8
    x-ncp-apigw-timestamp: {Timestamp}
    x-ncp-iam-access-key: {Sub Account Access Key}
    x-ncp-apigw-signature-v2: {API Gateway Signature}
    

    Path Variables

    ItemRequirement statusTypeDescription
    deviceNameYesstringVirtual device name

    Request parameters

    Parameter nameRequirement statusTypeRestrictionsDescription
    nameNostringVirtual device mirror name (operate as default mirror when null)

    Request body

    Updates are only made for the keys specified in the state within the request body.
    Keys are deleted when you enter "null" for the key value.
    Use only one of the desired and reported properties for general requests.

    {
        "state" : {
            "desired" : "JSONObject",
            "reported" : "JSONObject"
        },
        "clientToken" : "string",
        "version" : "long"
    }
    
    ItemRequirement statusTypeDescriptionLimitations
    stateYesJSON ObjectState of the virtual device mirror
    state.desiredNoJSON ObjectState property and value requested to be updated for the virtual deviceAlthough the content of the JSON object is in free format, the sub-level JSON consists of up to six levels.
    state.reportedNoJSON ObjectState property and value reported by the virtual deviceAlthough the content of the JSON object is in free format, the sub-level JSON consists of up to six levels.
    clientTokenNostringWhen clientToken is included in the request, the clientToken gets displayed in the response as is.Up to 64 bytes
    versionNolongThe virtual device mirror is only updated when the version value of the request body and the current version value of the virtual device mirror match.

    Response

    Response body

    {
        "metadata": {
            "desired" : {
                "key" : {
                    "timstamp" : "long"
                }
            },
            "reported" : {
                "key" : {
                    "timstamp" : "long"
                }
            }
        },
        "state": {
            "desired": {
                "key": "value"
            },
            "reported": {
                "key": "value"
            }
        },
        "clientToken" : "string",
        "version": "long",
        "timestamp": "long"
    }
    
    ItemTypeDescription
    metadataJSON ObjectObject that expresses the time when the key was updated in desired and reported state
    metadata.desired.{keyName}.timestamptimestampTime when the key was updated in desired state
    metadata.reported.{keyName}.timestamplongTime when the key was updated in reported state
    stateJSON ObjectState of the request body
    state.desiredJSONObjectstate.desired of the request body
    state.reportedJSONObjectstate.reported of the request body
    clientTokenstringclientToken of the request body
    versionlongVersion of the virtual device mirror
    timestamplongTime when the virtual device mirror update response was created

    Example

    Request body

    {
        "state": {
            "desired": {
                "id": "abc1",
                "temperature": 33 ,
                "isOn": true
            }
        },
        "clientToken": "ABVS111",
        "version": 4
    }
    

    Response body

    {
        "metadata": {
            "desired": {
                "temperature": {
                    "timestamp": 1631097617
                },
                "isOn": {
                    "timestamp": 1631097617
                },
                "id": {
                    "timestamp": 1631097617
                }
            }
        },
        "clientToken": "ABVS111",
        "state": {
            "desired": {
                "temperature": 33,
                "isOn": true,
                "id": "abc1"
            },
            "reported": {
                "temperature": 35,
                "isOn": false,
                "id": "abc1"
            }
        },
        "version": 5,
        "timestamp": 1631097617
    }
    

    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.