def get_project_build_summary( self, username, project, limit=30, offset=0, status_filter=None, branch=None, vcs_type='github'): """Build summary for each of the last 30 builds for a single git repo. :param username: Org or user name. :param project: Case sensitive repo name. :param limit: The number of builds to return. Maximum 100, defaults \ to 30. :param offset: The API returns builds starting from this offset, \ defaults to 0. :param status_filter: Restricts which builds are returned. \ Set to "completed", "successful", "running" or "failed". \ Defaults to no filter. :param branch: Narrow returned builds to a single branch. :param vcs_type: Defaults to github. On circleci.com you can \ also pass in ``bitbucket``. :type limit: int :type offset: int :raises InvalidFilterError: when filter is not a valid filter. Endpoint: GET: ``/project/:vcs-type/:username/:project`` """ valid_filters = [None, 'completed', 'successful', 'failed', 'running'] if status_filter not in valid_filters: raise InvalidFilterError(status_filter, 'status') if branch: endpoint = 'project/{0}/{1}/{2}/tree/{3}?limit={4}&offset={5}&filter={6}'.format( vcs_type, username, project, branch, limit, offset, status_filter ) else: endpoint = 'project/{0}/{1}/{2}?limit={3}&offset={4}&filter={5}'.format( vcs_type, username, project, limit, offset, status_filter ) resp = self._request('GET', endpoint) return resp
def get_latest_artifact( self, username, project, branch=None, status_filter='completed', vcs_type='github'): """List the artifacts produced by the latest build on a given branch. .. note:: This endpoint is a little bit flakey. If the "latest" \ build does not have any artifacts, rathern than returning \ an empty set, the API will 404. :param username: org or user name :param project: case sensitive repo name :param branch: The branch you would like to look in for the latest build. Returns artifacts for latest build in entire project if omitted. :param filter: Restricts which builds are returned. defaults to 'completed' valid filters: "completed", "successful", "failed" :param vcs_type: defaults to github on circleci.com you can also pass in bitbucket :raises InvalidFilterError: when filter is not a valid filter. Endpoint: GET: ``/project/:vcs-type/:username/:project/latest/artifacts`` """ valid_filters = ['completed', 'successful', 'failed'] if status_filter not in valid_filters: raise InvalidFilterError(status_filter, 'artifacts') # passing None makes the API 404 if branch: endpoint = 'project/{0}/{1}/{2}/latest/artifacts?branch={3}&filter={4}'.format( vcs_type, username, project, branch, status_filter ) else: endpoint = 'project/{0}/{1}/{2}/latest/artifacts?filter={3}'.format( vcs_type, username, project, status_filter ) resp = self._request('GET', endpoint) return resp
def setUp(self): self.base = CircleCIException('fake') self.key = BadKeyError('fake') self.verb = BadVerbError('fake') self.filter = InvalidFilterError('fake', 'status') self.afilter = InvalidFilterError('fake', 'artifacts')