def GetRepoIssues(self, milestone=None, state='open', assignee='*', creator=None, mentioned=None, labels=None, sort='created', direction='desc', since=None, per_page=30): method_params = {} if None is title: title = '{0:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now()) method_params = { k: v for k, v in locals().items() if None is not v and 'self' != k and 'method_params' != k } print(method_params) method = 'GET' endpoint = 'repos/:owner/:repo/issues' params = self.__auth.Route(method, endpoint).GetRequestParameters() if 'params' in params: params['params'].update(method_params) else: params['params'] = method_params print(params) paginator = web.http.Paginator.Paginator( web.service.github.api.v3.Response.Response()) url = Endpoint(endpoint).ToUrl(owner=self.__args.username, repo=os.path.basename( self.__args.path_dir_pj)) return paginator.Paginate(url, **params) """
def gets(self, visibility=None, affiliation=None, type=None, sort='full_name', direction=None, per_page=30): if (visibility is None) and (affiliation is None) and (type is None): type = 'all' self.__raise_param_error(visibility, ['all', 'public', 'private'], 'visibility') if not(None is affiliation): for a in affiliation.split(','): self.__raise_param_error(a, ['owner', 'collaborator', 'organization_member'], 'affiliation') self.__raise_param_error(type, ['all', 'owner', 'public', 'private', 'member'], 'type') self.__raise_param_error(sort, ['created', 'updated', 'pushed', 'full_name'], 'sort') if direction is None: if sort == 'full_name': direction = 'asc' else: direction = 'desc' else: self.__raise_param_error(direction, ['asc', 'desc'], 'direction') method = 'GET' endpoint = 'user/repos' #url = urllib.parse.urljoin('https://api.github.com', 'user/repos') params = self.__auth.Route(method, endpoint).GetRequestParameters() params.update(self.__GetCreateParameter(visibility, affiliation, type, sort, direction, per_page)) #params = self.__GetCreateParameter(visibility, affiliation, type, sort, direction, per_page) url = Endpoint(endpoint).ToUrl() paginator = web.http.Paginator.Paginator(web.service.github.api.v3.Response.Response()) return paginator.Paginate(url, **params)
def edit(self, name=None, description=None, homepage=None): if None is name: name = os.path.basename(self.__args.path_dir_pj) if None is description: description = self.__args.description if None is homepage: homepage = self.__args.homepage method = 'PATCH' endpoint = 'repos/:owner/:repo' #params = self.__auth.Get('PATCH', endpoint) params = self.__auth.Route(method, endpoint).GetRequestParameters() #endpoint = endpoint.replace(':owner', self.__args.username) #endpoint = endpoint.replace(':repo', os.path.basename(self.__args.path_dir_pj)) params['data'] = {} params['data']['name'] = name if not(None is description or '' == description): params['data']['description'] = description if not(None is homepage or '' == homepage): params['data']['homepage'] = homepage params['data'] = json.dumps(params['data']) #url = urllib.parse.urljoin("https://api.github.com", endpoint) url = Endpoint(endpoint).ToUrl(owner=self.__args.username, repo=os.path.basename(self.__args.path_dir_pj)) Log().Logger.debug(url) Log().Logger.debug(params['headers']) Log().Logger.debug(params['data']) r = requests.patch(url, **params) return self.__response.Get(r)
def create(self, title, body=None, labels=None, milestone=None, assignees=None): method_params = {} if None is title: title = '{0:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now()) method_params = { k: v for k, v in locals().items() if None is not v and 'self' != k and 'method_params' != k } print(method_params) method = 'POST' endpoint = 'repos/:owner/:repo/issues' params = self.__auth.Route(method, endpoint).GetRequestParameters() url = Endpoint(endpoint).ToUrl(owner=self.__args.username, repo=os.path.basename( self.__args.path_dir_pj)) Log().Logger.debug(urllib.parse.urljoin(url)) Log().Logger.debug(params) r = requests.post(urllib.parse.urljoin(url), **params) return self.__response.Get(r) """
def Create(self, scopes=None, note=None, note_url=None, client_id=None, client_secret=None, fingerprint=None): if not(self.__IsValidGrants(scopes)): raise Exception("invalid grant names.: {0}\n use from the following. : {1}".format(scopes, self.__GetGrants())) if note is None: note = "token_note_{0:%Y%m%d%H%M%S%f}".format(datetime.datetime.now()) data = {"note": note} if None is not scopes: data.update({"scopes": scopes}) if None is not note_url: data.update({"note_url": note_url}) if None is not client_id: data.update({"client_id": client_id}) if None is not client_secret: data.update({"client_secret": client_secret}) if None is not fingerprint: data.update({"fingerprint": fingerprint}) method = 'POST' endpoint = 'authorizations' params = self.__auth.Route(method, endpoint).GetRequestParameters() params['data'] = json.dumps(data) #url = 'https://api.github.com/' + endpoint url = Endpoint(endpoint).ToUrl() web.log.Log.Log().Logger.debug(url) web.log.Log.Log().Logger.debug(params) r = requests.post(url, **params) return self.__response.Get(r)
def Get(self): method = 'GET' endpoint = 'users/:username' #params = self.__reqp.Get(method, endpoint) params = self.__auth.Route(method, endpoint).GetRequestParameters() #url = 'https://api.github.com/users/{username}'.format(username=username) url = Endpoint(endpoint).ToUrl(username=username) Log().Logger.debug(url) r = requests.get(url, **params) return self.__response.Get(r)
def Delete(self, auth_id): method = 'DELETE' endpoint = 'authorizations/:id' params = self.__auth.Route(method, endpoint).GetRequestParameters() #url = 'https://api.github.com/authorizations/{auth_id}'.format(auth_id=auth_id) url = Endpoint(endpoint).ToUrl(id=auth_id) web.log.Log.Log().Logger.debug(url) web.log.Log.Log().Logger.debug(params) r = requests.delete(url, **params) return self.__response.Get(r)
def Gets(self): method = 'GET' endpoint = 'authorizations' #url = 'https://api.github.com/' + endpoint url = Endpoint(endpoint).ToUrl() params = self.__auth.Route(method, endpoint).GetRequestParameters() web.log.Log.Log().Logger.debug(url) web.log.Log.Log().Logger.debug(params) r = requests.get(url, **params) return self.__response.Get(r)
def Gets(self): method = 'GET' endpoint = 'user/emails' #params = self.__reqp.Get(method, endpoint) params = self.__auth.Route(method, endpoint).GetRequestParameters() Log().Logger.debug(params) paginator = web.http.Paginator.Paginator( web.service.github.api.v3.Response.Response()) #url = 'https://api.github.com/user/emails' url = Endpoint(endpoint).ToUrl() return paginator.Paginate(url, **params)
def list_public_repos(self, since, per_page=30): method = 'GET' endpoint = 'repositories' #params = self.__auth.Get(method, endpoint) params = self.__auth.Route(method, endpoint).GetRequestParameters() params['params'] = json.dumps({"since": since, "per_page": per_page}) print(params) Log().Logger.debug(params) #r = requests.get(urllib.parse.urljoin("https://api.github.com", endpoint), **params) url = Endpoint(endpoint).ToUrl() r = requests.get(url, **params) return self.__response.Get(r)
def create(self, name, description=None, homepage=None): method = 'POST' endpoint = 'user/repos' #params = self.__auth.Get(method, endpoint) params = self.__auth.Route(method, endpoint).GetRequestParameters() params['data'] = json.dumps({"name": name, "description": description, "homepage": homepage}) Log().Logger.debug(urllib.parse.urljoin("https://api.github.com", endpoint)) Log().Logger.debug(params) url = Endpoint(endpoint).ToUrl() #r = requests.post(urllib.parse.urljoin("https://api.github.com", endpoint), **params) r = requests.post(url, **params) return self.__response.Get(r)
def delete(self, username=None, repo_name=None): if None is username: username = self.__args.username if None is repo_name: repo_name = os.path.basename(self.__args.path_dir_pj) method = 'DELETE' endpoint = 'repos/:owner/:repo' #params = self.__auth.Get('DELETE', endpoint) params = self.__auth.Route(method, endpoint).GetRequestParameters() #endpoint = endpoint.replace(':owner', username) #endpoint = endpoint.replace(':repo', repo_name) #r = requests.delete(urllib.parse.urljoin("https://api.github.com", endpoint), **params) url = Endpoint(endpoint).ToUrl(owner=username, repo=repo_name) r = requests.delete(url, **params) return self.__response.Get(r)