Skip to content

Commit

Permalink
Remove deprecated objects/methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauvain Pocentek committed Nov 10, 2017
1 parent c30121b commit ba6e09e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 79 deletions.
13 changes: 13 additions & 0 deletions RELEASE_NOTES.rst
Expand Up @@ -4,6 +4,19 @@ Release notes

This page describes important changes between python-gitlab releases.

Changes from 1.1 to 1.2
=======================

* The following deprecated methods and objects have been removed:

* gitlab.v3.object ``Key`` and ``KeyManager`` objects: use ``DeployKey`` and
``DeployKeyManager`` instead
* gitlab.v3.objects.Project ``archive_`` and ``unarchive_`` methods
* gitlab.Gitlab ``credentials_auth``, ``token_auth``, ``set_url``,
``set_token`` and ``set_credentials`` methods. Once a Gitlab object has been
created its URL and authentication information cannot be updated: create a
new Gitlab object if you need to use new information

Changes from 1.0.2 to 1.1
=========================

Expand Down
4 changes: 2 additions & 2 deletions docs/gl_objects/deploy_keys.rst
Expand Up @@ -16,8 +16,8 @@ Reference

* v3 API:

+ :class:`gitlab.v3.objects.Key`
+ :class:`gitlab.v3.objects.KeyManager`
+ :class:`gitlab.v3.objects.DeployKey`
+ :class:`gitlab.v3.objects.DeployKeyManager`
+ :attr:`gitlab.Gitlab.deploykeys`

* GitLab API: https://docs.gitlab.com/ce/api/deploy_keys.html
Expand Down
48 changes: 0 additions & 48 deletions gitlab/__init__.py
Expand Up @@ -118,7 +118,6 @@ def __init__(self, url, private_token=None, oauth_token=None, email=None,
self.users = objects.UserManager(self)
self.todos = objects.TodoManager(self)
if self._api_version == '3':
self.keys = objects.KeyManager(self)
self.teams = objects.TeamManager(self)
else:
self.dockerfiles = objects.DockerfileManager(self)
Expand Down Expand Up @@ -198,12 +197,6 @@ def auth(self):
else:
self._credentials_auth()

def credentials_auth(self):
"""Performs an authentication using email/password."""
warnings.warn('credentials_auth() is deprecated and will be removed.',
DeprecationWarning)
self._credentials_auth()

def _credentials_auth(self):
if not self.email or not self.password:
raise GitlabAuthenticationError("Missing email/password")
Expand All @@ -221,12 +214,6 @@ def _credentials_auth(self):

self._set_token(self.user.private_token)

def token_auth(self):
"""Performs an authentication using the private token."""
warnings.warn('token_auth() is deprecated and will be removed.',
DeprecationWarning)
self._token_auth()

def _token_auth(self):
if self.api_version == '3':
self.user = self._objects.CurrentUser(self)
Expand Down Expand Up @@ -256,17 +243,6 @@ def version(self):

return self._server_version, self._server_revision

def set_url(self, url):
"""Updates the GitLab URL.
Args:
url (str): Base URL of the GitLab server.
"""
warnings.warn('set_url() is deprecated, create a new Gitlab instance '
'if you need an updated URL.',
DeprecationWarning)
self._url = '%s/api/v%s' % (url, self._api_version)

def _construct_url(self, id_, obj, parameters, action=None):
if 'next_url' in parameters:
return parameters['next_url']
Expand All @@ -291,17 +267,6 @@ def _construct_url(self, id_, obj, parameters, action=None):
else:
return url

def set_token(self, token):
"""Sets the private token for authentication.
Args:
token (str): The private token.
"""
warnings.warn('set_token() is deprecated, use the private_token '
'argument of the Gitlab constructor.',
DeprecationWarning)
self._set_token(token)

def _set_token(self, private_token, oauth_token=None):
self.private_token = private_token if private_token else None
self.oauth_token = oauth_token if oauth_token else None
Expand All @@ -315,19 +280,6 @@ def _set_token(self, private_token, oauth_token=None):
if "PRIVATE-TOKEN" in self.headers:
del self.headers["PRIVATE-TOKEN"]

def set_credentials(self, email, password):
"""Sets the email/login and password for authentication.
Args:
email (str): The user email or login.
password (str): The user password.
"""
warnings.warn('set_credentials() is deprecated, use the email and '
'password arguments of the Gitlab constructor.',
DeprecationWarning)
self.email = email
self.password = password

def enable_debug(self):
import logging
try:
Expand Down
29 changes: 0 additions & 29 deletions gitlab/v3/objects.py
Expand Up @@ -19,7 +19,6 @@
from __future__ import absolute_import
import base64
import json
import warnings

import six
from six.moves import urllib
Expand Down Expand Up @@ -295,23 +294,6 @@ class BroadcastMessageManager(BaseManager):
obj_cls = BroadcastMessage


class Key(GitlabObject):
_url = '/deploy_keys'
canGet = 'from_list'
canCreate = False
canUpdate = False
canDelete = False

def __init__(self, *args, **kwargs):
warnings.warn("`Key` is deprecated, use `DeployKey` instead",
DeprecationWarning)
super(Key, self).__init__(*args, **kwargs)


class KeyManager(BaseManager):
obj_cls = Key


class DeployKey(GitlabObject):
_url = '/deploy_keys'
canGet = 'from_list'
Expand Down Expand Up @@ -2043,11 +2025,6 @@ def archive(self, **kwargs):
raise_error_from_response(r, GitlabCreateError, 201)
return Project(self.gitlab, r.json()) if r.status_code == 201 else self

def archive_(self, **kwargs):
warnings.warn("`archive_()` is deprecated, use `archive()` instead",
DeprecationWarning)
return self.archive(**kwargs)

def unarchive(self, **kwargs):
"""Unarchive a project.
Expand All @@ -2063,12 +2040,6 @@ def unarchive(self, **kwargs):
raise_error_from_response(r, GitlabCreateError, 201)
return Project(self.gitlab, r.json()) if r.status_code == 201 else self

def unarchive_(self, **kwargs):
warnings.warn("`unarchive_()` is deprecated, "
"use `unarchive()` instead",
DeprecationWarning)
return self.unarchive(**kwargs)

def share(self, group_id, group_access, **kwargs):
"""Share the project with a group.
Expand Down

0 comments on commit ba6e09e

Please sign in to comment.