repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
kislyuk/aegea
aegea/packages/github3/orgs.py
Team.edit
def edit(self, name, permission=''): """Edit this team. :param str name: (required) :param str permission: (optional), ('pull', 'push', 'admin') :returns: bool """ if name: data = {'name': name, 'permission': permission} json = self._json(self._patch(self._api, data=dumps(data)), 200) if json: self._update_(json) return True return False
python
def edit(self, name, permission=''): """Edit this team. :param str name: (required) :param str permission: (optional), ('pull', 'push', 'admin') :returns: bool """ if name: data = {'name': name, 'permission': permission} json = self._json(self._patch(self._api, data=dumps(data)), 200) if json: self._update_(json) return True return False
[ "def", "edit", "(", "self", ",", "name", ",", "permission", "=", "''", ")", ":", "if", "name", ":", "data", "=", "{", "'name'", ":", "name", ",", "'permission'", ":", "permission", "}", "json", "=", "self", ".", "_json", "(", "self", ".", "_patch", "(", "self", ".", "_api", ",", "data", "=", "dumps", "(", "data", ")", ")", ",", "200", ")", "if", "json", ":", "self", ".", "_update_", "(", "json", ")", "return", "True", "return", "False" ]
Edit this team. :param str name: (required) :param str permission: (optional), ('pull', 'push', 'admin') :returns: bool
[ "Edit", "this", "team", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L98-L111
kislyuk/aegea
aegea/packages/github3/orgs.py
Team.has_repo
def has_repo(self, repo): """Checks if this team has access to ``repo`` :param str repo: (required), form: 'user/repo' :returns: bool """ url = self._build_url('repos', repo, base_url=self._api) return self._boolean(self._get(url), 204, 404)
python
def has_repo(self, repo): """Checks if this team has access to ``repo`` :param str repo: (required), form: 'user/repo' :returns: bool """ url = self._build_url('repos', repo, base_url=self._api) return self._boolean(self._get(url), 204, 404)
[ "def", "has_repo", "(", "self", ",", "repo", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'repos'", ",", "repo", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_boolean", "(", "self", ".", "_get", "(", "url", ")", ",", "204", ",", "404", ")" ]
Checks if this team has access to ``repo`` :param str repo: (required), form: 'user/repo' :returns: bool
[ "Checks", "if", "this", "team", "has", "access", "to", "repo" ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L113-L120
kislyuk/aegea
aegea/packages/github3/orgs.py
Team.invite
def invite(self, username): """Invite the user to join this team. This returns a dictionary like so:: {'state': 'pending', 'url': 'https://api.github.com/teams/...'} :param str username: (required), user to invite to join this team. :returns: dictionary """ url = self._build_url('memberships', username, base_url=self._api) return self._json(self._put(url), 200)
python
def invite(self, username): """Invite the user to join this team. This returns a dictionary like so:: {'state': 'pending', 'url': 'https://api.github.com/teams/...'} :param str username: (required), user to invite to join this team. :returns: dictionary """ url = self._build_url('memberships', username, base_url=self._api) return self._json(self._put(url), 200)
[ "def", "invite", "(", "self", ",", "username", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'memberships'", ",", "username", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_json", "(", "self", ".", "_put", "(", "url", ")", ",", "200", ")" ]
Invite the user to join this team. This returns a dictionary like so:: {'state': 'pending', 'url': 'https://api.github.com/teams/...'} :param str username: (required), user to invite to join this team. :returns: dictionary
[ "Invite", "the", "user", "to", "join", "this", "team", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L123-L134
kislyuk/aegea
aegea/packages/github3/orgs.py
Team.membership_for
def membership_for(self, username): """Retrieve the membership information for the user. :param str username: (required), name of the user :returns: dictionary """ url = self._build_url('memberships', username, base_url=self._api) json = self._json(self._get(url), 200) return json or {}
python
def membership_for(self, username): """Retrieve the membership information for the user. :param str username: (required), name of the user :returns: dictionary """ url = self._build_url('memberships', username, base_url=self._api) json = self._json(self._get(url), 200) return json or {}
[ "def", "membership_for", "(", "self", ",", "username", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'memberships'", ",", "username", ",", "base_url", "=", "self", ".", "_api", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_get", "(", "url", ")", ",", "200", ")", "return", "json", "or", "{", "}" ]
Retrieve the membership information for the user. :param str username: (required), name of the user :returns: dictionary
[ "Retrieve", "the", "membership", "information", "for", "the", "user", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L171-L179
kislyuk/aegea
aegea/packages/github3/orgs.py
Team.remove_member
def remove_member(self, login): """Remove ``login`` from this team. :param str login: (required), login of the member to remove :returns: bool """ warnings.warn( 'This is no longer supported by the GitHub API, see ' 'https://developer.github.com/changes/2014-09-23-one-more-week' '-before-the-add-team-member-api-breaking-change/', DeprecationWarning) url = self._build_url('members', login, base_url=self._api) return self._boolean(self._delete(url), 204, 404)
python
def remove_member(self, login): """Remove ``login`` from this team. :param str login: (required), login of the member to remove :returns: bool """ warnings.warn( 'This is no longer supported by the GitHub API, see ' 'https://developer.github.com/changes/2014-09-23-one-more-week' '-before-the-add-team-member-api-breaking-change/', DeprecationWarning) url = self._build_url('members', login, base_url=self._api) return self._boolean(self._delete(url), 204, 404)
[ "def", "remove_member", "(", "self", ",", "login", ")", ":", "warnings", ".", "warn", "(", "'This is no longer supported by the GitHub API, see '", "'https://developer.github.com/changes/2014-09-23-one-more-week'", "'-before-the-add-team-member-api-breaking-change/'", ",", "DeprecationWarning", ")", "url", "=", "self", ".", "_build_url", "(", "'members'", ",", "login", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_boolean", "(", "self", ".", "_delete", "(", "url", ")", ",", "204", ",", "404", ")" ]
Remove ``login`` from this team. :param str login: (required), login of the member to remove :returns: bool
[ "Remove", "login", "from", "this", "team", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L182-L194
kislyuk/aegea
aegea/packages/github3/orgs.py
Team.revoke_membership
def revoke_membership(self, username): """Revoke this user's team membership. :param str username: (required), name of the team member :returns: bool """ url = self._build_url('memberships', username, base_url=self._api) return self._boolean(self._delete(url), 204, 404)
python
def revoke_membership(self, username): """Revoke this user's team membership. :param str username: (required), name of the team member :returns: bool """ url = self._build_url('memberships', username, base_url=self._api) return self._boolean(self._delete(url), 204, 404)
[ "def", "revoke_membership", "(", "self", ",", "username", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'memberships'", ",", "username", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_boolean", "(", "self", ".", "_delete", "(", "url", ")", ",", "204", ",", "404", ")" ]
Revoke this user's team membership. :param str username: (required), name of the team member :returns: bool
[ "Revoke", "this", "user", "s", "team", "membership", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L197-L204
kislyuk/aegea
aegea/packages/github3/orgs.py
Team.remove_repo
def remove_repo(self, repo): """Remove ``repo`` from this team. :param str repo: (required), form: 'user/repo' :returns: bool """ url = self._build_url('repos', repo, base_url=self._api) return self._boolean(self._delete(url), 204, 404)
python
def remove_repo(self, repo): """Remove ``repo`` from this team. :param str repo: (required), form: 'user/repo' :returns: bool """ url = self._build_url('repos', repo, base_url=self._api) return self._boolean(self._delete(url), 204, 404)
[ "def", "remove_repo", "(", "self", ",", "repo", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'repos'", ",", "repo", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_boolean", "(", "self", ".", "_delete", "(", "url", ")", ",", "204", ",", "404", ")" ]
Remove ``repo`` from this team. :param str repo: (required), form: 'user/repo' :returns: bool
[ "Remove", "repo", "from", "this", "team", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L207-L214
kislyuk/aegea
aegea/packages/github3/orgs.py
Organization.add_member
def add_member(self, login, team): """Add ``login`` to ``team`` and thereby to this organization. .. warning:: This method is no longer valid. To add a member to a team, you must now retrieve the team directly, and use the ``invite`` method. Any user that is to be added to an organization, must be added to a team as per the GitHub api. .. note:: This method is of complexity O(n). This iterates over all teams in your organization and only adds the user when the team name matches the team parameter above. If you want constant time, you should retrieve the team and call ``add_member`` on that team directly. :param str login: (required), login name of the user to be added :param str team: (required), team name :returns: bool """ warnings.warn( 'This is no longer supported by the GitHub API, see ' 'https://developer.github.com/changes/2014-09-23-one-more-week' '-before-the-add-team-member-api-breaking-change/', DeprecationWarning) for t in self.iter_teams(): if team == t.name: return t.add_member(login) return False
python
def add_member(self, login, team): """Add ``login`` to ``team`` and thereby to this organization. .. warning:: This method is no longer valid. To add a member to a team, you must now retrieve the team directly, and use the ``invite`` method. Any user that is to be added to an organization, must be added to a team as per the GitHub api. .. note:: This method is of complexity O(n). This iterates over all teams in your organization and only adds the user when the team name matches the team parameter above. If you want constant time, you should retrieve the team and call ``add_member`` on that team directly. :param str login: (required), login name of the user to be added :param str team: (required), team name :returns: bool """ warnings.warn( 'This is no longer supported by the GitHub API, see ' 'https://developer.github.com/changes/2014-09-23-one-more-week' '-before-the-add-team-member-api-breaking-change/', DeprecationWarning) for t in self.iter_teams(): if team == t.name: return t.add_member(login) return False
[ "def", "add_member", "(", "self", ",", "login", ",", "team", ")", ":", "warnings", ".", "warn", "(", "'This is no longer supported by the GitHub API, see '", "'https://developer.github.com/changes/2014-09-23-one-more-week'", "'-before-the-add-team-member-api-breaking-change/'", ",", "DeprecationWarning", ")", "for", "t", "in", "self", ".", "iter_teams", "(", ")", ":", "if", "team", "==", "t", ".", "name", ":", "return", "t", ".", "add_member", "(", "login", ")", "return", "False" ]
Add ``login`` to ``team`` and thereby to this organization. .. warning:: This method is no longer valid. To add a member to a team, you must now retrieve the team directly, and use the ``invite`` method. Any user that is to be added to an organization, must be added to a team as per the GitHub api. .. note:: This method is of complexity O(n). This iterates over all teams in your organization and only adds the user when the team name matches the team parameter above. If you want constant time, you should retrieve the team and call ``add_member`` on that team directly. :param str login: (required), login name of the user to be added :param str team: (required), team name :returns: bool
[ "Add", "login", "to", "team", "and", "thereby", "to", "this", "organization", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L256-L286
kislyuk/aegea
aegea/packages/github3/orgs.py
Organization.add_repo
def add_repo(self, repo, team): """Add ``repo`` to ``team``. .. note:: This method is of complexity O(n). This iterates over all teams in your organization and only adds the repo when the team name matches the team parameter above. If you want constant time, you should retrieve the team and call ``add_repo`` on that team directly. :param str repo: (required), form: 'user/repo' :param str team: (required), team name """ for t in self.iter_teams(): if team == t.name: return t.add_repo(repo) return False
python
def add_repo(self, repo, team): """Add ``repo`` to ``team``. .. note:: This method is of complexity O(n). This iterates over all teams in your organization and only adds the repo when the team name matches the team parameter above. If you want constant time, you should retrieve the team and call ``add_repo`` on that team directly. :param str repo: (required), form: 'user/repo' :param str team: (required), team name """ for t in self.iter_teams(): if team == t.name: return t.add_repo(repo) return False
[ "def", "add_repo", "(", "self", ",", "repo", ",", "team", ")", ":", "for", "t", "in", "self", ".", "iter_teams", "(", ")", ":", "if", "team", "==", "t", ".", "name", ":", "return", "t", ".", "add_repo", "(", "repo", ")", "return", "False" ]
Add ``repo`` to ``team``. .. note:: This method is of complexity O(n). This iterates over all teams in your organization and only adds the repo when the team name matches the team parameter above. If you want constant time, you should retrieve the team and call ``add_repo`` on that team directly. :param str repo: (required), form: 'user/repo' :param str team: (required), team name
[ "Add", "repo", "to", "team", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L289-L305
kislyuk/aegea
aegea/packages/github3/orgs.py
Organization.create_repo
def create_repo(self, name, description='', homepage='', private=False, has_issues=True, has_wiki=True, has_downloads=True, team_id=0, auto_init=False, gitignore_template=''): """Create a repository for this organization if the authenticated user is a member. :param str name: (required), name of the repository :param str description: (optional) :param str homepage: (optional) :param bool private: (optional), If ``True``, create a private repository. API default: ``False`` :param bool has_issues: (optional), If ``True``, enable issues for this repository. API default: ``True`` :param bool has_wiki: (optional), If ``True``, enable the wiki for this repository. API default: ``True`` :param bool has_downloads: (optional), If ``True``, enable downloads for this repository. API default: ``True`` :param int team_id: (optional), id of the team that will be granted access to this repository :param bool auto_init: (optional), auto initialize the repository. :param str gitignore_template: (optional), name of the template; this is ignored if auto_int = False. :returns: :class:`Repository <github3.repos.Repository>` .. warning: ``name`` should be no longer than 100 characters """ url = self._build_url('repos', base_url=self._api) data = {'name': name, 'description': description, 'homepage': homepage, 'private': private, 'has_issues': has_issues, 'has_wiki': has_wiki, 'has_downloads': has_downloads, 'auto_init': auto_init, 'gitignore_template': gitignore_template} if team_id > 0: data.update({'team_id': team_id}) json = self._json(self._post(url, data), 201) return Repository(json, self) if json else None
python
def create_repo(self, name, description='', homepage='', private=False, has_issues=True, has_wiki=True, has_downloads=True, team_id=0, auto_init=False, gitignore_template=''): """Create a repository for this organization if the authenticated user is a member. :param str name: (required), name of the repository :param str description: (optional) :param str homepage: (optional) :param bool private: (optional), If ``True``, create a private repository. API default: ``False`` :param bool has_issues: (optional), If ``True``, enable issues for this repository. API default: ``True`` :param bool has_wiki: (optional), If ``True``, enable the wiki for this repository. API default: ``True`` :param bool has_downloads: (optional), If ``True``, enable downloads for this repository. API default: ``True`` :param int team_id: (optional), id of the team that will be granted access to this repository :param bool auto_init: (optional), auto initialize the repository. :param str gitignore_template: (optional), name of the template; this is ignored if auto_int = False. :returns: :class:`Repository <github3.repos.Repository>` .. warning: ``name`` should be no longer than 100 characters """ url = self._build_url('repos', base_url=self._api) data = {'name': name, 'description': description, 'homepage': homepage, 'private': private, 'has_issues': has_issues, 'has_wiki': has_wiki, 'has_downloads': has_downloads, 'auto_init': auto_init, 'gitignore_template': gitignore_template} if team_id > 0: data.update({'team_id': team_id}) json = self._json(self._post(url, data), 201) return Repository(json, self) if json else None
[ "def", "create_repo", "(", "self", ",", "name", ",", "description", "=", "''", ",", "homepage", "=", "''", ",", "private", "=", "False", ",", "has_issues", "=", "True", ",", "has_wiki", "=", "True", ",", "has_downloads", "=", "True", ",", "team_id", "=", "0", ",", "auto_init", "=", "False", ",", "gitignore_template", "=", "''", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'repos'", ",", "base_url", "=", "self", ".", "_api", ")", "data", "=", "{", "'name'", ":", "name", ",", "'description'", ":", "description", ",", "'homepage'", ":", "homepage", ",", "'private'", ":", "private", ",", "'has_issues'", ":", "has_issues", ",", "'has_wiki'", ":", "has_wiki", ",", "'has_downloads'", ":", "has_downloads", ",", "'auto_init'", ":", "auto_init", ",", "'gitignore_template'", ":", "gitignore_template", "}", "if", "team_id", ">", "0", ":", "data", ".", "update", "(", "{", "'team_id'", ":", "team_id", "}", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_post", "(", "url", ",", "data", ")", ",", "201", ")", "return", "Repository", "(", "json", ",", "self", ")", "if", "json", "else", "None" ]
Create a repository for this organization if the authenticated user is a member. :param str name: (required), name of the repository :param str description: (optional) :param str homepage: (optional) :param bool private: (optional), If ``True``, create a private repository. API default: ``False`` :param bool has_issues: (optional), If ``True``, enable issues for this repository. API default: ``True`` :param bool has_wiki: (optional), If ``True``, enable the wiki for this repository. API default: ``True`` :param bool has_downloads: (optional), If ``True``, enable downloads for this repository. API default: ``True`` :param int team_id: (optional), id of the team that will be granted access to this repository :param bool auto_init: (optional), auto initialize the repository. :param str gitignore_template: (optional), name of the template; this is ignored if auto_int = False. :returns: :class:`Repository <github3.repos.Repository>` .. warning: ``name`` should be no longer than 100 characters
[ "Create", "a", "repository", "for", "this", "organization", "if", "the", "authenticated", "user", "is", "a", "member", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L308-L351
kislyuk/aegea
aegea/packages/github3/orgs.py
Organization.conceal_member
def conceal_member(self, login): """Conceal ``login``'s membership in this organization. :returns: bool """ url = self._build_url('public_members', login, base_url=self._api) return self._boolean(self._delete(url), 204, 404)
python
def conceal_member(self, login): """Conceal ``login``'s membership in this organization. :returns: bool """ url = self._build_url('public_members', login, base_url=self._api) return self._boolean(self._delete(url), 204, 404)
[ "def", "conceal_member", "(", "self", ",", "login", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'public_members'", ",", "login", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_boolean", "(", "self", ".", "_delete", "(", "url", ")", ",", "204", ",", "404", ")" ]
Conceal ``login``'s membership in this organization. :returns: bool
[ "Conceal", "login", "s", "membership", "in", "this", "organization", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L354-L360
kislyuk/aegea
aegea/packages/github3/orgs.py
Organization.create_team
def create_team(self, name, repo_names=[], permission=''): """Assuming the authenticated user owns this organization, create and return a new team. :param str name: (required), name to be given to the team :param list repo_names: (optional) repositories, e.g. ['github/dotfiles'] :param str permission: (optional), options: - ``pull`` -- (default) members can not push or administer repositories accessible by this team - ``push`` -- members can push and pull but not administer repositories accessible by this team - ``admin`` -- members can push, pull and administer repositories accessible by this team :returns: :class:`Team <Team>` """ data = {'name': name, 'repo_names': repo_names, 'permission': permission} url = self._build_url('teams', base_url=self._api) json = self._json(self._post(url, data), 201) return Team(json, self._session) if json else None
python
def create_team(self, name, repo_names=[], permission=''): """Assuming the authenticated user owns this organization, create and return a new team. :param str name: (required), name to be given to the team :param list repo_names: (optional) repositories, e.g. ['github/dotfiles'] :param str permission: (optional), options: - ``pull`` -- (default) members can not push or administer repositories accessible by this team - ``push`` -- members can push and pull but not administer repositories accessible by this team - ``admin`` -- members can push, pull and administer repositories accessible by this team :returns: :class:`Team <Team>` """ data = {'name': name, 'repo_names': repo_names, 'permission': permission} url = self._build_url('teams', base_url=self._api) json = self._json(self._post(url, data), 201) return Team(json, self._session) if json else None
[ "def", "create_team", "(", "self", ",", "name", ",", "repo_names", "=", "[", "]", ",", "permission", "=", "''", ")", ":", "data", "=", "{", "'name'", ":", "name", ",", "'repo_names'", ":", "repo_names", ",", "'permission'", ":", "permission", "}", "url", "=", "self", ".", "_build_url", "(", "'teams'", ",", "base_url", "=", "self", ".", "_api", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_post", "(", "url", ",", "data", ")", ",", "201", ")", "return", "Team", "(", "json", ",", "self", ".", "_session", ")", "if", "json", "else", "None" ]
Assuming the authenticated user owns this organization, create and return a new team. :param str name: (required), name to be given to the team :param list repo_names: (optional) repositories, e.g. ['github/dotfiles'] :param str permission: (optional), options: - ``pull`` -- (default) members can not push or administer repositories accessible by this team - ``push`` -- members can push and pull but not administer repositories accessible by this team - ``admin`` -- members can push, pull and administer repositories accessible by this team :returns: :class:`Team <Team>`
[ "Assuming", "the", "authenticated", "user", "owns", "this", "organization", "create", "and", "return", "a", "new", "team", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L363-L385
kislyuk/aegea
aegea/packages/github3/orgs.py
Organization.edit
def edit(self, billing_email=None, company=None, email=None, location=None, name=None): """Edit this organization. :param str billing_email: (optional) Billing email address (private) :param str company: (optional) :param str email: (optional) Public email address :param str location: (optional) :param str name: (optional) :returns: bool """ json = None data = {'billing_email': billing_email, 'company': company, 'email': email, 'location': location, 'name': name} self._remove_none(data) if data: json = self._json(self._patch(self._api, data=dumps(data)), 200) if json: self._update_(json) return True return False
python
def edit(self, billing_email=None, company=None, email=None, location=None, name=None): """Edit this organization. :param str billing_email: (optional) Billing email address (private) :param str company: (optional) :param str email: (optional) Public email address :param str location: (optional) :param str name: (optional) :returns: bool """ json = None data = {'billing_email': billing_email, 'company': company, 'email': email, 'location': location, 'name': name} self._remove_none(data) if data: json = self._json(self._patch(self._api, data=dumps(data)), 200) if json: self._update_(json) return True return False
[ "def", "edit", "(", "self", ",", "billing_email", "=", "None", ",", "company", "=", "None", ",", "email", "=", "None", ",", "location", "=", "None", ",", "name", "=", "None", ")", ":", "json", "=", "None", "data", "=", "{", "'billing_email'", ":", "billing_email", ",", "'company'", ":", "company", ",", "'email'", ":", "email", ",", "'location'", ":", "location", ",", "'name'", ":", "name", "}", "self", ".", "_remove_none", "(", "data", ")", "if", "data", ":", "json", "=", "self", ".", "_json", "(", "self", ".", "_patch", "(", "self", ".", "_api", ",", "data", "=", "dumps", "(", "data", ")", ")", ",", "200", ")", "if", "json", ":", "self", ".", "_update_", "(", "json", ")", "return", "True", "return", "False" ]
Edit this organization. :param str billing_email: (optional) Billing email address (private) :param str company: (optional) :param str email: (optional) Public email address :param str location: (optional) :param str name: (optional) :returns: bool
[ "Edit", "this", "organization", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L388-L414
kislyuk/aegea
aegea/packages/github3/orgs.py
Organization.is_public_member
def is_public_member(self, login): """Check if the user with login ``login`` is a public member. :returns: bool """ url = self._build_url('public_members', login, base_url=self._api) return self._boolean(self._get(url), 204, 404)
python
def is_public_member(self, login): """Check if the user with login ``login`` is a public member. :returns: bool """ url = self._build_url('public_members', login, base_url=self._api) return self._boolean(self._get(url), 204, 404)
[ "def", "is_public_member", "(", "self", ",", "login", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'public_members'", ",", "login", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_boolean", "(", "self", ".", "_get", "(", "url", ")", ",", "204", ",", "404", ")" ]
Check if the user with login ``login`` is a public member. :returns: bool
[ "Check", "if", "the", "user", "with", "login", "login", "is", "a", "public", "member", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L424-L430
kislyuk/aegea
aegea/packages/github3/orgs.py
Organization.iter_repos
def iter_repos(self, type='', number=-1, etag=None): """Iterate over repos for this organization. :param str type: (optional), accepted values: ('all', 'public', 'member', 'private', 'forks', 'sources'), API default: 'all' :param int number: (optional), number of members to return. Default: -1 will return all available. :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Repository <github3.repos.Repository>` """ url = self._build_url('repos', base_url=self._api) params = {} if type in ('all', 'public', 'member', 'private', 'forks', 'sources'): params['type'] = type return self._iter(int(number), url, Repository, params, etag)
python
def iter_repos(self, type='', number=-1, etag=None): """Iterate over repos for this organization. :param str type: (optional), accepted values: ('all', 'public', 'member', 'private', 'forks', 'sources'), API default: 'all' :param int number: (optional), number of members to return. Default: -1 will return all available. :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Repository <github3.repos.Repository>` """ url = self._build_url('repos', base_url=self._api) params = {} if type in ('all', 'public', 'member', 'private', 'forks', 'sources'): params['type'] = type return self._iter(int(number), url, Repository, params, etag)
[ "def", "iter_repos", "(", "self", ",", "type", "=", "''", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'repos'", ",", "base_url", "=", "self", ".", "_api", ")", "params", "=", "{", "}", "if", "type", "in", "(", "'all'", ",", "'public'", ",", "'member'", ",", "'private'", ",", "'forks'", ",", "'sources'", ")", ":", "params", "[", "'type'", "]", "=", "type", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "Repository", ",", "params", ",", "etag", ")" ]
Iterate over repos for this organization. :param str type: (optional), accepted values: ('all', 'public', 'member', 'private', 'forks', 'sources'), API default: 'all' :param int number: (optional), number of members to return. Default: -1 will return all available. :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Repository <github3.repos.Repository>`
[ "Iterate", "over", "repos", "for", "this", "organization", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L468-L484
kislyuk/aegea
aegea/packages/github3/orgs.py
Organization.iter_teams
def iter_teams(self, number=-1, etag=None): """Iterate over teams that are part of this organization. :param int number: (optional), number of teams to return. Default: -1 returns all available teams. :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Team <Team>`\ s """ url = self._build_url('teams', base_url=self._api) return self._iter(int(number), url, Team, etag=etag)
python
def iter_teams(self, number=-1, etag=None): """Iterate over teams that are part of this organization. :param int number: (optional), number of teams to return. Default: -1 returns all available teams. :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Team <Team>`\ s """ url = self._build_url('teams', base_url=self._api) return self._iter(int(number), url, Team, etag=etag)
[ "def", "iter_teams", "(", "self", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'teams'", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "Team", ",", "etag", "=", "etag", ")" ]
Iterate over teams that are part of this organization. :param int number: (optional), number of teams to return. Default: -1 returns all available teams. :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Team <Team>`\ s
[ "Iterate", "over", "teams", "that", "are", "part", "of", "this", "organization", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L487-L497
kislyuk/aegea
aegea/packages/github3/orgs.py
Organization.publicize_member
def publicize_member(self, login): """Make ``login``'s membership in this organization public. :returns: bool """ url = self._build_url('public_members', login, base_url=self._api) return self._boolean(self._put(url), 204, 404)
python
def publicize_member(self, login): """Make ``login``'s membership in this organization public. :returns: bool """ url = self._build_url('public_members', login, base_url=self._api) return self._boolean(self._put(url), 204, 404)
[ "def", "publicize_member", "(", "self", ",", "login", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'public_members'", ",", "login", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_boolean", "(", "self", ".", "_put", "(", "url", ")", ",", "204", ",", "404", ")" ]
Make ``login``'s membership in this organization public. :returns: bool
[ "Make", "login", "s", "membership", "in", "this", "organization", "public", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L500-L506
kislyuk/aegea
aegea/packages/github3/orgs.py
Organization.remove_repo
def remove_repo(self, repo, team): """Remove ``repo`` from ``team``. :param str repo: (required), form: 'user/repo' :param str team: (required) :returns: bool """ for t in self.iter_teams(): if team == t.name: return t.remove_repo(repo) return False
python
def remove_repo(self, repo, team): """Remove ``repo`` from ``team``. :param str repo: (required), form: 'user/repo' :param str team: (required) :returns: bool """ for t in self.iter_teams(): if team == t.name: return t.remove_repo(repo) return False
[ "def", "remove_repo", "(", "self", ",", "repo", ",", "team", ")", ":", "for", "t", "in", "self", ".", "iter_teams", "(", ")", ":", "if", "team", "==", "t", ".", "name", ":", "return", "t", ".", "remove_repo", "(", "repo", ")", "return", "False" ]
Remove ``repo`` from ``team``. :param str repo: (required), form: 'user/repo' :param str team: (required) :returns: bool
[ "Remove", "repo", "from", "team", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L519-L529
kislyuk/aegea
aegea/packages/github3/orgs.py
Organization.team
def team(self, team_id): """Returns Team object with information about team specified by ``team_id``. :param int team_id: (required), unique id for the team :returns: :class:`Team <Team>` """ json = None if int(team_id) > 0: url = self._build_url('teams', str(team_id)) json = self._json(self._get(url), 200) return Team(json, self._session) if json else None
python
def team(self, team_id): """Returns Team object with information about team specified by ``team_id``. :param int team_id: (required), unique id for the team :returns: :class:`Team <Team>` """ json = None if int(team_id) > 0: url = self._build_url('teams', str(team_id)) json = self._json(self._get(url), 200) return Team(json, self._session) if json else None
[ "def", "team", "(", "self", ",", "team_id", ")", ":", "json", "=", "None", "if", "int", "(", "team_id", ")", ">", "0", ":", "url", "=", "self", ".", "_build_url", "(", "'teams'", ",", "str", "(", "team_id", ")", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_get", "(", "url", ")", ",", "200", ")", "return", "Team", "(", "json", ",", "self", ".", "_session", ")", "if", "json", "else", "None" ]
Returns Team object with information about team specified by ``team_id``. :param int team_id: (required), unique id for the team :returns: :class:`Team <Team>`
[ "Returns", "Team", "object", "with", "information", "about", "team", "specified", "by", "team_id", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L532-L543
kislyuk/aegea
aegea/packages/github3/orgs.py
Membership.edit
def edit(self, state): """Edit the user's membership. :param str state: (required), the state the membership should be in. Only accepts ``"active"``. :returns: itself """ if state and state.lower() == 'active': data = dumps({'state': state.lower()}) json = self._json(self._patch(self._api, data=data)) self._update_attributes(json) return self
python
def edit(self, state): """Edit the user's membership. :param str state: (required), the state the membership should be in. Only accepts ``"active"``. :returns: itself """ if state and state.lower() == 'active': data = dumps({'state': state.lower()}) json = self._json(self._patch(self._api, data=data)) self._update_attributes(json) return self
[ "def", "edit", "(", "self", ",", "state", ")", ":", "if", "state", "and", "state", ".", "lower", "(", ")", "==", "'active'", ":", "data", "=", "dumps", "(", "{", "'state'", ":", "state", ".", "lower", "(", ")", "}", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_patch", "(", "self", ".", "_api", ",", "data", "=", "data", ")", ")", "self", ".", "_update_attributes", "(", "json", ")", "return", "self" ]
Edit the user's membership. :param str state: (required), the state the membership should be in. Only accepts ``"active"``. :returns: itself
[ "Edit", "the", "user", "s", "membership", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/orgs.py#L567-L578
kislyuk/aegea
aegea/packages/github3/repos/release.py
Release.delete
def delete(self): """Users with push access to the repository can delete a release. :returns: True if successful; False if not successful """ url = self._api return self._boolean( self._delete(url, headers=Release.CUSTOM_HEADERS), 204, 404 )
python
def delete(self): """Users with push access to the repository can delete a release. :returns: True if successful; False if not successful """ url = self._api return self._boolean( self._delete(url, headers=Release.CUSTOM_HEADERS), 204, 404 )
[ "def", "delete", "(", "self", ")", ":", "url", "=", "self", ".", "_api", "return", "self", ".", "_boolean", "(", "self", ".", "_delete", "(", "url", ",", "headers", "=", "Release", ".", "CUSTOM_HEADERS", ")", ",", "204", ",", "404", ")" ]
Users with push access to the repository can delete a release. :returns: True if successful; False if not successful
[ "Users", "with", "push", "access", "to", "the", "repository", "can", "delete", "a", "release", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/release.py#L57-L67
kislyuk/aegea
aegea/packages/github3/repos/release.py
Release.edit
def edit(self, tag_name=None, target_commitish=None, name=None, body=None, draft=None, prerelease=None): """Users with push access to the repository can edit a release. If the edit is successful, this object will update itself. :param str tag_name: (optional), Name of the tag to use :param str target_commitish: (optional), The "commitish" value that determines where the Git tag is created from. Defaults to the repository's default branch. :param str name: (optional), Name of the release :param str body: (optional), Description of the release :param boolean draft: (optional), True => Release is a draft :param boolean prerelease: (optional), True => Release is a prerelease :returns: True if successful; False if not successful """ url = self._api data = { 'tag_name': tag_name, 'target_commitish': target_commitish, 'name': name, 'body': body, 'draft': draft, 'prerelease': prerelease, } self._remove_none(data) r = self._session.patch( url, data=json.dumps(data), headers=Release.CUSTOM_HEADERS ) successful = self._boolean(r, 200, 404) if successful: # If the edit was successful, let's update the object. self.__init__(r.json(), self) return successful
python
def edit(self, tag_name=None, target_commitish=None, name=None, body=None, draft=None, prerelease=None): """Users with push access to the repository can edit a release. If the edit is successful, this object will update itself. :param str tag_name: (optional), Name of the tag to use :param str target_commitish: (optional), The "commitish" value that determines where the Git tag is created from. Defaults to the repository's default branch. :param str name: (optional), Name of the release :param str body: (optional), Description of the release :param boolean draft: (optional), True => Release is a draft :param boolean prerelease: (optional), True => Release is a prerelease :returns: True if successful; False if not successful """ url = self._api data = { 'tag_name': tag_name, 'target_commitish': target_commitish, 'name': name, 'body': body, 'draft': draft, 'prerelease': prerelease, } self._remove_none(data) r = self._session.patch( url, data=json.dumps(data), headers=Release.CUSTOM_HEADERS ) successful = self._boolean(r, 200, 404) if successful: # If the edit was successful, let's update the object. self.__init__(r.json(), self) return successful
[ "def", "edit", "(", "self", ",", "tag_name", "=", "None", ",", "target_commitish", "=", "None", ",", "name", "=", "None", ",", "body", "=", "None", ",", "draft", "=", "None", ",", "prerelease", "=", "None", ")", ":", "url", "=", "self", ".", "_api", "data", "=", "{", "'tag_name'", ":", "tag_name", ",", "'target_commitish'", ":", "target_commitish", ",", "'name'", ":", "name", ",", "'body'", ":", "body", ",", "'draft'", ":", "draft", ",", "'prerelease'", ":", "prerelease", ",", "}", "self", ".", "_remove_none", "(", "data", ")", "r", "=", "self", ".", "_session", ".", "patch", "(", "url", ",", "data", "=", "json", ".", "dumps", "(", "data", ")", ",", "headers", "=", "Release", ".", "CUSTOM_HEADERS", ")", "successful", "=", "self", ".", "_boolean", "(", "r", ",", "200", ",", "404", ")", "if", "successful", ":", "# If the edit was successful, let's update the object.", "self", ".", "__init__", "(", "r", ".", "json", "(", ")", ",", "self", ")", "return", "successful" ]
Users with push access to the repository can edit a release. If the edit is successful, this object will update itself. :param str tag_name: (optional), Name of the tag to use :param str target_commitish: (optional), The "commitish" value that determines where the Git tag is created from. Defaults to the repository's default branch. :param str name: (optional), Name of the release :param str body: (optional), Description of the release :param boolean draft: (optional), True => Release is a draft :param boolean prerelease: (optional), True => Release is a prerelease :returns: True if successful; False if not successful
[ "Users", "with", "push", "access", "to", "the", "repository", "can", "edit", "a", "release", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/release.py#L70-L106
kislyuk/aegea
aegea/packages/github3/repos/release.py
Release.iter_assets
def iter_assets(self, number=-1, etag=None): """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 """ url = self._build_url('assets', base_url=self._api) return self._iter(number, url, Asset, etag=etag)
python
def iter_assets(self, number=-1, etag=None): """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 """ url = self._build_url('assets', base_url=self._api) return self._iter(number, url, Asset, etag=etag)
[ "def", "iter_assets", "(", "self", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'assets'", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_iter", "(", "number", ",", "url", ",", "Asset", ",", "etag", "=", "etag", ")" ]
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
[ "Iterate", "over", "the", "assets", "available", "for", "this", "release", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/release.py#L108-L116
kislyuk/aegea
aegea/packages/github3/repos/release.py
Release.upload_asset
def upload_asset(self, content_type, name, asset): """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:`Asset <Asset>` """ headers = Release.CUSTOM_HEADERS.copy() headers.update({'Content-Type': content_type}) url = self.upload_urlt.expand({'name': name}) r = self._post(url, data=asset, json=False, headers=headers, verify=False) if r.status_code in (201, 202): return Asset(r.json(), self) raise GitHubError(r)
python
def upload_asset(self, content_type, name, asset): """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:`Asset <Asset>` """ headers = Release.CUSTOM_HEADERS.copy() headers.update({'Content-Type': content_type}) url = self.upload_urlt.expand({'name': name}) r = self._post(url, data=asset, json=False, headers=headers, verify=False) if r.status_code in (201, 202): return Asset(r.json(), self) raise GitHubError(r)
[ "def", "upload_asset", "(", "self", ",", "content_type", ",", "name", ",", "asset", ")", ":", "headers", "=", "Release", ".", "CUSTOM_HEADERS", ".", "copy", "(", ")", "headers", ".", "update", "(", "{", "'Content-Type'", ":", "content_type", "}", ")", "url", "=", "self", ".", "upload_urlt", ".", "expand", "(", "{", "'name'", ":", "name", "}", ")", "r", "=", "self", ".", "_post", "(", "url", ",", "data", "=", "asset", ",", "json", "=", "False", ",", "headers", "=", "headers", ",", "verify", "=", "False", ")", "if", "r", ".", "status_code", "in", "(", "201", ",", "202", ")", ":", "return", "Asset", "(", "r", ".", "json", "(", ")", ",", "self", ")", "raise", "GitHubError", "(", "r", ")" ]
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:`Asset <Asset>`
[ "Upload", "an", "asset", "to", "this", "release", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/release.py#L119-L137
kislyuk/aegea
aegea/packages/github3/repos/release.py
Asset.download
def download(self, path=''): """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 :returns: bool -- True if successful, False otherwise """ headers = { 'Accept': 'application/octet-stream' } resp = self._get(self._api, allow_redirects=False, stream=True, headers=headers) if resp.status_code == 302: # Amazon S3 will reject the redirected request unless we omit # certain request headers headers.update({ 'Content-Type': None, }) with self._session.no_auth(): resp = self._get(resp.headers['location'], stream=True, headers=headers) if self._boolean(resp, 200, 404): stream_response_to_file(resp, path) return True return False
python
def download(self, path=''): """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 :returns: bool -- True if successful, False otherwise """ headers = { 'Accept': 'application/octet-stream' } resp = self._get(self._api, allow_redirects=False, stream=True, headers=headers) if resp.status_code == 302: # Amazon S3 will reject the redirected request unless we omit # certain request headers headers.update({ 'Content-Type': None, }) with self._session.no_auth(): resp = self._get(resp.headers['location'], stream=True, headers=headers) if self._boolean(resp, 200, 404): stream_response_to_file(resp, path) return True return False
[ "def", "download", "(", "self", ",", "path", "=", "''", ")", ":", "headers", "=", "{", "'Accept'", ":", "'application/octet-stream'", "}", "resp", "=", "self", ".", "_get", "(", "self", ".", "_api", ",", "allow_redirects", "=", "False", ",", "stream", "=", "True", ",", "headers", "=", "headers", ")", "if", "resp", ".", "status_code", "==", "302", ":", "# Amazon S3 will reject the redirected request unless we omit", "# certain request headers", "headers", ".", "update", "(", "{", "'Content-Type'", ":", "None", ",", "}", ")", "with", "self", ".", "_session", ".", "no_auth", "(", ")", ":", "resp", "=", "self", ".", "_get", "(", "resp", ".", "headers", "[", "'location'", "]", ",", "stream", "=", "True", ",", "headers", "=", "headers", ")", "if", "self", ".", "_boolean", "(", "resp", ",", "200", ",", "404", ")", ":", "stream_response_to_file", "(", "resp", ",", "path", ")", "return", "True", "return", "False" ]
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 :returns: bool -- True if successful, False otherwise
[ "Download", "the", "data", "for", "this", "asset", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/release.py#L169-L197
kislyuk/aegea
aegea/packages/github3/repos/release.py
Asset.edit
def edit(self, name, label=None): """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 """ if not name: return False edit_data = {'name': name, 'label': label} self._remove_none(edit_data) r = self._patch( self._api, data=json.dumps(edit_data), headers=Release.CUSTOM_HEADERS ) successful = self._boolean(r, 200, 404) if successful: self.__init__(r.json(), self) return successful
python
def edit(self, name, label=None): """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 """ if not name: return False edit_data = {'name': name, 'label': label} self._remove_none(edit_data) r = self._patch( self._api, data=json.dumps(edit_data), headers=Release.CUSTOM_HEADERS ) successful = self._boolean(r, 200, 404) if successful: self.__init__(r.json(), self) return successful
[ "def", "edit", "(", "self", ",", "name", ",", "label", "=", "None", ")", ":", "if", "not", "name", ":", "return", "False", "edit_data", "=", "{", "'name'", ":", "name", ",", "'label'", ":", "label", "}", "self", ".", "_remove_none", "(", "edit_data", ")", "r", "=", "self", ".", "_patch", "(", "self", ".", "_api", ",", "data", "=", "json", ".", "dumps", "(", "edit_data", ")", ",", "headers", "=", "Release", ".", "CUSTOM_HEADERS", ")", "successful", "=", "self", ".", "_boolean", "(", "r", ",", "200", ",", "404", ")", "if", "successful", ":", "self", ".", "__init__", "(", "r", ".", "json", "(", ")", ",", "self", ")", "return", "successful" ]
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
[ "Edit", "this", "asset", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/release.py#L199-L219
kislyuk/aegea
aegea/deploy.py
ls
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.now(tzutc()) - timedelta(days=15) for topic in resources.sns.topics.all(): account_id = ARN(topic.arn).account_id try: bucket = resources.s3.Bucket("deploy-status-{}".format(account_id)) status_objects = bucket.objects.filter(Prefix=ARN(topic.arn).resource) recent_status_objects = {o.key: o for o in status_objects if o.last_modified > max_age} except ClientError: continue if ARN(topic.arn).resource.startswith("github"): for queue in queues: queue_name = os.path.basename(queue.url) if queue_name.startswith(ARN(topic.arn).resource): row = dict(Topic=topic, Queue=queue) status_object = bucket.Object(os.path.join(queue_name, "status")) if status_object.key not in recent_status_objects: continue try: github, owner, repo, events, instance = os.path.dirname(status_object.key).split("-", 4) status = json.loads(status_object.get()["Body"].read().decode("utf-8")) row.update(status, Owner=owner, Repo=repo, Instance=instance, Updated=status_object.last_modified) except Exception: pass table.append(row) args.columns = ["Owner", "Repo", "Instance", "Status", "Ref", "Commit", "Updated", "Topic", "Queue"] page_output(tabulate(table, args))
python
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.now(tzutc()) - timedelta(days=15) for topic in resources.sns.topics.all(): account_id = ARN(topic.arn).account_id try: bucket = resources.s3.Bucket("deploy-status-{}".format(account_id)) status_objects = bucket.objects.filter(Prefix=ARN(topic.arn).resource) recent_status_objects = {o.key: o for o in status_objects if o.last_modified > max_age} except ClientError: continue if ARN(topic.arn).resource.startswith("github"): for queue in queues: queue_name = os.path.basename(queue.url) if queue_name.startswith(ARN(topic.arn).resource): row = dict(Topic=topic, Queue=queue) status_object = bucket.Object(os.path.join(queue_name, "status")) if status_object.key not in recent_status_objects: continue try: github, owner, repo, events, instance = os.path.dirname(status_object.key).split("-", 4) status = json.loads(status_object.get()["Body"].read().decode("utf-8")) row.update(status, Owner=owner, Repo=repo, Instance=instance, Updated=status_object.last_modified) except Exception: pass table.append(row) args.columns = ["Owner", "Repo", "Instance", "Status", "Ref", "Commit", "Updated", "Topic", "Queue"] page_output(tabulate(table, args))
[ "def", "ls", "(", "args", ")", ":", "table", "=", "[", "]", "queues", "=", "list", "(", "resources", ".", "sqs", ".", "queues", ".", "filter", "(", "QueueNamePrefix", "=", "\"github\"", ")", ")", "max_age", "=", "datetime", ".", "now", "(", "tzutc", "(", ")", ")", "-", "timedelta", "(", "days", "=", "15", ")", "for", "topic", "in", "resources", ".", "sns", ".", "topics", ".", "all", "(", ")", ":", "account_id", "=", "ARN", "(", "topic", ".", "arn", ")", ".", "account_id", "try", ":", "bucket", "=", "resources", ".", "s3", ".", "Bucket", "(", "\"deploy-status-{}\"", ".", "format", "(", "account_id", ")", ")", "status_objects", "=", "bucket", ".", "objects", ".", "filter", "(", "Prefix", "=", "ARN", "(", "topic", ".", "arn", ")", ".", "resource", ")", "recent_status_objects", "=", "{", "o", ".", "key", ":", "o", "for", "o", "in", "status_objects", "if", "o", ".", "last_modified", ">", "max_age", "}", "except", "ClientError", ":", "continue", "if", "ARN", "(", "topic", ".", "arn", ")", ".", "resource", ".", "startswith", "(", "\"github\"", ")", ":", "for", "queue", "in", "queues", ":", "queue_name", "=", "os", ".", "path", ".", "basename", "(", "queue", ".", "url", ")", "if", "queue_name", ".", "startswith", "(", "ARN", "(", "topic", ".", "arn", ")", ".", "resource", ")", ":", "row", "=", "dict", "(", "Topic", "=", "topic", ",", "Queue", "=", "queue", ")", "status_object", "=", "bucket", ".", "Object", "(", "os", ".", "path", ".", "join", "(", "queue_name", ",", "\"status\"", ")", ")", "if", "status_object", ".", "key", "not", "in", "recent_status_objects", ":", "continue", "try", ":", "github", ",", "owner", ",", "repo", ",", "events", ",", "instance", "=", "os", ".", "path", ".", "dirname", "(", "status_object", ".", "key", ")", ".", "split", "(", "\"-\"", ",", "4", ")", "status", "=", "json", ".", "loads", "(", "status_object", ".", "get", "(", ")", "[", "\"Body\"", "]", ".", "read", "(", ")", ".", "decode", "(", "\"utf-8\"", ")", ")", "row", ".", "update", "(", "status", ",", "Owner", "=", "owner", ",", "Repo", "=", "repo", ",", "Instance", "=", "instance", ",", "Updated", "=", "status_object", ".", "last_modified", ")", "except", "Exception", ":", "pass", "table", ".", "append", "(", "row", ")", "args", ".", "columns", "=", "[", "\"Owner\"", ",", "\"Repo\"", ",", "\"Instance\"", ",", "\"Status\"", ",", "\"Ref\"", ",", "\"Commit\"", ",", "\"Updated\"", ",", "\"Topic\"", ",", "\"Queue\"", "]", "page_output", "(", "tabulate", "(", "table", ",", "args", ")", ")" ]
List status of all configured SNS-SQS message buses and instances subscribed to them.
[ "List", "status", "of", "all", "configured", "SNS", "-", "SQS", "message", "buses", "and", "instances", "subscribed", "to", "them", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/deploy.py#L93-L125
kislyuk/aegea
aegea/deploy.py
grant
def grant(args): """ 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. """ try: role = resources.iam.Role(args.iam_role_or_instance) role.load() except ClientError: role = get_iam_role_for_instance(args.iam_role_or_instance) role.attach_policy(PolicyArn=ensure_deploy_iam_policy().arn) for private_repo in [args.repo] + list(private_submodules(args.repo)): gh_owner_name, gh_repo_name = parse_repo_name(private_repo) secret = secrets.put(argparse.Namespace(secret_name="deploy.{}.{}".format(gh_owner_name, gh_repo_name), iam_role=role.name, instance_profile=None, iam_group=None, iam_user=None, generate_ssh_key=True)) get_repo(private_repo).create_key(__name__ + "." + role.name, secret["ssh_public_key"]) logger.info("Created deploy key %s for IAM role %s to access GitHub repo %s", secret["ssh_key_fingerprint"], role.name, private_repo)
python
def grant(args): """ 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. """ try: role = resources.iam.Role(args.iam_role_or_instance) role.load() except ClientError: role = get_iam_role_for_instance(args.iam_role_or_instance) role.attach_policy(PolicyArn=ensure_deploy_iam_policy().arn) for private_repo in [args.repo] + list(private_submodules(args.repo)): gh_owner_name, gh_repo_name = parse_repo_name(private_repo) secret = secrets.put(argparse.Namespace(secret_name="deploy.{}.{}".format(gh_owner_name, gh_repo_name), iam_role=role.name, instance_profile=None, iam_group=None, iam_user=None, generate_ssh_key=True)) get_repo(private_repo).create_key(__name__ + "." + role.name, secret["ssh_public_key"]) logger.info("Created deploy key %s for IAM role %s to access GitHub repo %s", secret["ssh_key_fingerprint"], role.name, private_repo)
[ "def", "grant", "(", "args", ")", ":", "try", ":", "role", "=", "resources", ".", "iam", ".", "Role", "(", "args", ".", "iam_role_or_instance", ")", "role", ".", "load", "(", ")", "except", "ClientError", ":", "role", "=", "get_iam_role_for_instance", "(", "args", ".", "iam_role_or_instance", ")", "role", ".", "attach_policy", "(", "PolicyArn", "=", "ensure_deploy_iam_policy", "(", ")", ".", "arn", ")", "for", "private_repo", "in", "[", "args", ".", "repo", "]", "+", "list", "(", "private_submodules", "(", "args", ".", "repo", ")", ")", ":", "gh_owner_name", ",", "gh_repo_name", "=", "parse_repo_name", "(", "private_repo", ")", "secret", "=", "secrets", ".", "put", "(", "argparse", ".", "Namespace", "(", "secret_name", "=", "\"deploy.{}.{}\"", ".", "format", "(", "gh_owner_name", ",", "gh_repo_name", ")", ",", "iam_role", "=", "role", ".", "name", ",", "instance_profile", "=", "None", ",", "iam_group", "=", "None", ",", "iam_user", "=", "None", ",", "generate_ssh_key", "=", "True", ")", ")", "get_repo", "(", "private_repo", ")", ".", "create_key", "(", "__name__", "+", "\".\"", "+", "role", ".", "name", ",", "secret", "[", "\"ssh_public_key\"", "]", ")", "logger", ".", "info", "(", "\"Created deploy key %s for IAM role %s to access GitHub repo %s\"", ",", "secret", "[", "\"ssh_key_fingerprint\"", "]", ",", "role", ".", "name", ",", "private_repo", ")" ]
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.
[ "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", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/deploy.py#L138-L162
kislyuk/aegea
aegea/packages/github3/repos/contents.py
Contents.delete
def delete(self, message, branch=None, committer=None, author=None): """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 authenticated user's information will be used. You must specify both a name and email. :param dict author: (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email. :returns: :class:`Commit <github3.git.Commit>` """ json = None if message: data = {'message': message, 'sha': self.sha, 'branch': branch, 'committer': validate_commmitter(committer), 'author': validate_commmitter(author)} self._remove_none(data) json = self._json(self._delete(self._api, data=dumps(data)), 200) if 'commit' in json: json = Commit(json['commit'], self) return json
python
def delete(self, message, branch=None, committer=None, author=None): """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 authenticated user's information will be used. You must specify both a name and email. :param dict author: (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email. :returns: :class:`Commit <github3.git.Commit>` """ json = None if message: data = {'message': message, 'sha': self.sha, 'branch': branch, 'committer': validate_commmitter(committer), 'author': validate_commmitter(author)} self._remove_none(data) json = self._json(self._delete(self._api, data=dumps(data)), 200) if 'commit' in json: json = Commit(json['commit'], self) return json
[ "def", "delete", "(", "self", ",", "message", ",", "branch", "=", "None", ",", "committer", "=", "None", ",", "author", "=", "None", ")", ":", "json", "=", "None", "if", "message", ":", "data", "=", "{", "'message'", ":", "message", ",", "'sha'", ":", "self", ".", "sha", ",", "'branch'", ":", "branch", ",", "'committer'", ":", "validate_commmitter", "(", "committer", ")", ",", "'author'", ":", "validate_commmitter", "(", "author", ")", "}", "self", ".", "_remove_none", "(", "data", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_delete", "(", "self", ".", "_api", ",", "data", "=", "dumps", "(", "data", ")", ")", ",", "200", ")", "if", "'commit'", "in", "json", ":", "json", "=", "Commit", "(", "json", "[", "'commit'", "]", ",", "self", ")", "return", "json" ]
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 authenticated user's information will be used. You must specify both a name and email. :param dict author: (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email. :returns: :class:`Commit <github3.git.Commit>`
[ "Delete", "this", "file", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/contents.py#L97-L121
kislyuk/aegea
aegea/packages/github3/repos/contents.py
Contents.update
def update(self, message, content, branch=None, committer=None, author=None): """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 committer: (optional), if no information is given the authenticated user's information will be used. You must specify both a name and email. :param dict author: (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email. :returns: :class:`Commit <github3.git.Commit>` """ if content and not isinstance(content, bytes): raise ValueError( # (No coverage) 'content must be a bytes object') # (No coverage) json = None if message and content: content = b64encode(content).decode('utf-8') data = {'message': message, 'content': content, 'branch': branch, 'sha': self.sha, 'committer': validate_commmitter(committer), 'author': validate_commmitter(author)} self._remove_none(data) json = self._json(self._put(self._api, data=dumps(data)), 200) if 'content' in json and 'commit' in json: self.__init__(json['content'], self) json = Commit(json['commit'], self) return json
python
def update(self, message, content, branch=None, committer=None, author=None): """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 committer: (optional), if no information is given the authenticated user's information will be used. You must specify both a name and email. :param dict author: (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email. :returns: :class:`Commit <github3.git.Commit>` """ if content and not isinstance(content, bytes): raise ValueError( # (No coverage) 'content must be a bytes object') # (No coverage) json = None if message and content: content = b64encode(content).decode('utf-8') data = {'message': message, 'content': content, 'branch': branch, 'sha': self.sha, 'committer': validate_commmitter(committer), 'author': validate_commmitter(author)} self._remove_none(data) json = self._json(self._put(self._api, data=dumps(data)), 200) if 'content' in json and 'commit' in json: self.__init__(json['content'], self) json = Commit(json['commit'], self) return json
[ "def", "update", "(", "self", ",", "message", ",", "content", ",", "branch", "=", "None", ",", "committer", "=", "None", ",", "author", "=", "None", ")", ":", "if", "content", "and", "not", "isinstance", "(", "content", ",", "bytes", ")", ":", "raise", "ValueError", "(", "# (No coverage)", "'content must be a bytes object'", ")", "# (No coverage)", "json", "=", "None", "if", "message", "and", "content", ":", "content", "=", "b64encode", "(", "content", ")", ".", "decode", "(", "'utf-8'", ")", "data", "=", "{", "'message'", ":", "message", ",", "'content'", ":", "content", ",", "'branch'", ":", "branch", ",", "'sha'", ":", "self", ".", "sha", ",", "'committer'", ":", "validate_commmitter", "(", "committer", ")", ",", "'author'", ":", "validate_commmitter", "(", "author", ")", "}", "self", ".", "_remove_none", "(", "data", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_put", "(", "self", ".", "_api", ",", "data", "=", "dumps", "(", "data", ")", ")", ",", "200", ")", "if", "'content'", "in", "json", "and", "'commit'", "in", "json", ":", "self", ".", "__init__", "(", "json", "[", "'content'", "]", ",", "self", ")", "json", "=", "Commit", "(", "json", "[", "'commit'", "]", ",", "self", ")", "return", "json" ]
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 committer: (optional), if no information is given the authenticated user's information will be used. You must specify both a name and email. :param dict author: (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email. :returns: :class:`Commit <github3.git.Commit>`
[ "Update", "this", "file", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/contents.py#L124-L157
kislyuk/aegea
aegea/packages/github3/gists/gist.py
Gist.edit
def edit(self, description='', files={}): """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 'filename' where the former is the content of the file and the latter is the new name of the file. :returns: bool -- whether the edit was successful """ data = {} json = None if description: data['description'] = description if files: data['files'] = files if data: json = self._json(self._patch(self._api, data=dumps(data)), 200) if json: self._update_(json) return True return False
python
def edit(self, description='', files={}): """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 'filename' where the former is the content of the file and the latter is the new name of the file. :returns: bool -- whether the edit was successful """ data = {} json = None if description: data['description'] = description if files: data['files'] = files if data: json = self._json(self._patch(self._api, data=dumps(data)), 200) if json: self._update_(json) return True return False
[ "def", "edit", "(", "self", ",", "description", "=", "''", ",", "files", "=", "{", "}", ")", ":", "data", "=", "{", "}", "json", "=", "None", "if", "description", ":", "data", "[", "'description'", "]", "=", "description", "if", "files", ":", "data", "[", "'files'", "]", "=", "files", "if", "data", ":", "json", "=", "self", ".", "_json", "(", "self", ".", "_patch", "(", "self", ".", "_api", ",", "data", "=", "dumps", "(", "data", ")", ")", ",", "200", ")", "if", "json", ":", "self", ".", "_update_", "(", "json", ")", "return", "True", "return", "False" ]
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 'filename' where the former is the content of the file and the latter is the new name of the file. :returns: bool -- whether the edit was successful
[ "Edit", "this", "gist", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/gists/gist.py#L137-L160
kislyuk/aegea
aegea/packages/github3/gists/gist.py
Gist.fork
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), 201) return Gist(json, self) if json else None
python
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), 201) return Gist(json, self) if json else None
[ "def", "fork", "(", "self", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'forks'", ",", "base_url", "=", "self", ".", "_api", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_post", "(", "url", ")", ",", "201", ")", "return", "Gist", "(", "json", ",", "self", ")", "if", "json", "else", "None" ]
Fork this gist. :returns: :class:`Gist <Gist>` if successful, ``None`` otherwise
[ "Fork", "this", "gist", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/gists/gist.py#L163-L171
kislyuk/aegea
aegea/packages/github3/gists/gist.py
Gist.is_starred
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 = self._build_url('star', base_url=self._api) return self._boolean(self._get(url), 204, 404)
python
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 = self._build_url('star', base_url=self._api) return self._boolean(self._get(url), 204, 404)
[ "def", "is_starred", "(", "self", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'star'", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_boolean", "(", "self", ".", "_get", "(", "url", ")", ",", "204", ",", "404", ")" ]
Check to see if this gist is starred by the authenticated user. :returns: bool -- True if it is starred, False otherwise
[ "Check", "to", "see", "if", "this", "gist", "is", "starred", "by", "the", "authenticated", "user", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/gists/gist.py#L182-L189
kislyuk/aegea
aegea/packages/github3/gists/gist.py
Gist.iter_commits
def iter_commits(self, number=-1, etag=None): """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 over. Default: -1 will iterate over all commits associated with this gist. :param str etag: (optional), ETag from a previous request to this endpoint. :returns: generator of :class:`GistHistory <github3.gists.history.GistHistory>` """ url = self._build_url('commits', base_url=self._api) return self._iter(int(number), url, GistHistory)
python
def iter_commits(self, number=-1, etag=None): """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 over. Default: -1 will iterate over all commits associated with this gist. :param str etag: (optional), ETag from a previous request to this endpoint. :returns: generator of :class:`GistHistory <github3.gists.history.GistHistory>` """ url = self._build_url('commits', base_url=self._api) return self._iter(int(number), url, GistHistory)
[ "def", "iter_commits", "(", "self", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'commits'", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "GistHistory", ")" ]
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 over. Default: -1 will iterate over all commits associated with this gist. :param str etag: (optional), ETag from a previous request to this endpoint. :returns: generator of :class:`GistHistory <github3.gists.history.GistHistory>`
[ "Iter", "over", "the", "commits", "on", "this", "gist", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/gists/gist.py#L205-L227
kislyuk/aegea
aegea/packages/github3/gists/gist.py
Gist.iter_forks
def iter_forks(self, number=-1, etag=None): """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 to this endpoint. :returns: generator of :class:`Gist <Gist>` """ url = self._build_url('forks', base_url=self._api) return self._iter(int(number), url, Gist, etag=etag)
python
def iter_forks(self, number=-1, etag=None): """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 to this endpoint. :returns: generator of :class:`Gist <Gist>` """ url = self._build_url('forks', base_url=self._api) return self._iter(int(number), url, Gist, etag=etag)
[ "def", "iter_forks", "(", "self", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'forks'", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "Gist", ",", "etag", "=", "etag", ")" ]
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 to this endpoint. :returns: generator of :class:`Gist <Gist>`
[ "Iterator", "of", "forks", "of", "this", "gist", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/gists/gist.py#L237-L252
kislyuk/aegea
aegea/packages/github3/gists/gist.py
Gist.star
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)
python
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)
[ "def", "star", "(", "self", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'star'", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_boolean", "(", "self", ".", "_put", "(", "url", ")", ",", "204", ",", "404", ")" ]
Star this gist. :returns: bool -- True if successful, False otherwise
[ "Star", "this", "gist", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/gists/gist.py#L255-L262
kislyuk/aegea
aegea/packages/github3/gists/gist.py
Gist.unstar
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, 404)
python
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, 404)
[ "def", "unstar", "(", "self", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'star'", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_boolean", "(", "self", ".", "_delete", "(", "url", ")", ",", "204", ",", "404", ")" ]
Un-star this gist. :returns: bool -- True if successful, False otherwise
[ "Un", "-", "star", "this", "gist", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/gists/gist.py#L265-L272
kislyuk/aegea
aegea/packages/github3/repos/comment.py
RepoComment.update
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}), 200) if json: self._update_(json) return True return False
python
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}), 200) if json: self._update_(json) return True return False
[ "def", "update", "(", "self", ",", "body", ")", ":", "json", "=", "None", "if", "body", ":", "json", "=", "self", ".", "_json", "(", "self", ".", "_post", "(", "self", ".", "_api", ",", "data", "=", "{", "'body'", ":", "body", "}", ")", ",", "200", ")", "if", "json", ":", "self", ".", "_update_", "(", "json", ")", "return", "True", "return", "False" ]
Update this comment. :param str body: (required) :returns: bool
[ "Update", "this", "comment", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/comment.py#L60-L73
kislyuk/aegea
aegea/ssh.py
scp
def scp(args): """ Transfer files to or from EC2 instance. Use "--" to separate scp args from aegea args: aegea scp -- -r local_dir instance_name:~/remote_dir """ if args.scp_args[0] == "--": del args.scp_args[0] user_or_hostname_chars = string.ascii_letters + string.digits for i, arg in enumerate(args.scp_args): if arg[0] in user_or_hostname_chars and ":" in arg: hostname, colon, path = arg.partition(":") username, at, hostname = hostname.rpartition("@") hostname = resolve_instance_public_dns(hostname) if not (username or at): try: username, at = get_linux_username(), "@" except Exception: logger.info("Unable to determine IAM username, using local username") args.scp_args[i] = username + at + hostname + colon + path os.execvp("scp", ["scp"] + args.scp_args)
python
def scp(args): """ Transfer files to or from EC2 instance. Use "--" to separate scp args from aegea args: aegea scp -- -r local_dir instance_name:~/remote_dir """ if args.scp_args[0] == "--": del args.scp_args[0] user_or_hostname_chars = string.ascii_letters + string.digits for i, arg in enumerate(args.scp_args): if arg[0] in user_or_hostname_chars and ":" in arg: hostname, colon, path = arg.partition(":") username, at, hostname = hostname.rpartition("@") hostname = resolve_instance_public_dns(hostname) if not (username or at): try: username, at = get_linux_username(), "@" except Exception: logger.info("Unable to determine IAM username, using local username") args.scp_args[i] = username + at + hostname + colon + path os.execvp("scp", ["scp"] + args.scp_args)
[ "def", "scp", "(", "args", ")", ":", "if", "args", ".", "scp_args", "[", "0", "]", "==", "\"--\"", ":", "del", "args", ".", "scp_args", "[", "0", "]", "user_or_hostname_chars", "=", "string", ".", "ascii_letters", "+", "string", ".", "digits", "for", "i", ",", "arg", "in", "enumerate", "(", "args", ".", "scp_args", ")", ":", "if", "arg", "[", "0", "]", "in", "user_or_hostname_chars", "and", "\":\"", "in", "arg", ":", "hostname", ",", "colon", ",", "path", "=", "arg", ".", "partition", "(", "\":\"", ")", "username", ",", "at", ",", "hostname", "=", "hostname", ".", "rpartition", "(", "\"@\"", ")", "hostname", "=", "resolve_instance_public_dns", "(", "hostname", ")", "if", "not", "(", "username", "or", "at", ")", ":", "try", ":", "username", ",", "at", "=", "get_linux_username", "(", ")", ",", "\"@\"", "except", "Exception", ":", "logger", ".", "info", "(", "\"Unable to determine IAM username, using local username\"", ")", "args", ".", "scp_args", "[", "i", "]", "=", "username", "+", "at", "+", "hostname", "+", "colon", "+", "path", "os", ".", "execvp", "(", "\"scp\"", ",", "[", "\"scp\"", "]", "+", "args", ".", "scp_args", ")" ]
Transfer files to or from EC2 instance. Use "--" to separate scp args from aegea args: aegea scp -- -r local_dir instance_name:~/remote_dir
[ "Transfer", "files", "to", "or", "from", "EC2", "instance", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/ssh.py#L61-L83
kislyuk/aegea
aegea/buckets.py
ls
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 = clients.s3.get_bucket_location(Bucket=bucket.name)["LocationConstraint"] cloudwatch = resources.cloudwatch bucket_region = bucket.LocationConstraint or "us-east-1" if bucket_region != cloudwatch.meta.client.meta.region_name: cloudwatch = boto3.Session(region_name=bucket_region).resource("cloudwatch") data = get_cloudwatch_metric_stats("AWS/S3", "NumberOfObjects", start_time=datetime.utcnow() - timedelta(days=2), end_time=datetime.utcnow(), period=3600, BucketName=bucket.name, StorageType="AllStorageTypes", resource=cloudwatch) bucket.NumberOfObjects = int(data["Datapoints"][-1]["Average"]) if data["Datapoints"] else None data = get_cloudwatch_metric_stats("AWS/S3", "BucketSizeBytes", start_time=datetime.utcnow() - timedelta(days=2), end_time=datetime.utcnow(), period=3600, BucketName=bucket.name, StorageType="StandardStorage", resource=cloudwatch) bucket.BucketSizeBytes = format_number(data["Datapoints"][-1]["Average"]) if data["Datapoints"] else None table.append(bucket) page_output(tabulate(table, args))
python
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 = clients.s3.get_bucket_location(Bucket=bucket.name)["LocationConstraint"] cloudwatch = resources.cloudwatch bucket_region = bucket.LocationConstraint or "us-east-1" if bucket_region != cloudwatch.meta.client.meta.region_name: cloudwatch = boto3.Session(region_name=bucket_region).resource("cloudwatch") data = get_cloudwatch_metric_stats("AWS/S3", "NumberOfObjects", start_time=datetime.utcnow() - timedelta(days=2), end_time=datetime.utcnow(), period=3600, BucketName=bucket.name, StorageType="AllStorageTypes", resource=cloudwatch) bucket.NumberOfObjects = int(data["Datapoints"][-1]["Average"]) if data["Datapoints"] else None data = get_cloudwatch_metric_stats("AWS/S3", "BucketSizeBytes", start_time=datetime.utcnow() - timedelta(days=2), end_time=datetime.utcnow(), period=3600, BucketName=bucket.name, StorageType="StandardStorage", resource=cloudwatch) bucket.BucketSizeBytes = format_number(data["Datapoints"][-1]["Average"]) if data["Datapoints"] else None table.append(bucket) page_output(tabulate(table, args))
[ "def", "ls", "(", "args", ")", ":", "table", "=", "[", "]", "for", "bucket", "in", "filter_collection", "(", "resources", ".", "s3", ".", "buckets", ",", "args", ")", ":", "bucket", ".", "LocationConstraint", "=", "clients", ".", "s3", ".", "get_bucket_location", "(", "Bucket", "=", "bucket", ".", "name", ")", "[", "\"LocationConstraint\"", "]", "cloudwatch", "=", "resources", ".", "cloudwatch", "bucket_region", "=", "bucket", ".", "LocationConstraint", "or", "\"us-east-1\"", "if", "bucket_region", "!=", "cloudwatch", ".", "meta", ".", "client", ".", "meta", ".", "region_name", ":", "cloudwatch", "=", "boto3", ".", "Session", "(", "region_name", "=", "bucket_region", ")", ".", "resource", "(", "\"cloudwatch\"", ")", "data", "=", "get_cloudwatch_metric_stats", "(", "\"AWS/S3\"", ",", "\"NumberOfObjects\"", ",", "start_time", "=", "datetime", ".", "utcnow", "(", ")", "-", "timedelta", "(", "days", "=", "2", ")", ",", "end_time", "=", "datetime", ".", "utcnow", "(", ")", ",", "period", "=", "3600", ",", "BucketName", "=", "bucket", ".", "name", ",", "StorageType", "=", "\"AllStorageTypes\"", ",", "resource", "=", "cloudwatch", ")", "bucket", ".", "NumberOfObjects", "=", "int", "(", "data", "[", "\"Datapoints\"", "]", "[", "-", "1", "]", "[", "\"Average\"", "]", ")", "if", "data", "[", "\"Datapoints\"", "]", "else", "None", "data", "=", "get_cloudwatch_metric_stats", "(", "\"AWS/S3\"", ",", "\"BucketSizeBytes\"", ",", "start_time", "=", "datetime", ".", "utcnow", "(", ")", "-", "timedelta", "(", "days", "=", "2", ")", ",", "end_time", "=", "datetime", ".", "utcnow", "(", ")", ",", "period", "=", "3600", ",", "BucketName", "=", "bucket", ".", "name", ",", "StorageType", "=", "\"StandardStorage\"", ",", "resource", "=", "cloudwatch", ")", "bucket", ".", "BucketSizeBytes", "=", "format_number", "(", "data", "[", "\"Datapoints\"", "]", "[", "-", "1", "]", "[", "\"Average\"", "]", ")", "if", "data", "[", "\"Datapoints\"", "]", "else", "None", "table", ".", "append", "(", "bucket", ")", "page_output", "(", "tabulate", "(", "table", ",", "args", ")", ")" ]
List S3 buckets. See also "aws s3 ls". Use "aws s3 ls NAME" to list bucket contents.
[ "List", "S3", "buckets", ".", "See", "also", "aws", "s3", "ls", ".", "Use", "aws", "s3", "ls", "NAME", "to", "list", "bucket", "contents", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/buckets.py#L21-L43
kislyuk/aegea
aegea/packages/github3/issues/label.py
Label.update
def update(self, name, color): """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 """ json = None if name and color: if color[0] == '#': color = color[1:] json = self._json(self._patch(self._api, data=dumps({ 'name': name, 'color': color})), 200) if json: self._update_(json) return True return False
python
def update(self, name, color): """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 """ json = None if name and color: if color[0] == '#': color = color[1:] json = self._json(self._patch(self._api, data=dumps({ 'name': name, 'color': color})), 200) if json: self._update_(json) return True return False
[ "def", "update", "(", "self", ",", "name", ",", "color", ")", ":", "json", "=", "None", "if", "name", "and", "color", ":", "if", "color", "[", "0", "]", "==", "'#'", ":", "color", "=", "color", "[", "1", ":", "]", "json", "=", "self", ".", "_json", "(", "self", ".", "_patch", "(", "self", ".", "_api", ",", "data", "=", "dumps", "(", "{", "'name'", ":", "name", ",", "'color'", ":", "color", "}", ")", ")", ",", "200", ")", "if", "json", ":", "self", ".", "_update_", "(", "json", ")", "return", "True", "return", "False" ]
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
[ "Update", "this", "label", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/issues/label.py#L43-L62
kislyuk/aegea
aegea/packages/github3/session.py
GitHubSession.basic_auth
def basic_auth(self, username, password): """Set the Basic Auth credentials on this Session. :param str username: Your GitHub username :param str password: Your GitHub password """ if not (username and password): return self.auth = (username, password) # Disable token authentication self.headers.pop('Authorization', None)
python
def basic_auth(self, username, password): """Set the Basic Auth credentials on this Session. :param str username: Your GitHub username :param str password: Your GitHub password """ if not (username and password): return self.auth = (username, password) # Disable token authentication self.headers.pop('Authorization', None)
[ "def", "basic_auth", "(", "self", ",", "username", ",", "password", ")", ":", "if", "not", "(", "username", "and", "password", ")", ":", "return", "self", ".", "auth", "=", "(", "username", ",", "password", ")", "# Disable token authentication", "self", ".", "headers", ".", "pop", "(", "'Authorization'", ",", "None", ")" ]
Set the Basic Auth credentials on this Session. :param str username: Your GitHub username :param str password: Your GitHub password
[ "Set", "the", "Basic", "Auth", "credentials", "on", "this", "Session", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/session.py#L36-L48
kislyuk/aegea
aegea/packages/github3/session.py
GitHubSession.build_url
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', key) if not key in __url_cache__: __logs__.info('Missed the cache building the url') __url_cache__[key] = '/'.join(parts) return __url_cache__[key]
python
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', key) if not key in __url_cache__: __logs__.info('Missed the cache building the url') __url_cache__[key] = '/'.join(parts) return __url_cache__[key]
[ "def", "build_url", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "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'", ",", "key", ")", "if", "not", "key", "in", "__url_cache__", ":", "__logs__", ".", "info", "(", "'Missed the cache building the url'", ")", "__url_cache__", "[", "key", "]", "=", "'/'", ".", "join", "(", "parts", ")", "return", "__url_cache__", "[", "key", "]" ]
Builds a new API url from scratch.
[ "Builds", "a", "new", "API", "url", "from", "scratch", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/session.py#L50-L60
kislyuk/aegea
aegea/packages/github3/session.py
GitHubSession.retrieve_client_credentials
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('client_secret') return (client_id, client_secret)
python
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('client_secret') return (client_id, client_secret)
[ "def", "retrieve_client_credentials", "(", "self", ")", ":", "client_id", "=", "self", ".", "params", ".", "get", "(", "'client_id'", ")", "client_secret", "=", "self", ".", "params", ".", "get", "(", "'client_secret'", ")", "return", "(", "client_id", ",", "client_secret", ")" ]
Return the client credentials. :returns: tuple(client_id, client_secret)
[ "Return", "the", "client", "credentials", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/session.py#L90-L97
kislyuk/aegea
aegea/packages/github3/session.py
GitHubSession.token_auth
def token_auth(self, token): """Use an application token for authentication. :param str token: Application token retrieved from GitHub's /authorizations endpoint """ if not token: return self.headers.update({ 'Authorization': 'token {0}'.format(token) }) # Unset username/password so we stop sending them self.auth = None
python
def token_auth(self, token): """Use an application token for authentication. :param str token: Application token retrieved from GitHub's /authorizations endpoint """ if not token: return self.headers.update({ 'Authorization': 'token {0}'.format(token) }) # Unset username/password so we stop sending them self.auth = None
[ "def", "token_auth", "(", "self", ",", "token", ")", ":", "if", "not", "token", ":", "return", "self", ".", "headers", ".", "update", "(", "{", "'Authorization'", ":", "'token {0}'", ".", "format", "(", "token", ")", "}", ")", "# Unset username/password so we stop sending them", "self", ".", "auth", "=", "None" ]
Use an application token for authentication. :param str token: Application token retrieved from GitHub's /authorizations endpoint
[ "Use", "an", "application", "token", "for", "authentication", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/session.py#L108-L121
kislyuk/aegea
aegea/packages/github3/session.py
GitHubSession.no_auth
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 if old_token_auth: self.headers['Authorization'] = old_token_auth
python
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 if old_token_auth: self.headers['Authorization'] = old_token_auth
[ "def", "no_auth", "(", "self", ")", ":", "old_basic_auth", ",", "self", ".", "auth", "=", "self", ".", "auth", ",", "None", "old_token_auth", "=", "self", ".", "headers", ".", "pop", "(", "'Authorization'", ",", "None", ")", "yield", "self", ".", "auth", "=", "old_basic_auth", "if", "old_token_auth", ":", "self", ".", "headers", "[", "'Authorization'", "]", "=", "old_token_auth" ]
Unset authentication temporarily as a context manager.
[ "Unset", "authentication", "temporarily", "as", "a", "context", "manager", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/session.py#L136-L145
kislyuk/aegea
aegea/packages/github3/repos/hook.py
Hook.edit
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 :param list add_events: (optional), events to be added to the list of events that this hook triggers for :param list rm_events: (optional), events to be remvoed from the list of events that this hook triggers for :param bool active: (optional), should this event be active :returns: bool """ data = {'config': config, 'active': active} if events: data['events'] = events if add_events: data['add_events'] = add_events if rm_events: data['remove_events'] = rm_events json = self._json(self._patch(self._api, data=dumps(data)), 200) if json: self._update_(json) return True return False
python
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 :param list add_events: (optional), events to be added to the list of events that this hook triggers for :param list rm_events: (optional), events to be remvoed from the list of events that this hook triggers for :param bool active: (optional), should this event be active :returns: bool """ data = {'config': config, 'active': active} if events: data['events'] = events if add_events: data['add_events'] = add_events if rm_events: data['remove_events'] = rm_events json = self._json(self._patch(self._api, data=dumps(data)), 200) if json: self._update_(json) return True return False
[ "def", "edit", "(", "self", ",", "config", "=", "{", "}", ",", "events", "=", "[", "]", ",", "add_events", "=", "[", "]", ",", "rm_events", "=", "[", "]", ",", "active", "=", "True", ")", ":", "data", "=", "{", "'config'", ":", "config", ",", "'active'", ":", "active", "}", "if", "events", ":", "data", "[", "'events'", "]", "=", "events", "if", "add_events", ":", "data", "[", "'add_events'", "]", "=", "add_events", "if", "rm_events", ":", "data", "[", "'remove_events'", "]", "=", "rm_events", "json", "=", "self", ".", "_json", "(", "self", ".", "_patch", "(", "self", ".", "_api", ",", "data", "=", "dumps", "(", "data", ")", ")", ",", "200", ")", "if", "json", ":", "self", ".", "_update_", "(", "json", ")", "return", "True", "return", "False" ]
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 triggers for :param list rm_events: (optional), events to be remvoed from the list of events that this hook triggers for :param bool active: (optional), should this event be active :returns: bool
[ "Edit", "this", "hook", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/hook.py#L65-L96
kislyuk/aegea
aegea/packages/github3/repos/hook.py
Hook.ping
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)
python
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)
[ "def", "ping", "(", "self", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'pings'", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_boolean", "(", "self", ".", "_post", "(", "url", ")", ",", "204", ",", "404", ")" ]
Ping this hook. :returns: bool
[ "Ping", "this", "hook", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/hook.py#L99-L105
kislyuk/aegea
aegea/packages/github3/decorators.py
requires_auth
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')) if auth: return func(self, *args, **kwargs) else: from .models import GitHubError # Mock a 401 response r = generate_fake_error_response( '{"message": "Requires authentication"}' ) raise GitHubError(r) return auth_wrapper
python
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')) if auth: return func(self, *args, **kwargs) else: from .models import GitHubError # Mock a 401 response r = generate_fake_error_response( '{"message": "Requires authentication"}' ) raise GitHubError(r) return auth_wrapper
[ "def", "requires_auth", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "auth_wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "auth", "=", "False", "if", "hasattr", "(", "self", ",", "'_session'", ")", ":", "auth", "=", "(", "self", ".", "_session", ".", "auth", "or", "self", ".", "_session", ".", "headers", ".", "get", "(", "'Authorization'", ")", ")", "if", "auth", ":", "return", "func", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "else", ":", "from", ".", "models", "import", "GitHubError", "# Mock a 401 response", "r", "=", "generate_fake_error_response", "(", "'{\"message\": \"Requires authentication\"}'", ")", "raise", "GitHubError", "(", "r", ")", "return", "auth_wrapper" ]
Decorator to note which object methods require authorization.
[ "Decorator", "to", "note", "which", "object", "methods", "require", "authorization", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/decorators.py#L28-L46
kislyuk/aegea
aegea/packages/github3/decorators.py
requires_basic_auth
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, '_session') and self._session.auth: return func(self, *args, **kwargs) else: from .models import GitHubError # Mock a 401 response r = generate_fake_error_response( '{"message": "Requires username/password authentication"}' ) raise GitHubError(r) return auth_wrapper
python
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, '_session') and self._session.auth: return func(self, *args, **kwargs) else: from .models import GitHubError # Mock a 401 response r = generate_fake_error_response( '{"message": "Requires username/password authentication"}' ) raise GitHubError(r) return auth_wrapper
[ "def", "requires_basic_auth", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "auth_wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "hasattr", "(", "self", ",", "'_session'", ")", "and", "self", ".", "_session", ".", "auth", ":", "return", "func", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "else", ":", "from", ".", "models", "import", "GitHubError", "# Mock a 401 response", "r", "=", "generate_fake_error_response", "(", "'{\"message\": \"Requires username/password authentication\"}'", ")", "raise", "GitHubError", "(", "r", ")", "return", "auth_wrapper" ]
Specific (basic) authentication decorator. This is used to note which object methods require username/password authorization and won't work with token based authorization.
[ "Specific", "(", "basic", ")", "authentication", "decorator", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/decorators.py#L49-L67
kislyuk/aegea
aegea/packages/github3/decorators.py
requires_app_credentials
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._session.retrieve_client_credentials() if client_id and client_secret: return func(self, *args, **kwargs) else: from .models import GitHubError # Mock a 401 response r = generate_fake_error_response( '{"message": "Requires username/password authentication"}' ) raise GitHubError(r) return auth_wrapper
python
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._session.retrieve_client_credentials() if client_id and client_secret: return func(self, *args, **kwargs) else: from .models import GitHubError # Mock a 401 response r = generate_fake_error_response( '{"message": "Requires username/password authentication"}' ) raise GitHubError(r) return auth_wrapper
[ "def", "requires_app_credentials", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "auth_wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "client_id", ",", "client_secret", "=", "self", ".", "_session", ".", "retrieve_client_credentials", "(", ")", "if", "client_id", "and", "client_secret", ":", "return", "func", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "else", ":", "from", ".", "models", "import", "GitHubError", "# Mock a 401 response", "r", "=", "generate_fake_error_response", "(", "'{\"message\": \"Requires username/password authentication\"}'", ")", "raise", "GitHubError", "(", "r", ")", "return", "auth_wrapper" ]
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.
[ "Require", "client_id", "and", "client_secret", "to", "be", "associated", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/decorators.py#L70-L90
kislyuk/aegea
aegea/audit.py
Auditor.audit_1_1
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] != "N/A" and self.parse_date(row[field]) > datetime.now(tzutc()) - timedelta(days=1): raise Exception("Root account last used less than a day ago ({})".format(field))
python
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] != "N/A" and self.parse_date(row[field]) > datetime.now(tzutc()) - timedelta(days=1): raise Exception("Root account last used less than a day ago ({})".format(field))
[ "def", "audit_1_1", "(", "self", ")", ":", "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", "]", "!=", "\"N/A\"", "and", "self", ".", "parse_date", "(", "row", "[", "field", "]", ")", ">", "datetime", ".", "now", "(", "tzutc", "(", ")", ")", "-", "timedelta", "(", "days", "=", "1", ")", ":", "raise", "Exception", "(", "\"Root account last used less than a day ago ({})\"", ".", "format", "(", "field", ")", ")" ]
1.1 Avoid the use of the "root" account (Scored)
[ "1", ".", "1", "Avoid", "the", "use", "of", "the", "root", "account", "(", "Scored", ")" ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/audit.py#L54-L60
kislyuk/aegea
aegea/audit.py
Auditor.audit_1_2
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(row["mfa_active"]): raise Exception("Account {} has a console password but no MFA".format(row["user"]))
python
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(row["mfa_active"]): raise Exception("Account {} has a console password but no MFA".format(row["user"]))
[ "def", "audit_1_2", "(", "self", ")", ":", "# noqa", "for", "row", "in", "self", ".", "credential_report", ":", "if", "row", "[", "\"user\"", "]", "==", "\"<root_account>\"", "or", "json", ".", "loads", "(", "row", "[", "\"password_enabled\"", "]", ")", ":", "if", "not", "json", ".", "loads", "(", "row", "[", "\"mfa_active\"", "]", ")", ":", "raise", "Exception", "(", "\"Account {} has a console password but no MFA\"", ".", "format", "(", "row", "[", "\"user\"", "]", ")", ")" ]
1.2 Ensure multi-factor authentication (MFA) is enabled for all IAM users that have a console password (Scored)
[ "1", ".", "2", "Ensure", "multi", "-", "factor", "authentication", "(", "MFA", ")", "is", "enabled", "for", "all", "IAM", "users", "that", "have", "a", "console", "password", "(", "Scored", ")" ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/audit.py#L62-L67
kislyuk/aegea
aegea/audit.py
Auditor.audit_1_3
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_{}_last_used_date".format(access_key)] if last_used != "N/A" and self.parse_date(last_used) < datetime.now(tzutc()) - timedelta(days=90): msg = "Active access key {} in account {} last used over 90 days ago" raise Exception(msg.format(access_key, row["user"]))
python
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_{}_last_used_date".format(access_key)] if last_used != "N/A" and self.parse_date(last_used) < datetime.now(tzutc()) - timedelta(days=90): msg = "Active access key {} in account {} last used over 90 days ago" raise Exception(msg.format(access_key, row["user"]))
[ "def", "audit_1_3", "(", "self", ")", ":", "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_{}_last_used_date\"", ".", "format", "(", "access_key", ")", "]", "if", "last_used", "!=", "\"N/A\"", "and", "self", ".", "parse_date", "(", "last_used", ")", "<", "datetime", ".", "now", "(", "tzutc", "(", ")", ")", "-", "timedelta", "(", "days", "=", "90", ")", ":", "msg", "=", "\"Active access key {} in account {} last used over 90 days ago\"", "raise", "Exception", "(", "msg", ".", "format", "(", "access_key", ",", "row", "[", "\"user\"", "]", ")", ")" ]
1.3 Ensure credentials unused for 90 days or greater are disabled (Scored)
[ "1", ".", "3", "Ensure", "credentials", "unused", "for", "90", "days", "or", "greater", "are", "disabled", "(", "Scored", ")" ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/audit.py#L69-L77
kislyuk/aegea
aegea/audit.py
Auditor.audit_1_4
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_{}_last_rotated".format(access_key)] if self.parse_date(last_rotated) < datetime.now(tzutc()) - timedelta(days=90): msg = "Active access key {} in account {} last rotated over 90 days ago" raise Exception(msg.format(access_key, row["user"]))
python
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_{}_last_rotated".format(access_key)] if self.parse_date(last_rotated) < datetime.now(tzutc()) - timedelta(days=90): msg = "Active access key {} in account {} last rotated over 90 days ago" raise Exception(msg.format(access_key, row["user"]))
[ "def", "audit_1_4", "(", "self", ")", ":", "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_{}_last_rotated\"", ".", "format", "(", "access_key", ")", "]", "if", "self", ".", "parse_date", "(", "last_rotated", ")", "<", "datetime", ".", "now", "(", "tzutc", "(", ")", ")", "-", "timedelta", "(", "days", "=", "90", ")", ":", "msg", "=", "\"Active access key {} in account {} last rotated over 90 days ago\"", "raise", "Exception", "(", "msg", ".", "format", "(", "access_key", ",", "row", "[", "\"user\"", "]", ")", ")" ]
1.4 Ensure access keys are rotated every 90 days or less (Scored)
[ "1", ".", "4", "Ensure", "access", "keys", "are", "rotated", "every", "90", "days", "or", "less", "(", "Scored", ")" ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/audit.py#L79-L87
kislyuk/aegea
aegea/audit.py
Auditor.audit_1_12
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_active"]))
python
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_active"]))
[ "def", "audit_1_12", "(", "self", ")", ":", "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_active\"", "]", ")", ")" ]
1.12 Ensure no root account access key exists (Scored)
[ "1", ".", "12", "Ensure", "no", "root", "account", "access", "key", "exists", "(", "Scored", ")" ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/audit.py#L117-L122
kislyuk/aegea
aegea/audit.py
Auditor.audit_1_13
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"]))
python
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"]))
[ "def", "audit_1_13", "(", "self", ")", ":", "for", "row", "in", "self", ".", "credential_report", ":", "if", "row", "[", "\"user\"", "]", "==", "\"<root_account>\"", ":", "self", ".", "assertTrue", "(", "json", ".", "loads", "(", "row", "[", "\"mfa_active\"", "]", ")", ")" ]
1.13 Ensure hardware MFA is enabled for the "root" account (Scored)
[ "1", ".", "13", "Ensure", "hardware", "MFA", "is", "enabled", "for", "the", "root", "account", "(", "Scored", ")" ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/audit.py#L124-L128
kislyuk/aegea
aegea/audit.py
Auditor.audit_1_15
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))
python
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))
[ "def", "audit_1_15", "(", "self", ")", ":", "for", "policy", "in", "resources", ".", "iam", ".", "policies", ".", "all", "(", ")", ":", "self", ".", "assertEqual", "(", "len", "(", "list", "(", "policy", ".", "attached_users", ".", "all", "(", ")", ")", ")", ",", "0", ",", "\"{} has users attached to it\"", ".", "format", "(", "policy", ")", ")" ]
1.15 Ensure IAM policies are attached only to groups or roles (Scored)
[ "1", ".", "15", "Ensure", "IAM", "policies", "are", "attached", "only", "to", "groups", "or", "roles", "(", "Scored", ")" ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/audit.py#L133-L136
kislyuk/aegea
aegea/audit.py
Auditor.audit_2_2
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't have log file validation enabled")
python
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't have log file validation enabled")
[ "def", "audit_2_2", "(", "self", ")", ":", "self", ".", "assertGreater", "(", "len", "(", "self", ".", "trails", ")", ",", "0", ",", "\"No CloudTrail trails configured\"", ")", "self", ".", "assertTrue", "(", "all", "(", "trail", "[", "\"LogFileValidationEnabled\"", "]", "for", "trail", "in", "self", ".", "trails", ")", ",", "\"Some CloudTrail trails don't have log file validation enabled\"", ")" ]
2.2 Ensure CloudTrail log file validation is enabled (Scored)
[ "2", ".", "2", "Ensure", "CloudTrail", "log", "file", "validation", "is", "enabled", "(", "Scored", ")" ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/audit.py#L142-L146
kislyuk/aegea
aegea/audit.py
Auditor.audit_2_3
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: # for grant in s3.Bucket(trail["S3BucketName"]).Acl().grants: # print(s3.Bucket(trail["S3BucketName"]).Policy().policy) for bucket in s3.buckets.all(): print(bucket) try: print(" Policy:", bucket.Policy().policy) except Exception: pass for grant in bucket.Acl().grants: try: print(" Grant:", grant) except Exception: pass
python
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: # for grant in s3.Bucket(trail["S3BucketName"]).Acl().grants: # print(s3.Bucket(trail["S3BucketName"]).Policy().policy) for bucket in s3.buckets.all(): print(bucket) try: print(" Policy:", bucket.Policy().policy) except Exception: pass for grant in bucket.Acl().grants: try: print(" Grant:", grant) except Exception: pass
[ "def", "audit_2_3", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")", "import", "boto3", "s3", "=", "boto3", ".", "session", ".", "Session", "(", "region_name", "=", "\"us-east-1\"", ")", ".", "resource", "(", "\"s3\"", ")", "# s3 = boto3.resource(\"s3\")", "# for trail in self.trails:", "# for grant in s3.Bucket(trail[\"S3BucketName\"]).Acl().grants:", "# print(s3.Bucket(trail[\"S3BucketName\"]).Policy().policy)", "for", "bucket", "in", "s3", ".", "buckets", ".", "all", "(", ")", ":", "print", "(", "bucket", ")", "try", ":", "print", "(", "\" Policy:\"", ",", "bucket", ".", "Policy", "(", ")", ".", "policy", ")", "except", "Exception", ":", "pass", "for", "grant", "in", "bucket", ".", "Acl", "(", ")", ".", "grants", ":", "try", ":", "print", "(", "\" Grant:\"", ",", "grant", ")", "except", "Exception", ":", "pass" ]
2.3 Ensure the S3 bucket CloudTrail logs to is not publicly accessible (Scored)
[ "2", ".", "3", "Ensure", "the", "S3", "bucket", "CloudTrail", "logs", "to", "is", "not", "publicly", "accessible", "(", "Scored", ")" ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/audit.py#L148-L167
kislyuk/aegea
aegea/audit.py
Auditor.audit_2_4
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.assertGreater(trail_status["LatestCloudWatchLogsDeliveryTime"], datetime.now(tzutc()) - timedelta(days=1))
python
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.assertGreater(trail_status["LatestCloudWatchLogsDeliveryTime"], datetime.now(tzutc()) - timedelta(days=1))
[ "def", "audit_2_4", "(", "self", ")", ":", "for", "trail", "in", "self", ".", "trails", ":", "self", ".", "assertIn", "(", "\"CloudWatchLogsLogGroupArn\"", ",", "trail", ")", "trail_status", "=", "clients", ".", "cloudtrail", ".", "get_trail_status", "(", "Name", "=", "trail", "[", "\"TrailARN\"", "]", ")", "self", ".", "assertGreater", "(", "trail_status", "[", "\"LatestCloudWatchLogsDeliveryTime\"", "]", ",", "datetime", ".", "now", "(", "tzutc", "(", ")", ")", "-", "timedelta", "(", "days", "=", "1", ")", ")" ]
2.4 Ensure CloudTrail trails are integrated with CloudWatch Logs (Scored)
[ "2", ".", "4", "Ensure", "CloudTrail", "trails", "are", "integrated", "with", "CloudWatch", "Logs", "(", "Scored", ")" ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/audit.py#L169-L175
kislyuk/aegea
aegea/audit.py
Auditor.audit_2_5
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_recorder_status() self.assertGreater(len(res["ConfigurationRecordersStatus"]), 0)
python
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_recorder_status() self.assertGreater(len(res["ConfigurationRecordersStatus"]), 0)
[ "def", "audit_2_5", "(", "self", ")", ":", "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_recorder_status", "(", ")", "self", ".", "assertGreater", "(", "len", "(", "res", "[", "\"ConfigurationRecordersStatus\"", "]", ")", ",", "0", ")" ]
2.5 Ensure AWS Config is enabled in all regions (Scored)
[ "2", ".", "5", "Ensure", "AWS", "Config", "is", "enabled", "in", "all", "regions", "(", "Scored", ")" ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/audit.py#L177-L183
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.authorization
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('authorizations', str(id_num)) json = self._json(self._get(url), 200) return Authorization(json, self) if json else None
python
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('authorizations', str(id_num)) json = self._json(self._get(url), 200) return Authorization(json, self) if json else None
[ "def", "authorization", "(", "self", ",", "id_num", ")", ":", "json", "=", "None", "if", "int", "(", "id_num", ")", ">", "0", ":", "url", "=", "self", ".", "_build_url", "(", "'authorizations'", ",", "str", "(", "id_num", ")", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_get", "(", "url", ")", ",", "200", ")", "return", "Authorization", "(", "json", ",", "self", ")", "if", "json", "else", "None" ]
Get information about authorization ``id``. :param int id_num: (required), unique id of the authorization :returns: :class:`Authorization <Authorization>`
[ "Get", "information", "about", "authorization", "id", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L76-L86
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.authorize
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: (optional), areas you want this token to apply to, i.e., 'gist', 'user' :param str note: (optional), note about the authorization :param str note_url: (optional), url for the application :param str client_id: (optional), 20 character OAuth client key for which to create a token :param str client_secret: (optional), 40 character OAuth client secret for which to create the token :returns: :class:`Authorization <Authorization>` """ json = None # TODO: Break this behaviour in 1.0 (Don't rely on self._session.auth) auth = None if self._session.auth: auth = self._session.auth elif login and password: auth = (login, password) if auth: url = self._build_url('authorizations') data = {'note': note, 'note_url': note_url, 'client_id': client_id, 'client_secret': client_secret} if scopes: data['scopes'] = scopes with self._session.temporary_basic_auth(*auth): json = self._json(self._post(url, data=data), 201) return Authorization(json, self) if json else None
python
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: (optional), areas you want this token to apply to, i.e., 'gist', 'user' :param str note: (optional), note about the authorization :param str note_url: (optional), url for the application :param str client_id: (optional), 20 character OAuth client key for which to create a token :param str client_secret: (optional), 40 character OAuth client secret for which to create the token :returns: :class:`Authorization <Authorization>` """ json = None # TODO: Break this behaviour in 1.0 (Don't rely on self._session.auth) auth = None if self._session.auth: auth = self._session.auth elif login and password: auth = (login, password) if auth: url = self._build_url('authorizations') data = {'note': note, 'note_url': note_url, 'client_id': client_id, 'client_secret': client_secret} if scopes: data['scopes'] = scopes with self._session.temporary_basic_auth(*auth): json = self._json(self._post(url, data=data), 201) return Authorization(json, self) if json else None
[ "def", "authorize", "(", "self", ",", "login", ",", "password", ",", "scopes", "=", "None", ",", "note", "=", "''", ",", "note_url", "=", "''", ",", "client_id", "=", "''", ",", "client_secret", "=", "''", ")", ":", "json", "=", "None", "# TODO: Break this behaviour in 1.0 (Don't rely on self._session.auth)", "auth", "=", "None", "if", "self", ".", "_session", ".", "auth", ":", "auth", "=", "self", ".", "_session", ".", "auth", "elif", "login", "and", "password", ":", "auth", "=", "(", "login", ",", "password", ")", "if", "auth", ":", "url", "=", "self", ".", "_build_url", "(", "'authorizations'", ")", "data", "=", "{", "'note'", ":", "note", ",", "'note_url'", ":", "note_url", ",", "'client_id'", ":", "client_id", ",", "'client_secret'", ":", "client_secret", "}", "if", "scopes", ":", "data", "[", "'scopes'", "]", "=", "scopes", "with", "self", ".", "_session", ".", "temporary_basic_auth", "(", "*", "auth", ")", ":", "json", "=", "self", ".", "_json", "(", "self", ".", "_post", "(", "url", ",", "data", "=", "data", ")", ",", "201", ")", "return", "Authorization", "(", "json", ",", "self", ")", "if", "json", "else", "None" ]
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 authorization :param str note_url: (optional), url for the application :param str client_id: (optional), 20 character OAuth client key for which to create a token :param str client_secret: (optional), 40 character OAuth client secret for which to create the token :returns: :class:`Authorization <Authorization>`
[ "Obtain", "an", "authorization", "token", "from", "the", "GitHub", "API", "for", "the", "GitHub", "API", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L88-L123
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.check_authorization
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 """ p = self._session.params auth = (p.get('client_id'), p.get('client_secret')) if access_token and auth: url = self._build_url('applications', str(auth[0]), 'tokens', str(access_token)) resp = self._get(url, auth=auth, params={ 'client_id': None, 'client_secret': None }) return self._boolean(resp, 200, 404) return False
python
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 """ p = self._session.params auth = (p.get('client_id'), p.get('client_secret')) if access_token and auth: url = self._build_url('applications', str(auth[0]), 'tokens', str(access_token)) resp = self._get(url, auth=auth, params={ 'client_id': None, 'client_secret': None }) return self._boolean(resp, 200, 404) return False
[ "def", "check_authorization", "(", "self", ",", "access_token", ")", ":", "p", "=", "self", ".", "_session", ".", "params", "auth", "=", "(", "p", ".", "get", "(", "'client_id'", ")", ",", "p", ".", "get", "(", "'client_secret'", ")", ")", "if", "access_token", "and", "auth", ":", "url", "=", "self", ".", "_build_url", "(", "'applications'", ",", "str", "(", "auth", "[", "0", "]", ")", ",", "'tokens'", ",", "str", "(", "access_token", ")", ")", "resp", "=", "self", ".", "_get", "(", "url", ",", "auth", "=", "auth", ",", "params", "=", "{", "'client_id'", ":", "None", ",", "'client_secret'", ":", "None", "}", ")", "return", "self", ".", "_boolean", "(", "resp", ",", "200", ",", "404", ")", "return", "False" ]
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
[ "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", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L125-L142
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.create_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. ``{'spam.txt': {'content': 'File contents ...'}}`` :param bool public: (optional), make the gist public if True :returns: :class:`Gist <github3.gists.Gist>` """ new_gist = {'description': description, 'public': public, 'files': files} url = self._build_url('gists') json = self._json(self._post(url, data=new_gist), 201) return Gist(json, self) if json else None
python
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. ``{'spam.txt': {'content': 'File contents ...'}}`` :param bool public: (optional), make the gist public if True :returns: :class:`Gist <github3.gists.Gist>` """ new_gist = {'description': description, 'public': public, 'files': files} url = self._build_url('gists') json = self._json(self._post(url, data=new_gist), 201) return Gist(json, self) if json else None
[ "def", "create_gist", "(", "self", ",", "description", ",", "files", ",", "public", "=", "True", ")", ":", "new_gist", "=", "{", "'description'", ":", "description", ",", "'public'", ":", "public", ",", "'files'", ":", "files", "}", "url", "=", "self", ".", "_build_url", "(", "'gists'", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_post", "(", "url", ",", "data", "=", "new_gist", ")", ",", "201", ")", "return", "Gist", "(", "json", ",", "self", ")", "if", "json", "else", "None" ]
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 ...'}}`` :param bool public: (optional), make the gist public if True :returns: :class:`Gist <github3.gists.Gist>`
[ "Create", "a", "new", "gist", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L144-L160
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.create_issue
def create_issue(self, owner, repository, title, body=None, assignee=None, milestone=None, labels=[]): """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 to be created :param str body: (optional), The text of the issue, markdown formatted :param str assignee: (optional), Login of person to assign the issue to :param int milestone: (optional), id number of the milestone to attribute this issue to (e.g. ``m`` is a :class:`Milestone <github3.issues.Milestone>` object, ``m.number`` is what you pass here.) :param list labels: (optional), List of label names. :returns: :class:`Issue <github3.issues.Issue>` if successful, else None """ repo = None if owner and repository and title: repo = self.repository(owner, repository) if repo: return repo.create_issue(title, body, assignee, milestone, labels) # Regardless, something went wrong. We were unable to create the # issue return None
python
def create_issue(self, owner, repository, title, body=None, assignee=None, milestone=None, labels=[]): """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 to be created :param str body: (optional), The text of the issue, markdown formatted :param str assignee: (optional), Login of person to assign the issue to :param int milestone: (optional), id number of the milestone to attribute this issue to (e.g. ``m`` is a :class:`Milestone <github3.issues.Milestone>` object, ``m.number`` is what you pass here.) :param list labels: (optional), List of label names. :returns: :class:`Issue <github3.issues.Issue>` if successful, else None """ repo = None if owner and repository and title: repo = self.repository(owner, repository) if repo: return repo.create_issue(title, body, assignee, milestone, labels) # Regardless, something went wrong. We were unable to create the # issue return None
[ "def", "create_issue", "(", "self", ",", "owner", ",", "repository", ",", "title", ",", "body", "=", "None", ",", "assignee", "=", "None", ",", "milestone", "=", "None", ",", "labels", "=", "[", "]", ")", ":", "repo", "=", "None", "if", "owner", "and", "repository", "and", "title", ":", "repo", "=", "self", ".", "repository", "(", "owner", ",", "repository", ")", "if", "repo", ":", "return", "repo", ".", "create_issue", "(", "title", ",", "body", ",", "assignee", ",", "milestone", ",", "labels", ")", "# Regardless, something went wrong. We were unable to create the", "# issue", "return", "None" ]
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 to be created :param str body: (optional), The text of the issue, markdown formatted :param str assignee: (optional), Login of person to assign the issue to :param int milestone: (optional), id number of the milestone to attribute this issue to (e.g. ``m`` is a :class:`Milestone <github3.issues.Milestone>` object, ``m.number`` is what you pass here.) :param list labels: (optional), List of label names. :returns: :class:`Issue <github3.issues.Issue>` if successful, else None
[ "Create", "an", "issue", "on", "the", "project", "repository", "owned", "by", "owner", "with", "title", "title", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L163-L200
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.create_key
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>` """ created = None if title and key: url = self._build_url('user', 'keys') req = self._post(url, data={'title': title, 'key': key}) json = self._json(req, 201) if json: created = Key(json, self) return created
python
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>` """ created = None if title and key: url = self._build_url('user', 'keys') req = self._post(url, data={'title': title, 'key': key}) json = self._json(req, 201) if json: created = Key(json, self) return created
[ "def", "create_key", "(", "self", ",", "title", ",", "key", ")", ":", "created", "=", "None", "if", "title", "and", "key", ":", "url", "=", "self", ".", "_build_url", "(", "'user'", ",", "'keys'", ")", "req", "=", "self", ".", "_post", "(", "url", ",", "data", "=", "{", "'title'", ":", "title", ",", "'key'", ":", "key", "}", ")", "json", "=", "self", ".", "_json", "(", "req", ",", "201", ")", "if", "json", ":", "created", "=", "Key", "(", "json", ",", "self", ")", "return", "created" ]
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>`
[ "Create", "a", "new", "key", "for", "the", "authenticated", "user", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L203-L219
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.delete_key
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
python
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
[ "def", "delete_key", "(", "self", ",", "key_id", ")", ":", "key", "=", "self", ".", "key", "(", "key_id", ")", "if", "key", ":", "return", "key", ".", "delete", "(", ")", "return", "False" ]
Delete user key pointed to by ``key_id``. :param int key_id: (required), unique id used by Github :returns: bool
[ "Delete", "user", "key", "pointed", "to", "by", "key_id", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L262-L271
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.emojis
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/images/...', # ... } """ url = self._build_url('emojis') return self._json(self._get(url), 200)
python
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/images/...', # ... } """ url = self._build_url('emojis') return self._json(self._get(url), 200)
[ "def", "emojis", "(", "self", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'emojis'", ")", "return", "self", ".", "_json", "(", "self", ".", "_get", "(", "url", ")", ",", "200", ")" ]
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/...', # ... }
[ "Retrieves", "a", "dictionary", "of", "all", "of", "the", "emojis", "that", "GitHub", "supports", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L273-L285
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.feeds
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 = [ 'timeline_url', 'user_url', 'current_user_public_url', 'current_user_url', 'current_user_actor_url', 'current_user_organization_url', ] for url in urls: json[url] = URITemplate(json[url]) links = json.get('_links', {}) for d in links.values(): d['href'] = URITemplate(d['href']) return json
python
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 = [ 'timeline_url', 'user_url', 'current_user_public_url', 'current_user_url', 'current_user_actor_url', 'current_user_organization_url', ] for url in urls: json[url] = URITemplate(json[url]) links = json.get('_links', {}) for d in links.values(): d['href'] = URITemplate(d['href']) return json
[ "def", "feeds", "(", "self", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'feeds'", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_get", "(", "url", ")", ",", "200", ")", "del", "json", "[", "'ETag'", "]", "del", "json", "[", "'Last-Modified'", "]", "urls", "=", "[", "'timeline_url'", ",", "'user_url'", ",", "'current_user_public_url'", ",", "'current_user_url'", ",", "'current_user_actor_url'", ",", "'current_user_organization_url'", ",", "]", "for", "url", "in", "urls", ":", "json", "[", "url", "]", "=", "URITemplate", "(", "json", "[", "url", "]", ")", "links", "=", "json", ".", "get", "(", "'_links'", ",", "{", "}", ")", "for", "d", "in", "links", ".", "values", "(", ")", ":", "d", "[", "'href'", "]", "=", "URITemplate", "(", "d", "[", "'href'", "]", ")", "return", "json" ]
List GitHub's timeline resources in Atom format. :returns: dictionary parsed to include URITemplates
[ "List", "GitHub", "s", "timeline", "resources", "in", "Atom", "format", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L288-L311
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.follow
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, 404) return resp
python
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, 404) return resp
[ "def", "follow", "(", "self", ",", "login", ")", ":", "resp", "=", "False", "if", "login", ":", "url", "=", "self", ".", "_build_url", "(", "'user'", ",", "'following'", ",", "login", ")", "resp", "=", "self", ".", "_boolean", "(", "self", ".", "_put", "(", "url", ")", ",", "204", ",", "404", ")", "return", "resp" ]
Make the authenticated user follow login. :param str login: (required), user to follow :returns: bool
[ "Make", "the", "authenticated", "user", "follow", "login", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L314-L324
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.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: :class:`Gist <github3.gists.Gist>` """ url = self._build_url('gists', str(id_num)) json = self._json(self._get(url), 200) return Gist(json, self) if json else None
python
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 Gist(json, self) if json else None
[ "def", "gist", "(", "self", ",", "id_num", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'gists'", ",", "str", "(", "id_num", ")", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_get", "(", "url", ")", ",", "200", ")", "return", "Gist", "(", "json", ",", "self", ")", "if", "json", "else", "None" ]
Gets the gist using the specified id number. :param int id_num: (required), unique id of the gist :returns: :class:`Gist <github3.gists.Gist>`
[ "Gets", "the", "gist", "using", "the", "specified", "id", "number", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L326-L334
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.gitignore_template
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', '')
python
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', '')
[ "def", "gitignore_template", "(", "self", ",", "language", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'gitignore'", ",", "'templates'", ",", "language", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_get", "(", "url", ")", ",", "200", ")", "if", "not", "json", ":", "return", "''", "return", "json", ".", "get", "(", "'source'", ",", "''", ")" ]
Returns the template for language. :returns: str
[ "Returns", "the", "template", "for", "language", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L336-L345
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.gitignore_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 []
python
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 []
[ "def", "gitignore_templates", "(", "self", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'gitignore'", ",", "'templates'", ")", "return", "self", ".", "_json", "(", "self", ".", "_get", "(", "url", ")", ",", "200", ")", "or", "[", "]" ]
Returns the list of available templates. :returns: list of template names
[ "Returns", "the", "list", "of", "available", "templates", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L347-L353
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.is_following
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('user', 'following', login) json = self._boolean(self._get(url), 204, 404) return json
python
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('user', 'following', login) json = self._boolean(self._get(url), 204, 404) return json
[ "def", "is_following", "(", "self", ",", "login", ")", ":", "json", "=", "False", "if", "login", ":", "url", "=", "self", ".", "_build_url", "(", "'user'", ",", "'following'", ",", "login", ")", "json", "=", "self", ".", "_boolean", "(", "self", ".", "_get", "(", "url", ")", ",", "204", ",", "404", ")", "return", "json" ]
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
[ "Check", "if", "the", "authenticated", "user", "is", "following", "login", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L356-L367
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.is_subscribed
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: url = self._build_url('user', 'subscriptions', login, repo) json = self._boolean(self._get(url), 204, 404) return json
python
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: url = self._build_url('user', 'subscriptions', login, repo) json = self._boolean(self._get(url), 204, 404) return json
[ "def", "is_subscribed", "(", "self", ",", "login", ",", "repo", ")", ":", "json", "=", "False", "if", "login", "and", "repo", ":", "url", "=", "self", ".", "_build_url", "(", "'user'", ",", "'subscriptions'", ",", "login", ",", "repo", ")", "json", "=", "self", ".", "_boolean", "(", "self", ".", "_get", "(", "url", ")", ",", "204", ",", "404", ")", "return", "json" ]
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
[ "Check", "if", "the", "authenticated", "user", "is", "subscribed", "to", "login", "/", "repo", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L384-L395
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.issue
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: :class:`Issue <github3.issues.Issue>` """ repo = self.repository(owner, repository) if repo: return repo.issue(number) return None
python
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: :class:`Issue <github3.issues.Issue>` """ repo = self.repository(owner, repository) if repo: return repo.issue(number) return None
[ "def", "issue", "(", "self", ",", "owner", ",", "repository", ",", "number", ")", ":", "repo", "=", "self", ".", "repository", "(", "owner", ",", "repository", ")", "if", "repo", ":", "return", "repo", ".", "issue", "(", "number", ")", "return", "None" ]
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>`
[ "Fetch", "issue", "#", ":", "number", ":", "from", "https", ":", "//", "github", ".", "com", "/", ":", "owner", ":", "/", ":", "repository", ":" ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L397-L408
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_all_repos
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 id seen (allows restarting this iteration) :param str etag: (optional), ETag from a previous request to the same endpoint :param int per_page: (optional), number of repositories to list per request :returns: generator of :class:`Repository <github3.repos.Repository>` """ url = self._build_url('repositories') return self._iter(int(number), url, Repository, params={'since': since, 'per_page': per_page}, etag=etag)
python
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 id seen (allows restarting this iteration) :param str etag: (optional), ETag from a previous request to the same endpoint :param int per_page: (optional), number of repositories to list per request :returns: generator of :class:`Repository <github3.repos.Repository>` """ url = self._build_url('repositories') return self._iter(int(number), url, Repository, params={'since': since, 'per_page': per_page}, etag=etag)
[ "def", "iter_all_repos", "(", "self", ",", "number", "=", "-", "1", ",", "since", "=", "None", ",", "etag", "=", "None", ",", "per_page", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'repositories'", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "Repository", ",", "params", "=", "{", "'since'", ":", "since", ",", "'per_page'", ":", "per_page", "}", ",", "etag", "=", "etag", ")" ]
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: (optional), ETag from a previous request to the same endpoint :param int per_page: (optional), number of repositories to list per request :returns: generator of :class:`Repository <github3.repos.Repository>`
[ "Iterate", "over", "every", "repository", "in", "the", "order", "they", "were", "created", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L410-L426
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_all_users
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 the same endpoint :param int per_page: (optional), number of users to list per request :returns: generator of :class:`User <github3.users.User>` """ url = self._build_url('users') return self._iter(int(number), url, User, params={'per_page': per_page}, etag=etag)
python
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 the same endpoint :param int per_page: (optional), number of users to list per request :returns: generator of :class:`User <github3.users.User>` """ url = self._build_url('users') return self._iter(int(number), url, User, params={'per_page': per_page}, etag=etag)
[ "def", "iter_all_users", "(", "self", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ",", "per_page", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'users'", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "User", ",", "params", "=", "{", "'per_page'", ":", "per_page", "}", ",", "etag", "=", "etag", ")" ]
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), number of users to list per request :returns: generator of :class:`User <github3.users.User>`
[ "Iterate", "over", "every", "user", "in", "the", "order", "they", "signed", "up", "for", "GitHub", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L428-L440
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_authorizations
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 authorizations :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Authorization <Authorization>`\ s """ url = self._build_url('authorizations') return self._iter(int(number), url, Authorization, etag=etag)
python
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 authorizations :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Authorization <Authorization>`\ s """ url = self._build_url('authorizations') return self._iter(int(number), url, Authorization, etag=etag)
[ "def", "iter_authorizations", "(", "self", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'authorizations'", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "Authorization", ",", "etag", "=", "etag", ")" ]
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 previous request to the same endpoint :returns: generator of :class:`Authorization <Authorization>`\ s
[ "Iterate", "over", "authorizations", "for", "the", "authenticated", "user", ".", "This", "will", "return", "a", "404", "if", "you", "are", "using", "a", "token", "for", "authentication", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L443-L454
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_emails
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 the same endpoint :returns: generator of dicts """ url = self._build_url('user', 'emails') return self._iter(int(number), url, dict, etag=etag)
python
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 the same endpoint :returns: generator of dicts """ url = self._build_url('user', 'emails') return self._iter(int(number), url, dict, etag=etag)
[ "def", "iter_emails", "(", "self", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'user'", ",", "'emails'", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "dict", ",", "etag", "=", "etag", ")" ]
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: generator of dicts
[ "Iterate", "over", "email", "addresses", "for", "the", "authenticated", "user", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L457-L467
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_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: generator of :class:`Event <github3.events.Event>`\ s """ url = self._build_url('events') return self._iter(int(number), url, Event, etag=etag)
python
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: generator of :class:`Event <github3.events.Event>`\ s """ url = self._build_url('events') return self._iter(int(number), url, Event, etag=etag)
[ "def", "iter_events", "(", "self", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'events'", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "Event", ",", "etag", "=", "etag", ")" ]
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
[ "Iterate", "over", "public", "events", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L469-L479
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_followers
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 number: (optional), number of followers to return. Default: -1 returns all followers :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`User <github3.users.User>`\ s """ if login: return self.user(login).iter_followers() return self._iter_follow('followers', int(number), etag=etag)
python
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 number: (optional), number of followers to return. Default: -1 returns all followers :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`User <github3.users.User>`\ s """ if login: return self.user(login).iter_followers() return self._iter_follow('followers', int(number), etag=etag)
[ "def", "iter_followers", "(", "self", ",", "login", "=", "None", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "if", "login", ":", "return", "self", ".", "user", "(", "login", ")", ".", "iter_followers", "(", ")", "return", "self", ".", "_iter_follow", "(", "'followers'", ",", "int", "(", "number", ")", ",", "etag", "=", "etag", ")" ]
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: -1 returns all followers :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`User <github3.users.User>`\ 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", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L481-L495
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_following
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 :param int number: (optional), number of people to return. Default: -1 returns all people you follow :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`User <github3.users.User>`\ s """ if login: return self.user(login).iter_following() return self._iter_follow('following', int(number), etag=etag)
python
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 :param int number: (optional), number of people to return. Default: -1 returns all people you follow :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`User <github3.users.User>`\ s """ if login: return self.user(login).iter_following() return self._iter_follow('following', int(number), etag=etag)
[ "def", "iter_following", "(", "self", ",", "login", "=", "None", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "if", "login", ":", "return", "self", ".", "user", "(", "login", ")", ".", "iter_following", "(", ")", "return", "self", ".", "_iter_follow", "(", "'following'", ",", "int", "(", "number", ")", ",", "etag", "=", "etag", ")" ]
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 returns all people you follow :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`User <github3.users.User>`\ s
[ "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", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L497-L511
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_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 all available gists :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Gist <github3.gists.Gist>`\ s """ if username: url = self._build_url('users', username, 'gists') else: url = self._build_url('gists') return self._iter(int(number), url, Gist, etag=etag)
python
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 all available gists :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Gist <github3.gists.Gist>`\ s """ if username: url = self._build_url('users', username, 'gists') else: url = self._build_url('gists') return self._iter(int(number), url, Gist, etag=etag)
[ "def", "iter_gists", "(", "self", ",", "username", "=", "None", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "if", "username", ":", "url", "=", "self", ".", "_build_url", "(", "'users'", ",", "username", ",", "'gists'", ")", "else", ":", "url", "=", "self", ".", "_build_url", "(", "'gists'", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "Gist", ",", "etag", "=", "etag", ")" ]
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 previous request to the same endpoint :returns: generator of :class:`Gist <github3.gists.Gist>`\ s
[ "If", "no", "username", "is", "specified", "GET", "/", "gists", "otherwise", "GET", "/", "users", "/", ":", "username", "/", "gists" ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L513-L528
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_notifications
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 in which the user is participating :param int number: (optional), how many notifications to return :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Thread <github3.notifications.Thread>` """ params = None if all: params = {'all': all} elif participating: params = {'participating': participating} url = self._build_url('notifications') return self._iter(int(number), url, Thread, params, etag=etag)
python
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 in which the user is participating :param int number: (optional), how many notifications to return :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Thread <github3.notifications.Thread>` """ params = None if all: params = {'all': all} elif participating: params = {'participating': participating} url = self._build_url('notifications') return self._iter(int(number), url, Thread, params, etag=etag)
[ "def", "iter_notifications", "(", "self", ",", "all", "=", "False", ",", "participating", "=", "False", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "params", "=", "None", "if", "all", ":", "params", "=", "{", "'all'", ":", "all", "}", "elif", "participating", ":", "params", "=", "{", "'participating'", ":", "participating", "}", "url", "=", "self", ".", "_build_url", "(", "'notifications'", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "Thread", ",", "params", ",", "etag", "=", "etag", ")" ]
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 str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Thread <github3.notifications.Thread>`
[ "Iterate", "over", "the", "user", "s", "notification", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L531-L551
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_org_issues
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 :param str filter: accepted values: ('assigned', 'created', 'mentioned', 'subscribed') api-default: 'assigned' :param str state: accepted values: ('open', 'closed') api-default: 'open' :param str labels: comma-separated list of label names, e.g., 'bug,ui,@high' :param str sort: accepted values: ('created', 'updated', 'comments') api-default: created :param str direction: accepted values: ('asc', 'desc') api-default: desc :param since: (optional), Only issues after this date will be returned. This can be a `datetime` or an ISO8601 formatted date string, e.g., 2012-05-20T23:10:27Z :type since: datetime or string :param int number: (optional), number of issues to return. Default: -1, returns all available issues :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Issue <github3.issues.Issue>` """ url = self._build_url('orgs', name, 'issues') # issue_params will handle the since parameter params = issue_params(filter, state, labels, sort, direction, since) return self._iter(int(number), url, Issue, params, etag)
python
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 :param str filter: accepted values: ('assigned', 'created', 'mentioned', 'subscribed') api-default: 'assigned' :param str state: accepted values: ('open', 'closed') api-default: 'open' :param str labels: comma-separated list of label names, e.g., 'bug,ui,@high' :param str sort: accepted values: ('created', 'updated', 'comments') api-default: created :param str direction: accepted values: ('asc', 'desc') api-default: desc :param since: (optional), Only issues after this date will be returned. This can be a `datetime` or an ISO8601 formatted date string, e.g., 2012-05-20T23:10:27Z :type since: datetime or string :param int number: (optional), number of issues to return. Default: -1, returns all available issues :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Issue <github3.issues.Issue>` """ url = self._build_url('orgs', name, 'issues') # issue_params will handle the since parameter params = issue_params(filter, state, labels, sort, direction, since) return self._iter(int(number), url, Issue, params, etag)
[ "def", "iter_org_issues", "(", "self", ",", "name", ",", "filter", "=", "''", ",", "state", "=", "''", ",", "labels", "=", "''", ",", "sort", "=", "''", ",", "direction", "=", "''", ",", "since", "=", "None", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'orgs'", ",", "name", ",", "'issues'", ")", "# issue_params will handle the since parameter", "params", "=", "issue_params", "(", "filter", ",", "state", ",", "labels", ",", "sort", ",", "direction", ",", "since", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "Issue", ",", "params", ",", "etag", ")" ]
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: accepted values: ('open', 'closed') api-default: 'open' :param str labels: comma-separated list of label names, e.g., 'bug,ui,@high' :param str sort: accepted values: ('created', 'updated', 'comments') api-default: created :param str direction: accepted values: ('asc', 'desc') api-default: desc :param since: (optional), Only issues after this date will be returned. This can be a `datetime` or an ISO8601 formatted date string, e.g., 2012-05-20T23:10:27Z :type since: datetime or string :param int number: (optional), number of issues to return. Default: -1, returns all available issues :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Issue <github3.issues.Issue>`
[ "Iterate", "over", "the", "organnization", "s", "issues", "if", "the", "authenticated", "user", "belongs", "to", "it", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L554-L584
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_repo_issues
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 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: name of the repository :param int milestone: None, '*', or ID of milestone :param str state: accepted values: ('all', 'open', 'closed') api-default: 'open' :param str assignee: '*' or login of the user :param str mentioned: login of the user :param str labels: comma-separated list of label names, e.g., 'bug,ui,@high' :param str sort: accepted values: ('created', 'updated', 'comments') api-default: created :param str direction: accepted values: ('asc', 'desc') api-default: desc :param since: (optional), Only issues after this date will be returned. This can be a `datetime` or an ISO8601 formatted date string, e.g., 2012-05-20T23:10:27Z :type since: datetime or string :param int number: (optional), number of issues to return. Default: -1 returns all issues :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Issue <github3.issues.Issue>`\ s """ if owner and repository: repo = self.repository(owner, repository) return repo.iter_issues(milestone, state, assignee, mentioned, labels, sort, direction, since, number, etag) return iter([])
python
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 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: name of the repository :param int milestone: None, '*', or ID of milestone :param str state: accepted values: ('all', 'open', 'closed') api-default: 'open' :param str assignee: '*' or login of the user :param str mentioned: login of the user :param str labels: comma-separated list of label names, e.g., 'bug,ui,@high' :param str sort: accepted values: ('created', 'updated', 'comments') api-default: created :param str direction: accepted values: ('asc', 'desc') api-default: desc :param since: (optional), Only issues after this date will be returned. This can be a `datetime` or an ISO8601 formatted date string, e.g., 2012-05-20T23:10:27Z :type since: datetime or string :param int number: (optional), number of issues to return. Default: -1 returns all issues :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Issue <github3.issues.Issue>`\ s """ if owner and repository: repo = self.repository(owner, repository) return repo.iter_issues(milestone, state, assignee, mentioned, labels, sort, direction, since, number, etag) return iter([])
[ "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", ")", ":", "if", "owner", "and", "repository", ":", "repo", "=", "self", ".", "repository", "(", "owner", ",", "repository", ")", "return", "repo", ".", "iter_issues", "(", "milestone", ",", "state", ",", "assignee", ",", "mentioned", ",", "labels", ",", "sort", ",", "direction", ",", "since", ",", "number", ",", "etag", ")", "return", "iter", "(", "[", "]", ")" ]
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: name of the repository :param int milestone: None, '*', or ID of milestone :param str state: accepted values: ('all', 'open', 'closed') api-default: 'open' :param str assignee: '*' or login of the user :param str mentioned: login of the user :param str labels: comma-separated list of label names, e.g., 'bug,ui,@high' :param str sort: accepted values: ('created', 'updated', 'comments') api-default: created :param str direction: accepted values: ('asc', 'desc') api-default: desc :param since: (optional), Only issues after this date will be returned. This can be a `datetime` or an ISO8601 formatted date string, e.g., 2012-05-20T23:10:27Z :type since: datetime or string :param int number: (optional), number of issues to return. Default: -1 returns all issues :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Issue <github3.issues.Issue>`\ s
[ "List", "issues", "on", "owner", "/", "repository", ".", "Only", "owner", "and", "repository", "are", "required", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L659-L699
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_orgs
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: (optional), number of organizations to return. Default: -1 returns all available organizations :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Organization <github3.orgs.Organization>`\ s """ if login: url = self._build_url('users', login, 'orgs') else: url = self._build_url('user', 'orgs') return self._iter(int(number), url, Organization, etag=etag)
python
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: (optional), number of organizations to return. Default: -1 returns all available organizations :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Organization <github3.orgs.Organization>`\ s """ if login: url = self._build_url('users', login, 'orgs') else: url = self._build_url('user', 'orgs') return self._iter(int(number), url, Organization, etag=etag)
[ "def", "iter_orgs", "(", "self", ",", "login", "=", "None", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "if", "login", ":", "url", "=", "self", ".", "_build_url", "(", "'users'", ",", "login", ",", "'orgs'", ")", "else", ":", "url", "=", "self", ".", "_build_url", "(", "'user'", ",", "'orgs'", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "Organization", ",", "etag", "=", "etag", ")" ]
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. Default: -1 returns all available organizations :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Organization <github3.orgs.Organization>`\ s
[ "Iterate", "over", "public", "organizations", "for", "login", "if", "provided", ";", "otherwise", "iterate", "over", "public", "and", "private", "organizations", "for", "the", "authenticated", "user", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L714-L732
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_repos
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: (optional), accepted values: ('all', 'owner', 'public', 'private', 'member') API default: 'all' :param str sort: (optional), accepted values: ('created', 'updated', 'pushed', 'full_name') API default: 'created' :param str direction: (optional), accepted values: ('asc', 'desc'), API default: 'asc' when using 'full_name', 'desc' otherwise :param int number: (optional), number of repositories to return. Default: -1 returns all repositories :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Repository <github3.repos.Repository>` objects """ url = self._build_url('user', 'repos') params = {} if type in ('all', 'owner', 'public', 'private', 'member'): params.update(type=type) if sort in ('created', 'updated', 'pushed', 'full_name'): params.update(sort=sort) if direction in ('asc', 'desc'): params.update(direction=direction) return self._iter(int(number), url, Repository, params, etag)
python
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: (optional), accepted values: ('all', 'owner', 'public', 'private', 'member') API default: 'all' :param str sort: (optional), accepted values: ('created', 'updated', 'pushed', 'full_name') API default: 'created' :param str direction: (optional), accepted values: ('asc', 'desc'), API default: 'asc' when using 'full_name', 'desc' otherwise :param int number: (optional), number of repositories to return. Default: -1 returns all repositories :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Repository <github3.repos.Repository>` objects """ url = self._build_url('user', 'repos') params = {} if type in ('all', 'owner', 'public', 'private', 'member'): params.update(type=type) if sort in ('created', 'updated', 'pushed', 'full_name'): params.update(sort=sort) if direction in ('asc', 'desc'): params.update(direction=direction) return self._iter(int(number), url, Repository, params, etag)
[ "def", "iter_repos", "(", "self", ",", "type", "=", "None", ",", "sort", "=", "None", ",", "direction", "=", "None", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'user'", ",", "'repos'", ")", "params", "=", "{", "}", "if", "type", "in", "(", "'all'", ",", "'owner'", ",", "'public'", ",", "'private'", ",", "'member'", ")", ":", "params", ".", "update", "(", "type", "=", "type", ")", "if", "sort", "in", "(", "'created'", ",", "'updated'", ",", "'pushed'", ",", "'full_name'", ")", ":", "params", ".", "update", "(", "sort", "=", "sort", ")", "if", "direction", "in", "(", "'asc'", ",", "'desc'", ")", ":", "params", ".", "update", "(", "direction", "=", "direction", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "Repository", ",", "params", ",", "etag", ")" ]
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: 'all' :param str sort: (optional), accepted values: ('created', 'updated', 'pushed', 'full_name') API default: 'created' :param str direction: (optional), accepted values: ('asc', 'desc'), API default: 'asc' when using 'full_name', 'desc' otherwise :param int number: (optional), number of repositories to return. Default: -1 returns all repositories :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Repository <github3.repos.Repository>` objects
[ "List", "public", "repositories", "for", "the", "authenticated", "user", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L735-L769
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_starred
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 GitHub's API. :param str login: (optional), name of user whose stars you want to see :param str sort: (optional), either 'created' (when the star was created) or 'updated' (when the repository was last pushed to) :param str direction: (optional), either 'asc' or 'desc'. Default: 'desc' :param int number: (optional), number of repositories to return. Default: -1 returns all repositories :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Repository <github3.repos.Repository>` """ if login: return self.user(login).iter_starred(sort, direction) params = {'sort': sort, 'direction': direction} self._remove_none(params) url = self._build_url('user', 'starred') return self._iter(int(number), url, Repository, params, etag)
python
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 GitHub's API. :param str login: (optional), name of user whose stars you want to see :param str sort: (optional), either 'created' (when the star was created) or 'updated' (when the repository was last pushed to) :param str direction: (optional), either 'asc' or 'desc'. Default: 'desc' :param int number: (optional), number of repositories to return. Default: -1 returns all repositories :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Repository <github3.repos.Repository>` """ if login: return self.user(login).iter_starred(sort, direction) params = {'sort': sort, 'direction': direction} self._remove_none(params) url = self._build_url('user', 'starred') return self._iter(int(number), url, Repository, params, etag)
[ "def", "iter_starred", "(", "self", ",", "login", "=", "None", ",", "sort", "=", "None", ",", "direction", "=", "None", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "if", "login", ":", "return", "self", ".", "user", "(", "login", ")", ".", "iter_starred", "(", "sort", ",", "direction", ")", "params", "=", "{", "'sort'", ":", "sort", ",", "'direction'", ":", "direction", "}", "self", ".", "_remove_none", "(", "params", ")", "url", "=", "self", ".", "_build_url", "(", "'user'", ",", "'starred'", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "Repository", ",", "params", ",", "etag", ")" ]
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 sort: (optional), either 'created' (when the star was created) or 'updated' (when the repository was last pushed to) :param str direction: (optional), either 'asc' or 'desc'. Default: 'desc' :param int number: (optional), number of repositories to return. Default: -1 returns all repositories :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Repository <github3.repos.Repository>`
[ "Iterate", "over", "repositories", "starred", "by", "login", "or", "the", "authenticated", "user", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L771-L797
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_subscriptions
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 repositories to return. Default: -1 returns all repositories :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Repository <github3.repos.Repository>` """ if login: return self.user(login).iter_subscriptions() url = self._build_url('user', 'subscriptions') return self._iter(int(number), url, Repository, etag=etag)
python
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 repositories to return. Default: -1 returns all repositories :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Repository <github3.repos.Repository>` """ if login: return self.user(login).iter_subscriptions() url = self._build_url('user', 'subscriptions') return self._iter(int(number), url, Repository, etag=etag)
[ "def", "iter_subscriptions", "(", "self", ",", "login", "=", "None", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "if", "login", ":", "return", "self", ".", "user", "(", "login", ")", ".", "iter_subscriptions", "(", ")", "url", "=", "self", ".", "_build_url", "(", "'user'", ",", "'subscriptions'", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "Repository", ",", "etag", "=", "etag", ")" ]
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 :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of :class:`Repository <github3.repos.Repository>`
[ "Iterate", "over", "repositories", "subscribed", "to", "by", "login", "or", "the", "authenticated", "user", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L799-L815
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.iter_user_teams
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. :returns: generator of :class:`Team <github3.orgs.Team>` objects """ url = self._build_url('user', 'teams') return self._iter(int(number), url, Team, etag=etag)
python
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. :returns: generator of :class:`Team <github3.orgs.Team>` objects """ url = self._build_url('user', 'teams') return self._iter(int(number), url, Team, etag=etag)
[ "def", "iter_user_teams", "(", "self", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'user'", ",", "'teams'", ")", "return", "self", ".", "_iter", "(", "int", "(", "number", ")", ",", "url", ",", "Team", ",", "etag", "=", "etag", ")" ]
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>` objects
[ "Gets", "the", "authenticated", "user", "s", "teams", "across", "all", "of", "organizations", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L853-L863
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.login
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_factor_callback: (optional), function you implement to provide the Two Factor Authentication code to GitHub when necessary """ if username and password: self._session.basic_auth(username, password) elif token: self._session.token_auth(token) # The Session method handles None for free. self._session.two_factor_auth_callback(two_factor_callback)
python
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_factor_callback: (optional), function you implement to provide the Two Factor Authentication code to GitHub when necessary """ if username and password: self._session.basic_auth(username, password) elif token: self._session.token_auth(token) # The Session method handles None for free. self._session.two_factor_auth_callback(two_factor_callback)
[ "def", "login", "(", "self", ",", "username", "=", "None", ",", "password", "=", "None", ",", "token", "=", "None", ",", "two_factor_callback", "=", "None", ")", ":", "if", "username", "and", "password", ":", "self", ".", "_session", ".", "basic_auth", "(", "username", ",", "password", ")", "elif", "token", ":", "self", ".", "_session", ".", "token_auth", "(", "token", ")", "# The Session method handles None for free.", "self", ".", "_session", ".", "two_factor_auth_callback", "(", "two_factor_callback", ")" ]
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 GitHub when necessary
[ "Logs", "the", "user", "into", "GitHub", "for", "protected", "API", "calls", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L878-L894
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.markdown
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', this is the repository to use as the context for the rendering :param bool raw: (optional), renders a document like a README.md, no gfm, no context :returns: str -- HTML formatted text """ data = None json = False headers = {} if raw: url = self._build_url('markdown', 'raw') data = text headers['content-type'] = 'text/plain' else: url = self._build_url('markdown') data = {} if text: data['text'] = text if mode in ('markdown', 'gfm'): data['mode'] = mode if context: data['context'] = context json = True if data: req = self._post(url, data=data, json=json, headers=headers) if req.ok: return req.content return ''
python
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', this is the repository to use as the context for the rendering :param bool raw: (optional), renders a document like a README.md, no gfm, no context :returns: str -- HTML formatted text """ data = None json = False headers = {} if raw: url = self._build_url('markdown', 'raw') data = text headers['content-type'] = 'text/plain' else: url = self._build_url('markdown') data = {} if text: data['text'] = text if mode in ('markdown', 'gfm'): data['mode'] = mode if context: data['context'] = context json = True if data: req = self._post(url, data=data, json=json, headers=headers) if req.ok: return req.content return ''
[ "def", "markdown", "(", "self", ",", "text", ",", "mode", "=", "''", ",", "context", "=", "''", ",", "raw", "=", "False", ")", ":", "data", "=", "None", "json", "=", "False", "headers", "=", "{", "}", "if", "raw", ":", "url", "=", "self", ".", "_build_url", "(", "'markdown'", ",", "'raw'", ")", "data", "=", "text", "headers", "[", "'content-type'", "]", "=", "'text/plain'", "else", ":", "url", "=", "self", ".", "_build_url", "(", "'markdown'", ")", "data", "=", "{", "}", "if", "text", ":", "data", "[", "'text'", "]", "=", "text", "if", "mode", "in", "(", "'markdown'", ",", "'gfm'", ")", ":", "data", "[", "'mode'", "]", "=", "mode", "if", "context", ":", "data", "[", "'context'", "]", "=", "context", "json", "=", "True", "if", "data", ":", "req", "=", "self", ".", "_post", "(", "url", ",", "data", "=", "data", ",", "json", "=", "json", ",", "headers", "=", "headers", ")", "if", "req", ".", "ok", ":", "return", "req", ".", "content", "return", "''" ]
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 rendering :param bool raw: (optional), renders a document like a README.md, no gfm, no context :returns: str -- HTML formatted text
[ "Render", "an", "arbitrary", "markdown", "document", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L896-L932
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.membership_in
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)
python
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)
[ "def", "membership_in", "(", "self", ",", "organization", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'user'", ",", "'memberships'", ",", "'orgs'", ",", "str", "(", "organization", ")", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_get", "(", "url", ")", ",", "200", ")", "return", "Membership", "(", "json", ",", "self", ")" ]
Retrieve the user's membership in the specified organization.
[ "Retrieve", "the", "user", "s", "membership", "in", "the", "specified", "organization", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L935-L940
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.meta
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)
python
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)
[ "def", "meta", "(", "self", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'meta'", ")", "return", "self", ".", "_json", "(", "self", ".", "_get", "(", "url", ")", ",", "200", ")" ]
Returns a dictionary with arrays of addresses in CIDR format specifying theaddresses that the incoming service hooks will originate from. .. versionadded:: 0.5
[ "Returns", "a", "dictionary", "with", "arrays", "of", "addresses", "in", "CIDR", "format", "specifying", "theaddresses", "that", "the", "incoming", "service", "hooks", "will", "originate", "from", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L942-L950
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.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: ascii art of Octocat """ url = self._build_url('octocat') req = self._get(url, params={'s': say}) return req.content if req.ok else ''
python
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 req.ok else ''
[ "def", "octocat", "(", "self", ",", "say", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'octocat'", ")", "req", "=", "self", ".", "_get", "(", "url", ",", "params", "=", "{", "'s'", ":", "say", "}", ")", "return", "req", ".", "content", "if", "req", ".", "ok", "else", "''" ]
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
[ "Returns", "an", "easter", "egg", "of", "the", "API", "." ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L952-L960
kislyuk/aegea
aegea/packages/github3/github.py
GitHub.organization
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), 200) return Organization(json, self) if json else None
python
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), 200) return Organization(json, self) if json else None
[ "def", "organization", "(", "self", ",", "login", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'orgs'", ",", "login", ")", "json", "=", "self", ".", "_json", "(", "self", ".", "_get", "(", "url", ")", ",", "200", ")", "return", "Organization", "(", "json", ",", "self", ")", "if", "json", "else", "None" ]
Returns a Organization object for the login name :param str login: (required), login name of the org :returns: :class:`Organization <github3.orgs.Organization>`
[ "Returns", "a", "Organization", "object", "for", "the", "login", "name" ]
train
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/github.py#L963-L971