Comment 2 for bug 1585917

Revision history for this message
Abhishek Kekane (abhishek-kekane) wrote :

As of now while creating a member for image "member" is expected in request body where as "member_id" is returned in response body. This behavior is causing problem to add schema validation for member because in schema "member_id" is defined. If we change this to "member" then we are able to perform the validation but it is eliminating "member_id" from the response as it is not present in the schema. In order to solve this issue we are having two solutions:

Solution 1: Add "member" attribute in schema

New schema will look like:
_MEMBER_SCHEMA = {
    'member_id': {
        'type': 'string',
        'description': _('An identifier for the image member (tenantId)')
    },
    'member': {
        'type': 'string',
        'maxLength': 255,
        'description': _('An identifier for the image member (tenantId)')
    },
    'image_id': {
        'type': 'string',
        'description': _('An identifier for the image'),
        'pattern': ('^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}'
                    '-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$'),
    },
    'created_at': {
        'type': 'string',
        'description': _('Date and time of image member creation'),
        # TODO(brian-rosmaita): our jsonschema library doesn't seem to like the
        # format attribute, figure out why (and also fix in images.py)
        # 'format': 'date-time',
    },
    'updated_at': {
        'type': 'string',
        'description': _('Date and time of last modification of image member'),
        # 'format': 'date-time',
    },
    'status': {
        'type': 'string',
        'description': _('The status of this image member'),
        'enum': [
            'pending',
            'accepted',
            'rejected'
        ]
    },
    'schema': {
        'readOnly': True,
        'type': 'string'
    }
}

pros:
1. Present behavior of api will be maintianed
2. Less changes in code

cons:
1. Two attributes for member in schema

Solution 2: Replace "member_id" attribute with "member" in schema

pros:
1. No need to add duplicate eliments in schema

cons:
1. Will change api behavior as "member" instead of "member_id" will be returned in response body
2. Requires lot of code chagne in glance and also needs changes in python-glanceclient

Please give us your opinion about the same.

NOTE:
As of now for member creation schema is not used for validation purpose.