-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[FEATURE REQ] azure-core support for extensible enum of type Integer and Float #38839
Comments
Do you have usecases for where Integer and Float are needed? |
I believe @billwert has a case where |
Yeah, we have an enum that looks like this in typespec:
The codegen for this becomes an public final class ReleaseDelay extends ExpandableStringEnum<ReleaseDelay> {
/**
* Release the event after 0 seconds.
*/
@Generated
public static final ReleaseDelay BY0_SECONDS = fromLong(0L);
/**
* Release the event after 10 seconds.
*/
@Generated
public static final ReleaseDelay BY10_SECONDS = fromLong(10L);
<snip> Also of interest is the code generator emitted this when the type was used: requestOptions.addQueryParam("releaseDelayInSeconds", String.valueOf(releaseDelayInSeconds.toLong()),
false) However the type didn't define a |
Hi Bill, thanks very much on the use case. I wasn't expecting to see the usage so soon (issue was mainly for parity with other codegen). The half baked class is mostly due to the "fixed enum" as such
@doc("Supported delays for release operation.")
enum ReleaseDelay {
@doc("Release the event after 0 seconds.")
By0Seconds: 0,
@doc("Release the event after 10 seconds.")
By10Seconds: 10,
@doc("Release the event after 60 seconds.")
By60Seconds: 60,
@doc("Release the event after 600 seconds.")
By600Seconds: 600,
@doc("Release the event after 3600 seconds.")
By3600Seconds: 3600,
@doc("Release the event after 0.5 seconds.")
By05Seconds: 0.5,
} Though in future, the extensible enum would be written as @doc("Supported delays for release operation.")
union ReleaseDelay {
int32,
@doc("Release the event after 0 seconds.")
By0Seconds: 0,
@doc("Release the event after 10 seconds.")
By10Seconds: 10,
@doc("Release the event after 60 seconds.")
By60Seconds: 60,
@doc("Release the event after 600 seconds.")
By600Seconds: 600,
@doc("Release the event after 3600 seconds.")
By3600Seconds: 3600,
} where we would know the type on that So far, we don't have a azure-core class for extensible enum as int/float. A formal support would depend on this issue about the decision on azure-core. Meanwhile, since the lib is still preview, we may use this class for the EventGrid. And replace the class when azure-core be ready. Maybe customize the API in client to be requestOptions.addQueryParam("releaseDelayInSeconds", releaseDelayInSeconds.toString(), false) It happens that we do not really need a @srnagar Do let us know what you think we can do, before we had the azure-core class. |
Is your feature request related to a problem? Please describe.
azure-core support for extensible enum of type Integer and Float.
Similar to String type https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core/src/main/java/com/azure/core/util/ExpandableStringEnum.java
Describe the solution you'd like
Possibly a generic class
ExpandableEnum<T>
(orExtensibleEnum<>
?).Describe alternatives you've considered
Class generated via codegen without azure-core class.
Additional context
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
The text was updated successfully, but these errors were encountered: