1414from openstack .database .v1 import flavor as _flavor
1515from openstack .database .v1 import instance as _instance
1616from openstack .database .v1 import user as _user
17- from openstack import proxy
17+ from openstack import proxy2
1818
1919
20- class Proxy (proxy .BaseProxy ):
20+ class Proxy (proxy2 .BaseProxy ):
2121
22- def create_database (self , ** attrs ):
22+ def create_database (self , instance , ** attrs ):
2323 """Create a new database from attributes
2424
25+ :param instance: This can be either the ID of an instance
26+ or a :class:`~openstack.database.v1.instance.Instance`
2527 :param dict attrs: Keyword arguments which will be used to create
2628 a :class:`~openstack.database.v1.database.Database`,
2729 comprised of the properties on the Database class.
2830
2931 :returns: The results of server creation
3032 :rtype: :class:`~openstack.database.v1.database.Database`
3133 """
32- return self ._create (_database .Database , ** attrs )
34+ instance = self ._get_resource (_instance .Instance , instance )
35+ return self ._create (_database .Database , instance_id = instance .id ,
36+ ** attrs )
3337
34- def delete_database (self , database , ignore_missing = True ):
38+ def delete_database (self , database , instance = None , ignore_missing = True ):
3539 """Delete a database
3640
3741 :param database: The value can be either the ID of a database or a
3842 :class:`~openstack.database.v1.database.Database` instance.
43+ :param instance: This parameter needs to be specified when
44+ an ID is given as `database`.
45+ It can be either the ID of an instance
46+ or a :class:`~openstack.database.v1.instance.Instance`
3947 :param bool ignore_missing: When set to ``False``
4048 :class:`~openstack.exceptions.ResourceNotFound` will be
4149 raised when the database does not exist.
@@ -44,37 +52,52 @@ def delete_database(self, database, ignore_missing=True):
4452
4553 :returns: ``None``
4654 """
47- self ._delete (_database .Database , database ,
55+ instance_id = self ._get_uri_attribute (database , instance ,
56+ "instance_id" )
57+ self ._delete (_database .Database , database , instance_id = instance_id ,
4858 ignore_missing = ignore_missing )
4959
50- def find_database (self , name_or_id , ignore_missing = True ):
60+ def find_database (self , name_or_id , instance , ignore_missing = True ):
5161 """Find a single database
5262
5363 :param name_or_id: The name or ID of a database.
64+ :param instance: This can be either the ID of an instance
65+ or a :class:`~openstack.database.v1.instance.Instance`
5466 :param bool ignore_missing: When set to ``False``
5567 :class:`~openstack.exceptions.ResourceNotFound` will be
5668 raised when the resource does not exist.
5769 When set to ``True``, None will be returned when
5870 attempting to find a nonexistent resource.
5971 :returns: One :class:`~openstack.database.v1.database.Database` or None
6072 """
73+ instance = self ._get_resource (_instance .Instance , instance )
6174 return self ._find (_database .Database , name_or_id ,
75+ instance_id = instance .id ,
6276 ignore_missing = ignore_missing )
6377
64- def databases (self , ** query ):
78+ def databases (self , instance , ** query ):
6579 """Return a generator of databases
6680
81+ :param instance: This can be either the ID of an instance
82+ or a :class:`~openstack.database.v1.instance.Instance`
83+ instance that the interface belongs to.
6784 :param kwargs \*\*query: Optional query parameters to be sent to limit
6885 the resources being returned.
6986
7087 :returns: A generator of database objects
7188 :rtype: :class:`~openstack.database.v1.database.Database`
7289 """
73- return self ._list (_database .Database , paginated = False , ** query )
90+ instance = self ._get_resource (_instance .Instance , instance )
91+ return self ._list (_database .Database , paginated = False ,
92+ instance_id = instance .id , ** query )
7493
75- def get_database (self , database ):
94+ def get_database (self , database , instance = None ):
7695 """Get a single database
7796
97+ :param instance: This parameter needs to be specified when
98+ an ID is given as `database`.
99+ It can be either the ID of an instance
100+ or a :class:`~openstack.database.v1.instance.Instance`
78101 :param database: The value can be the ID of a database or a
79102 :class:`~openstack.database.v1.database.Database`
80103 instance.
@@ -202,23 +225,30 @@ def update_instance(self, instance, **attrs):
202225 """
203226 return self ._update (_instance .Instance , instance , ** attrs )
204227
205- def create_user (self , ** attrs ):
228+ def create_user (self , instance , ** attrs ):
206229 """Create a new user from attributes
207230
231+ :param instance: This can be either the ID of an instance
232+ or a :class:`~openstack.database.v1.instance.Instance`
208233 :param dict attrs: Keyword arguments which will be used to create
209234 a :class:`~openstack.database.v1.user.User`,
210235 comprised of the properties on the User class.
211236
212237 :returns: The results of server creation
213238 :rtype: :class:`~openstack.database.v1.user.User`
214239 """
215- return self ._create (_user .User , ** attrs )
240+ instance = self ._get_resource (_instance .Instance , instance )
241+ return self ._create (_user .User , instance_id = instance .id , ** attrs )
216242
217- def delete_user (self , user , ignore_missing = True ):
243+ def delete_user (self , user , instance = None , ignore_missing = True ):
218244 """Delete a user
219245
220246 :param user: The value can be either the ID of a user or a
221247 :class:`~openstack.database.v1.user.User` instance.
248+ :param instance: This parameter needs to be specified when
249+ an ID is given as `user`.
250+ It can be either the ID of an instance
251+ or a :class:`~openstack.database.v1.instance.Instance`
222252 :param bool ignore_missing: When set to ``False``
223253 :class:`~openstack.exceptions.ResourceNotFound` will be
224254 raised when the user does not exist.
@@ -227,41 +257,55 @@ def delete_user(self, user, ignore_missing=True):
227257
228258 :returns: ``None``
229259 """
230- self ._delete (_user .User , user , ignore_missing = ignore_missing )
260+ instance = self ._get_resource (_instance .Instance , instance )
261+ self ._delete (_user .User , user , ignore_missing = ignore_missing ,
262+ instance_id = instance .id )
231263
232- def find_user (self , name_or_id , ignore_missing = True ):
264+ def find_user (self , name_or_id , instance , ignore_missing = True ):
233265 """Find a single user
234266
235267 :param name_or_id: The name or ID of a user.
268+ :param instance: This can be either the ID of an instance
269+ or a :class:`~openstack.database.v1.instance.Instance`
236270 :param bool ignore_missing: When set to ``False``
237271 :class:`~openstack.exceptions.ResourceNotFound` will be
238272 raised when the resource does not exist.
239273 When set to ``True``, None will be returned when
240274 attempting to find a nonexistent resource.
241275 :returns: One :class:`~openstack.database.v1.user.User` or None
242276 """
243- return self ._find (_user .User , name_or_id ,
277+ instance = self ._get_resource (_instance .Instance , instance )
278+ return self ._find (_user .User , name_or_id , instance_id = instance .id ,
244279 ignore_missing = ignore_missing )
245280
246- def users (self , ** query ):
281+ def users (self , instance , ** query ):
247282 """Return a generator of users
248283
284+ :param instance: This can be either the ID of an instance
285+ or a :class:`~openstack.database.v1.instance.Instance`
249286 :param kwargs \*\*query: Optional query parameters to be sent to limit
250287 the resources being returned.
251288
252289 :returns: A generator of user objects
253290 :rtype: :class:`~openstack.database.v1.user.User`
254291 """
255- return self ._list (_user .User , paginated = False , ** query )
292+ instance = self ._get_resource (_instance .Instance , instance )
293+ return self ._list (_user .User , instance_id = instance .id ,
294+ paginated = False , ** query )
256295
257- def get_user (self , user ):
296+ def get_user (self , user , instance = None ):
258297 """Get a single user
259298
260299 :param user: The value can be the ID of a user or a
261300 :class:`~openstack.database.v1.user.User` instance.
301+ :param instance: This parameter needs to be specified when
302+ an ID is given as `database`.
303+ It can be either the ID of an instance
304+ or a :class:`~openstack.database.v1.instance.Instance`
262305
263306 :returns: One :class:`~openstack.database.v1.user.User`
264307 :raises: :class:`~openstack.exceptions.ResourceNotFound`
265308 when no resource can be found.
266309 """
310+ instance = self ._get_resource (_instance .Instance , instance )
267311 return self ._get (_user .User , user )
0 commit comments