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

Always return an object from API methods and deprecate all existing API methods #1054

Merged
12 commits merged into from Feb 24, 2023
Merged

Always return an object from API methods and deprecate all existing API methods #1054

12 commits merged into from Feb 24, 2023

Conversation

ghost
Copy link

@ghost ghost commented Oct 12, 2022

Purpose

The current API methods return different object types in the "result" property. In #790 it has been discussed the need to always return an object to facilitate expanding the results. It was also noted that the API methods' names could be harmonized and improved. This first work is about providing new API methods based on the discussion in #790, and deprecate all existing API methods.

This is the first step of the process:

Mapping between old and new method names:

current method name current top-level property new method name new top-level property
version_info object system_versions object
profile_names array conf_profiles object
get_language_tags array conf_languages object
get_host_by_name array lookup_address_records object
get_data_from_parent_zone object lookup_delegation_data object
start_domain_test integer job_create object
test_progress integer job_status object
get_test_results object job_results object
get_test_params object job_params object
get_test_history array domain_history object
add_api_user integer user_create object
add_batch_job integer batch_create object
get_batch_job_result object batch_status object

Context

Partially addresses #790.

Changes

Deprecate all existing API methods, see the array in the Purpose section for the new method names.

How to test this PR

Test should pass. At this stage the new methods are not used.

@ghost ghost requested a review from mattias-p October 12, 2022 15:23
@matsduf
Copy link
Contributor

matsduf commented Oct 12, 2022

I do think that the new names are better than the old ones, but is it worth the change to get better names?

#790 suggests that it should be possible to send deprecation messages with the result message, and that can sound appealing but would that really work? Who would read those messages? Do you envision that those messages are shown to the Zonemaster GUI users? Or how should those messages go to some maintainer?

@ghost
Copy link
Author

ghost commented Oct 13, 2022

I do think that the new names are better than the old ones, but is it worth the change to get better names?

Do we think this is a change we'd like to see at some point? Do we want to harmonize the API? Do we want to clean our codebase? I would answer yes to all.
Furthermore one of the point raised in #790 is our use of the "test" term that refers to several different things (a test case, a test of a zone…) , making it easy to mix things up.
I think it's important to keep our API and code base harmonized. Currently there is a lot of room for improvements (see #791 for example).

docs/API.md Outdated Show resolved Hide resolved
docs/API.md Outdated Show resolved Hide resolved
docs/API.md Show resolved Hide resolved
@ghost ghost marked this pull request as ready for review February 9, 2023 12:51
@ghost ghost requested review from hannaeko, marc-vanderwal and tgreenx February 9, 2023 12:51
@ghost ghost added the V-Minor Versioning: The change gives an update of minor in version. label Feb 9, 2023
@ghost ghost added this to the v2023.1 milestone Feb 9, 2023
@ghost ghost requested a review from matsduf February 9, 2023 12:52
@matsduf
Copy link
Contributor

matsduf commented Feb 9, 2023

job_progress returns the status of ongoing job or completed job.
batch_status returns the status of ongoing batch or completed batch.

job_progress and batch_progress or job_status and batch_status?

@ghost
Copy link
Author

ghost commented Feb 9, 2023

Good point, I like *_status, it's more generic. I'll provide an update. I've rebased and updated.

docs/API.md Outdated Show resolved Hide resolved
docs/API.md Outdated Show resolved Hide resolved
docs/API.md Outdated Show resolved Hide resolved
@ghost ghost requested a review from matsduf February 10, 2023 14:49
@matsduf
Copy link
Contributor

matsduf commented Feb 14, 2023

E.g. method start_domain_test is deprecated, but it is also used in some t files (e.g. t/lifecycle.t). Other deprecated methods might be used in the t files. The new methods are not added, which I think they should be. The deprecated methods could maybe be removed now, but it would be better if they are kept until they are removed.

Else this looks good.

@ghost
Copy link
Author

ghost commented Feb 15, 2023

I planned to do this on a second stage, ie in a follow-up PR. If this is ok, could you approve this PR?

@ghost ghost changed the title Always return an object from API methods + deprecate and replace all existing API methods Always return an object from API methods and deprecate all existing API methods Feb 15, 2023
@matsduf
Copy link
Contributor

matsduf commented Feb 15, 2023

I planned to do this on a second stage, ie in a follow-up PR. If this is ok, could you approve this PR?

That is also fine.

matsduf
matsduf previously approved these changes Feb 15, 2023
Copy link
Contributor

@tgreenx tgreenx left a comment

Choose a reason for hiding this comment

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

The renaming of methods is clear and appreciated. A few comments; other than that, LGTM.

Comment on lines 68 to 70
connect "system_version" => {
handler => $handler,
action => "system_version"
Copy link
Contributor

Choose a reason for hiding this comment

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

"system_version" -> "system_versions"
(two occurrences)

Copy link
Author

Choose a reason for hiding this comment

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

fixed

docs/API.md Outdated
* [API method: conf_profiles](#api-method-conf_profiles)
* [API method: conf_languages](#api-method-conf_languages)
* [API method: lookup_address_records](#api-method-lookup_address_records)
* [API method: lookup_delegatio_data](#api-method-lookup_delegation_data)
Copy link
Contributor

Choose a reason for hiding this comment

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

lookup_delegatio_data -> lookup_delegation_data

Copy link
Author

Choose a reason for hiding this comment

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

fixed

connect "batch_status" => {
handler => $handler,
action => "batch_status"
};
};

if ($config->RPCAPI_enable_add_api_user) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this PR also introduce the new appropriate, unused config parameter RPCAPI_enable_user_create ?

Copy link
Author

@ghost ghost Feb 22, 2023

Choose a reason for hiding this comment

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

good point, I've created this new config parameter and marked old one as deprecated

$router->connect("user_create", {
handler => $handler,
action => "user_create"
});
}

if ($config->RPCAPI_enable_add_batch_job) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this PR also introduce the new appropriate, unused config parameter RPCAPI_enable_batch_create ?

Copy link
Author

@ghost ghost Feb 22, 2023

Choose a reason for hiding this comment

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

good point, I've created this new config parameter and marked old one as deprecated

Alexandre Pion added 4 commits February 22, 2023 17:49
And mark old ones as deprecated
Some old API methods were already returning an object. This object can
be returned.
Alexandre Pion added 3 commits February 22, 2023 18:56
* Document new API methods
* Mark old API methods as deprecated
* Link to new API methods from deprecated one
* Update return values for new API methods
Alexandre Pion added 5 commits February 22, 2023 18:59
* create "RPCAPI.enable_batch_create" and "RPCAPI.enable_user_create"
* mark "RPCAPI.enable_add_batch_job" and "RPCAPI.enable_add_api_user" as
  deprecated
Copy link
Contributor

@matsduf matsduf left a comment

Choose a reason for hiding this comment

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

This is still fine.

@ghost ghost merged commit c6bbe44 into zonemaster:develop Feb 24, 2023
@ghost ghost deleted the rpcapi-deprecation-warnings-1 branch February 24, 2023 10:38
@ghost ghost mentioned this pull request Mar 13, 2023
@marc-vanderwal
Copy link
Contributor

Release test successful.

I found one minor latent issue, #1105. But it’s very minor (it’s only visible by manually poking at the API) and seems more like an old oversight. It is not a regression introduced by this pull request, so this issue should not prevent the upcoming release from taking place.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-ReleaseTested Status: The PR has been successfully tested in release testing V-Minor Versioning: The change gives an update of minor in version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants