Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getZipDownloadLimit and getMaxEmbargoDurationInMonths API info endpoints #9881

Merged
merged 11 commits into from
Sep 13, 2023

Conversation

GPortas
Copy link
Contributor

@GPortas GPortas commented Sep 6, 2023

What this PR does / why we need it:

The PR includes the following new endpoints:

  • getZipDownloadLimit (/api/info/zipDownloadLimit): Get the configured zip file download limit. The response contains the long value of the limit in bytes.

  • getMaxEmbargoDurationInMonths (/api/info/settings/:MaxEmbargoDurationInMonths): Get the max embargo duration in months, if available.

Which issue(s) this PR closes:

Special notes for your reviewer:

These new endpoints are required by IQSS/dataverse-client-javascript#84

Suggestions on how to test this:

Via curl:

curl "$SERVER_URL/api/info/settings/incompleteMetadataViaApi
curl "$SERVER_URL/api/info/settings/:MaxEmbargoDurationInMonths

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

No

Is there a release notes update needed for this change?:

Yes

Additional documentation:

None

@github-actions

This comment has been minimized.

@GPortas GPortas marked this pull request as ready for review September 6, 2023 11:35
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@pdurbin pdurbin self-assigned this Sep 6, 2023
Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this looks great. I'm glad to see tests (good to delete the seeing before and after) and docs.

I did ask a couple questions.


- getZipDownloadLimit (/api/info/zipDownloadLimit): Get the configured zip file download limit. The response contains the long value of the limit in bytes.

- getEmbargoEnabled (/api/info/embargoEnabled): Know if the Dataverse instance has been configured to allow embargoes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something feels off to me...

We should probably make an active decision about two things:

  • Should we continue putting "settings" in the path?
  • Should we match the name of the setting including the colon?

Another way to ask this is which of the following we want.

/api/info/zipDownloadLimit
/api/info/settings/zipDownloadLimit
/api/info/settings/:ZipDownloadLimit

For reference here is a sorted list of "info" endpoints as of this PR:

/api/info/apiTermsOfUse
/api/info/embargoEnabled
/api/info/server
/api/info/settings/:DatasetPublishPopupCustomText
/api/info/settings/incompleteMetadataViaApi
/api/info/version
/api/info/zipDownloadLimit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems appropriate to me to add the setting subpath, and even include the colon if it is more understandable for the setting name, as long as the endpoint only reads the setting value, with no other operations around it.

For example, the /admin/settings/{name} endpoint returns the plain value of the setting if it exists, otherwise it returns a not found error.

On the other hand, the info/zipDownloadLimitendpoint does more than read the setting, since if the associated setting is not found it assigns a default value. So I find appropriate to exclude the "settings" endpoint subpath/naming here.

Same for the info/embargoEnabled endpoint, that after reading the :MaxEmbargoDurationInMonths setting, based on its possible values, checks whether the embargo functionality is enabled or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GPortas I wrote some docs to merge into this PR once we are happy with them:


Know if the Dataverse instance has been configured to allow embargoes.

The endpoint checks whether the database setting :ref:`:MaxEmbargoDurationInMonths`, which enables the embargo feature, has a value that enables the feature or not.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, will the SPA (or some other system) need to know the value of :MaxEmbargoDurationInMonths? If so, should we return it now, as part of the endpoint we're adding? Or would we add a second endpoint to get the number of months?

Copy link
Contributor Author

@GPortas GPortas Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I'm not entirely sure, but I don't think so, considering that the embargo duration is something that is managed internally by the setting, and that for now, I've only seen that the UI needs to know if the feature is enable (To show / not show related UI) or if a file is embargoed, but not the configured embargo duration.

In any case, if necessary in the future, we can extend the endpoint to include the setting value or create a separate endpoint. For now I have preferred to keep it simple.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming the SPA will need to perform some validation when we get to the EDIT side of the dataset page. I can imagine an error like this:

"Please an embargo date before September 8, 2025" (for example)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. When creating an embargo, there is a date picker that I was overlooking where dates within the range determined by the :MaxEmbargoDurationInMonths setting are displayed. So the SPA has to know the value of the setting beforehand.

I think then it is better to directly expose the setting. Something like: /api/info/settings/:MaxEmbargoDurationInMonths

Then the SPA/consumer will know if the feature is enabled (by having a value set different than 0) and the embargo duration in months.

What do you think? @pdurbin

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, directly exposing the setting sounds good.

@GPortas GPortas removed their assignment Sep 11, 2023
@github-actions

This comment has been minimized.

2 similar comments
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@GPortas
Copy link
Contributor Author

GPortas commented Sep 11, 2023

Updated! @pdurbin

@pdurbin
Copy link
Member

pdurbin commented Sep 11, 2023

@GPortas great, I just updated this PR to reflect the embargo change:

Can you please review and merge if you're happy with it?

@GPortas
Copy link
Contributor Author

GPortas commented Sep 11, 2023

Thanks @pdurbin, I just reviewed it.

Looks great, just one minor request.

@pdurbin
Copy link
Member

pdurbin commented Sep 11, 2023

