deb-python-openstacksdk/doc/source/users/resource.rst
Brian Curtin 2be9e9b6ba Document the synchronized parameter.
It is apparently confusing that the `synchronized` parameter exists in
the class signature of each resource subclass, but it's not documented
anywhere. This change moves the parameter to _synchronized and pushes
documentation of the parameter down to the new/existing methods, as it's
not directly useful to end-users in the initializer, but is necessary in
those classmethods.

Change-Id: I42a01f24d44383889cccce2a2e89442eea1943d7
Closes-Bug: 1645007
2016-11-29 12:21:19 -05:00

1.2 KiB

NOTE: This module is being phased out in favor of openstack.resource2. Once all services have been moved over to use resource2, that module will take this `resource` name.

Resource

openstack.resource

The prop class

openstack.resource.prop

The Resource class

openstack.resource.Resource

How path_args are used

As Resources often contain compound Resource.base_paths, meaning the path is constructed from more than just that string, the various request methods need a way to fill in the missing parts. That's where path_args come in.

For example:

class ServerIP(resource.Resource):
    base_path = "/servers/%(server_id)s/ips"

Making a GET request to obtain server IPs requires the ID of the server to check. This is handled by passing {"server_id": "12345"} as the path_args argument when calling Resource.get_by_id. From there, the method uses Python's string interpolation to fill in the server_id piece of the URL, and then makes the request.