It doesn’t seem possible to efficiently and idempotently create Fly Machines.
After sending out the POST /v1/apps/user-functions/machines
request but failing to receive the response due to a network error, the client can retry the request safely and get back an HTTP 422 if the remote end has created the machine (with the same name) previously. But the client still does not know the ID of the machine. It has to query the “List Machines for an App” and find out the ID.
If there are a lot of machines in an app, the list operation would not be efficient - it is an O(n)
query.
A solution would be to extend the “Get a Machine” or “List Machines for an App” API, or create a new API endpoint, to provide the ability to query a machine by name instead of ID.