snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
11.03k stars 3.18k forks source link

[Feature Request]: Faster way to fetch all assigned hardware by predefined kit #15140

Open s681562 opened 3 months ago

s681562 commented 3 months ago

Is your feature request related to a problem? Please describe.

For now I have an predefined kit. This kit has maybe 20 related assets. I want fetch same data structure like seeing on snipe-it homepage in one call. In only one call I want fetch all related data for my kit. For now I must take over twenty calls only for this one task. The other problem is, that /api/v1/kits/4/models respond only metadata. Metadata are good for understand underlaying table row structure like price is double and color is string. But I need my real data like price = 20.0, or color = "red". My app takes too long time for fetching all data in this case.

Describe the solution you'd like

I want one call.

/api/v1/kits/4/hardware -> list of all asset with real data assigned to this kit number 4

Save time, save stress load for server, makes things easy going.

Describe alternatives you've considered

For now I must going over twenty rounds.

I call /api/v1/kits -> list of all kits I call /api/v1/kits/4/models -> list of all models with metadata related to my kit number 4 I call /api/v1/hardware/1 -> list of asset with real data I call /api/v1/hardware/2 -> list of asset with real data I call /api/v1/hardware/3 -> list of asset with real data call call call call .... I call /api/v1/hardware/19 -> list of asset with real data I call /api/v1/hardware/20 -> list of asset with real data

This is doing a lot of server stress and it takes time.

If I call /api/vi1/kits/4/hardware... I got an error.

{ "status": "error", "message": "404 endpoint not found. Please check the API reference at https:\/\/snipe-it.readme.io\/reference to find a valid API endpoint.", "payload": null }

Additional context

Yes, I can wrap all request in a python threading solution. My more than 20 requests can be processed in the multithreading pool as parallel tasks. But... notice. Without my great idea of /api/v1/kits/4/hardware server will have a lot of stress.

s681562 commented 3 months ago

Ah... here is a workaround:

go through hardware and search for model => id loop through models

perfect, finally you got your asset list for kits/4

This in only 2 requests.

Challenge: How to do this in one request like /api/v1/kits/4/hardware?