Skip to content

Commit 10cd255

Browse files
authored
Final Java Fixes (Azure#48620)
* regen * final regen for enums * update samples, readme, tests, changelogs
1 parent 59b98c1 commit 10cd255

33 files changed

+614
-558
lines changed

sdk/ai/azure-ai-agents/CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,22 @@
88

99
### Breaking Changes
1010

11-
- `MemoryStoreUpdateStatus` changed from a standard Java `enum` to an `ExpandableStringEnum`-based class. The `values()` method now returns a `Collection` instead of an array, and instances should be compared using `.equals()` rather than `==`.
11+
- The following types changed from standard Java `enum` to `ExpandableStringEnum`-based classes, allowing unknown values to be handled without throwing exceptions. The `values()` method now returns a `Collection` instead of an array, and instances should be compared using `.equals()` rather than `==`:
12+
- `ComputerEnvironment`
13+
- `ContainerMemoryLimit`
14+
- `GrammarSyntax`
15+
- `ImageGenActionEnum`
16+
- `ImageGenToolBackground`
17+
- `ImageGenToolModeration`
18+
- `ImageGenToolOutputFormat`
19+
- `ImageGenToolQuality`
20+
- `ImageGenToolSize`
21+
- `InputFidelity`
22+
- `McpToolConnectorId`
23+
- `MemoryStoreUpdateStatus`
24+
- `RankerVersionType`
25+
- `SearchContextSize`
26+
- `WebSearchToolSearchContextSize`
1227
- Renamed `getObject()` to `getObjectType()` in `AgentDetails`, `AgentVersionDetails`, and `MemoryStoreDetails`. The underlying field was renamed from `object` to `objectType`.
1328
- Renamed `MCPToolConnectorId` enum to `McpToolConnectorId` for consistent casing. The `McpTool` methods `getConnectorType()` and `setConnectorType()` now use `McpToolConnectorId` instead of `MCPToolConnectorId`.
1429
- `getContainerAsAutoCodeInterpreterToolParam()` on `CodeInterpreterTool` renamed to `getContainerAsAutoCodeInterpreterToolParameter()`, and `setContainer(AutoCodeInterpreterToolParam)` now accepts `AutoCodeInterpreterToolParameter` instead.
Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,75 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33
// Code generated by Microsoft (R) TypeSpec Code Generator.
4-
54
package com.azure.ai.agents.models;
65

6+
import com.azure.core.annotation.Generated;
7+
import com.azure.core.util.ExpandableStringEnum;
8+
import java.util.Collection;
9+
710
/**
811
* Defines values for ComputerEnvironment.
912
*/
10-
public enum ComputerEnvironment {
13+
public final class ComputerEnvironment extends ExpandableStringEnum<ComputerEnvironment> {
14+
1115
/**
12-
* Enum value windows.
16+
* Static value windows for ComputerEnvironment.
1317
*/
14-
WINDOWS("windows"),
18+
@Generated
19+
public static final ComputerEnvironment WINDOWS = fromString("windows");
1520

1621
/**
17-
* Enum value mac.
22+
* Static value mac for ComputerEnvironment.
1823
*/
19-
MAC("mac"),
24+
@Generated
25+
public static final ComputerEnvironment MAC = fromString("mac");
2026

2127
/**
22-
* Enum value linux.
28+
* Static value linux for ComputerEnvironment.
2329
*/
24-
LINUX("linux"),
30+
@Generated
31+
public static final ComputerEnvironment LINUX = fromString("linux");
2532

2633
/**
27-
* Enum value ubuntu.
34+
* Static value ubuntu for ComputerEnvironment.
2835
*/
29-
UBUNTU("ubuntu"),
36+
@Generated
37+
public static final ComputerEnvironment UBUNTU = fromString("ubuntu");
3038

3139
/**
32-
* Enum value browser.
40+
* Static value browser for ComputerEnvironment.
3341
*/
34-
BROWSER("browser");
42+
@Generated
43+
public static final ComputerEnvironment BROWSER = fromString("browser");
3544

3645
/**
37-
* The actual serialized value for a ComputerEnvironment instance.
46+
* Creates a new instance of ComputerEnvironment value.
47+
*
48+
* @deprecated Use the {@link #fromString(String)} factory method.
3849
*/
39-
private final String value;
40-
41-
ComputerEnvironment(String value) {
42-
this.value = value;
50+
@Generated
51+
@Deprecated
52+
public ComputerEnvironment() {
4353
}
4454

4555
/**
46-
* Parses a serialized value to a ComputerEnvironment instance.
47-
*
48-
* @param value the serialized value to parse.
49-
* @return the parsed ComputerEnvironment object, or null if unable to parse.
56+
* Creates or finds a ComputerEnvironment from its string representation.
57+
*
58+
* @param name a name to look for.
59+
* @return the corresponding ComputerEnvironment.
5060
*/
51-
public static ComputerEnvironment fromString(String value) {
52-
if (value == null) {
53-
return null;
54-
}
55-
ComputerEnvironment[] items = ComputerEnvironment.values();
56-
for (ComputerEnvironment item : items) {
57-
if (item.toString().equalsIgnoreCase(value)) {
58-
return item;
59-
}
60-
}
61-
return null;
61+
@Generated
62+
public static ComputerEnvironment fromString(String name) {
63+
return fromString(name, ComputerEnvironment.class);
6264
}
6365

6466
/**
65-
* {@inheritDoc}
67+
* Gets known ComputerEnvironment values.
68+
*
69+
* @return known ComputerEnvironment values.
6670
*/
67-
@Override
68-
public String toString() {
69-
return this.value;
71+
@Generated
72+
public static Collection<ComputerEnvironment> values() {
73+
return values(ComputerEnvironment.class);
7074
}
7175
}
Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,69 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33
// Code generated by Microsoft (R) TypeSpec Code Generator.
4-
54
package com.azure.ai.agents.models;
65

6+
import com.azure.core.annotation.Generated;
7+
import com.azure.core.util.ExpandableStringEnum;
8+
import java.util.Collection;
9+
710
/**
811
* Defines values for ContainerMemoryLimit.
912
*/
10-
public enum ContainerMemoryLimit {
13+
public final class ContainerMemoryLimit extends ExpandableStringEnum<ContainerMemoryLimit> {
14+
1115
/**
12-
* Enum value 1g.
16+
* Static value 1g for ContainerMemoryLimit.
1317
*/
14-
MEMORY_1GB("1g"),
18+
@Generated
19+
public static final ContainerMemoryLimit MEMORY_1GB = fromString("1g");
1520

1621
/**
17-
* Enum value 4g.
22+
* Static value 4g for ContainerMemoryLimit.
1823
*/
19-
MEMORY_4GB("4g"),
24+
@Generated
25+
public static final ContainerMemoryLimit MEMORY_4GB = fromString("4g");
2026

2127
/**
22-
* Enum value 16g.
28+
* Static value 16g for ContainerMemoryLimit.
2329
*/
24-
MEMORY_16GB("16g"),
30+
@Generated
31+
public static final ContainerMemoryLimit MEMORY_16GB = fromString("16g");
2532

2633
/**
27-
* Enum value 64g.
34+
* Static value 64g for ContainerMemoryLimit.
2835
*/
29-
MEMORY_64GB("64g");
36+
@Generated
37+
public static final ContainerMemoryLimit MEMORY_64GB = fromString("64g");
3038

3139
/**
32-
* The actual serialized value for a ContainerMemoryLimit instance.
40+
* Creates a new instance of ContainerMemoryLimit value.
41+
*
42+
* @deprecated Use the {@link #fromString(String)} factory method.
3343
*/
34-
private final String value;
35-
36-
ContainerMemoryLimit(String value) {
37-
this.value = value;
44+
@Generated
45+
@Deprecated
46+
public ContainerMemoryLimit() {
3847
}
3948

4049
/**
41-
* Parses a serialized value to a ContainerMemoryLimit instance.
42-
*
43-
* @param value the serialized value to parse.
44-
* @return the parsed ContainerMemoryLimit object, or null if unable to parse.
50+
* Creates or finds a ContainerMemoryLimit from its string representation.
51+
*
52+
* @param name a name to look for.
53+
* @return the corresponding ContainerMemoryLimit.
4554
*/
46-
public static ContainerMemoryLimit fromString(String value) {
47-
if (value == null) {
48-
return null;
49-
}
50-
ContainerMemoryLimit[] items = ContainerMemoryLimit.values();
51-
for (ContainerMemoryLimit item : items) {
52-
if (item.toString().equalsIgnoreCase(value)) {
53-
return item;
54-
}
55-
}
56-
return null;
55+
@Generated
56+
public static ContainerMemoryLimit fromString(String name) {
57+
return fromString(name, ContainerMemoryLimit.class);
5758
}
5859

5960
/**
60-
* {@inheritDoc}
61+
* Gets known ContainerMemoryLimit values.
62+
*
63+
* @return known ContainerMemoryLimit values.
6164
*/
62-
@Override
63-
public String toString() {
64-
return this.value;
65+
@Generated
66+
public static Collection<ContainerMemoryLimit> values() {
67+
return values(ContainerMemoryLimit.class);
6568
}
6669
}
Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,57 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33
// Code generated by Microsoft (R) TypeSpec Code Generator.
4-
54
package com.azure.ai.agents.models;
65

6+
import com.azure.core.annotation.Generated;
7+
import com.azure.core.util.ExpandableStringEnum;
8+
import java.util.Collection;
9+
710
/**
811
* Defines values for GrammarSyntax.
912
*/
10-
public enum GrammarSyntax {
13+
public final class GrammarSyntax extends ExpandableStringEnum<GrammarSyntax> {
14+
1115
/**
12-
* Enum value lark.
16+
* Static value lark for GrammarSyntax.
1317
*/
14-
LARK("lark"),
18+
@Generated
19+
public static final GrammarSyntax LARK = fromString("lark");
1520

1621
/**
17-
* Enum value regex.
22+
* Static value regex for GrammarSyntax.
1823
*/
19-
REGEX("regex");
24+
@Generated
25+
public static final GrammarSyntax REGEX = fromString("regex");
2026

2127
/**
22-
* The actual serialized value for a GrammarSyntax instance.
28+
* Creates a new instance of GrammarSyntax value.
29+
*
30+
* @deprecated Use the {@link #fromString(String)} factory method.
2331
*/
24-
private final String value;
25-
26-
GrammarSyntax(String value) {
27-
this.value = value;
32+
@Generated
33+
@Deprecated
34+
public GrammarSyntax() {
2835
}
2936

3037
/**
31-
* Parses a serialized value to a GrammarSyntax instance.
32-
*
33-
* @param value the serialized value to parse.
34-
* @return the parsed GrammarSyntax object, or null if unable to parse.
38+
* Creates or finds a GrammarSyntax from its string representation.
39+
*
40+
* @param name a name to look for.
41+
* @return the corresponding GrammarSyntax.
3542
*/
36-
public static GrammarSyntax fromString(String value) {
37-
if (value == null) {
38-
return null;
39-
}
40-
GrammarSyntax[] items = GrammarSyntax.values();
41-
for (GrammarSyntax item : items) {
42-
if (item.toString().equalsIgnoreCase(value)) {
43-
return item;
44-
}
45-
}
46-
return null;
43+
@Generated
44+
public static GrammarSyntax fromString(String name) {
45+
return fromString(name, GrammarSyntax.class);
4746
}
4847

4948
/**
50-
* {@inheritDoc}
49+
* Gets known GrammarSyntax values.
50+
*
51+
* @return known GrammarSyntax values.
5152
*/
52-
@Override
53-
public String toString() {
54-
return this.value;
53+
@Generated
54+
public static Collection<GrammarSyntax> values() {
55+
return values(GrammarSyntax.class);
5556
}
5657
}

0 commit comments

Comments
 (0)