~ubuntu-branches/ubuntu/utopic/maas/utopic-proposed

« back to all changes in this revision

Viewing changes to src/maasserver/api/account.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez, Diogo Matsubara, Jeroen Vermeulen, Raphaël Badin, Greg Lutostanski, Gavin Panella, Julian Edwards, Graham Binns, Andres Rodriguez
  • Date: 2014-08-21 14:05:40 UTC
  • mfrom: (1.2.35)
  • Revision ID: package-import@ubuntu.com-20140821140540-khodrzopm91kl4le
Tags: 1.7.0~beta1+bzr2781-0ubuntu1
* New upstream release, 1.7.0 Beta 1

[Diogo Matsubara]
* debian/control:
  - maas-cluster-controller depends on syslinux-dev | 
    syslinux-common (LP: #1328659)
  - python-maas-provisioningserver depends on
    python-paramiko (LP: #1334401)

[Jeroen Vermeulen]
* debian/extras/99-maas-sudoers:
  - Let maas user import, including sudo tgt-admin and sudo uec2roottar.
* debian/maas-cluster-controller.install:
  - Stop installing obsolete file bootresources.yaml.

[ Raphaël Badin ]
* debian/control:
  - maas-cluster-controller depends on python-pexpect
* debian/extras/99-maas-sudoers:
  - Add rule 'maas-dhcp-server stop' job.

[ Greg Lutostanski ]
* debian/control:
  - maas-cluster-controller depends on grub-common
  - maas-provisioningserver not maas-cluster-controller depends on
    python-pexpect (LP: #1352273)
  - maas-provisioningserver not maas-cluster-controller depends on
    python-seamicroclient (LP: #1332532)

[ Gavin Panella ]
* debian/maas-cluster-controller.postinst
  - Allow maas-pserv to bind to all IPv6 addresses too.

[ Julian Edwards ]
* debian/maas-region-controller-min.apport
  debian/maas-region-controller-min.logrotate
  debian/maas-region-controller-min.postinst
  debian/maas-region-controller.postinst
  - Change the log file name maas.log to maas-django.log
* debian/maas-cluster-controller.postinst
  debian/maas-common.install
  debian/maas-region-controller-min.postinst
  debian/maas-region-controller.postinst
  - Install /var/log/maas/maas.log as a syslog file.
  - Ensure logging is set up for upgrades 

[ Graham Binns ]
* debian/maas-region-controller.postinst:
  - Add symlinks for squid3, squid-deb-proxy and apache log directories to
    /var/log/maas.

[ Andres Rodriguez ]
* debian/maas-region-controller.postinst: Force symlink creation
  for external logs.
* debian/maas-region-controller.postinst: Do not change celery's
  rabbitmq password on upgrade that to not lock remote
  Cluster Controllers if upgrading from 1.5+. (LP: #1300507)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2014 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
"""API handler: `Account`."""
 
5
 
 
6
from __future__ import (
 
7
    absolute_import,
 
8
    print_function,
 
9
    unicode_literals,
 
10
    )
 
11
 
 
12
str = None
 
13
 
 
14
__metaclass__ = type
 
15
__all__ = [
 
16
    'AccountHandler',
 
17
    ]
 
18
 
 
19
 
 
20
from maasserver.api.support import (
 
21
    operation,
 
22
    OperationsHandler,
 
23
    )
 
24
from maasserver.api.utils import get_mandatory_param
 
25
from piston.utils import rc
 
26
 
 
27
 
 
28
class AccountHandler(OperationsHandler):
 
29
    """Manage the current logged-in user."""
 
30
    api_doc_section_name = "Logged-in user"
 
31
    create = read = update = delete = None
 
32
 
 
33
    @operation(idempotent=False)
 
34
    def create_authorisation_token(self, request):
 
35
        """Create an authorisation OAuth token and OAuth consumer.
 
36
 
 
37
        :return: a json dict with three keys: 'token_key',
 
38
            'token_secret' and 'consumer_key' (e.g.
 
39
            {token_key: 's65244576fgqs', token_secret: 'qsdfdhv34',
 
40
            consumer_key: '68543fhj854fg'}).
 
41
        :rtype: string (json)
 
42
 
 
43
        """
 
44
        profile = request.user.get_profile()
 
45
        consumer, token = profile.create_authorisation_token()
 
46
        return {
 
47
            'token_key': token.key, 'token_secret': token.secret,
 
48
            'consumer_key': consumer.key,
 
49
            }
 
50
 
 
51
    @operation(idempotent=False)
 
52
    def delete_authorisation_token(self, request):
 
53
        """Delete an authorisation OAuth token and the related OAuth consumer.
 
54
 
 
55
        :param token_key: The key of the token to be deleted.
 
56
        :type token_key: unicode
 
57
        """
 
58
        profile = request.user.get_profile()
 
59
        token_key = get_mandatory_param(request.data, 'token_key')
 
60
        profile.delete_authorisation_token(token_key)
 
61
        return rc.DELETED
 
62
 
 
63
    @classmethod
 
64
    def resource_uri(cls, *args, **kwargs):
 
65
        return ('account_handler', [])