convertion from string to enum fails
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 51
Description
### Describe the bug
When issuing an ec2::DescribeNetworkInterfaces, the returned NetworkInterfaceType is a string that the sdk can convert to an Enum using an internal map. However, the value returned by the API for Nat Gateway does not match the value in the map. The result is that the Enum value returned does not correctly reflect the type of the interface (an "unknown to sdk" Enum value is returned)
Here are the returned values from `services/ec2/src/main/resources/codegen-resources/service-2.json:46316`:
```json
"NetworkInterfaceType":{
"type":"string",
"enum":[
"interface",
"natGateway",
"efa",
"trunk",
"load_balancer",
"network_load_balancer",
"vpc_endpoint",
"branch",
"transit_gateway",
"lambda",
"quicksight",
"global_accelerator_managed",
"api_gateway_managed",
"gateway_load_balancer",
"gateway_load_balancer_endpoint",
"iot_rules_managed",
"aws_codestar_connections_managed"
]
},
```
Note that `natGateway` is camel cased while the others use underscores.
Following is the the XML response from the AWS API for a specific interface. Note the last line ` nat_gateway`
```xml
eni-0c712113537506cd7
subnet-0a415aa89455cf4f8
vpc-04f987fff6675ec10
us-west-1a
Interface for NAT Gateway nat-06a39644e236c7926
036476006320
213236389121
true
in-use
06:c6:2a:ae:e4:23
10.56.5.210
ip-10-56-5-210.us-west-1.compute.internal
false
ela-attach-fcc879c1
amazon-aws
1
attached
false
50.18.200.169
ec2-50-18-200-169.us-west-1.compute.amazonaws.com
036476006320
eipalloc-0f749c8c6fe1d8101
eipassoc-a56ec57f
true
10.56.5.210
ip-10-56-5-210.us-west-1.compute.internal
true
50.18.200.169
ec2-50-18-200-169.us-west-1.compute.amazonaws.com
036476006320
eipalloc-0f749c8c6fe1d8101
eipassoc-a56ec57f
true
nat_gateway
```
### Expected Behavior
The Network Interface Type should resolve to NAT_GATEWAY.
### Current Behavior
The Network Interface Type resolves to UNKNOWN_TO_SDK_VERSION
### Reproduction Steps
```java
try(var client = Ec2Client.builder().build()) {
var req = DescribeNetworkInterfacesRequest.builder().build();
var resp = client.describeNetworkInterfaces(req);
for(NetworkInterface nwif : resp.networkInterfaces()) {
var ifType = nwif.interfaceType();
var ifTypeName = nwif.interfaceTypeAsString();
if (ifTypeName != null && ifTypeName.toLowerCase().contains("nat")) {
System.out.println(ifTypeName);
System.out.println(ifType);
}
}
}
```
Response is:
```
nat_gateway
null
```
Indicating that the string internally stored by the SDK is `nat_gateway` and the convertion to Enum fails. This is due to the incorrect string defined here:
```
public enum NetworkInterfaceType {
INTERFACE("interface"),
NAT_GATEWAY("natGateway"), <======= should be nat_gateway
EFA("efa"),
TRUNK("trunk"),
LOAD_BALANCER("load_balancer"),
NETWORK_LOAD_BALANCER("network_load_balancer"),
VPC_ENDPOINT("vpc_endpoint"),
BRANCH("branch"),
TRANSIT_GATEWAY("transit_gateway"),
LAMBDA("lambda"),
QUICKSIGHT("quicksight"),
GLOBAL_ACCELERATOR_MANAGED("global_accelerator_managed"),
API_GATEWAY_MANAGED("api_gateway_managed"),
GATEWAY_LOAD_BALANCER("gateway_load_balancer"),
GATEWAY_LOAD_BALANCER_ENDPOINT("gateway_load_balancer_endpoint"),
IOT_RULES_MANAGED("iot_rules_managed"),
AWS_CODESTAR_CONNECTIONS_MANAGED("aws_codestar_connections_managed"),
UNKNOWN_TO_SDK_VERSION((String)null);
private static final Map VALUE_MAP = EnumUtils.uniqueIndex(NetworkInterfaceType.class, NetworkInterfaceType::toString);
```
### Possible Solution
Update `services/ec2/src/main/resources/codegen-resources/service-2.json:46316 to replace `"natGateway"` with `"nat_gateway"`.
### Additional Information/Context
_No response_
### AWS Java SDK version used
2.26.18
### JDK version used
openjdk version "17.0.9" 2023-10-17
### Operating System and version
Linux 5.10.219-208.866.amzn2.x86_64 aws/aws-sdk-java-v2#1 SMP Tue Jun 18 14:00:06 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Contributor guide
Assessment
This issue has not been assessed yet.