我在一个工作空间下有1000多个处于关闭状态的项目。
我从 - https://rally1.rallydev.com/slm/webservice/1.29/subscription?fetch=Workspaces,Name,Projects,State
我们希望更新"家长"对于标记为"已关闭"。
的项目import sys
from pyral import Rally, rallyWorkset
options = [arg for arg in sys.argv[1:] if arg.startswith('--')]
args = [arg for arg in sys.argv[1:] if arg not in options]
server = <server>
apikey = <api_key>
workspace = <workspace>
project = <project_name>
rally = Rally(server,apikey=apikey, workspace=workspace, project=project)
rally.enableLogging('mypyral.log')
检查项目状态的方法 -
projects = rally.getProjects(workspace=workspace)
for proj in projects:
print (" %12.12s %s %s" % (proj.oid, proj.Name, proj.State))
我没有找到任何更新项目内容的引用 - Rest API post
方法 - http://pyral.readthedocs.io/en/latest/interface.html?highlight=post
答案 0 :(得分:1)
我会按以下方式进行:
#get object for 'New Parent':
target_project = rally.getProject('NewParentForClosedProjects')
projects = rally.getProjects(workspace = workspace) 对于项目中的项目:
#get children of project
children = proj.Children
for child in children:
#if project closed:
if child.State == 'Closed':
#Then update Parent to new one:
project_fields = {
"ObjectID": child.oid,
"Parent": target_project.ref
}
try:
result = rally.update('Project', project_fields)
print "Project %s has been successfully updated with new %s parent" % (str(child.Name), str(child.Parent))
except RallyRESTException, ex:
print "Update failure for Project %s" % (str(child.Name))
print ex