Add response to Publish a package file endpoint
What does this MR do and why?
- Add package file as a response for Publish a package file endpoint.
- A new optional attribute select is introduced.
- Select can take package_file as an input.
Currently, the endpoint can be used to upload the package files
but as this endpoint does not return any information about the created file we can't perform other operations like deleting a file, showing information about the uploaded file to the user etc.
We at the Secure team is building a feature for corpus management and going to use a generic package to store corpus files. The frontend is building a screen where users can upload one or many package files. We want users to delete the files on the same screen in case they have uploaded the incorrect file. This MR will enable us to do so.
Designs can be viewed here: https://www.figma.com/file/eSIeuIPKFwEDs4X9ky2O5E/Corpus-Registry?node-id=432%3A1
Describe in detail what your merge request does and why.
Steps to test
Following curl requests can be used to test the different scenarios: Without select(Current)
curl --header "PRIVATE-TOKEN: yourtoken" \
--upload-file corpus1_file.txt \
"http://gitlab.localdev:3000/api/v4/projects/1/packages/generic/corpus1_package/0.0.1/corpus1_file.txt?status=default"
{"message":"201 Created"}
With select = package_file
curl --header "PRIVATE-TOKEN: yourtoken" \
--upload-file corpus1_file.txt \
"http://gitlab.localdev:3000/api/v4/projects/1/packages/generic/corpus1_package/0.0.1/corpus1_file.txt?status=default&select=package_file"
{"id":37,"package_id":26,"created_at":"2021-10-12T12:20:22.651Z","updated_at":"2021-10-12T12:20:22.651Z","size":0,"file_store":1,"file_md5":null,"file_sha1":null,"file_name":"corpus1_file.txt","file":{"url":"/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b/packages/26/files/37/corpus1_file.txt"},"file_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","verification_retry_at":null,"verified_at":null,"verification_failure":null,"verification_retry_count":null,"verification_checksum":null,"verification_state":0,"verification_started_at":null,"new_file_path":null
With select = invalid_value
curl --header "PRIVATE-TOKEN: yourtoken" \
--upload-file corpus1_file.txt \
"http://gitlab.localdev:3000/api/v4/projects/1/packages/generic/corpus1_package/0.0.1/corpus1_file.txt?status=default&select=invalid"
{"error":"select does not have a valid value"}
How to set up and validate locally
Just pull the code and run the curl.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #342680 (closed)