For convenient reference in development, here are the Orcoursetrion API docs.
The actions that are available to use.
Action library access
orcoursetrion.actions.
create_export_repo
(course, term, description=None)¶Creates a studio based course repo at
ORC_GH_API_URL
with key
ORC_GH_OAUTH2_TOKEN
, at
organization ORC_STUDIO_ORG
,
and with collabarator
ORC_STUDIO_DEPLOY_TEAM
Raises: |
|
---|---|
Parameters: |
|
Returns: | Github dictionary of a repo (https://developer.github.com/v3/repos/#create) |
Return type: | dict |
orcoursetrion.actions.
rerun_studio
(course, term, new_term, description=None)¶Run any actions needed to re-run a Studio course.
This will remove the hooks from the specified term, and then create a new
export repo for the new_term
. It finds the repo based on
ORC_STUDIO_ORG
as the organization,
ORC_COURSE_PREFIX
as the prefix,
replacing all the dots in course
and appending “-term
”.
Parameters: |
|
---|---|
Raises: |
|
Returns: | Github dictionary of the newly created repo (https://developer.github.com/v3/repos/#create) |
Return type: | dict |
orcoursetrion.actions.
release_studio
(course, term)¶Moves a studio course to be ready for production.
Currently this will just add a hook to the production server, but it will eventually take care of everything else needed for a transfer as well.
Parameters: |
|
---|---|
Raises: |
|
Returns: | Nothing returned, raises on failure |
Return type: | None |
orcoursetrion.actions.
create_xml_repo
(course, term, team=None, members=None, description=None)¶Creates a course repo at
ORC_GH_API_URL
with key
ORC_GH_OAUTH2_TOKEN
and at
organization ORC_XML_ORG
, and
with team
as a collaborator (Along with
ORC_XML_DEPLOY_TEAM
).
If team
is not provided, then it will be generated with
ORC_COURSE_PREFIX
, course
,
and term
If members
is provided, the team
membership will be
replaced with the members listed. It will also create the team if
it doesn’t already exist regardless of the value of members
.
This also adds a github Web hook to the course development
environment gitreload
server via
ORC_STAGING_GITRELOAD
.
Raises: |
|
---|---|
Parameters: |
|
Returns: | Github dictionary of a repo (https://developer.github.com/v3/repos/#create) |
Return type: | dict |
orcoursetrion.actions.
rerun_xml
(course, term)¶Run any actions needed to re-run an XML course.
Currently this only deletes the Web hooks, but eventually it will
also copy the repo to a history clean one, and setup up that new
one with hooks. It finds the repo based on
ORC_XML_ORG
as the organization,
ORC_COURSE_PREFIX
as the prefix,
replacing all the dots in course
and appending “-term
”.
Parameters: |
|
---|---|
Raises: |
|
Returns: | Number of hooks removed |
Return type: | int |
orcoursetrion.actions.
release_xml
(course, term)¶Moves an XML course to be ready for production.
Currently this will just add a hook to the production server, but it will eventually take care of everything else needed for a transfer as well (i.e. making live branch, import it to lms...).
Parameters: |
|
---|---|
Raises: |
|
Returns: | Nothing returned, raises on failure |
Return type: | None |
orcoursetrion.actions.
put_team
(org, team, read_only, members)¶Create or update a team with the list of members
.
If members
is None, the team will be created if it doesn’t
exist, but membership will not be changed.
Parameters: |
|
---|---|
Raises: |
|
Returns: | Github team dictionary (https://developer.github.com/v3/orgs/teams/#response-1) |
Return type: | dict |
API libraries.
Orchestrion library
orcoursetrion.lib.
GitHub
(api_url, oauth2_token)¶Bases: object
API class for handling calls to github
Initialize a requests session for use with this class by specifying the base API endpoint and key.
Parameters: |
|
---|
add_repo_file
(org, repo, committer, message, path, contents)¶Adds the contents
provided to the path
in the repo
specified and committed by the commiter
parameters
provided.
https://developer.github.com/v3/repos/contents/#create-a-file
Note
This commits directly to the default branch of the repo.
Parameters: |
|
---|---|
Raises: |
|
Returns: | None |
add_team_repo
(org, repo, team)¶Add a repo to an existing team (by name) in the specified org.
We first look up the team to get its ID (https://developer.github.com/v3/orgs/teams/#list-teams), and then add the repo to that team (https://developer.github.com/v3/orgs/teams/#add-team-repo).
Parameters: |
|
---|---|
Raises: |
|
add_web_hook
(org, repo, url)¶Adds an active hook to a github repository.
This utilizes https://developer.github.com/v3/repos/hooks/#create-a-hook to create a form type Web hook that responds to push events (basically all the defaults).
Parameters: |
|
---|---|
Raises: |
|
Returns: | Github dictionary of a hook (https://developer.github.com/v3/repos/hooks/#response-2) |
Return type: | dict |
create_repo
(org, repo, description)¶Creates a new github repository or raises exceptions
Parameters: |
|
---|---|
Raises: |
|
Returns: | Github dictionary of a repo (https://developer.github.com/v3/repos/#create) |
Return type: | dict |
delete_web_hooks
(org, repo)¶Delete all the Web hooks for a repository
Uses https://developer.github.com/v3/repos/hooks/#list-hooks to get a list of all hooks, and then runs https://developer.github.com/v3/repos/hooks/#delete-a-hook to remove each of them. :param org: Organization to create the repo in. :type org: str :param repo: Name of the repo to remove hooks from. :type repo: str
Raises: |
|
---|---|
Returns: | Number of hooks removed |
Return type: | int |
put_team
(org, team_name, read_only, members)¶Create a team in a github organization.
Utilize
https://developer.github.com/v3/orgs/teams/#list-teams,
https://developer.github.com/v3/orgs/teams/#create-team,
https://developer.github.com/v3/orgs/teams/#list-team-members,
https://developer.github.com/v3/orgs/teams/#add-team-membership,
and
https://developer.github.com/v3/orgs/teams/#remove-team-membership.
to create a team and/or replace an existing team’s membership
with the members
list.
Parameters: |
|
---|---|
Raises: |
|
Returns: | The team dictionary (https://developer.github.com/v3/orgs/teams/#response-1) |
Return type: | dict |
shallow_copy_repo
(src_repo, dst_repo, committer, branch=None)¶Copies one branch repo’s contents to a new repo in the same organization without history.
Danger
This will overwrite the destination repo’s default branch and rewrite its history.
The basic workflow is:
.git
folderParameters: |
|
---|---|
Raises: |
|
Returns: | None |
orcoursetrion.lib.
GitHubException
¶Bases: exceptions.Exception
Base exception class others inherit.
orcoursetrion.lib.
GitHubRepoExists
¶Bases: orcoursetrion.lib.github.GitHubException
Repo exists, and thus cannot be created.
orcoursetrion.lib.
GitHubRepoDoesNotExist
¶Bases: orcoursetrion.lib.github.GitHubException
Repo does not exist, and therefore actions can’t be taken on it.
orcoursetrion.lib.
GitHubUnknownError
¶Bases: orcoursetrion.lib.github.GitHubException
Unexpected status code exception
orcoursetrion.lib.
GitHubNoTeamFound
¶Bases: orcoursetrion.lib.github.GitHubException
Name team not found in list
Configuration options
Configuration needed for Orchestrion to function (i.e. API keys)
config.
ORC_GH_OAUTH2_TOKEN
= GitHub OAUTH2 Token¶config.
ORC_GH_API_URL
= GitHub API URL¶config.
ORC_GH_NAME
= Git committer name to use.¶config.
ORC_GH_EMAIL
= Git committer e-mail to use¶config.
ORC_COURSE_PREFIX
= Prefix to use in repository name¶config.
ORC_STUDIO_ORG
= Organization to use for Studio export repos¶config.
ORC_STUDIO_DEPLOY_TEAM
= Deployment team for Studio Export repos¶config.
ORC_XML_ORG
= Organization to use for XML/latex2edx courses¶config.
ORC_XML_DEPLOY_TEAM
= Deployment team for XML/latex2edx courses¶config.
ORC_STAGING_GITRELOAD
= `gitreload <https://github.com/mitodl/gitreload>`_
server URL (including username and password) for the
course development LMS.¶config.
ORC_PRODUCTION_GITRELOAD
= `gitreload <https://github.com/mitodl/gitreload>`_
server URL (including username and password) for the
course production LMS.¶