Files
deb-python-openstacksdk/doc/source/resource.rst
Brian Curtin 0d8be32a1e Complete the Resource class documentation
Document the CRUD methods with explanations of arguments, return value,
and exceptions that could be raised. This also introduces a change to
the autoclass setting so that it orders the members by how they are
written in the source, instead of alphabetical order.

A second change is going to be submitted that does some reordering
of methods so that more common methods will be near the top and the more
internal (but still public) methods near the bottom.

Change-Id: I94facb4d6c4e8d446e8e696afb75f1a3268d3722
2015-01-12 09:56:53 -06:00

999 B

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.