Jump to: navigation, search

Glance-api-v2-refactor-schemas

Revision as of 15:52, 5 June 2012 by Markwash (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In the glance v2 api, schemas are used to communicate the expected format and attributes of image objects, access record objects, and image tags. These schemas are specific to v2. They are not used by v1 and would likely be changed in any future version. However, they presently live in project-global namespace. And they are served up by a single monolithic API object which is therefore required to know about all schemas.

This blueprint proposes to refactor schemas to individual objects and move them under the glance/api/v2 library umbrella. To make room, other libraries in glance.api.v2 may need to be moved around as well.

Sample library structure:


glance/
  api/
    v2/
      router.py
      resources/ # move wsgi resource modules to here
        images.py
        image_tags.py
        image_data.py
        image_access.py
        schemas.py
        ...
      schemas/  # move schemas to objects that live in these modules
        image.py
        image_access.py
        image_tags.py
        ...
      ...


Schema objects would have methods to get the raw text of the schema and to validate objects. They would be instantiated directly in the schemas resource and in the various deserializers to access their functionality.