openstacksdk/doc/source/user/resource.rst
Monty Taylor 40d425c595
Merge user and users sections of the docs
The openstack doc standard location is 'user', so go with that.
Incorporate pages from the shade and occ docs into the appropriate
places in the user index file.

This still leaves user/logging and user/guide/logging which need to be
rationalized. That will come in the next commit, as it also needs to
actually rationalize the logging helper functions.

Remove the Makefile, as it's not used by things.

Change-Id: I26f36370ef9651f4bcaa7dee3b903309463d9592
2018-01-15 19:19:50 -06: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.