<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_bundle(self, href=None, name=None, notify_url=None, version=None, external_id=None):
 """Update a bundle. Note that only the 'name' and 'notify_url' can be update. 'href' the relative href to the bundle. May not be None. 'name' the name of the bundle. May be None. 'notify_url' the URL for notifications on this bundle. 'version' the object version. May be None; if not None, must be an integer, and the version must match the version of the bundle. If not, a 409 conflict error will cause an APIException to be thrown. 'external_id' an arbitrary id (string) you can associate with this bundle. May be None. Returns a data structure equivalent to the JSON returned by the API. If the response status is not 2xx, throws an APIException. If the JSON to python data struct conversion fails, throws an APIDataException."""


        # Argument error checking.
        assert href is not None
        assert version is None or isinstance(version, int)

        # Prepare the data we're going to include in our bundle update.
        data = None

        fields = {}
        if name is not None:
            fields['name'] = name
        if notify_url is not None:
            fields['notify_url'] = notify_url
        if version is not None:
            fields['version'] = version
        if external_id is not None:
            fields['external_id'] = external_id

        if len(fields) > 0:
            data = fields

        raw_result = self.put(href, data)

        if raw_result.status < 200 or raw_result.status > 202:
            raise APIException(raw_result.status, raw_result.json)

        # Convert the JSON to a python data struct.

        return self._parse_json(raw_result.json)