Giter Club home page Giter Club logo

python-gitlab3's People

Contributors

alexvh avatar doctormo avatar klowner avatar lhelwerd avatar lyda avatar msshin avatar odwyer avatar samrocketman avatar weberw avatar

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

Watchers

 avatar  avatar  avatar  avatar  avatar

python-gitlab3's Issues

Creation of projects in groups

Creating a project within a group / namespace seems to be only possible by:

repo = gl.add_project(reponame) # this creates the project in the user's namespace
if repo:
    mygroup.transfer_project(repo.id) # api user needs admin rights for this, while directly creating it within group mygroup would work since it is a master user on the group :(

Self-Signed Certificates

I saw there is a correction on Self-Signed Certificates, but this functionality is not working yet. I still cannot connect to my gitlab due to get request fail. When will the Self-Signed Certificates issue will be release?

Please release v0.5.3

It seems that v0.5.2 of python-gitlab3 still has a critical bug.

https://github.com/alexvh/python-gitlab3/blob/v0.5.2/gitlab3/__init__.py#L354

However, if you use master the bug is fixed.

https://github.com/alexvh/python-gitlab3/blob/master/gitlab3/__init__.py#L354-L355

I'm getting reports of users having trouble because of this and I didn't realize it before. Could you please release v0.5.3 based off of master?

My own local issue for tracking is samrocketman/gitlab-mirrors#27. I see you have v0.5.3 and v0.5.4 listed in the changelog. Perhaps this just needs to be tagged.

It's really easy to hurt yourself

While the dynamically generated objects are fun it's really easy to hurt yourself. For example I did the following....

group.delete_member(git.find_user(username="sag47"))

I deleted my user entirely from GitLab. When I'm developing against an API I usually use the python interactive interpreter to test out the functions as I go along. Can you think of a way to protect against actions like this? I imagine that if I passed a group object to that delete_member function it would delete the group as well (and delete all of the projects located within it).

Luckily I'm on a test instance doing development but I think it would be useful to think about. I'm still new to your well formed interface python code. I've not seen anybody create classes like that before (though it is pretty cool). I'll try to brainstorm and come up with an acceptable solution as well. Perhaps doing a test for object type before executing anything and provide a meaningful exception.

The reason why I thought to do that with the user object is because in the interactive prompt I saw the following error message...

