diff --git a/stacktaskclient/v1/client.py b/stacktaskclient/v1/client.py index c28ee33..c409c64 100644 --- a/stacktaskclient/v1/client.py +++ b/stacktaskclient/v1/client.py @@ -13,12 +13,13 @@ # under the License. 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 roles +from stacktaskclient.v1 import signup from stacktaskclient.v1 import status +from stacktaskclient.v1 import tasks +from stacktaskclient.v1 import tokens +from stacktaskclient.v1 import users class Client(object): @@ -40,6 +41,7 @@ class Client(object): self.managed_roles = roles.ManagedRoleManager(self.http_client) self.tokens = tokens.TokenManager(self.http_client) self.tasks = tasks.TaskManager(self.http_client) + self.signup = signup.SignupManager(self.http_client) self.notifications = notifications.NotificationManager( self.http_client) self.status = status.StatusManager(self.http_client) diff --git a/stacktaskclient/v1/shell.py b/stacktaskclient/v1/shell.py index 435de92..714ae09 100644 --- a/stacktaskclient/v1/shell.py +++ b/stacktaskclient/v1/shell.py @@ -350,9 +350,7 @@ def do_user_invite(sc, args): @utils.arg('user_id', metavar='', help=_('User id for unconfirmed user.')) def do_user_invite_cancel(sc, args): - """ - Cancel user details. - """ + """ Cancel user invitation. """ try: resp = sc.users.cancel(args.user_id) print 'Success: %s' % resp.json() @@ -439,3 +437,25 @@ def do_status(sc, args): print json.dumps( status.json(), sort_keys=True, indent=4, separators=(',', ': ')) + + +# Sign-up +@utils.arg('user', metavar='', + help=_('User name for new account.')) +@utils.arg('email', metavar='', + help=_('email of the new account')) +@utils.arg('project_name', metavar='', + 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 + """ + 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=(',', ': ')) diff --git a/stacktaskclient/v1/signup.py b/stacktaskclient/v1/signup.py new file mode 100644 index 0000000..c20c3df --- /dev/null +++ b/stacktaskclient/v1/signup.py @@ -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)