INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Edit this hook. | def edit(self, config={}, events=[], add_events=[], rm_events=[],
active=True):
"""Edit this hook.
:param dict config: (optional), key-value pairs of settings for this
hook
:param list events: (optional), which events should this be triggered
for
:pa... |
Ping this hook. | def ping(self):
"""Ping this hook.
:returns: bool
"""
url = self._build_url('pings', base_url=self._api)
return self._boolean(self._post(url), 204, 404) |
Decorator to note which object methods require authorization. | def requires_auth(func):
"""Decorator to note which object methods require authorization."""
@wraps(func)
def auth_wrapper(self, *args, **kwargs):
auth = False
if hasattr(self, '_session'):
auth = (self._session.auth or
self._session.headers.get('Authorization... |
Specific ( basic ) authentication decorator. | def requires_basic_auth(func):
"""Specific (basic) authentication decorator.
This is used to note which object methods require username/password
authorization and won't work with token based authorization.
"""
@wraps(func)
def auth_wrapper(self, *args, **kwargs):
if hasattr(self, '_ses... |
Require client_id and client_secret to be associated. | def requires_app_credentials(func):
"""Require client_id and client_secret to be associated.
This is used to note and enforce which methods require a client_id and
client_secret to be used.
"""
@wraps(func)
def auth_wrapper(self, *args, **kwargs):
client_id, client_secret = self._sessi... |
1. 1 Avoid the use of the root account ( Scored ) | def audit_1_1(self):
"""1.1 Avoid the use of the "root" account (Scored)"""
for row in self.credential_report:
if row["user"] == "<root_account>":
for field in "password_last_used", "access_key_1_last_used_date", "access_key_2_last_used_date":
if row[field... |
1. 2 Ensure multi - factor authentication ( MFA ) is enabled for all IAM users that have a console password ( Scored ) | def audit_1_2(self):
"""1.2 Ensure multi-factor authentication (MFA) is enabled for all IAM users that have a console password (Scored)""" # noqa
for row in self.credential_report:
if row["user"] == "<root_account>" or json.loads(row["password_enabled"]):
if not json.loads(r... |
1. 3 Ensure credentials unused for 90 days or greater are disabled ( Scored ) | def audit_1_3(self):
"""1.3 Ensure credentials unused for 90 days or greater are disabled (Scored)"""
for row in self.credential_report:
for access_key in "1", "2":
if json.loads(row["access_key_{}_active".format(access_key)]):
last_used = row["access_key_... |
1. 4 Ensure access keys are rotated every 90 days or less ( Scored ) | def audit_1_4(self):
"""1.4 Ensure access keys are rotated every 90 days or less (Scored)"""
for row in self.credential_report:
for access_key in "1", "2":
if json.loads(row["access_key_{}_active".format(access_key)]):
last_rotated = row["access_key_{}_las... |
1. 12 Ensure no root account access key exists ( Scored ) | def audit_1_12(self):
"""1.12 Ensure no root account access key exists (Scored)"""
for row in self.credential_report:
if row["user"] == "<root_account>":
self.assertFalse(json.loads(row["access_key_1_active"]))
self.assertFalse(json.loads(row["access_key_2_act... |
1. 13 Ensure hardware MFA is enabled for the root account ( Scored ) | def audit_1_13(self):
"""1.13 Ensure hardware MFA is enabled for the "root" account (Scored)"""
for row in self.credential_report:
if row["user"] == "<root_account>":
self.assertTrue(json.loads(row["mfa_active"])) |
1. 15 Ensure IAM policies are attached only to groups or roles ( Scored ) | def audit_1_15(self):
"""1.15 Ensure IAM policies are attached only to groups or roles (Scored)"""
for policy in resources.iam.policies.all():
self.assertEqual(len(list(policy.attached_users.all())), 0, "{} has users attached to it".format(policy)) |
2. 2 Ensure CloudTrail log file validation is enabled ( Scored ) | def audit_2_2(self):
"""2.2 Ensure CloudTrail log file validation is enabled (Scored)"""
self.assertGreater(len(self.trails), 0, "No CloudTrail trails configured")
self.assertTrue(all(trail["LogFileValidationEnabled"] for trail in self.trails),
"Some CloudTrail trails don... |
2. 3 Ensure the S3 bucket CloudTrail logs to is not publicly accessible ( Scored ) | def audit_2_3(self):
"""2.3 Ensure the S3 bucket CloudTrail logs to is not publicly accessible (Scored)"""
raise NotImplementedError()
import boto3
s3 = boto3.session.Session(region_name="us-east-1").resource("s3")
# s3 = boto3.resource("s3")
# for trail in self.trails:
... |
2. 4 Ensure CloudTrail trails are integrated with CloudWatch Logs ( Scored ) | def audit_2_4(self):
"""2.4 Ensure CloudTrail trails are integrated with CloudWatch Logs (Scored)"""
for trail in self.trails:
self.assertIn("CloudWatchLogsLogGroupArn", trail)
trail_status = clients.cloudtrail.get_trail_status(Name=trail["TrailARN"])
self.assertGreat... |
2. 5 Ensure AWS Config is enabled in all regions ( Scored ) | def audit_2_5(self):
"""2.5 Ensure AWS Config is enabled in all regions (Scored)"""
import boto3
for region in boto3.Session().get_available_regions("config"):
aws_config = boto3.session.Session(region_name=region).client("config")
res = aws_config.describe_configuration_... |
Get information about authorization id. | def authorization(self, id_num):
"""Get information about authorization ``id``.
:param int id_num: (required), unique id of the authorization
:returns: :class:`Authorization <Authorization>`
"""
json = None
if int(id_num) > 0:
url = self._build_url('authoriza... |
Obtain an authorization token from the GitHub API for the GitHub API. | def authorize(self, login, password, scopes=None, note='', note_url='',
client_id='', client_secret=''):
"""Obtain an authorization token from the GitHub API for the GitHub
API.
:param str login: (required)
:param str password: (required)
:param list scopes: (o... |
OAuth applications can use this method to check token validity without hitting normal rate limits because of failed login attempts. If the token is valid it will return True otherwise it will return False. | def check_authorization(self, access_token):
"""OAuth applications can use this method to check token validity
without hitting normal rate limits because of failed login attempts.
If the token is valid, it will return True, otherwise it will return
False.
:returns: bool
... |
Create a new gist. | def create_gist(self, description, files, public=True):
"""Create a new gist.
If no login was provided, it will be anonymous.
:param str description: (required), description of gist
:param dict files: (required), file names with associated dictionaries
for content, e.g. ``{... |
Create an issue on the project repository owned by owner with title title. | def create_issue(self,
owner,
repository,
title,
body=None,
assignee=None,
milestone=None,
labels=[]):
"""Create an issue on the project 'repository' owned by 'owner... |
Create a new key for the authenticated user. | def create_key(self, title, key):
"""Create a new key for the authenticated user.
:param str title: (required), key title
:param key: (required), actual key contents, accepts path as a string
or file-like object
:returns: :class:`Key <github3.users.Key>`
"""
... |
Delete user key pointed to by key_id. | def delete_key(self, key_id):
"""Delete user key pointed to by ``key_id``.
:param int key_id: (required), unique id used by Github
:returns: bool
"""
key = self.key(key_id)
if key:
return key.delete()
return False |
Retrieves a dictionary of all of the emojis that GitHub supports. | def emojis(self):
"""Retrieves a dictionary of all of the emojis that GitHub supports.
:returns: dictionary where the key is what would be in between the
colons and the value is the URL to the image, e.g., ::
{
'+1': 'https://github.global.ssl.fastly.net... |
List GitHub s timeline resources in Atom format. | def feeds(self):
"""List GitHub's timeline resources in Atom format.
:returns: dictionary parsed to include URITemplates
"""
url = self._build_url('feeds')
json = self._json(self._get(url), 200)
del json['ETag']
del json['Last-Modified']
urls = [
... |
Make the authenticated user follow login. | def follow(self, login):
"""Make the authenticated user follow login.
:param str login: (required), user to follow
:returns: bool
"""
resp = False
if login:
url = self._build_url('user', 'following', login)
resp = self._boolean(self._put(url), 204... |
Gets the gist using the specified id number. | def gist(self, id_num):
"""Gets the gist using the specified id number.
:param int id_num: (required), unique id of the gist
:returns: :class:`Gist <github3.gists.Gist>`
"""
url = self._build_url('gists', str(id_num))
json = self._json(self._get(url), 200)
return... |
Returns the template for language. | def gitignore_template(self, language):
"""Returns the template for language.
:returns: str
"""
url = self._build_url('gitignore', 'templates', language)
json = self._json(self._get(url), 200)
if not json:
return ''
return json.get('source', '') |
Returns the list of available templates. | def gitignore_templates(self):
"""Returns the list of available templates.
:returns: list of template names
"""
url = self._build_url('gitignore', 'templates')
return self._json(self._get(url), 200) or [] |
Check if the authenticated user is following login. | def is_following(self, login):
"""Check if the authenticated user is following login.
:param str login: (required), login of the user to check if the
authenticated user is checking
:returns: bool
"""
json = False
if login:
url = self._build_url('u... |
Check if the authenticated user is subscribed to login/ repo. | def is_subscribed(self, login, repo):
"""Check if the authenticated user is subscribed to login/repo.
:param str login: (required), owner of repository
:param str repo: (required), name of repository
:returns: bool
"""
json = False
if login and repo:
... |
Fetch issue #: number: from https:// github. com/: owner:/: repository: | def issue(self, owner, repository, number):
"""Fetch issue #:number: from https://github.com/:owner:/:repository:
:param str owner: (required), owner of the repository
:param str repository: (required), name of the repository
:param int number: (required), issue number
:return: ... |
Iterate over every repository in the order they were created. | def iter_all_repos(self, number=-1, since=None, etag=None, per_page=None):
"""Iterate over every repository in the order they were created.
:param int number: (optional), number of repositories to return.
Default: -1, returns all of them
:param int since: (optional), last repository... |
Iterate over every user in the order they signed up for GitHub. | def iter_all_users(self, number=-1, etag=None, per_page=None):
"""Iterate over every user in the order they signed up for GitHub.
:param int number: (optional), number of users to return. Default: -1,
returns all of them
:param str etag: (optional), ETag from a previous request to t... |
Iterate over authorizations for the authenticated user. This will return a 404 if you are using a token for authentication. | def iter_authorizations(self, number=-1, etag=None):
"""Iterate over authorizations for the authenticated user. This will
return a 404 if you are using a token for authentication.
:param int number: (optional), number of authorizations to return.
Default: -1 returns all available au... |
Iterate over email addresses for the authenticated user. | def iter_emails(self, number=-1, etag=None):
"""Iterate over email addresses for the authenticated user.
:param int number: (optional), number of email addresses to return.
Default: -1 returns all available email addresses
:param str etag: (optional), ETag from a previous request to... |
Iterate over public events. | def iter_events(self, number=-1, etag=None):
"""Iterate over public events.
:param int number: (optional), number of events to return. Default: -1
returns all available events
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns... |
If login is provided iterate over a generator of followers of that login name ; otherwise return a generator of followers of the authenticated user. | def iter_followers(self, login=None, number=-1, etag=None):
"""If login is provided, iterate over a generator of followers of that
login name; otherwise return a generator of followers of the
authenticated user.
:param str login: (optional), login of the user to check
:param int... |
If login is provided iterate over a generator of users being followed by login ; otherwise return a generator of people followed by the authenticated user. | def iter_following(self, login=None, number=-1, etag=None):
"""If login is provided, iterate over a generator of users being
followed by login; otherwise return a generator of people followed by
the authenticated user.
:param str login: (optional), login of the user to check
:pa... |
If no username is specified GET/ gists otherwise GET/ users/: username/ gists | def iter_gists(self, username=None, number=-1, etag=None):
"""If no username is specified, GET /gists, otherwise GET
/users/:username/gists
:param str login: (optional), login of the user to check
:param int number: (optional), number of gists to return. Default: -1
returns ... |
Iterate over the user s notification. | def iter_notifications(self, all=False, participating=False, number=-1,
etag=None):
"""Iterate over the user's notification.
:param bool all: (optional), iterate over all notifications
:param bool participating: (optional), only iterate over notifications
... |
Iterate over the organnization s issues if the authenticated user belongs to it. | def iter_org_issues(self, name, filter='', state='', labels='', sort='',
direction='', since=None, number=-1, etag=None):
"""Iterate over the organnization's issues if the authenticated user
belongs to it.
:param str name: (required), name of the organization
:pa... |
List issues on owner/ repository. Only owner and repository are required. | def iter_repo_issues(self, owner, repository, milestone=None,
state=None, assignee=None, mentioned=None,
labels=None, sort=None, direction=None, since=None,
number=-1, etag=None):
"""List issues on owner/repository. Only owner and reposi... |
Iterate over public organizations for login if provided ; otherwise iterate over public and private organizations for the authenticated user. | def iter_orgs(self, login=None, number=-1, etag=None):
"""Iterate over public organizations for login if provided; otherwise
iterate over public and private organizations for the authenticated
user.
:param str login: (optional), user whose orgs you wish to list
:param int number... |
List public repositories for the authenticated user. | def iter_repos(self, type=None, sort=None, direction=None, number=-1,
etag=None):
"""List public repositories for the authenticated user.
.. versionchanged:: 0.6
Removed the login parameter for correctness. Use iter_user_repos
instead
:param str type: (... |
Iterate over repositories starred by login or the authenticated user. | def iter_starred(self, login=None, sort=None, direction=None, number=-1,
etag=None):
"""Iterate over repositories starred by ``login`` or the authenticated
user.
.. versionchanged:: 0.5
Added sort and direction parameters (optional) as per the change in
... |
Iterate over repositories subscribed to by login or the authenticated user. | def iter_subscriptions(self, login=None, number=-1, etag=None):
"""Iterate over repositories subscribed to by ``login`` or the
authenticated user.
:param str login: (optional), name of user whose subscriptions you want
to see
:param int number: (optional), number of reposito... |
Gets the authenticated user s teams across all of organizations. | def iter_user_teams(self, number=-1, etag=None):
"""Gets the authenticated user's teams across all of organizations.
List all of the teams across all of the organizations to which the
authenticated user belongs. This method requires user or repo scope
when authenticating via OAuth.
... |
Logs the user into GitHub for protected API calls. | def login(self, username=None, password=None, token=None,
two_factor_callback=None):
"""Logs the user into GitHub for protected API calls.
:param str username: login name
:param str password: password for the login
:param str token: OAuth token
:param func two_fact... |
Render an arbitrary markdown document. | def markdown(self, text, mode='', context='', raw=False):
"""Render an arbitrary markdown document.
:param str text: (required), the text of the document to render
:param str mode: (optional), 'markdown' or 'gfm'
:param str context: (optional), only important when using mode 'gfm',
... |
Retrieve the user s membership in the specified organization. | def membership_in(self, organization):
"""Retrieve the user's membership in the specified organization."""
url = self._build_url('user', 'memberships', 'orgs',
str(organization))
json = self._json(self._get(url), 200)
return Membership(json, self) |
Returns a dictionary with arrays of addresses in CIDR format specifying theaddresses that the incoming service hooks will originate from. | def meta(self):
"""Returns a dictionary with arrays of addresses in CIDR format
specifying theaddresses that the incoming service hooks will originate
from.
.. versionadded:: 0.5
"""
url = self._build_url('meta')
return self._json(self._get(url), 200) |
Returns an easter egg of the API. | def octocat(self, say=None):
"""Returns an easter egg of the API.
:params str say: (optional), pass in what you'd like Octocat to say
:returns: ascii art of Octocat
"""
url = self._build_url('octocat')
req = self._get(url, params={'s': say})
return req.content if... |
Returns a Organization object for the login name | def organization(self, login):
"""Returns a Organization object for the login name
:param str login: (required), login name of the org
:returns: :class:`Organization <github3.orgs.Organization>`
"""
url = self._build_url('orgs', login)
json = self._json(self._get(url), 2... |
List organizations of which the user is a current or pending member. | def organization_memberships(self, state=None, number=-1, etag=None):
"""List organizations of which the user is a current or pending member.
:param str state: (option), state of the membership, i.e., active,
pending
:returns: iterator of :class:`Membership <github3.orgs.Membership>... |
Create/ update a pubsubhubbub hook. | def pubsubhubbub(self, mode, topic, callback, secret=''):
"""Create/update a pubsubhubbub hook.
:param str mode: (required), accepted values: ('subscribe',
'unsubscribe')
:param str topic: (required), form:
https://github.com/:user/:repo/events/:event
:param str ... |
Fetch pull_request #: number: from: owner:/: repository | def pull_request(self, owner, repository, number):
"""Fetch pull_request #:number: from :owner:/:repository
:param str owner: (required), owner of the repository
:param str repository: (required), name of the repository
:param int number: (required), issue number
:return: :class... |
Returns a dictionary with information from/ rate_limit. | def rate_limit(self):
"""Returns a dictionary with information from /rate_limit.
The dictionary has two keys: ``resources`` and ``rate``. In
``resources`` you can access information about ``core`` or ``search``.
Note: the ``rate`` key will be deprecated before version 3 of the
... |
Returns a Repository object for the specified combination of owner and repository | def repository(self, owner, repository):
"""Returns a Repository object for the specified combination of
owner and repository
:param str owner: (required)
:param str repository: (required)
:returns: :class:`Repository <github3.repos.Repository>`
"""
json = None
... |
Revoke specified authorization for an OAuth application. | def revoke_authorization(self, access_token):
"""Revoke specified authorization for an OAuth application.
Revoke all authorization tokens created by your application. This will
only work if you have already called ``set_client_id``.
:param str access_token: (required), the access_token... |
Find code via the code search API. | def search_code(self, query, sort=None, order=None, per_page=None,
text_match=False, number=-1, etag=None):
"""Find code via the code search API.
The query can contain any combination of the following supported
qualifiers:
- ``in`` Qualifies which fields are searche... |
Find issues by state and keyword | def search_issues(self, query, sort=None, order=None, per_page=None,
text_match=False, number=-1, etag=None):
"""Find issues by state and keyword
The query can contain any combination of the following supported
qualifers:
- ``type`` With this qualifier you can res... |
Find repositories via various criteria. | def search_repositories(self, query, sort=None, order=None,
per_page=None, text_match=False, number=-1,
etag=None):
"""Find repositories via various criteria.
The query can contain any combination of the following supported
qualifers:
... |
Find users via the Search API. | def search_users(self, query, sort=None, order=None, per_page=None,
text_match=False, number=-1, etag=None):
"""Find users via the Search API.
The query can contain any combination of the following supported
qualifers:
- ``type`` With this qualifier you can restri... |
Star to login/ repo | def star(self, login, repo):
"""Star to login/repo
:param str login: (required), owner of the repo
:param str repo: (required), name of the repo
:return: bool
"""
resp = False
if login and repo:
url = self._build_url('user', 'starred', login, repo)
... |
Make the authenticated user stop following login | def unfollow(self, login):
"""Make the authenticated user stop following login
:param str login: (required)
:returns: bool
"""
resp = False
if login:
url = self._build_url('user', 'following', login)
resp = self._boolean(self._delete(url), 204, 40... |
Unstar to login/ repo | def unstar(self, login, repo):
"""Unstar to login/repo
:param str login: (required), owner of the repo
:param str repo: (required), name of the repo
:return: bool
"""
resp = False
if login and repo:
url = self._build_url('user', 'starred', login, repo... |
If authenticated as this user update the information with the information provided in the parameters. All parameters are optional. | def update_user(self, name=None, email=None, blog=None,
company=None, location=None, hireable=False, bio=None):
"""If authenticated as this user, update the information with
the information provided in the parameters. All parameters are
optional.
:param str name: e.g... |
Returns a User object for the specified login name if provided. If no login name is provided this will return a User object for the authenticated user. | def user(self, login=None):
"""Returns a User object for the specified login name if
provided. If no login name is provided, this will return a User
object for the authenticated user.
:param str login: (optional)
:returns: :class:`User <github3.users.User>`
"""
i... |
Returns a quote from the Zen of GitHub. Yet another API Easter Egg | def zen(self):
"""Returns a quote from the Zen of GitHub. Yet another API Easter Egg
:returns: str
"""
url = self._build_url('zen')
resp = self._get(url)
return resp.content if resp.status_code == 200 else '' |
This is a simple way to get statistics about your system. | def admin_stats(self, option):
"""This is a simple way to get statistics about your system.
:param str option: (required), accepted values: ('all', 'repos',
'hooks', 'pages', 'orgs', 'users', 'pulls', 'issues',
'milestones', 'gists', 'comments')
:returns: dict
""... |
Update this key. | def update(self, title, key):
"""Update this key.
:param str title: (required), title of the key
:param str key: (required), text of the key file
:returns: bool
"""
json = None
if title and key:
data = {'title': title, 'key': key}
json = s... |
Add the email addresses in addresses to the authenticated user s account. | def add_email_addresses(self, addresses=[]):
"""Add the email addresses in ``addresses`` to the authenticated
user's account.
:param list addresses: (optional), email addresses to be added
:returns: list of email addresses
"""
json = []
if addresses:
... |
Delete the email addresses in addresses from the authenticated user s account. | def delete_email_addresses(self, addresses=[]):
"""Delete the email addresses in ``addresses`` from the
authenticated user's account.
:param list addresses: (optional), email addresses to be removed
:returns: bool
"""
url = self._build_url('user', 'emails')
retur... |
Checks if this user can be assigned to issues on login/ repository. | def is_assignee_on(self, login, repository):
"""Checks if this user can be assigned to issues on login/repository.
:returns: :class:`bool`
"""
url = self._build_url('repos', login, repository, 'assignees',
self.login)
return self._boolean(self._get(... |
Checks if this user is following login. | def is_following(self, login):
"""Checks if this user is following ``login``.
:param str login: (required)
:returns: bool
"""
url = self.following_urlt.expand(other_user=login)
return self._boolean(self._get(url), 204, 404) |
Iterate over events performed by this user. | def iter_events(self, public=False, number=-1, etag=None):
"""Iterate over events performed by this user.
:param bool public: (optional), only list public events for the
authenticated user
:param int number: (optional), number of events to return. Default: -1
returns all... |
Iterate over the followers of this user. | def iter_followers(self, number=-1, etag=None):
"""Iterate over the followers of this user.
:param int number: (optional), number of followers to return. Default:
-1 returns all available
:param str etag: (optional), ETag from a previous request to the same
endpoint
... |
Iterate over the public keys of this user. | def iter_keys(self, number=-1, etag=None):
"""Iterate over the public keys of this user.
.. versionadded:: 0.5
:param int number: (optional), number of keys to return. Default: -1
returns all available keys
:param str etag: (optional), ETag from a previous request to the sa... |
Iterate over events as they appear on the user s organization dashboard. You must be authenticated to view this. | def iter_org_events(self, org, number=-1, etag=None):
"""Iterate over events as they appear on the user's organization
dashboard. You must be authenticated to view this.
:param str org: (required), name of the organization
:param int number: (optional), number of events to return. Defau... |
Iterate over organizations the user is member of | def iter_orgs(self, number=-1, etag=None):
"""Iterate over organizations the user is member of
:param int number: (optional), number of organizations to return.
Default: -1 returns all available organization
:param str etag: (optional), ETag from a previous request to the same
... |
Iterate over repositories starred by this user. | def iter_starred(self, sort=None, direction=None, number=-1, etag=None):
"""Iterate over repositories starred by this user.
.. versionchanged:: 0.5
Added sort and direction parameters (optional) as per the change in
GitHub's API.
:param int number: (optional), number of s... |
Iterate over repositories subscribed to by this user. | def iter_subscriptions(self, number=-1, etag=None):
"""Iterate over repositories subscribed to by this user.
:param int number: (optional), number of subscriptions to return.
Default: -1, returns all available
:param str etag: (optional), ETag from a previous request to the same
... |
If authenticated as this user update the information with the information provided in the parameters. | def update(self, name=None, email=None, blog=None, company=None,
location=None, hireable=False, bio=None):
"""If authenticated as this user, update the information with
the information provided in the parameters.
:param str name: e.g., 'John Smith', not login name
:param ... |
Delete subscription for this thread. | def delete_subscription(self):
"""Delete subscription for this thread.
:returns: bool
"""
url = self._build_url('subscription', base_url=self._api)
return self._boolean(self._delete(url), 204, 404) |
Set the user s subscription for this thread | def set_subscription(self, subscribed, ignored):
"""Set the user's subscription for this thread
:param bool subscribed: (required), determines if notifications should
be received from this thread.
:param bool ignored: (required), determines if notifications should be
ign... |
Checks the status of the user s subscription to this thread. | def subscription(self):
"""Checks the status of the user's subscription to this thread.
:returns: :class:`Subscription <Subscription>`
"""
url = self._build_url('subscription', base_url=self._api)
json = self._json(self._get(url), 200)
return Subscription(json, self) if ... |
Set the user s subscription for this subscription | def set(self, subscribed, ignored):
"""Set the user's subscription for this subscription
:param bool subscribed: (required), determines if notifications should
be received from this thread.
:param bool ignored: (required), determines if notifications should be
ignored fr... |
Examples:: locate_ami ( product = com. ubuntu. cloud: server: 16. 04: amd64 channel = daily stream = daily region = us - west - 2 ) locate_ami ( product = Amazon Linux AMI 2016. 09 ) | def locate_ami(product, region=None, channel="releases", stream="released", root_store="ssd", virt="hvm"):
"""
Examples::
locate_ami(product="com.ubuntu.cloud:server:16.04:amd64", channel="daily", stream="daily", region="us-west-2")
locate_ami(product="Amazon Linux AMI 2016.09")
"""
if r... |
Add login as a collaborator to a repository. | def add_collaborator(self, login):
"""Add ``login`` as a collaborator to a repository.
:param str login: (required), login of the user
:returns: bool -- True if successful, False otherwise
"""
resp = False
if login:
url = self._build_url('collaborators', logi... |
Get the tarball or zipball archive for this repo at ref. | def archive(self, format, path='', ref='master'):
"""Get the tarball or zipball archive for this repo at ref.
See: http://developer.github.com/v3/repos/contents/#get-archive-link
:param str format: (required), accepted values: ('tarball',
'zipball')
:param path: (optional),... |
Returns a single Asset. | def asset(self, id):
"""Returns a single Asset.
:param int id: (required), id of the asset
:returns: :class:`Asset <github3.repos.release.Asset>`
"""
data = None
if int(id) > 0:
url = self._build_url('releases', 'assets', str(id),
... |
Get the blob indicated by sha. | def blob(self, sha):
"""Get the blob indicated by ``sha``.
:param str sha: (required), sha of the blob
:returns: :class:`Blob <github3.git.Blob>` if successful, otherwise
None
"""
url = self._build_url('git', 'blobs', sha, base_url=self._api)
json = self._jso... |
Get the branch name of this repository. | def branch(self, name):
"""Get the branch ``name`` of this repository.
:param str name: (required), branch name
:type name: str
:returns: :class:`Branch <github3.repos.branch.Branch>`
"""
json = None
if name:
url = self._build_url('branches', name, ba... |
Get a single ( repo ) commit. See: func: git_commit for the Git Data Commit. | def commit(self, sha):
"""Get a single (repo) commit. See :func:`git_commit` for the Git Data
Commit.
:param str sha: (required), sha of the commit
:returns: :class:`RepoCommit <github3.repos.commit.RepoCommit>` if
successful, otherwise None
"""
url = self._b... |
Get a single commit comment. | def commit_comment(self, comment_id):
"""Get a single commit comment.
:param int comment_id: (required), id of the comment used by GitHub
:returns: :class:`RepoComment <github3.repos.comment.RepoComment>` if
successful, otherwise None
"""
url = self._build_url('comme... |
Compare two commits. | def compare_commits(self, base, head):
"""Compare two commits.
:param str base: (required), base for the comparison
:param str head: (required), compare this against base
:returns: :class:`Comparison <github3.repos.comparison.Comparison>` if
successful, else None
"""... |
Get the contents of the file pointed to by path. | def contents(self, path, ref=None):
"""Get the contents of the file pointed to by ``path``.
If the path provided is actually a directory, you will receive a
dictionary back of the form::
{
'filename.md': Contents(), # Where Contents an instance
'git... |
Create a blob with content. | def create_blob(self, content, encoding):
"""Create a blob with ``content``.
:param str content: (required), content of the blob
:param str encoding: (required), ('base64', 'utf-8')
:returns: string of the SHA returned
"""
sha = ''
if encoding in ('base64', 'utf-... |
Create a comment on a commit. | def create_comment(self, body, sha, path=None, position=None, line=1):
"""Create a comment on a commit.
:param str body: (required), body of the message
:param str sha: (required), commit id
:param str path: (optional), relative path of the file to comment
on
:param ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.