Add unauthenticated signup support to stacktask client.
* Unauthenticated requests to sign-up require --bypass-url as we can not use Openstack service catalog. Change-Id: I1545e620e148bfffee46324bff9467f0cd6b6593
This commit is contained in:
parent
4c65446546
commit
b7f6bc52c7
@ -13,12 +13,13 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from stacktaskclient.common import http
|
from stacktaskclient.common import http
|
||||||
from stacktaskclient.v1 import users
|
|
||||||
from stacktaskclient.v1 import roles
|
|
||||||
from stacktaskclient.v1 import tokens
|
|
||||||
from stacktaskclient.v1 import tasks
|
|
||||||
from stacktaskclient.v1 import notifications
|
from stacktaskclient.v1 import notifications
|
||||||
|
from stacktaskclient.v1 import roles
|
||||||
|
from stacktaskclient.v1 import signup
|
||||||
from stacktaskclient.v1 import status
|
from stacktaskclient.v1 import status
|
||||||
|
from stacktaskclient.v1 import tasks
|
||||||
|
from stacktaskclient.v1 import tokens
|
||||||
|
from stacktaskclient.v1 import users
|
||||||
|
|
||||||
|
|
||||||
class Client(object):
|
class Client(object):
|
||||||
@ -40,6 +41,7 @@ class Client(object):
|
|||||||
self.managed_roles = roles.ManagedRoleManager(self.http_client)
|
self.managed_roles = roles.ManagedRoleManager(self.http_client)
|
||||||
self.tokens = tokens.TokenManager(self.http_client)
|
self.tokens = tokens.TokenManager(self.http_client)
|
||||||
self.tasks = tasks.TaskManager(self.http_client)
|
self.tasks = tasks.TaskManager(self.http_client)
|
||||||
|
self.signup = signup.SignupManager(self.http_client)
|
||||||
self.notifications = notifications.NotificationManager(
|
self.notifications = notifications.NotificationManager(
|
||||||
self.http_client)
|
self.http_client)
|
||||||
self.status = status.StatusManager(self.http_client)
|
self.status = status.StatusManager(self.http_client)
|
||||||
|
@ -350,9 +350,7 @@ def do_user_invite(sc, args):
|
|||||||
@utils.arg('user_id', metavar='<userid>',
|
@utils.arg('user_id', metavar='<userid>',
|
||||||
help=_('User id for unconfirmed user.'))
|
help=_('User id for unconfirmed user.'))
|
||||||
def do_user_invite_cancel(sc, args):
|
def do_user_invite_cancel(sc, args):
|
||||||
"""
|
""" Cancel user invitation. """
|
||||||
Cancel user details.
|
|
||||||
"""
|
|
||||||
try:
|
try:
|
||||||
resp = sc.users.cancel(args.user_id)
|
resp = sc.users.cancel(args.user_id)
|
||||||
print 'Success: %s' % resp.json()
|
print 'Success: %s' % resp.json()
|
||||||
@ -439,3 +437,25 @@ def do_status(sc, args):
|
|||||||
print json.dumps(
|
print json.dumps(
|
||||||
status.json(), sort_keys=True,
|
status.json(), sort_keys=True,
|
||||||
indent=4, separators=(',', ': '))
|
indent=4, separators=(',', ': '))
|
||||||
|
|
||||||
|
|
||||||
|
# Sign-up
|
||||||
|
@utils.arg('user', metavar='<user>',
|
||||||
|
help=_('User name for new account.'))
|
||||||
|
@utils.arg('email', metavar='<email>',
|
||||||
|
help=_('email of the new account'))
|
||||||
|
@utils.arg('project_name', metavar='<project_name>',
|
||||||
|
help=_('name of the new project'))
|
||||||
|
def do_sign_up(sc, args):
|
||||||
|
"""Submits a sign-up from a user requesting a new project and account.
|
||||||
|
|
||||||
|
Note: You can perform an unauthenticated request to this endpoint using
|
||||||
|
--os-no-client-auth and --bypass-url <stacktask url>
|
||||||
|
"""
|
||||||
|
status = sc.signup.post(args.user, args.email, args.project_name)
|
||||||
|
if status.status_code != 200:
|
||||||
|
print "Failed: %s" % status.reason
|
||||||
|
return
|
||||||
|
print json.dumps(
|
||||||
|
status.json(), sort_keys=True,
|
||||||
|
indent=4, separators=(',', ': '))
|
||||||
|
27
stacktaskclient/v1/signup.py
Normal file
27
stacktaskclient/v1/signup.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# Copyright (C) 2016 Catalyst IT Ltd
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from stacktaskclient.openstack.common.apiclient import base
|
||||||
|
|
||||||
|
|
||||||
|
class SignupManager(base.BaseManager):
|
||||||
|
|
||||||
|
def post(self, username, email, project_name):
|
||||||
|
url = '/openstack/sign-up'
|
||||||
|
fields = {
|
||||||
|
'username': username,
|
||||||
|
'email': email,
|
||||||
|
'project_name': project_name
|
||||||
|
}
|
||||||
|
return self.client.post(url, data=fields)
|
Loading…
x
Reference in New Issue
Block a user