urbanobservatory / standards

Standards and schema documentation for the observatories programme
2 stars 0 forks source link

Query string values that mean "not set yet". #15

Closed SiBell closed 4 years ago

SiBell commented 5 years ago

Example

Let's say I want to get a list of all my sensors:

GET /sensors

If I want to get all the sensors in a given deployment then I could use:

GET /sensors?inDeployment=public-weather-stations

Now what if I want to get all the sensors that are not in a deployment yet?

Possible solutions:

  1. GET /sensors?inDeployment=false

Downside: You'll have to ban deployments called 'false'. The same would apply if you used null instead of false.

  1. GET /sensors?inDeployment=

Downside: This is ambiguous as to whether it means a) give me all sensors whatever the deployment, or b) gives me sensors not in a deployment.

  1. GET /sensors?assignedToDeployment=false

Downside: You need to document another query string parameter. And probably forbid the presence of inDeployment when assignedToDeployment=false.

lukeshope commented 5 years ago

Could we adopt the same approach proposed for greater than/less than cases?

Something along the lines of inDeployment__isNull=true or inDeployment[isNull]=true?

SiBell commented 5 years ago

Works for me.

I'd planned not to include any Null values in my API response, i.e. this:

{
  "id": "sensor-1",
  "name": "sensor 1"
}

Rather than this:

{
  "id": "sensor-1",
  "name": "sensor 1",
  "inDeployment": null
}

Assuming it's fine to omit null properties, and doesn't break any rules of the standards we're sticking to, then perhaps inDeployment__isDefined=false is better?

lukeshope commented 5 years ago

Happy to go with isDefined as a the condition, I agree about not including nulls in these cases. Should we come up with a list of all the conditions we think we might need to use as query parameters, and the types they're applicable to, as in

SiBell commented 5 years ago

Yep good plan. Pop them in a table and whack it in the standards draft, e.g:

conditional properties types applicable to description example
gte numbers, date strings Filter resources by property values greater than or equal to that specified startdate__gte=2019-05-24

What me to make a first stab at this?

lukeshope commented 4 years ago

Closing this as discussion of the same matter has now moved to #18.