openstacksdk/doc/source/users/resource.rst
Brian Curtin f86cc2fc8e Reorganize existing documentation files
This change creates two directories of content, based on who they're
relevant to: users and contributors. Files which were in the top-level
folder were moved, as well as some within folders in that top-level.
This is one change of a multi-step process, so it only deals with
renamings in order to make further changes cleaner.

Change-Id: I3c9bb7da4f283e2696e7bcea84824c778bbcecfb
Partial-Bug: 1416553
2015-02-03 12:43:28 -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.