Feature #2176

API server supports atomic find_or_create operation

Added by Tom Clegg over 3 years ago. Updated 4 months ago.

Status:ClosedStart date:03/07/2017
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:-Estimated time:8.00 hours
Target version:-
Story points1.0Remaining (hours)0.00 hour
Velocity based estimate-

Description

Generalize the special case in jobs.create.

Add optional find_or_create flag to create method. If set:
  • If filters parameter is provided, look up objects using those filters.
    • If exactly one result is found, return that.
    • If no results are found, create a new object as usual.
    • If >1 results are found, return an error.
  • If filters parameter is not provided, look up objects using the provided resource_attrs as a where parameter, and proceed as above.
Jobs.create should be rearranged to use the generic mechanism.
  • Move no_reuse (and other params that aren't actually resource attributes) out of resource_attrs, e.g., params[:job][:minimum_script_version]=X should move to something like params[:filters]=[['script_version','>=',X]] and JobsController should override apply_where_limit_order_params to use find_commit_range when >= and <= filters are used with the script_version attribute.
  • Implement exclude_script_versions=X as params[:filters]=[['script_version','not in',X]] (adding a "not in" operator should be trivial)
  • Implement the range logic so the client can do commit range lookups itself using list, not just implicitly via create

Subtasks

Task #2637: Add support for filters to generic create APIClosedPeter Amstutz

History

#1 Updated by Tom Clegg over 3 years ago

  • Release set to 4

#2 Updated by Tom Clegg over 3 years ago

  • Target version set to 2014-05-07 Storing and Organizing Data

#3 Updated by Tom Clegg about 3 years ago

  • Subject changed from API server supports find_or_create operation to API server supports atomic find_or_create operation
  • Description updated (diff)

#4 Updated by Peter Amstutz about 3 years ago

  • Assignee set to Peter Amstutz

#5 Updated by Tom Clegg about 3 years ago

  • Target version deleted (2014-05-07 Storing and Organizing Data)
  • Release deleted (4)

#6 Updated by Tom Clegg almost 3 years ago

  • Target version set to Arvados Future Sprints

#7 Updated by Peter Amstutz about 1 year ago

  • Assignee deleted (Peter Amstutz)

#8 Updated by Peter Amstutz 4 months ago

  • Status changed from New to Closed

Containers API uses a different approach. Does not have compelling use case in other APIs.

#9 Updated by Tom Clegg 4 months ago

  • Target version deleted (Arvados Future Sprints)

Also available in: Atom PDF