Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def delete_project_iteration(path, organization=None, project=None, detect=None):
"""Delete iteration.
"""
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)
response = client.delete_classification_node(project=project,
structure_group=_STRUCTURE_GROUP_ITERATION,
path=path)
return response
def delete_project_area(path, organization=None, project=None, detect=None):
"""Delete area.
"""
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_AREA)
response = client.delete_classification_node(project=project,
structure_group=_STRUCTURE_GROUP_AREA,
path=path)
return response
def get_project_areas(depth=1, path=None, organization=None, project=None, detect=None):
"""List areas for a project.
:param depth: Depth of child nodes to be fetched. Example: --depth 3
:type depth: int
"""
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_AREA)
list_of_areas = client.get_classification_node(project=project,
structure_group=_STRUCTURE_GROUP_AREA,
depth=depth, path=path)
return list_of_areas
def get_project_iterations(depth=1, path=None, organization=None, project=None, detect=None):
"""List iterations for a project.
:param depth: Depth of child nodes to be fetched. Example: --depth 3.
:type depth: int
"""
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)
list_of_iterations = client.get_classification_node(project=project,
structure_group=_STRUCTURE_GROUP_ITERATION,
depth=depth, path=path)
return list_of_iterations
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
def update_project_area(path, name=None, child_id=None, organization=None, project=None, detect=None):
"""Update area.
: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)
path = resolve_classification_node_path(client, path, project, _STRUCTURE_GROUP_AREA)
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)
def create_project_iteration(name, path=None, start_date=None, finish_date=None,
organization=None, project=None, detect=None):
"""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,
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)
if path:
path = resolve_classification_node_path(client, path, project, _STRUCTURE_GROUP_AREA)
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