>>> group.delete_member(5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.1-py2.7.egg/gitlab3/__init__.py", line 204, in parent_fn
    return obj.delete()
AttributeError: 'int' object has no attribute 'delete'

where the int is my user.id. I thought to myself, "Oh, it must want a user object!" Sadly I boarded the fail train.

:goberserk:

Boolean values are incorrectly marshaled on save

Boolean values (e.g. Hook.push_events) are incorrectly handled on save().
A value of True is interpreted as false by the Gitlab API. Since in objects loaded from the Gitlab API boolean values are converted to Python types, all boolean fields will be set to false on save.

Possible issue with DELETE group and project

Now that I actually start using it I encountered an issue for Group. About to test project.

>>> git.Group(43).delete()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.1-py2.7.egg/gitlab3/__init__.py", line 206, in self_fn
    return self._delete(api._q_url)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.1-py2.7.egg/gitlab3/__init__.py", line 418, in _delete
    return self._request(requests.delete, api_url, addl_keys, data)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.1-py2.7.egg/gitlab3/__init__.py", line 429, in _request
    self._check_status_code(r.status_code, url, data)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.1-py2.7.egg/gitlab3/__init__.py", line 405, in _check_status_code
    raise self._code_to_exc[status_code](msg)
gitlab3.exceptions.ResourceNotFound: URL: https://example.com/api/v3/groups/:id, Data: None

And now for project...

>>> git.Project(185).delete()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.1-py2.7.egg/gitlab3/__init__.py", line 206, in self_fn
    return self._delete(api._q_url)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.1-py2.7.egg/gitlab3/__init__.py", line 418, in _delete
    return self._request(requests.delete, api_url, addl_keys, data)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.1-py2.7.egg/gitlab3/__init__.py", line 429, in _request
    self._check_status_code(r.status_code, url, data)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.1-py2.7.egg/gitlab3/__init__.py", line 405, in _check_status_code
    raise self._code_to_exc[status_code](msg)
gitlab3.exceptions.ResourceNotFound: URL: https://example.com/api/v3/projects/:id, Data: None

API interfaces are out of date

The latest GitLab API create project documentation includes the optional parameter namespace_id which I would like to use. I have an open enhancement with samrocketman/gitlab-mirrors#66. Any chance you could get around to updating the API? If you like we could use this ticket to track which API interfaces are out of date.

get single project by id or namespace/name

V3 API allows to get a single project by id or NAMESPACE/PROJECT_NAME

Get single project

Get a specific project, identified by project ID or NAMESPACE/PROJECT_NAME, which is owned by     the authenticated user. If using namespaced projects call make sure that the     NAMESPACE/PROJECT_NAME is URL-encoded, eg. /api/v3/projects/diaspora%2Fdiaspora (where / is     represented by %2F).

GET /projects/:id
Parameters:

id(required) - The ID or NAMESPACE/PROJECT_NAME of a project

Using gitlab3.project('namespace/projectname') yelds ResourceNotFound as it doesn't encode the '/'

Easily worked around by doing so in the call (gitlab3.project('namespace%2Fprojectname')) but maybe it should be done by the library itself.

gitlab3.exceptions.MissingRequiredAttribute

i using gitlab-mirrors to mirror github repo, it always throw exception during mirror https://github.com/AFNetworking/AFNetworking.git, other repo is ok

Traceback (most recent call last):
  File "lib/manage_gitlab_project.py", line 109, in <module>
    found_project=createproject(project_name)
  File "lib/manage_gitlab_project.py", line 95, in createproject
    new_project=git.add_project(pname,description=description,**project_options)
  File "build/bdist.linux-x86_64/egg/gitlab3/__init__.py", line 184, in fn
  File "build/bdist.linux-x86_64/egg/gitlab3/__init__.py", line 418, in _post
  File "build/bdist.linux-x86_64/egg/gitlab3/__init__.py", line 435, in _request
  File "build/bdist.linux-x86_64/egg/gitlab3/__init__.py", line 411, in _check_status_code
gitlab3.exceptions.MissingRequiredAttribute: URL: http://gitlab.dev/api/v3/projects, Data: {'wall_enabled': 'false', 'snippets_enabled': 'false', 'merge_requests_enabled': 'false', 'name': 'AFNetworking-AFNetworking', 'issues_enabled': 'false', 'wiki_enabled': 'false', 'public': 'true', 'description': 'Mirror of https://github.com/AFNetworking/AFNetworking.git'}

Gitlab: 7.8.1
Gitlab3: 0.5.4

How to get all projects from all users

Sorry I'm not sure this is an issue, but I'm looking for the gitlab API feature that returns all projects from all users ("GET /projects/all"), and I can't find out how to do it with your API.

Is it possible? Thanks.

Transferring a project is forbidden with GitLab 7.6.2

In a nutshell... (this is on a virtualbox image so none of the secrets matter)

import gitlab3 as gitlab
token_secret='xmjRs_poU_RdQUGMBeqN'
gitlab_url='http://192.168.10.111'
gitlab_namespace='Mirrors'
gitlab_user='gitmirror'
git=gitlab.GitLab(gitlab_url=gitlab_url,token=token_secret,ssl_verify=True)
#a group was created with an ID of 3 and project that has an ID of 2
git.group(3).transfer_project(2)

From that action I get the following exception stack trace.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/gitlab3/__init__.py", line 248, in fn
    return req_fn(_self, url, addl_keys=arg_keys, data=kwargs)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3/__init__.py", line 418, in _post
    return self._request(requests.post, api_url, addl_keys, data)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3/__init__.py", line 435, in _request
    self._check_status_code(r.status_code, url, data)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3/__init__.py", line 411, in _check_status_code
    raise self._code_to_exc[status_code](msg)
gitlab3.exceptions.ForbiddenRequest: URL: http://192.168.10.111/api/v3/groups/3/projects/2, Data: {}

Use incremental tags

I request that you use incremental tags for your releases. I'm currently using another library but have an open issue to use yours (see samrocketman/gitlab-mirrors#11). e.g.

The setup.py history would be a good place to start for deciding what commits to tag with versions.

This would be highly beneficial to me. Right now the current library I'm using doesn't use tags the way I would like and the development workflow seems to be unstable (they're still learning workflow so that's expected). However, if you note in my prerequisite documentation you'll see that I refer to the commit ID of the pyapi-gitlab library rather than using a tag or a branch. This is to ensure guaranteed compatibility when installing my software. I'm writing my software with the intention to run it on production systems so I'd like a stable library to use.

If you use tags then I will be able to easily refer to a tag rather than a very large commit ID. Commit IDs don't bode well for someone implementing my software in a production system. It seems you already have a good set up for tagging but you just haven't done it yet.

Error when adding ssh key to user

I'm logged in as admin and I'm trying to add a ssh key to a user using the command gl_user.add_ssh_key(title, ssh_key). I get the following exception

Traceback (most recent call last):
  File "./link_users_to_projects.py", line 136, in <module>
    gl_user.add_ssh_key(title, ssh_key)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.2-py2.7.egg/gitlab3/__init__.py", line 184, in fn
    data = parent._post(api._uq_url, data=kwargs)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.2-py2.7.egg/gitlab3/__init__.py", line 416, in _post
    return self._request(requests.post, api_url, addl_keys, data)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.2-py2.7.egg/gitlab3/__init__.py", line 433, in _request
    self._check_status_code(r.status_code, url, data)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.2-py2.7.egg/gitlab3/__init__.py", line 409, in _check_status_code
    raise self._code_to_exc[status_code](msg)
gitlab3.exceptions.ResourceNotFound: URL: https://gitlab.c3sl.ufpr.br/api/v3/users/114/keys, Data: {'key': 'ssh-dss AAAAB3NzaC1kc3MAAACBAOo/7hdfdVrw/nviuqk8RyJr1U1zkgwrrvio+qqtVBSLyW97xQreSwuWeGpPWYB8b2yMMW8wz34EUfPHtiiKU02ZkxOEmaaza+KojizhoPNkM+l6pUwmz/2rSi176VLmOXSdRFb3Ng58iDvFCyjwFK8NqVHELXjjYdOQJzxW2WLtAAAAFQC3nj4MtGVrIvivSi63okCUi4TglQAAAIEA0vk5nhFca6K7XW8aJD6RxQpBNaad06l0u8FJU6CxmNNEDW2K07n91NoFh946pn4pV5YnuYOCt5nedPmggGebQ7kRfWCZcdgviAqlYyuV+1r8VPlLgOg+R+eV6XTNWOSgd1aXckXI5TSWbH7kV4dDUr6xV8jtt6sefRf1A+f7q4AAAACBALXQRBTWkHwxquPZi2ui4yRTubNdtatgEjSFmoC1V+wrA9Z5xl3ViQl2eOKlQCQDfHaJFzC/UvBkilggUZfL4NyuSWueL5XR02iA6BjJEGHHSORsSG0NrgIIupwd5VSB+4oSWOagAjhm5laZYCWFnuqS7J9l2h3x21xt3W0UC6Ib eap08@mumm', 'title': 'eap08@mumm'}

Can only connect to one server at a time

I was trying to use the library to migrate some information from an older server to a new server, so I did

old = GitLab(old_url, old_token)
new = GitLab(new_url, new_token)

for u in old.users():
    print u.name

This showed me users from the new server instead of the old server.

get_user error

here is the code

>>> gl.get_user(130)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/py3/lib/python3.6/site-packages/gitlab3/__init__.py", line 158, in fn
    if key and '/' in key:
TypeError: argument of type 'int' is not iterable
>>>

NotImplementedError: a tzinfo subclass must implement dst()

The class GitLabTzInfo doesn't implement dst()

The result is a NotImplementedError while trying to do strftime on a commit date:

In [109]: create_date = gl.project(1).commits()[0].created_at

In [110]: create_date.strftime("%Y")
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-110-a0314fffbd8e> in <module>()
----> 1 create_date.strftime("%Y")

NotImplementedError: a tzinfo subclass must implement dst()

A work-around is to set create_date.tzinfo.dst = lambda _: None

https://github.com/alexvh/python-gitlab3/blob/master/gitlab3/__init__.py#L359

Does not work with GitLab 6.4.3

>>> import gitlab3
>>> git=gitlab.GitLab('https://gitlab.example.com/','abcdefg_token')
>>> git.find_user(username="sag47")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.2-py2.7.egg/gitlab3/__init__.py", line 145, in fn
    return _find_matches(objects, kwargs, find_all)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.2-py2.7.egg/gitlab3/__init__.py", line 103, in _find_matches
    for obj in objects:
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.2-py2.7.egg/gitlab3/__init__.py", line 57, in _query_list
    yield api_cls(parent, obj)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.2-py2.7.egg/gitlab3/__init__.py", line 316, in __init__
    self._convert_dates(json_data)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.2-py2.7.egg/gitlab3/__init__.py", line 343, in _convert_dates
    data[key] = self._convert_gitlab_date(val)
  File "/usr/local/lib/python2.7/dist-packages/gitlab3-0.5.2-py2.7.egg/gitlab3/__init__.py", line 354, in _convert_gitlab_date
    dt = datetime.strptime(datetime_str, fmt)
  File "/usr/lib/python2.7/_strptime.py", line 328, in _strptime
    data_string[found.end():])
ValueError: unconverted data remains: .000

I get that for functions which previously worked. It's been a while since I've picked this up so I can only assume the API has changed enough that your lib no longer works.

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.