I just wanted to mention @landreev 's idea at standup to someday expose more database settings automatically fix via API instead of exposing them here and there. Roughly:

  • add a column to the setting table to indicate if it's safe to expose the database setting publicly
  • expose the database setting publicly programmatically via a predictable path, but only if it's safe to do so

I sort of assume one could get a dump of public settings at once as well. Not sure. I'm not sure about JVM options and MicroProfile settings either. Needs more discussion and an issue.

@poikilotherm
Copy link
Contributor

A few thoughts:

  • DB settings are hacky right now. Should be refactored.
  • Information about safe exposure can be held in the enum instead of the table
  • Exposing MPCONFIG JvmSettings is easy to do, also with making sure secrets are kept secret

stub out page on API design, especially paths
@pdurbin
Copy link
Member

pdurbin commented Sep 11, 2023

I kicked of a run of the API tests here: https://github.com/gdcc/api-test-runner/actions/runs/6148788525

Soon we'll have Jenkins/Ansible back and testing the post 6.0 world:

@github-actions

This comment has been minimized.

@GPortas
Copy link
Contributor Author

GPortas commented Sep 11, 2023

@pdurbin

I like the idea.

I can foresee that more settings exposed via API will be needed for the development of the SPA.

Considering this argument: "Information about safe exposure can be held in the enum instead of the table", we can add public settings to the enum in an emerging way as we need their exposure. @poikilotherm

For the next setting to be exposed we can evaluate this design in more depth and implement it at that time.

@GPortas GPortas changed the title Add getZipDownloadLimit and getEmbargoEnabled API info endpoints Add getZipDownloadLimit and getMaxEmbargoDurationInMonths API info endpoints Sep 11, 2023
@pdurbin
Copy link
Member

pdurbin commented Sep 11, 2023

https://github.com/gdcc/api-test-runner/actions/runs/6148788525 passed so I'm going to go ahead and approve this.

Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@pdurbin pdurbin removed their assignment Sep 11, 2023
@kcondon kcondon self-assigned this Sep 11, 2023
@kcondon
Copy link
Contributor

kcondon commented Sep 11, 2023

Please refresh from develop to update version to 6.0, thanks!

@pdurbin pdurbin added this to the 6.1 milestone Sep 12, 2023
@GPortas
Copy link
Contributor Author

GPortas commented Sep 12, 2023

Done, thanks @kcondon !

@github-actions
Copy link

📦 Pushed preview images as

ghcr.io/gdcc/dataverse:9880-info-zip-download-limit-embargo
ghcr.io/gdcc/configbaker:9880-info-zip-download-limit-embargo

🚢 See on GHCR. Use by referencing with full name as printed above, mind the registry name.

@cmbz cmbz added the Size: 3 A percentage of a sprint. 2.1 hours. label Sep 13, 2023
@kcondon
Copy link
Contributor

kcondon commented Sep 13, 2023

@GPortas, when I'm doing a smoke test (create collection, dataset, publish) I'm getting a 500 error when publishing:

publish_err.txt

Update: I've retested this a few times and am no longer seeing this. Not sure what caused it.

@kcondon kcondon merged commit a8f6631 into develop Sep 13, 2023
15 of 16 checks passed
@kcondon kcondon deleted the 9880-info-zip-download-limit-embargo branch September 13, 2023 21:33
jeromeroucou pushed a commit to Recherche-Data-Gouv/dataverse that referenced this pull request Sep 14, 2023
@GPortas
Copy link
Contributor Author

GPortas commented Sep 14, 2023

In a quick glance, the error seems related to faces UI, I'm not sure if we should give it much importance. In any case it should have no relation to the changes implemented in this PR.

Thanks, @kcondon.

stevenwinship pushed a commit that referenced this pull request Jun 3, 2024
* Remove unused import

* Merge users with same groups

* Added additional line in Permalinks config

Added an additional line to restart Payara after changing settings in Permalinks section

* Revert "#9717 grant CREATE instead of ALL per pdurbin"

This reverts commit f71274e.

* CREATE instead of ALL for public schema

* Added: getZipDownloadLimit and getEmbargoEnabled API info endpoints

* Added: docs for new info API endpoints

* Fixed: missing guides reference in config.rst

* Changed: :MaxEmbargoDurationInMonths setting directly exposed via API info endpoint

* Changed: updated release notes

* Changed: private Info.java method renamed

* stub out page on API design, esp paths #9880

* remove embargo example, no longer used in #9881

* typo #9880

* Remove unused GPL-licensed code

For unknown reasons, in 2009 several files from the JDK were copied into
the Dataverse codebase, instead of referenced.
It appears that these classes weren't really used.

* Removed unused code

---------

Co-authored-by: Jérôme ROUCOU <jerome.roucou@inrae.fr>
Co-authored-by: Pradyumna Sridhara <95268690+prsridha@users.noreply.github.com>
Co-authored-by: Philip Durbin <philip_durbin@harvard.edu>
Co-authored-by: GPortas <hey@gportas.me>
Co-authored-by: bencomp <ben@companjen.name>
Co-authored-by: jeromeroucou <jeromeroucou@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Size: 3 A percentage of a sprint. 2.1 hours.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Spike - API] Extend the info API to return zip download limit and embargo enabled/disabled
5 participants