def delete(self, server_id, user_group_id): """ Remove a user's access from a server """ server = server_api.get_server(server_id) server_api.remove_group_from_server(self.user, server, user_group_id) return '', HTTP_STATUS.DELETED
def get(self, server_id): server = server_api.get_server(server_id) no_access = request.args.get('no_access') if no_access: access = set(server.get_users()) all_users = set(user_api.get_all_users()) return list(all_users.difference(access)) return server.get_all_users()
def post(self, server_group_id): """ Add a server to a ServerGroup """ args = server_group_server_parser.parse_args() server = server_api.get_server(args.get('server_id')) server_group = server_group_api.get_server_group(server_group_id) server_group_api.add_server_to_server_group(self.user, server, server_group) return marshal(server_group, server_group_fields), HTTP_STATUS.CREATED
def post(self, server_id): """ Add user access to a server :param server_id: The server id supplied in the URL """ server = server_api.get_server(server_id) args = server_user_parser.parse_args() server_api.add_user_to_server(self.user, server, args.get('user_id')) return marshal(server.get_all_users(), user_fields), HTTP_STATUS.CREATED
def delete(self, server_group_id, server_id): server_group = server_group_api.get_server_group(server_group_id) server = server_api.get_server(server_id) server_group_api.remove_server_from_server_group(self.user, server, server_group) return '', HTTP_STATUS.DELETED
def put(self, server_id): server = server_api.get_server(server_id) args = server_update_parser.parse_args() updated_server = server_api.update_server(self.user, server, **args) return updated_server
def get(self, server_id): return server_api.get_server(server_id)