Ejemplo n.º 1
0
def update_project_area(path=None,
                        name=None,
                        child_id=None,
                        organization=None,
                        project=None,
                        detect=None):
    """Move area or update area name.
    :param name: New name of the area.
    :type: str
    :param child_id: Move an existing area and add as child node for this area.
    :type: int
    """
    if name is None and child_id is None:
        raise CLIError('Either --name or --child-id should be provided.')
    organization, project = resolve_instance_and_project(
        detect=detect, organization=organization, project=project)
    client = get_work_item_tracking_client(organization)
    if child_id:
        move_classification_node_object = WorkItemClassificationNode()
        move_classification_node_object.id = child_id
        response = client.create_or_update_classification_node(
            project=project,
            posted_node=move_classification_node_object,
            structure_group=_STRUCTURE_GROUP_AREA,
            path=path)
    classification_node_object = client.get_classification_node(
        project=project, structure_group=_STRUCTURE_GROUP_AREA, path=path)
    if name is not None:
        classification_node_object.name = name
        response = client.update_classification_node(
            project=project,
            posted_node=classification_node_object,
            structure_group=_STRUCTURE_GROUP_AREA,
            path=path)
    return response
def update_project_iteration(path,
                             child_id=None,
                             name=None,
                             start_date=None,
                             finish_date=None,
                             organization=None,
                             project=None,
                             detect=None):
    """Update project iteration.
    :param name: New name of the iteration.
    :type: str
    :param child_id: Move an existing iteration and add as child node for this iteration.
    :type: int
    """
    if start_date is None and finish_date is None and name is None and child_id is None:
        raise CLIError(
            'At least one of --start-date , --finish-date , --child-id or --name arguments is required.'
        )
    organization, project = resolve_instance_and_project(
        detect=detect, organization=organization, project=project)
    client = get_work_item_tracking_client(organization)
    path = resolve_classification_node_path(client, path, project,
                                            _STRUCTURE_GROUP_ITERATION)
    if child_id:
        move_classification_node_object = WorkItemClassificationNode()
        move_classification_node_object.id = child_id
        update_iteration = client.create_or_update_classification_node(
            project=project,
            posted_node=move_classification_node_object,
            structure_group=_STRUCTURE_GROUP_ITERATION,
            path=path)
    classification_node_object = client.get_classification_node(
        project=project, structure_group=_STRUCTURE_GROUP_ITERATION, path=path)
    if classification_node_object.attributes is None and \
       ((start_date and not finish_date) or (not start_date and finish_date)):
        raise CLIError(
            'You must specify both start and finish dates or neither date')
    if classification_node_object.attributes is None:
        attributes_obj = {}
        classification_node_object.attributes = attributes_obj
    if start_date:
        start_date = convert_date_only_string_to_iso8601(value=start_date,
                                                         argument='start_date')
        classification_node_object.attributes['startDate'] = start_date
    if finish_date:
        finish_date = convert_date_only_string_to_iso8601(
            value=finish_date, argument='finish_date')
        classification_node_object.attributes['finishDate'] = finish_date
    if name is not None:
        classification_node_object.name = name
    update_iteration = client.update_classification_node(
        project=project,
        posted_node=classification_node_object,
        structure_group=_STRUCTURE_GROUP_ITERATION,
        path=path)
    return update_iteration
Ejemplo n.º 3
0
def get_root_nodes_response():
    root_nodes_list = []
    classification_node1 = WorkItemClassificationNode()
    classification_node1.structure_type = 'area'
    classification_node1.name = TEST_PROJECT_NAME
    classification_node1.additional_properties[
        'path'] = PATH_SEPARATOR + TEST_PROJECT_NAME + PATH_SEPARATOR + 'Area'
    root_nodes_list.append(classification_node1)
    classification_node2 = WorkItemClassificationNode()
    classification_node2.structure_type = 'iteration'
    classification_node2.name = TEST_PROJECT_NAME
    classification_node2.additional_properties[
        'path'] = PATH_SEPARATOR + TEST_PROJECT_NAME + PATH_SEPARATOR + 'Iteration'
    root_nodes_list.append(classification_node2)
    return root_nodes_list
Ejemplo n.º 4
0
def create_project_area(name,
                        path=None,
                        organization=None,
                        project=None,
                        detect=None):
    """Create area.
    :param name: Name of the area.
    :type: str
    """
    organization, project = resolve_instance_and_project(
        detect=detect, organization=organization, project=project)
    client = get_work_item_tracking_client(organization)
    classification_node_object = WorkItemClassificationNode()
    classification_node_object.name = name
    response = client.create_or_update_classification_node(
        project=project,
        posted_node=classification_node_object,
        structure_group=_STRUCTURE_GROUP_AREA,
        path=path)
    return response
Ejemplo n.º 5
0
def create_project_iteration(name, path=None, start_date=None, finish_date=None,
                             organization=None, project=None, detect=None):
    """(PREVIEW) Create iteration.
    :param name: Name of the iteration.
    :type: str
    """
    if start_date is None and finish_date is None and name is None:
        raise CLIError('At least one of --start-date , --finish-date or --name arguments is required.')
    organization, project = resolve_instance_and_project(detect=detect,
                                                         organization=organization,
                                                         project=project)
    client = get_work_item_tracking_client(organization)
    if path:
        path = resolve_classification_node_path(client, path, project, _STRUCTURE_GROUP_ITERATION)
    classification_node_object = WorkItemClassificationNode()
    if ((start_date and not finish_date) or (not start_date and finish_date)):
        raise CLIError('You must specify both start and finish dates or neither date')
    if classification_node_object.attributes is None:
        attributes_obj = {}
        classification_node_object.attributes = attributes_obj
        if start_date:
            start_date = convert_date_only_string_to_iso8601(value=start_date, argument='start_date')
            classification_node_object.attributes['startDate'] = start_date
        if finish_date:
            finish_date = convert_date_only_string_to_iso8601(value=finish_date, argument='finish_date')
            classification_node_object.attributes['finishDate'] = finish_date
    if name is not None:
        classification_node_object.name = name
    response = client.create_or_update_classification_node(project=project,
                                                           posted_node=classification_node_object,
                                                           structure_group=_STRUCTURE_GROUP_ITERATION,
                                                           path=path)
    return response