Base API Library
osc_lib.api.api.BaseAPI(session=None, service_type=None, endpoint=None, **kwargs)¶Bases: object
Base API wrapper for keystoneauth1.session.Session
Encapsulate the translation between keystoneauth1.session.Session and requests.Session in a single layer:
HEADER_NAME = 'OpenStack-API-Version'¶SERVICE_TYPE = ''¶create(url, session=None, method=None, **params)¶Create a new resource
| Parameters: |
|
|---|
delete(url, session=None, **params)¶Delete a resource
| Parameters: |
|
|---|
find(path, value=None, attr=None, headers=None)¶Find a single resource by name or ID
| Parameters: |
|
|---|
find_attr(path, value=None, attr=None, resource=None)¶Find a resource via attribute or ID
Most APIs return a list wrapped by a dict with the resource name as key. Some APIs (Identity) return a dict when a query string is present and there is one return value. Take steps to unwrap these bodies and return a single dict without any resource wrappers.
| Parameters: |
|
|---|
find_bulk(path, headers=None, **kwargs)¶Bulk load and filter locally
| Parameters: |
|
|---|---|
| Returns: | list of resource dicts |
find_one(path, **kwargs)¶Find a resource by name or ID
| Parameters: | path (string) – The API-specific portion of the URL path |
|---|---|
| Returns: | resource dict |
list(path, session=None, body=None, detailed=False, headers=None, **params)¶Return a list of resources
GET ${ENDPOINT}/${PATH}?${PARAMS}
path is often the object’s plural resource type
| Parameters: |
|
|---|---|
| Returns: | JSON-decoded response, could be a list or a dict-wrapped-list |
Authentication Library
osc_lib.api.auth.build_auth_plugins_option_parser(parser)¶Auth plugins options builder
Builds dynamically the list of options expected by each available authentication plugin.
osc_lib.api.auth.check_valid_authentication_options(options, auth_plugin_name)¶Validate authentication options, and provide helpful error messages
| Parameters: | required_scope – indicate whether a scoped token is required |
|---|
Validate authorization options, and provide helpful error messages.
osc_lib.api.auth.get_keystone2keystone_auth(local_auth, service_provider, project_id=None, project_name=None, project_domain_id=None, project_domain_name=None)¶Return Keystone 2 Keystone authentication for service provider.
| Parameters: |
|
|---|---|
| Returns: | Keystone2Keystone auth object for service provider |
osc_lib.api.auth.get_options_list()¶Gather plugin options so the help action has them available
osc_lib.api.auth.get_plugin_list()¶Gather plugin list and cache it
API Utilities Library
osc_lib.api.utils.simple_filter(data=None, attr=None, value=None, property_field=None)¶Filter a list of dicts
| Parameters: |
|
|---|---|
| Returns: | Returns the filtered list |
| Rtype list: |
This simple filter (one attribute, one exact-match value) searches a
list of dicts to select items. It first searches the item dict for a
matching attr then does an exact-match on the value. If
property_field is given, it will look inside that field (if it
exists and is a dict) for a matching value.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.