Giter Club home page Giter Club logo

pyapi-gitlab's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyapi-gitlab's Issues

GitLab 6.2 release API changes

It's that time again... API changes in the new 6.2 release. Namely:

  - Added search for projects by name to api (Izaak Alpert)
  - API: Remove group
  - API: Remove project

Also, not sure why it isn't in the CHANGELOG but but according to a blog post Feature: Download repo archive (Izaak Alpert) has been added as well.

Versions, tags and branches

You should take advantage of tags and branches. You should also version your software and keep stability branches for each major version. Similar to how @gitlabhq does it in their projects. As fast as development is for GitLab I think it would be useful in case you need to completely refactor python-gitlab for a new version of GitLab you have a stable branch for previous versions of GitLab. Just thinking ahead. Tags would provide releases for people to download. Since you don't take advantage of that I mention which commit ID to checkout in your project in my documentation because it's the only way to ensure that it works with that version since you don't use tags or branches.

git-flow is a popular workflow method which I like to use. As part of that workflow ideally you should only accept pull requests which come from branches off of master. Accepting master branch pull requests from forked projects is not a good workflow model and has the great potential of messing up your code base. If you notice with each pull request I make to you it comes from a branch off of master but not master itself.

Host, User, and Token are required

git = gitlab.Gitlab("our_gitlab_host", token="mytoken")

That no longer works with the latest 6.1 branch of pyapi-gitlab. Now at a minimum host and user are required with token being optional (see source).

Is that intended? Should I update the documentation and pull request? I honestly think the old behavior was fine because it works just fine with just a host and token. Now you require user to be in the mix.

Update PyPI index with Python3 fix

The fix for Python3 in 84a2b08 is not available from PyPI. It would be great if this can be updated too. (I do know this is probably the wrong venue for this issue, but I couldn't find a better place. Feel free to delete me :))

No need for specifying GitLab version 5 or 6

I'd like to note that your previous code worked with GitLab 6. I think rather than forcing the python-gitlab user to specify which version of GitLab they're using it would be better to check if the public option exists.

If the public option exists, then use the new GitLab 6 createProject else fall back to GitLab 5 behavior. This will simplify usage of your API.

createproject() in the given group

Hi,

I have a very simple problem when creating a project. I would like to create the project in the given group, but I don't see this option in the list of arguments for createproject() function.

When I create a project it is created in my namespace say Administrator/. How can I move it to the group foo? I tried to use the function git.moveproject(groupID, projectID), but I can't get the project ID, as it is not visible when using function git.getprojects(), although I see it created in my namespace via gitlab web interface. So how I can get the projectID of the project created with createproject or create it the given group? Thank you for any hint.

verify_ssl parameter not passed to get/post requests

Dear users (and maintainer ;) ),

I'm using the wrapper script in combination with a (self-signed certiticate) gitlab instance:

git = gitlab.Gitlab("gitlab-instance-url", token="my-token", verify_ssl=False)

It works with a few methods, but not when using e.g. the wall methods. For example the *getissuewallnotes method:

request = requests.get(self.projects_url + "/" + str(project_id) + "/issues/" + str(issue_id) + "/notes", headers=self.headers)

Compared to the getprojectissue method, the verify=self.verify_ssl option is not passed. I changed the getissuewallnotes method to:

request = requests.get(self.projects_url + "/" + str(project_id) + "/issues/" + str(issue_id) + "/notes", headers=self.headers, verify=self.verify_ssl)

And everything works fine. There are a few more methods, where the verify option won't be passed like getsnippetwallnotes or getmergerequestwallnotes. I just want to report that issue.

Stefan

Is there a way to push to repos using the api?

I have a gitlab instance running. I can get the repo/project details using the api. But how can I push directly to the repo using the API? Has it been implemented?
I have been through the docs but have not found anything.

Import problem

Hi,

I have installed the latest version of gitlab, 6.6.5. In order to migrate from a gitolite to my fresh gitlab installation, I want to use the API to create my git repositories.

For this I've made a little python script

#!/usr/bin/env python

import gitlab
git.Gitlab("http://gitlab.domain.com", token="XXX")

and I have a error :

