用法

用法

在项目中如何使用 python-storyboardclient

from storyboardclient.v1 import client
api_url="https://storyboard-dev.openstack.org/api/v1"
access_token="$MY_ACCESS_TOKEN"
storyboard = client.Client(api_url, access_token)

访问令牌是可选的,但创建内容、更新内容或检索私有信息时是必需的。 非常重要的是使用 https,而不是 http,否则您会遇到各种奇怪的错误!

对于使用自签名证书(包括 storyboard-dev)访问实例,‘verify’ 设置是必要的。 因此,对于此类实例,您需要调整上面的示例以包含

verify = False
storyboard = client.Client(api_url, access_token, verify)

一些获取信息的示例命令

get_stories = storyboard.stories.get_all()
get_comments_on_one_story = storyboard.stories.get(1).comments.list()
get_tags_on_one_story = storyboard.stories.get(1).tags()
get_all_story_timeline_events = storyboard.stories.get(1).events.get_all()
get_worklists = storyboard.worklists.get_all()
get_worklists_in_board = storyboard.worklists.board_id.get(2)
get_due_dates = storyboard.due_dates.get_all()
get_due_dates_for_board = storyboard.due_dates.get_all(board_id=2)
get_users_in_team = storyboard.teams.get(1).users.get_all()
get_subscriptions = storyboard.subscriptions.get_all()
get_preferences_for_one_user = storyboard.users.get(1).user_preferences.get_all()
get_subscription_events = storyboard.subscription_events.get_all()
get_tokens_for_one_user = storyboard.users.get(1).user_tokens.list()
get_milestones = storyboard.milestones.get_all()
get_branches = storyboard.branches.get_all()
get_system_info = storyboard.system_info.get(None)

一些创建信息的示例命令

create_story = storyboard.stories.create(title="brand new invalid story with no tasks")
create_task = storyboard.tasks.create(title="new task with default settings", project_id=2, story_id=3)
create_branch = storyboard.branches.create(project_id=21, name='newbranch')
create_worklist = storyboard.worklists.create(title='new worklist', automatic=False)
create_board = storyboard.boards.create(title="new board", lanes='')

一些更新信息的示例命令

update_branch_title = storyboard.branches.update(id=21, name='new name')
update_worklist = storyboard.worklists.update(id=296, automatic=True)
update_board = storyboard.boards.update(id=3, title="new title")
注意:目前没有像
api/v1/permissions 形式的权限的单个端点。 有一些特定于某些资源的端点,例如:api/v1/worklists/1/permissions。 Python 客户端目前尚不支持这些(欢迎补丁!)

其他示例脚本片段

get_stories = storyboard.stories.get_all()
for story in get_stories:
    if "blah" in story.description:
    print story

for i in range (981277, 2000690):
    try:
        story = storyboard.stories.get(i)
        print story
    except Exception as e:
        print e

更长的示例脚本

from storyboardclient.v1 import client

storyboard = client.Client(api_url="https://storyboard-dev.openstack.org/api/v1", access_token="$MY_ACCESS_TOKEN")

stories = storyboard.stories.get_all()

for story in stories:
    try:
        if 'Cannot store contact information' in story.description and 'Friendlybot' not in story.description:
            story.comments.create(content="This needs your gerrit preferred e-mail address to match a primary e-mail address for a foundation individual member account.\n \n If you already followed the instructions at https://docs.openstack.org/infra/manual/developers.html#account-setup - in the specified order! - and still get that, see https://ask.openstack.org/question/56720 for additional troubleshooting tips.")
            storyboard.stories.update(id=story.id, description=story.description + '\n \n Friendlybot was here!')
    except:
        pass

TODO

需要填充关于更新看板和工作列表项目的章节。 需要添加看板和工作列表的时间线事件。

Creative Commons Attribution 3.0 License

除非另有说明,本文档根据 知识共享署名 3.0 许可协议 授权。请参阅所有 OpenStack 法律文件