compliance.utils.services package¶
Submodules¶
compliance.utils.services.github module¶
Compliance Github service helper.
- class compliance.utils.services.github.Github(config=None, base_url='https://github.com')[source]¶
Bases:
object
Github service helper class.
- add_issue(owner, repo, title, body='', annotation=None, **kwargs)[source]¶
Create a repository issue.
- add_issue_comment(owner, repo, issue, body, annotation=None)[source]¶
Create a comment for a repository issue.
- apply_labels(repo, issue, *labels)[source]¶
Add label(s) to an issue.
repo looks like: my-gh-org/my-gh-repo issue is an issue number (not id) API takes a json list of labels POST /repos/:owner/:repo/issues/:number/labels
- creates_for_project(url, data, org=False)[source]¶
Create a repository project based on a properly formed url.
- extract_owner_repo_issue(url)[source]¶
Retrieve the owner (org), repo and issue number from the url.
- get_all_projects(repo_path)[source]¶
Retrieve all GH repo projects.
repo_path looks like: my-gh-org/my-gh-repo
- get_branch_protection_details(repo, branch='master')[source]¶
Retrieve a repository branch’s branch protection details.
- Parameters:
repo – the organization/repository as a string.
branch – the branch as a string.
- Returns:
the repository branch’s branch protection details.
- get_commit_details(repo, since, branch='master', path=None)[source]¶
Retrieve a repository branch’s commit details since a given date/time.
- Parameters:
repo – the organization/repository as a string.
since – the starting date/time as a datetime.
branch – the branch as a string. Defaults to master.
path – if provided, only commits for the path will be returned.
- Returns:
the repo branch’s commit details since a given date/time.
- get_issue(owner, repo, issue, parse_annotations=False)[source]¶
Retrieve the content and metadata for a repository issue.
If parse_annotations is True, then returns (issue, body, annotations), where body is the body with the JSON annotations removed, and annotations is a dictionary of the annotations. The annotations will be an empty dictionary if there aren’t any.
- get_issue_comments(owner, repo, issue, parse_annotations=False)[source]¶
Retrieve a repository issue’s comments.
- get_project(project, org=False)[source]¶
Retrieve the GH org or org/repo project.
- For a repo project the project variable looks like:
my-gh-org/my-gh-repo/projects/1
- For an org project the project variable looks like:
my-gh-org/projects/1
- get_pull_requests(repo, since=None, **kwargs)[source]¶
Retrieve a repository’s pull request information.
- Parameters:
repo – the organization/repository as a string.
since – the starting date/time of a pull request as a datetime.
kwargs – key/value pairs of GH pulls API accepted params
- Returns:
Repository pull request metadata
- get_repo_details(repo)[source]¶
Retrieve a repository’s metadata.
- Parameters:
repo – the organization/repository as a string.
- Returns:
the repository’s metadata details.
- list_milestones(owner, repo, state='open', sort='due_on', direction='asc')[source]¶
Retrieve a repository’s milestones.
- make_request(method, url, parse=True, **kwargs)[source]¶
Perform a REST call to the Github API.
- Parameters:
method – HTTP request method
url – The URL to make the request to
parse – Return the JSON response content, defaults to True. If False then the entire response is returned
kwargs – Additional arguments added directly to the request call
- Returns:
response content from the request made
- paginate_api(api_url, **kwargs)[source]¶
Perform GET calls handling pagination.
- Parameters:
api_url – The URL to make the GET request to
kwargs – Additional arguments added directly to the request call
- Returns:
Combined paginated JSON content
- remove_labels(repo, issue, *labels)[source]¶
Remove label(s) from an issue.
repo looks like: my-gh-org/my-gh-repo issue is an issue number (not id) API takes a json list of labels POST /repos/:owner/:repo/issues/:number/labels
compliance.utils.services.pagerduty module¶
Compliance Pagerduty service helper.
- compliance.utils.services.pagerduty.delete(path, params=None, headers=None, creds=None)[source]¶
Perform a DELETE operation.
Returns the result as
requests.Response
object. This uses the PD API v2.- Parameters:
path – API endpoint to call (e.g. ‘users’)
params – a dictionary with parameters
headers – a dictionary with headers to include
creds – a Config object with PagerDuty credentials
- compliance.utils.services.pagerduty.get(path, params=None, headers=None, creds=None)[source]¶
Perform a GET operation.
Returns the pages wrapped as
requests.Response
object. This uses the PD API v2.- Parameters:
path – API endpoint to call (e.g. ‘users’)
params – a dictionary with parameters
headers – a dictionary with headers to include
creds – a Config object with PagerDuty credentials
- compliance.utils.services.pagerduty.post(path, params=None, headers=None, creds=None)[source]¶
Perform a POST operation.
Returns the result as
requests.Response
objects. This uses the PD API v2.- Parameters:
path – API endpoint to call (e.g. ‘users’)
params – a dictionary with parameters
headers – a dictionary with headers to include
creds – a Config object with PagerDuty credentials
- compliance.utils.services.pagerduty.put(path, params=None, headers=None, creds=None)[source]¶
Perform a PUT operation.
Return the result as
requests.Response
object. This uses the PD API v2.- Parameters:
path – API endpoint to call (e.g. ‘users’)
params – a dictionary with parameters
headers – a dictionary with headers to include
creds – a Config object with PagerDuty credentials
Module contents¶
Compliance automation utilities services package.