本文整理汇总了Python中pyrax.manager.BaseManager.delete方法的典型用法代码示例。如果您正苦于以下问题:Python BaseManager.delete方法的具体用法?Python BaseManager.delete怎么用?Python BaseManager.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyrax.manager.BaseManager
的用法示例。
在下文中一共展示了BaseManager.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CloudDatabaseInstance
# 需要导入模块: from pyrax.manager import BaseManager [as 别名]
# 或者: from pyrax.manager.BaseManager import delete [as 别名]
#.........这里部分代码省略.........
If a user with
that name already exists, a BadRequest (400) exception will
be raised.
"""
if not isinstance(database_names, list):
database_names = [database_names]
# The API only accepts names, not DB objects
database_names = [db if isinstance(db, basestring) else db.name
for db in database_names]
# Note that passing in non-None values is required for the create_body
# method to distinguish between this and the request to create and instance.
self._user_manager.create(name=name, password=password,
database_names=database_names, return_none=True)
# Since the API doesn't return the info for creating the user object, we
# have to do it manually.
return self._user_manager.find(name=name)
def _get_name(self, name_or_obj):
"""
For convenience, many methods accept either an object or the name
of the object as a parameter, but need the name to send to the
API. This method handles that conversion.
"""
if isinstance(name_or_obj, basestring):
return name_or_obj
try:
return name_or_obj.name
except AttributeError:
msg = "The object '%s' does not have a 'name' attribute." % name_or_obj
raise exc.MissingName(msg)
def delete_database(self, name_or_obj):
"""
Deletes the specified database. If no database by that name
exists, no exception will be raised; instead, nothing at all
is done.
"""
name = self._get_name(name_or_obj)
self._database_manager.delete(name)
def delete_user(self, name_or_obj):
"""
Deletes the specified user. If no user by that name
exists, no exception will be raised; instead, nothing at all
is done.
"""
name = self._get_name(name_or_obj)
self._user_manager.delete(name)
def enable_root_user(self):
"""
Enables login from any host for the root user and provides
the user with a generated root password.
"""
uri = "/instances/%s/root" % self.id
resp, body = self.manager.api.method_post(uri)
return body["user"]["password"]
def root_user_status(self):
"""
Returns True or False, depending on whether the root user