def update_work_item()

in azure-devops/azext_devops/dev/boards/work_item.py [0:0]


def update_work_item(id, title=None, description=None, assigned_to=None, state=None, area=None,  # pylint: disable=redefined-builtin
                     iteration=None, reason=None, discussion=None, fields=None, open=False,  # pylint: disable=redefined-builtin
                     organization=None, detect=None):
    r"""Update work items.
    :param id: The id of the work item to update.
    :type id: int
    :param title: Title of the work item.
    :type title: str
    :param description: Description of the work item.
    :type description: str
    :param assigned_to: Name of the person the work item is assigned-to (e.g. fabrikam).
    :type assigned_to: str
    :param state: State of the work item (e.g. active).
    :type state: str
    :param area: Area the work item is assigned to (e.g. Demos).
    :type area: str
    :param iteration: Iteration path of the work item (e.g. Demos\Iteration 1).
    :type iteration: str
    :param reason: Reason for the state of the work item.
    :type reason: str
    :param discussion: Comment to add to a discussion in a work item.
    :type discussion: str
    :param fields: Space separated "field=value" pairs for custom fields you would like to set.
    Refer https://aka.ms/azure-devops-cli-field-api for more details on fields.
    :type fields: [str]
    :param open: Open the work item in the default web browser.
    :type open: bool
    :rtype: :class:`<WorkItem> <v5_0.work-item-tracking.models.WorkItem>`
    """
    organization = resolve_instance(detect=detect, organization=organization)
    patch_document = []
    if title is not None:
        patch_document.append(_create_work_item_field_patch_operation('add', 'System.Title', title))
    if description is not None:
        patch_document.append(_create_work_item_field_patch_operation('add', 'System.Description', description))
    if assigned_to is not None:
        assigned_to = assigned_to.strip()
        # 'assigned to' does not take an identity id.  Display name works.
        if assigned_to == '':
            resolved_assigned_to = ''
        else:
            resolved_assigned_to = _resolve_identity_as_unique_user_id(assigned_to, organization)
        if resolved_assigned_to is not None:
            patch_document.append(_create_work_item_field_patch_operation('add', 'System.AssignedTo',
                                                                          resolved_assigned_to))
    if state is not None:
        patch_document.append(_create_work_item_field_patch_operation('add', 'System.State', state))
    if area is not None:
        patch_document.append(_create_work_item_field_patch_operation('add', 'System.AreaPath', area))
    if iteration is not None:
        patch_document.append(_create_work_item_field_patch_operation('add', 'System.IterationPath', iteration))
    if reason is not None:
        patch_document.append(_create_work_item_field_patch_operation('add', 'System.Reason', reason))
    if discussion is not None:
        patch_document.append(_create_work_item_field_patch_operation('add', 'System.History', discussion))
    if fields is not None and fields:
        for field in fields:
            kvp = field.split('=', 1)
            if len(kvp) == 2:
                patch_document.append(_create_work_item_field_patch_operation('add', kvp[0], kvp[1]))
            else:
                raise ValueError('The --fields argument should consist of space separated "field=value" pairs.')
    client = get_work_item_tracking_client(organization)
    work_item = client.update_work_item(document=patch_document, id=id)
    if open:
        _open_work_item(work_item, organization)
    return work_item