Skip to content

api,server: apis return their http request type #11382

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

shwstppr
Copy link
Contributor

@shwstppr shwstppr commented Aug 4, 2025

Description

This PR adds the httprequesttype parameter to the listApis response, allowing clients to invoke APIs using the appropriate HTTP methods — GET or POST. API classes can specify the supported HTTP methods via annotations. If no annotation is present, the request type will be inferred based on the API name.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

lisApis output,

(local) 🐱 > list apis filter=name,httprequesttype
{
  "api": [
    {
      "httprequesttype": "POST",
      "name": "createVPCOffering"
    },
    {
      "httprequesttype": "POST",
      "name": "ldapCreateAccount"
    },
    {
      "httprequesttype": "POST",
      "name": "copyIso"
    },
    {
      "httprequesttype": "POST",
      "name": "deleteAutoScaleVmProfile"
    },
    {
      "httprequesttype": "POST",
      "name": "rebootSystemVm"
    },
    {
      "httprequesttype": "GET",
      "name": "listDedicatedZones"
    },
    {
      "httprequesttype": "GET",
      "name": "listElastistorPool"
    },
    {
      "httprequesttype": "POST",
      "name": "changeBgpPeersForNetwork"
    },
    {
      "httprequesttype": "POST",
      "name": "removeNodesFromKubernetesCluster"
    },

How did you try to break this feature and the system with this change?

@sureshanaparti
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14531

@DaanHoogland
Copy link
Contributor

good initiative, would it make sense to have GET or POST as default so we don’t have to change all external plugins?

@shwstppr
Copy link
Contributor Author

shwstppr commented Aug 4, 2025

@DaanHoogland with change, it already returns GET/POST based on the apiName when the annotation is not added,

(local) 🐱 > list apis filter=name,httprequesttype
{
  "api": [
    {
      "httprequesttype": "POST",
      "name": "createVPCOffering"
    },
    {
      "httprequesttype": "POST",
      "name": "ldapCreateAccount"
    },
    {
      "httprequesttype": "POST",
      "name": "copyIso"
    },
    {
      "httprequesttype": "POST",
      "name": "deleteAutoScaleVmProfile"
    },
    {
      "httprequesttype": "POST",
      "name": "rebootSystemVm"
    },
    {
      "httprequesttype": "GET",
      "name": "listDedicatedZones"
    },
    {
      "httprequesttype": "GET",
      "name": "listElastistorPool"
    },
    {
      "httprequesttype": "POST",
      "name": "changeBgpPeersForNetwork"
    },
    {
      "httprequesttype": "POST",
      "name": "removeNodesFromKubernetesCluster"
    },
...

I added the annotation to some classes because they were listed in ApiServlet class as GET commands explicitly

@DaanHoogland
Copy link
Contributor

ok, @shwstppr , not claiming this as a universal truth but for this change

    String httpMethod() default “GET";

would have made the change simpler.

@shwstppr
Copy link
Contributor Author

shwstppr commented Aug 4, 2025

ok, @shwstppr , not claiming this as a universal truth but for this change

    String httpMethod() default “GET";

would have made the change simpler.

@DaanHoogland not necessarily IMO. If we return GET as default, then adding GET annotation will become useless, as we will always be double-checking. Leaving it empty helps in assigning a value using regex only when the annotation is not added

@sureshanaparti sureshanaparti added this to the 4.21.1 milestone Aug 4, 2025
@shwstppr shwstppr modified the milestones: 4.21.1, 4.22.0 Aug 4, 2025
Signed-off-by: Abhishek Kumar <[email protected]>
Copy link

codecov bot commented Aug 5, 2025

Codecov Report

❌ Patch coverage is 84.84848% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.37%. Comparing base (5cac4f6) to head (8efc627).
⚠️ Report is 46 commits behind head on main.

Files with missing lines Patch % Lines
server/src/main/java/com/cloud/api/ApiServlet.java 85.00% 0 Missing and 3 partials ⚠️
.../cloudstack/api/response/ApiDiscoveryResponse.java 85.71% 1 Missing ⚠️
.../cloudstack/discovery/ApiDiscoveryServiceImpl.java 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #11382      +/-   ##
============================================
- Coverage     17.37%   17.37%   -0.01%     
- Complexity    15222    15260      +38     
============================================
  Files          5885     5885              
  Lines        524875   525650     +775     
  Branches      64035    64167     +132     
============================================
+ Hits          91199    91314     +115     
- Misses       423387   424030     +643     
- Partials      10289    10306      +17     
Flag Coverage Δ
uitests 3.63% <ø> (-0.01%) ⬇️
unittests 18.41% <84.84%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@shwstppr
Copy link
Contributor Author

shwstppr commented Aug 5, 2025

@blueorangutan package

@blueorangutan
Copy link

@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14559

@shwstppr shwstppr closed this Aug 6, 2025
@shwstppr shwstppr reopened this Aug 6, 2025
Signed-off-by: Abhishek Kumar <[email protected]>
@shwstppr
Copy link
Contributor Author

shwstppr commented Aug 8, 2025

@blueorangutan package

@blueorangutan
Copy link

@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14580

@shwstppr
Copy link
Contributor Author

shwstppr commented Aug 8, 2025

@blueorangutan test

@blueorangutan
Copy link

@shwstppr a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-14048)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 56276 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11382-t14048-kvm-ol8.zip
Smoke tests completed. 146 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants