The gnocchiclient.v1.resource Module

class gnocchiclient.v1.resource.ResourceManager(client)

Bases: gnocchiclient.v1.base.Manager

batch_delete(query, resource_type='generic')

Delete a batch of resources based on attribute values.

Parameters:resource_type (str) – Type of the resource
create(resource_type, resource)

Create a resource.

Parameters:
  • resource_type (str) – Type of the resource
  • resource (dict) – Attribute of the resource
delete(resource_id)

Delete a resource.

Parameters:resource_id (str) – ID of the resource
get(resource_type, resource_id, history=False)

Get a resource.

Parameters:
  • resource_type (str) – Type of the resource
  • resource_id (str) – ID of the resource
  • history (bool) – Show the history of the resource
history(resource_type, resource_id, details=False, limit=None, marker=None, sorts=None)

Get a resource.

Parameters:
  • resource_type (str) – Type of the resource
  • resource_id (str) – ID of the resource
  • details (bool) – Show all attributes of resources
  • limit (int) – maximum number of resources to return
  • marker (str) – the last item of the previous page; we returns the next results after this value.
  • sorts (list of str) – list of resource attributes to order by. (example [“user_id:desc-nullslast”, “project_id:asc”]
list(resource_type='generic', details=False, history=False, limit=None, marker=None, sorts=None)

List resources.

Parameters:
  • resource_type (str) – Type of the resource
  • details (bool) – Show all attributes of resources
  • history (bool) – Show the history of resources
  • limit (int) – maximum number of resources to return
  • marker (str) – the last item of the previous page; we return the next results after this value.
  • sorts (list of str) – list of resource attributes to order by. (example [“user_id:desc-nullslast”, “project_id:asc”]
search(resource_type='generic', query=None, details=False, history=False, limit=None, marker=None, sorts=None)

List resources.

Parameters:
  • resource_type (str) – Type of the resource
  • query (dict) – The query dictionary
  • details (bool) – Show all attributes of resources
  • history (bool) – Show the history of resources
  • limit (int) – maximum number of resources to return
  • marker (str) – the last item of the previous page; we returns the next results after this value.
  • sorts (list of str) – list of resource attributes to order by. (example [“user_id:desc-nullslast”, “project_id:asc”]

See Gnocchi REST API documentation for the format of query dictionary http://gnocchi.xyz/rest.html#searching-for-resources

update(resource_type, resource_id, resource)

Update a resource.

Parameters:
  • resource_type (str) – Type of the resource
  • resource_id (str) – ID of the resource
  • resource (dict) – Attribute of the resource
url = 'v1/resource/'