# RPC update-properties

The update-properties RPC is used to update property values. If UniConfig Cloud Config is enabled, it also calls Refresh Bus Endpoint to update properties in runtime for all connected UniConfig instances.

The RPC only updates default properties, except for crypto properties for which there are separate RPCs (change-encryption-status and change-encryption-keys).

RPC sequence diagram with UniConfig Cloud Config enabled:

update-with-ucc
update-with-ucc

RPC sequence diagram with UniConfig Cloud Config disabled:

update-without-ucc
update-without-ucc

# RPC examples

# Successful example

RPC input contains the default properties with correct values.

RPC Request
curl --location --request POST 'http://localhost:8181/rests/operations/uniconfig-manager:update-properties' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
    "input": {
       "properties-map": [
            {
                "name": "netconf-default-parameters.session-timers.between-attempts-timeout",
                "value": "1500"
            },
            {
                "name": "gnmi-default-parameters.session-timers.internal-transaction-timeout",
                "value": "1000"
            },
            {
                "name": "notifications.kafka.transaction-notifications-enabled",
                "value": "false"
            }
       ]
    }
}'
RPC Response, Status: 200
{
  "output": {
    "update-properties-status": "There are 3 updated and 0 inserted properties successfully. Ignored keys: []"
  }
}

# Successful example

RPC input contains the crypto default property.

RPC Request
curl --location --request POST 'http://localhost:8181/rests/operations/uniconfig-manager:update-properties' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
    "input": {
       "properties-map": [
            {
                "name": "crypto.encrypt-enabled",
                "value": "true"
            },
            {
                "name": "crypto.actual-encryption-public-key",
                "value": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
            }
       ]
    }
}'
RPC Response, Status: 200
{
  "output": {
    "update-properties-status": "There are 0 updated and 0 inserted properties successfully. Ignored keys: [crypto.encrypt-enabled, crypto.actual-encryption-public-key]"
  }
}

# Successful example

RPC input contains an incorrect property name.

RPC Request
curl --location --request POST 'http://localhost:8181/rests/operations/uniconfig-manager:update-properties' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
    "input": {
       "properties-map": [
            {
                "name": "aaa",
                "value": "1000"
            }
       ]
    }
}'
RPC Response, Status: 200
{
  "output": {
    "update-properties-status": "There are 0 updated and 0 inserted properties successfully. Ignored keys: [aaa]"
  }
}

# Failed example

RPC input contains default properties with incorrect values.

RPC Request
curl --location --request POST 'http://localhost:8181/rests/operations/uniconfig-manager:update-properties' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
    "input": {
       "properties-map": [
            {
                "name": "netconf-default-parameters.session-timers.between-attempts-timeout",
                "value": "1500"
            },
            {
                "name": "gnmi-default-parameters.session-timers.internal-transaction-timeout",
                "value": "true"
            }
       ]
    }
}'
RPC Response, Status: 400
{
  "errors": {
    "error": [
      {
        "error-tag": "invalid-value",
        "error-info": "For input string: \"true\"",
        "error-message": "Integer property has invalid value true.",
        "error-type": "rpc"
      }
    ]
  }
}

# Failed example

RPC input contains default properties with incorrect values.

RPC Request
curl --location --request POST 'http://localhost:8181/rests/operations/uniconfig-manager:update-properties' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
    "input": {
       "properties-map": [
            {
                "name": "notifications.kafka.transaction-notifications-enabled",
                "value": "1000"
            }
       ]
    }
}'
RPC Response, Status: 400
{
  "errors": {
    "error": [
      {
        "error-tag": "invalid-value",
        "error-info": "The String did not match either specified value",
        "error-message": "Boolean property has invalid value 1000.",
        "error-type": "rpc"
      }
    ]
  }
}