Traceback (most recent call last):
  File "/tmp/gitlab.py", line 6, in <module>
    from gitlab import Gitlab
  File "/tmp/gitlab.py", line 6, in <module>
    from gitlab import Gitlab
ImportError: cannot import name Gitlab

I never had this error on a python script. Do anybody has a idea of what's going on ?

Regards,

Params page and per_page

Hi,
methods like git.getprojects() git.getusers(), etc. have parameters page=1 and per_page=20. These parameters are not in documentation and it can influence behavior of Python script a lot. It means that your script will work for few projects, users, groups, but when you go to the production, then it will stop to work, because you have hundreds of users, projects, etc.

I vote to remove/modify these parameter. If default parameter values would be None, then these methods would just get all projects, all users, etc., because it is thing, you usually want.

Cheers,
Jiri

Question

While running a small example:

import gitlab
git = gitlab.Gitlab("our_gitlab_host", token="mytoken")

I get the message

'module' object has no attribute 'Gitlab'

Code refactoring

Hi,
I strongly recommend to split init.py to several files. It would be also more logical to have several classes for Projects, Hooks, Groups, etc.

BTW: your pylint rating is very low: 3.69/10

Cheers,

Jiri

where is acceptmergerequest method?

i cannot find it. :(

In [2]: g = gitlab.Gitlab('http://xxxx')

In [3]: g.a
g.addcommenttomergerequest g.addprojectmember
g.adddeploykey g.addsshkey
g.addgroupmember g.addsshkeyuser
g.addprojecthook g.api_url

editissue() not working

if you do not pass all the parameters to editissue() it fails. we have to check if the args are empty before adding them to data.

There is gotta be a better way of doing this.

addsshkeyuser() doesn't work

This piece of code is wrong

    def addsshkeyuser(self, id_, title, key, sudo=""):
        """
        Add a new ssh key for the user identified by id
        :param id_: id of the user to add the key to
        :param title: title of the new key
        :param key: the key itself
        :return: true if added, false if it didn't add it
        (it could be because the name or key already exists)
        """
        data = {"title": title, "key": key}
        if sudo != "":
            data['sudo'] = sudo
        request = requests.post(self.keys_url + "/" + str(id_) + "/keys",
                                headers=self.headers, data=data)
        if request.status_code == 201:
            return True
        else:
            print(request)
            return False

But the problem with it is the url. No idea if it has changed on gitlab 6, or it was broken before but hte new url is:

POST /users/:id/keys

And we are using:

self.keys_url + "/" + str(id_) + "/keys"

where self.keys_url is:

self.host + "/api/v3/user/keys"

So we are missing the "s", so we need to change it to the users url which is:

self.users_url = self.host + "/api/v3/users"

Security of API calls

For any API call I need to attach a private_token and username as this

GET http://example.com/api/v3/projects?private_token=QVy1PB7sTxfy4pqfZM1U&sudo=username

Anybody snooping can find out the token username pair and cause havoc.
This can be fixed by restricting the domains from which API requests are handled by the git server.
Is there more elegant way of doing this? Am I missing something in the API?

Got 'u' prefix for every key/value pair of returned json

I simply called like below

import gitlab
git = gitlab.Gitlab('mygitlab.com', "sfsafasf1232eadssaf")
print git.getrepositories(1)

Here's piece of output

[{u'commit': {u'committer': {u'name': u'xxx', u'email': u'[email protected]'}, u'author': {u'name': u'xxx', u'email': u'[email protected]'}, u'tree': u'977592ce4a4460dc071a6f6fa99ffcb3b4ee4345', u'parents': [{u'id': u'ca36a241030f04cbd79c7e5fc72c60c518041c12'}], u'committed_date': u'2014-01-26T14:46:22+08:00', ..............

What's wrong with me? Thanks
I'm running on gitlab 6.4.3

Project description references python-gitlab

Your project description just under your project name states...

python-gitlab is a python wrapper for the Gitlab API.

I assume this is simply old and you're accidentally calling it python-gitlab.

Too generic test paths

I got a bug report for the pyapi-gitlab Debian package:

python-gitlab and python3-gitlab respectively ship the overly generic paths /usr/lib/python2.7/dist-packages/tests/__init__.py and /usr/lib/python3/dist-packages/tests/__init__.py, leading to de facto conflicts with similarly broken packages. Please either install these tests somewhere less likely to cause trouble or omit them altogether.

Please move the tests into the the gitlab namespace by putting them into the gitlab directory or adding gitlab_ as prefix or similar.

Add deploy keys

there is no way of interacting witht he repositories yet.

Add repository

There is no way of interacting with the repositories yet

Separate the library into smaller parts

Having so many functions into one class and one file is kind of ugly and it goes against PEP (too many functions for a class I believe).

We need to check if its viable to split it in several classes so you import what you need (from gitlab import projects for example)

sudo added to GitLab 6.1 API

GitLab 6.1 now has sudo as an option. I think it would be worth adding to the API of python-gitlab. You should start this in a new branch and tag it for 6.1 when it's ready. I'll add it if I ever need this functionality but for now I'm still working on other things in my corporate setup.

Get Labels API doesn't have pagination but pyapi `getlabels` does

Hi,

According to the GitLab docs, Get/List Labels does not have any pagination. However, this API does and has the page and per_page params. GitLab seems to ignore the extra params and keeps returning the full list of labels. So when getlabels is called with page=2, it still returns the full list, even with per_page=1.

Note that in a GitLab project Labels web page, it does paginate by 20 but via the API, it remains un-paginated and returns the whole list.

Had trouble with setting options for createProject

gitlabhq/gitlab-recipes#126

I was having trouble with setting new options for git.createProject. I was passing options to the function as booleans like True and I even tried str(True). I found that the API is expecting a number such as 0 or 1 e.g. public=1. I resolved that issue by writing str(int(True)).

Not sure if you care to modify anything as it wasn't really a problem with your project. But it might confuse developers trying to develop against the API with python-gitlab. Perhaps it would be useful to add a documentation example for git.createProject where it is setting some options changing defaults.

SSL ERROR

import gitlab
git = gitlab.Gitlab("https://gitlab.xxx.com")
git.login("[email protected]","xxxxx")

Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.6/site-packages/pyapi_gitlab-6.2.3-py2.6.egg/gitlab/init.py", line 53, in login
headers={"connection": "close"})
File "/usr/lib/python2.6/site-packages/requests-2.3.0-py2.6.egg/requests/api.py", line 88, in post
return request('post', url, data=data, *_kwargs)
File "/usr/lib/python2.6/site-packages/requests-2.3.0-py2.6.egg/requests/api.py", line 44, in request
return session.request(method=method, url=url, *_kwargs)
File "/usr/lib/python2.6/site-packages/requests-2.3.0-py2.6.egg/requests/sessions.py", line 456, in request
resp = self.send(prep, *_send_kwargs)
File "/usr/lib/python2.6/site-packages/requests-2.3.0-py2.6.egg/requests/sessions.py", line 585, in send
history = [resp for resp in gen] if allow_redirects else []
File "/usr/lib/python2.6/site-packages/requests-2.3.0-py2.6.egg/requests/sessions.py", line 179, in resolve_redirects
allow_redirects=False,
File "/usr/lib/python2.6/site-packages/requests-2.3.0-py2.6.egg/requests/sessions.py", line 559, in send
r = adapter.send(request, *_kwargs)
File "/usr/lib/python2.6/site-packages/requests-2.3.0-py2.6.egg/requests/adapters.py", line 382, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [Errno 1] _ssl.c:492: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

JSON response from createissue is discarded

The createissue function discards the returned json and only returns true or false.

This makes it much harder to work on an issue you just created via a script.

If you change:

 if request.status_code == 201:
            return True
        else:

            return False

to:

 if request.status_code == 201:
            return json.loads(request.content.decode("utf-8"))
        else:

            return False

It would allow a script to work on a created issue immediately instead of having to try and figure out what the ID of the new issue is.

Add new version to PIP

Bump the version, and add it to PIP... there are already 70+ commits of features since last version (6.3.2).

Custom Access Levels for Groups

So right now it seems that access levels for groups are hardcoded to only support the official gitlab access levels, would it be possible to add in support for custom access levels like so:

def addgroupmember(self, groupid, user_id, access_level, sudo="", custom=10):
    ...
    elif access_level.lower() == "guest":
        access_level = 10
    else:
        access_level = custom

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.