Skip to content

Add allowedValues annotations for remaining static enum parameters - #13783

Open
dheeraj12347 wants to merge 6 commits into
apache:mainfrom
dheeraj12347:feature/pr4-remaining-allowedvalues
Open

Add allowedValues annotations for remaining static enum parameters#13783
dheeraj12347 wants to merge 6 commits into
apache:mainfrom
dheeraj12347:feature/pr4-remaining-allowedvalues

Conversation

@dheeraj12347

Copy link
Copy Markdown
Contributor

Description

This PR adds missing allowedValues annotations for API parameters that expose a fixed set of valid values.

The updated commands are:

  • CreateDiskOfferingCmd (provisioningType)
  • CreateServiceOfferingCmd (provisioningType)
  • CreateConditionCmd (relationalOperator)
  • UpdateConditionCmd (relationalOperator)
  • ListUsersCmd (userSource)

These parameters already documented their valid values in the API description. This change makes the same information available through API discovery metadata, improving downstream tooling such as CloudMonkey autocompletion while preserving existing runtime behavior.

Testing

  • Successfully compiled using:
mvn -pl api -am -DskipTests compile

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds allowedValues metadata to API parameter discovery so fixed-value parameters can be surfaced in API discovery tooling (e.g., CloudMonkey autocompletion) without changing runtime behavior.

Changes:

  • Extends @Parameter with a new allowedValues() attribute and annotates multiple commands’ enum-like parameters.
  • Propagates allowedValues into API discovery responses via ApiDiscoveryServiceImpl and ApiParameterResponse.
  • Updates discovery test setup to account for the new annotation attribute.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
plugins/api/discovery/src/test/java/org/apache/cloudstack/discovery/ApiDiscoveryServiceImplTest.java Stubs allowedValues() on mocked @Parameter to keep tests passing after annotation change.
plugins/api/discovery/src/main/java/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java Reads allowedValues from @Parameter and exposes it in discovery response parameters.
plugins/api/discovery/src/main/java/org/apache/cloudstack/api/response/ApiParameterResponse.java Adds allowedvalues field (and getter/setter) to discovery parameter response model.
api/src/main/java/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java Adds allowedValues metadata for format and arch.
api/src/main/java/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java Adds allowedValues metadata for template filter and arch.
api/src/main/java/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotsCmd.java Adds allowedValues metadata for interval/snapshot/location types.
api/src/main/java/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotPolicyCmd.java Adds allowedValues metadata for snapshot policy interval type.
api/src/main/java/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java Adds allowedValues metadata for protocol.
api/src/main/java/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java Adds allowedValues metadata for ISO filter and arch.
api/src/main/java/org/apache/cloudstack/api/command/user/ipv6/CreateIpv6FirewallRuleCmd.java Adds allowedValues metadata for IPv6 firewall traffic type.
api/src/main/java/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java Adds allowedValues metadata for firewall protocol.
api/src/main/java/org/apache/cloudstack/api/command/user/backup/CreateBackupScheduleCmd.java Adds allowedValues metadata for backup schedule interval type.
api/src/main/java/org/apache/cloudstack/api/command/user/autoscale/UpdateConditionCmd.java Adds allowedValues metadata for relational operator.
api/src/main/java/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java Adds allowedValues metadata for relational operator.
api/src/main/java/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java Adds allowedValues metadata for internet protocol and network mode.
api/src/main/java/org/apache/cloudstack/api/command/admin/user/ListUsersCmd.java Adds allowedValues metadata for user authentication source.
api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java Adds allowedValues metadata for provisioning type.
api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java Adds allowedValues metadata for provisioning type.
api/src/main/java/org/apache/cloudstack/api/Parameter.java Adds allowedValues() to @Parameter annotation definition.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +241 to +246
String[] allowedValues = parameterAnnotation.allowedValues();
if (allowedValues.length > 0) {
paramResponse.setAllowedValues(
Collections.unmodifiableList(Arrays.asList(allowedValues))
);
}
Mockito.when(parameterMock.name()).thenReturn("paramName");
Mockito.when(parameterMock.since()).thenReturn("");
Mockito.when(parameterMock.entityType()).thenReturn(new Class[]{Object.class});
Mockito.when(parameterMock.allowedValues()).thenReturn(new String[]{});
Comment on lines +85 to +89
description = "The traffic type for the Ipv6 firewall rule, can be ingress or egress, defaulted to ingress if not specified",
allowedValues = {
"Ingress",
"Egress"
})
Comment on lines +98 to +103
description = "The internet protocol of the offering. Options are IPv4 and dualstack. Default is IPv4. dualstack will create an offering that supports both IPv4 and IPv6",
since = "4.17.0",
allowedValues = {
"IPv4",
"DualStack"
})
Comment on lines +243 to +245
paramResponse.setAllowedValues(
Collections.unmodifiableList(Arrays.asList(allowedValues))
);
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.65%. Comparing base (a4a52c9) to head (40a8a6e).
⚠️ Report is 189 commits behind head on main.

Files with missing lines Patch % Lines
.../cloudstack/api/response/ApiParameterResponse.java 0.00% 6 Missing ⚠️
.../cloudstack/discovery/ApiDiscoveryServiceImpl.java 57.14% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13783      +/-   ##
============================================
+ Coverage     18.08%   19.65%   +1.56%     
- Complexity    16721    19791    +3070     
============================================
  Files          6037     6368     +331     
  Lines        542580   574891   +32311     
  Branches      66428    70352    +3924     
============================================
+ Hits          98149   112968   +14819     
- Misses       433409   449650   +16241     
- Partials      11022    12273    +1251     
Flag Coverage Δ
uitests 3.41% <ø> (-0.11%) ⬇️
unittests 20.92% <40.00%> (+1.67%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants