src/agent/adu_core_interface/src/agent_workflow.c
_Bool ADUC_ContentData_Update(ADUC_ContentData* contentData, const JSON_Value* updateActionJson, _Bool requiredAllData)
{
    _Bool succeeded = false;

    unsigned int desiredAction;

    if (!ADUC_Json_GetUpdateAction(updateActionJson, &desiredAction))
    {
        Log_Error("Missing Action property.");
        goto done;
    }

    // Cancel actions don't contain any ContentData related fields.
    if (desiredAction == ADUCITF_UpdateAction_Cancel)
    {
        succeeded = true;
        goto done;
    }

    ADUC_UpdateId* expectedUpdateId = NULL;
    if (ADUC_Json_GetUpdateId(updateActionJson, &expectedUpdateId))
    {
        ADUC_UpdateId_Free(contentData->ExpectedUpdateId);
        contentData->ExpectedUpdateId = expectedUpdateId;
    }
    else if (requiredAllData)
    {
        Log_Error("Missing UpdateId property.");
        goto done;
    }

    char* installedCriteria = NULL;
    if (ADUC_Json_GetInstalledCriteria(updateActionJson, &installedCriteria))
    {
        free(contentData->InstalledCriteria);
        contentData->InstalledCriteria = installedCriteria;
    }
    else if (requiredAllData)
    {
        Log_Error("Missing installedCriteria property.");
        goto done;
    }

    char* updateType = NULL;
    if (ADUC_Json_GetUpdateType(updateActionJson, &updateType))
    {
        free(contentData->UpdateType);
        contentData->UpdateType = updateType;
    }
    else if (requiredAllData)
    {
        Log_Error("Missing UpdateType property.");
        goto done;
    }

    succeeded = true;

done:
    return succeeded;
}
/**
 * @brief Updates the provided ADUC_ContentData object with values from the provided JSON.
 *
 * @param[in,out] contentData The ADUC_ContentData object to update.
 * @param[in] updateActionJson The JSON to use to update the ADUC_ContentData.
 * @param[in,opt] requiredAllData The boolean indicates whether all data are required. Default is 'false'.
 * @return _Boolean A boolean indicates whether the content is updated successfully.
 */
@brief Updates the provided ADUC_ContentData object with values from the provided JSON.
@param[in,out] contentData The ADUC_ContentData object to update.
@param[in] updateActionJson The JSON to use to update the ADUC_ContentData.
@param[in,opt] requiredAllData The boolean indicates whether all data are required. Default is 'false'.
@return _Boolean A boolean indicates whether the content is updated successfully.
@brief Updates the provided ADUC_ContentData object with values from the provided JSON . @param [ in out ] contentData The ADUC_ContentData object to update . @param [ in ] updateActionJson The JSON to use to update the ADUC_ContentData . @param [ in opt ] requiredAllData The boolean indicates whether all data are required . Default is ' false ' . @return _Boolean A boolean indicates whether the content is updated successfully .
_Bool ADUC_ContentData_Update(ADUC_ContentData* contentData, const JSON_Value* updateActionJson, _Bool requiredAllData)
{
    _Bool succeeded = false;
    unsigned int desiredAction;
    if (!ADUC_Json_GetUpdateAction(updateActionJson, &desiredAction))
    {
        Log_Error("Missing Action property.");
        goto done;
    }
    if (desiredAction == ADUCITF_UpdateAction_Cancel)
    {
        succeeded = true;
        goto done;
    }
    ADUC_UpdateId* expectedUpdateId = NULL;
    if (ADUC_Json_GetUpdateId(updateActionJson, &expectedUpdateId))
    {
        ADUC_UpdateId_Free(contentData->ExpectedUpdateId);
        contentData->ExpectedUpdateId = expectedUpdateId;
    }
    else if (requiredAllData)
    {
        Log_Error("Missing UpdateId property.");
        goto done;
    }
    char* installedCriteria = NULL;
    if (ADUC_Json_GetInstalledCriteria(updateActionJson, &installedCriteria))
    {
        free(contentData->InstalledCriteria);
        contentData->InstalledCriteria = installedCriteria;
    }
    else if (requiredAllData)
    {
        Log_Error("Missing installedCriteria property.");
        goto done;
    }
    char* updateType = NULL;
    if (ADUC_Json_GetUpdateType(updateActionJson, &updateType))
    {
        free(contentData->UpdateType);
        contentData->UpdateType = updateType;
    }
    else if (requiredAllData)
    {
        Log_Error("Missing UpdateType property.");
        goto done;
    }
    succeeded = true;
done:
    return succeeded;
}
_Bool ADUC_ContentData_Update ( ADUC_ContentData * contentData , const JSON_Value * updateActionJson , _Bool requiredAllData ) { _Bool succeeded = false ; unsigned int desiredAction ; if ( ! ADUC_Json_GetUpdateAction ( updateActionJson , & desiredAction ) ) { Log_Error ( " " ) ; goto done ; } if ( desiredAction == ADUCITF_UpdateAction_Cancel ) { succeeded = true ; goto done ; } ADUC_UpdateId * expectedUpdateId = NULL ; if ( ADUC_Json_GetUpdateId ( updateActionJson , & expectedUpdateId ) ) { ADUC_UpdateId_Free ( contentData -> ExpectedUpdateId ) ; contentData -> ExpectedUpdateId = expectedUpdateId ; } else if ( requiredAllData ) { Log_Error ( " " ) ; goto done ; } char * installedCriteria = NULL ; if ( ADUC_Json_GetInstalledCriteria ( updateActionJson , & installedCriteria ) ) { free ( contentData -> InstalledCriteria ) ; contentData -> InstalledCriteria = installedCriteria ; } else if ( requiredAllData ) { Log_Error ( " " ) ; goto done ; } char * updateType = NULL ; if ( ADUC_Json_GetUpdateType ( updateActionJson , & updateType ) ) { free ( contentData -> UpdateType ) ; contentData -> UpdateType = updateType ; } else if ( requiredAllData ) { Log_Error ( " " ) ; goto done ; } succeeded = true ; done : return succeeded ; }
@brief Updates the provided ADUC_ContentData object with values from the provided JSON.
@brief Updates the provided ADUC_ContentData object with values from the provided JSON .
// Cancel actions don't contain any ContentData related fields.