# Migration guide for Jobs-for-AWS-IoT-embedded-sdk version $\geq$ v2.0.0

With Jobs-for-AWS-IoT-embedded-sdk versions $\geq$ v2.0.0, there are some breaking changes that need to be addressed when upgrading.

## Breaking Changes

The signature of the `Jobs_UpdateMsg` API has been changed from
```c
size_t Jobs_UpdateMsg( JobCurrentStatus_t status,
                       const char * expectedVersion,
                       size_t expectedVersionLength,
                       char * buffer,
                       size_t bufferSize )
```
to
```c
size_t Jobs_UpdateMsg( JobsUpdateRequest_t request,
                       char * buffer,
                       size_t bufferSize );
```
A new structure `JobsUpdateRequest_t` has been introduced. This struct is now passed as a parameter to the API to include values like `status`, `expectedVersion` and `expectedVersionLength` which were earlier direct input to the API. All values in the struct except `status` are now optional. Following is the definition of the `JobsUpdateRequest_t` struct.
```c
typedef struct
{
    JobCurrentStatus_t status;    /**< Status to update the job to. */
    const char * expectedVersion; /**< Expected version, optional. */
    size_t expectedVersionLength; /**< Expected version length, optional. */
    const char * statusDetails;   /**< JSON key-value pair, optional. */
    size_t statusDetailsLength;   /**< JSON key-value pair length, optional. */
} JobsUpdateRequest_t;
```
### Old Code Snippet
```c
const char * expectedVersion = "2";
size_t expectedVersionLength = ( sizeof(expectedVersion ) - 1U );
JobCurrentStatus_t status = Succeeded;
char messageBuffer[ UPDATE_JOB_MSG_LENGTH ]  = {0};
size_t messageLength = 0U;

messageLength = Jobs_UpdateMsg( status,
                                expectedVersion,
                                expectedVersionLength,
                                messageBuffer,
                                UPDATE_JOB_MSG_LENGTH );

if (messageLength > 0 )
{
    // The message string of length, messageLength, has been
    // generated in the buffer, messageBuffer, for the UpdateJobExecution API
    // Publish this message to the topic generated by Jobs_Update using an
    // MQTT client of your choice.
}
 ```

### New Code Snippet
```c
const char * expectedVersion = "2";
const chat * statusDetails = "{\"key\":\"value\"}"; // This can be any user defined JSON key value pair
char messageBuffer[ UPDATE_JOB_MSG_LENGTH ]  = {0};
size_t messageLength = 0U;

JobsUpdateRequest_t request;
request.status = Succeeded;
request.expectedVersion = expectedVersion;
request.expectedVersionLength = ( sizeof( expectedVersion ) - 1U );
request.statusDetails = statusDetails;
request.statusDetailsLength = ( sizeof( statusDetails ) - 1U );

messageLength = Jobs_UpdateMsg( request
                                messageBuffer,
                                UPDATE_JOB_MSG_LENGTH );

if (messageBufferLength > 0 )
{
    // The message string of length, messageLength, has been
    // generated in the buffer, messageBuffer, for the UpdateJobExecution API
    // Publish this message to the topic generated by Jobs_Update using an
    // MQTT client of your choice.
 }
```
