text stringlengths 81 112k |
|---|
Iterate over the assets available for this release.
:param int number: (optional), Number of assets to return
:param str etag: (optional), last ETag header sent
:returns: generator of :class:`Asset <Asset>` objects
def iter_assets(self, number=-1, etag=None):
"""Iterate over the assets... |
Upload an asset to this release.
All parameters are required.
:param str content_type: The content type of the asset. Wikipedia has
a list of common media types
:param str name: The name of the file
:param asset: The file or bytes object to upload.
:returns: :class:... |
Download the data for this asset.
:param path: (optional), path where the file should be saved
to, default is the filename provided in the headers and will be
written in the current directory.
it can take a file-like object as well
:type path: str, file
:retu... |
Edit this asset.
:param str name: (required), The file name of the asset
:param str label: (optional), An alternate description of the asset
:returns: boolean
def edit(self, name, label=None):
"""Edit this asset.
:param str name: (required), The file name of the asset
... |
List status of all configured SNS-SQS message buses and instances subscribed to them.
def ls(args):
"""
List status of all configured SNS-SQS message buses and instances subscribed to them.
"""
table = []
queues = list(resources.sqs.queues.filter(QueueNamePrefix="github"))
max_age = datetime.no... |
Given an IAM role or instance name, attach an IAM policy granting
appropriate permissions to subscribe to deployments. Given a
GitHub repo URL, create and record deployment keys for the repo
and any of its private submodules, making the keys accessible to
the IAM role.
def grant(args):
"""
Give... |
Delete this file.
:param str message: (required), commit message to describe the removal
:param str branch: (optional), branch where the file exists.
Defaults to the default branch of the repository.
:param dict committer: (optional), if no information is given the
authe... |
Update this file.
:param str message: (required), commit message to describe the update
:param str content: (required), content to update the file with
:param str branch: (optional), branch where the file exists.
Defaults to the default branch of the repository.
:param dict ... |
Edit this gist.
:param str description: (optional), description of the gist
:param dict files: (optional), files that make up this gist; the
key(s) should be the file name(s) and the values should be another
(optional) dictionary with (optional) keys: 'content' and
'... |
Fork this gist.
:returns: :class:`Gist <Gist>` if successful, ``None`` otherwise
def fork(self):
"""Fork this gist.
:returns: :class:`Gist <Gist>` if successful, ``None`` otherwise
"""
url = self._build_url('forks', base_url=self._api)
json = self._json(self._post(url... |
Check to see if this gist is starred by the authenticated user.
:returns: bool -- True if it is starred, False otherwise
def is_starred(self):
"""Check to see if this gist is starred by the authenticated user.
:returns: bool -- True if it is starred, False otherwise
"""
url =... |
Iter over the commits on this gist.
These commits will be requested from the API and should be the same as
what is in ``Gist.history``.
.. versionadded:: 0.6
.. versionchanged:: 0.9
Added param ``etag``.
:param int number: (optional), number of commits to iterate... |
Iterator of forks of this gist.
.. versionchanged:: 0.9
Added params ``number`` and ``etag``.
:param int number: (optional), number of forks to iterate over.
Default: -1 will iterate over all forks of this gist.
:param str etag: (optional), ETag from a previous request... |
Star this gist.
:returns: bool -- True if successful, False otherwise
def star(self):
"""Star this gist.
:returns: bool -- True if successful, False otherwise
"""
url = self._build_url('star', base_url=self._api)
return self._boolean(self._put(url), 204, 404) |
Un-star this gist.
:returns: bool -- True if successful, False otherwise
def unstar(self):
"""Un-star this gist.
:returns: bool -- True if successful, False otherwise
"""
url = self._build_url('star', base_url=self._api)
return self._boolean(self._delete(url), 204, 40... |
Update this comment.
:param str body: (required)
:returns: bool
def update(self, body):
"""Update this comment.
:param str body: (required)
:returns: bool
"""
json = None
if body:
json = self._json(self._post(self._api, data={'body': body}),... |
Transfer files to or from EC2 instance.
Use "--" to separate scp args from aegea args:
aegea scp -- -r local_dir instance_name:~/remote_dir
def scp(args):
"""
Transfer files to or from EC2 instance.
Use "--" to separate scp args from aegea args:
aegea scp -- -r local_dir instance_na... |
List S3 buckets. See also "aws s3 ls". Use "aws s3 ls NAME" to list bucket contents.
def ls(args):
"""
List S3 buckets. See also "aws s3 ls". Use "aws s3 ls NAME" to list bucket contents.
"""
table = []
for bucket in filter_collection(resources.s3.buckets, args):
bucket.LocationConstraint =... |
Update this label.
:param str name: (required), new name of the label
:param str color: (required), color code, e.g., 626262, no leading '#'
:returns: bool
def update(self, name, color):
"""Update this label.
:param str name: (required), new name of the label
:param st... |
Set the Basic Auth credentials on this Session.
:param str username: Your GitHub username
:param str password: Your GitHub password
def basic_auth(self, username, password):
"""Set the Basic Auth credentials on this Session.
:param str username: Your GitHub username
:param str... |
Builds a new API url from scratch.
def build_url(self, *args, **kwargs):
"""Builds a new API url from scratch."""
parts = [kwargs.get('base_url') or self.base_url]
parts.extend(args)
parts = [str(p) for p in parts]
key = tuple(parts)
__logs__.info('Building a url from %s... |
Return the client credentials.
:returns: tuple(client_id, client_secret)
def retrieve_client_credentials(self):
"""Return the client credentials.
:returns: tuple(client_id, client_secret)
"""
client_id = self.params.get('client_id')
client_secret = self.params.get('cli... |
Use an application token for authentication.
:param str token: Application token retrieved from GitHub's
/authorizations endpoint
def token_auth(self, token):
"""Use an application token for authentication.
:param str token: Application token retrieved from GitHub's
/a... |
Unset authentication temporarily as a context manager.
def no_auth(self):
"""Unset authentication temporarily as a context manager."""
old_basic_auth, self.auth = self.auth, None
old_token_auth = self.headers.pop('Authorization', None)
yield
self.auth = old_basic_auth
... |
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
:param list add_events: (optional), events to be added to the list of
events that this hook trig... |
Ping this hook.
:returns: bool
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 ... |
Specific (basic) authentication decorator.
This is used to note which object methods require username/password
authorization and won't work with token based authorization.
def requires_basic_auth(func):
"""Specific (basic) authentication decorator.
This is used to note which object methods require us... |
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.
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 ... |
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... |
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:
... |
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_{}_ac... |
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(acces... |
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"]))
... |
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_acti... |
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 att... |
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 se... |
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").resourc... |
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.cloud... |
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("con... |
Get information about authorization ``id``.
:param int id_num: (required), unique id of the authorization
:returns: :class:`Authorization <Authorization>`
def authorization(self, id_num):
"""Get information about authorization ``id``.
:param int id_num: (required), unique id of the au... |
Obtain an authorization token from the GitHub API for the GitHub
API.
:param str login: (required)
:param str password: (required)
:param list scopes: (optional), areas you want this token to apply to,
i.e., 'gist', 'user'
:param str note: (optional), note about the ... |
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
def check_authorization(self, access_token):
"""OAuth a... |
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. ``{'spam.txt': {'content': 'File contents
...'}}``
... |
Create an issue on the project 'repository' owned by 'owner'
with title 'title'.
body, assignee, milestone, labels are all optional.
:param str owner: (required), login of the owner
:param str repository: (required), repository name
:param str title: (required), Title of issue ... |
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>`
def create_key(self, title, key):
"""Create a new key fo... |
Delete user key pointed to by ``key_id``.
:param int key_id: (required), unique id used by Github
:returns: bool
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
"""
... |
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/images/...',
... |
List GitHub's timeline resources in Atom format.
:returns: dictionary parsed to include URITemplates
def feeds(self):
"""List GitHub's timeline resources in Atom format.
:returns: dictionary parsed to include URITemplates
"""
url = self._build_url('feeds')
json = self.... |
Make the authenticated user follow login.
:param str login: (required), user to follow
:returns: bool
def follow(self, login):
"""Make the authenticated user follow login.
:param str login: (required), user to follow
:returns: bool
"""
resp = False
if l... |
Gets the gist using the specified id number.
:param int id_num: (required), unique id of the gist
:returns: :class:`Gist <github3.gists.Gist>`
def gist(self, id_num):
"""Gets the gist using the specified id number.
:param int id_num: (required), unique id of the gist
:returns:... |
Returns the template for language.
:returns: str
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:
... |
Returns the list of available templates.
:returns: list of template names
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), 2... |
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
def is_following(self, login):
"""Check if the authenticated user is following login.
:param str login: (requir... |
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
def is_subscribed(self, login, repo):
"""Check if the authenticated user is subscribed to login/repo.
:... |
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: :class:`Issue <github3.issues.Issue>`
def issue(self, ... |
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 id seen (allows
restarting this iteration)
:param str etag: (opti... |
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 the same
endpoint
:param int per_page: (optional), numb... |
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 authorizations
:param str etag: (optional), ETag from a pr... |
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 the same
endpoint
:returns: generat... |
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: generator of :class:`Event <github3.events.Event>`\ s
... |
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 number: (optional), number of followers to return. Default:
... |
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
:param int number: (optional), number of people to return. Default: -1
... |
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 all available gists
:param str etag: (optional), ETag from a p... |
Iterate over the user's notification.
:param bool all: (optional), iterate over all notifications
:param bool participating: (optional), only iterate over notifications
in which the user is participating
:param int number: (optional), how many notifications to return
:param ... |
Iterate over the organnization's issues if the authenticated user
belongs to it.
:param str name: (required), name of the organization
:param str filter: accepted values:
('assigned', 'created', 'mentioned', 'subscribed')
api-default: 'assigned'
:param str state:... |
List issues on owner/repository. Only owner and repository are
required.
.. versionchanged:: 0.9.0
- The ``state`` parameter now accepts 'all' in addition to 'open'
and 'closed'.
:param str owner: login of the owner of the repository
:param str repository: na... |
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: (optional), number of organizations to return.
Defau... |
List public repositories for the authenticated user.
.. versionchanged:: 0.6
Removed the login parameter for correctness. Use iter_user_repos
instead
:param str type: (optional), accepted values:
('all', 'owner', 'public', 'private', 'member')
API default:... |
Iterate over repositories starred by ``login`` or the authenticated
user.
.. versionchanged:: 0.5
Added sort and direction parameters (optional) as per the change in
GitHub's API.
:param str login: (optional), name of user whose stars you want to see
:param str so... |
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 repositories to return.
Default: -1 returns all repositories
:p... |
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.
:returns: generator of :class:`Team <github3.orgs.Team>... |
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_factor_callback: (optional), function you implement to
provide the Two Factor Authentication code to G... |
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',
this is the repository to use as the context for the renderin... |
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._... |
Returns a dictionary with arrays of addresses in CIDR format
specifying theaddresses that the incoming service hooks will originate
from.
.. versionadded:: 0.5
def meta(self):
"""Returns a dictionary with arrays of addresses in CIDR format
specifying theaddresses that the incom... |
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
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: ... |
Returns a Organization object for the login name
:param str login: (required), login name of the org
:returns: :class:`Organization <github3.orgs.Organization>`
def organization(self, login):
"""Returns a Organization object for the login name
:param str login: (required), login name ... |
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>`
def organization_memberships(self, state=None, number=-1, etag=None):
... |
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 callback: (required), the URI that receives the updates
:para... |
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:`Issue <github3.issues.Issue>`
def pull_request(self, owner,... |
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
GitHub API is finalized. Do not r... |
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>`
def repository(self, owner, repository):
"""Returns a Repository object for ... |
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 to revoke
:returns: bool -- True if successful, ... |
Find code via the code search API.
The query can contain any combination of the following supported
qualifiers:
- ``in`` Qualifies which fields are searched. With this qualifier you
can restrict the search to just the file contents, the file path, or
both.
- ``langu... |
Find issues by state and keyword
The query can contain any combination of the following supported
qualifers:
- ``type`` With this qualifier you can restrict the search to issues
or pull request only.
- ``in`` Qualifies which fields are searched. With this qualifier you
... |
Find repositories via various criteria.
The query can contain any combination of the following supported
qualifers:
- ``in`` Qualifies which fields are searched. With this qualifier you
can restrict the search to just the repository name, description,
readme, or any combina... |
Find users via the Search API.
The query can contain any combination of the following supported
qualifers:
- ``type`` With this qualifier you can restrict the search to just
personal accounts or just organization accounts.
- ``in`` Qualifies which fields are searched. With t... |
Star to login/repo
:param str login: (required), owner of the repo
:param str repo: (required), name of the repo
:return: bool
def star(self, login, repo):
"""Star to login/repo
:param str login: (required), owner of the repo
:param str repo: (required), name of the re... |
Make the authenticated user stop following login
:param str login: (required)
:returns: bool
def unfollow(self, login):
"""Make the authenticated user stop following login
:param str login: (required)
:returns: bool
"""
resp = False
if login:
... |
Unstar to login/repo
:param str login: (required), owner of the repo
:param str repo: (required), name of the repo
:return: bool
def unstar(self, login, repo):
"""Unstar to login/repo
:param str login: (required), owner of the repo
:param str repo: (required), name of ... |
If authenticated as this user, update the information with
the information provided in the parameters. All parameters are
optional.
:param str name: e.g., 'John Smith', not login name
:param str email: e.g., 'john.smith@example.com'
:param str blog: e.g., 'http://www.example.com... |
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>`
def user(self, login=None):
"""Returns a User objec... |
Returns a quote from the Zen of GitHub. Yet another API Easter Egg
:returns: str
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 res... |
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
def admin_stats(self, option):
"""This is a... |
Update this key.
:param str title: (required), title of the key
:param str key: (required), text of the key file
:returns: bool
def update(self, title, key):
"""Update this key.
:param str title: (required), title of the key
:param str key: (required), text of the key ... |
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
def add_email_addresses(self, addresses=[]):
"""Add the email addresses in ``addresses`` to the authenticated
... |
Delete the email addresses in ``addresses`` from the
authenticated user's account.
:param list addresses: (optional), email addresses to be removed
:returns: bool
def delete_email_addresses(self, addresses=[]):
"""Delete the email addresses in ``addresses`` from the
authenticat... |
Checks if this user can be assigned to issues on login/repository.
:returns: :class:`bool`
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, repos... |
Checks if this user is following ``login``.
:param str login: (required)
:returns: bool
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=lo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.