davidhamann/python-fmrest

Let user chose version of Data API

Closed this issue · 4 comments

Starting with FMS 19, the FileMaker Data API version requested can use 'v1', 'v2', or 'vLatest'.

Could we let the user chose the version and default to 'vLatest' in case the user does not supply any version?

Unless this breaks anything compared to the currently hard coded 'v1'...

Good point. Do you know about any official documentation regarding this?

I had a quick look into the Data API code and it seems they added some undocumented routes like /fmi/data/<version>/refreshLicense that don't work with v1. However, for a v1 to v2 change I would assume some actual changes, not just additional endpoints. I couldn't find anything while skimming over it. Do you have an overview / know an official statement or would we need to figure this out ourselves?

The only differences I was able to spot are:

It seems these are no longer depending on the view setting (Form View or Table View), but are now always based on the Form View.

I believe implementation could be done with:

  • e.g. a Set in const.py, like API_VERSIONS = {'v1', 'v2', 'vLatest'}
  • replacing the hard coded 'v1' with '{version}' for all end points
  • in server.py add API_VERSIONS to from .const import ...
  • in Server.__init__ add version: str, and later on self.version = version if version in API_VERSIONS else "v1", this way it defaults to the currently hard coded version (or might vLatest be preferable?)
  • Finally, in all methods, as appropriate, add version = self.version, to string formatting (in order of appearance in the end points), e.g.:
API_PATH['xxxxx'].format(
            version = self.version,
            database=self.database,
            layout=self.layout,
            record_id=record_id
        )

Thanks, I've just confirmed the behaviour changes locally. Since the format of the response has not changed, it should be completely compatible with the code that processes the response. I'll try to code the changes today.

Thank you! And Happy Easter!