Skip to content

Commit 79070c4

Browse files
authored
[Automation] Generate SDK based on TypeSpec 0.21.2 (#42126)
1 parent eab9ea6 commit 79070c4

File tree

7 files changed

+405
-0
lines changed

7 files changed

+405
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
// Code generated by Microsoft (R) TypeSpec Code Generator.
4+
5+
package com.azure.resourcemanager.devopsinfrastructure.generated;
6+
7+
import com.azure.core.util.BinaryData;
8+
import com.azure.resourcemanager.devopsinfrastructure.models.AgentProfile;
9+
import com.azure.resourcemanager.devopsinfrastructure.models.FabricProfile;
10+
import com.azure.resourcemanager.devopsinfrastructure.models.ManagedServiceIdentity;
11+
import com.azure.resourcemanager.devopsinfrastructure.models.ManagedServiceIdentityType;
12+
import com.azure.resourcemanager.devopsinfrastructure.models.OrganizationProfile;
13+
import com.azure.resourcemanager.devopsinfrastructure.models.PoolUpdate;
14+
import com.azure.resourcemanager.devopsinfrastructure.models.PoolUpdateProperties;
15+
import com.azure.resourcemanager.devopsinfrastructure.models.ProvisioningState;
16+
import com.azure.resourcemanager.devopsinfrastructure.models.ResourcePredictions;
17+
import com.azure.resourcemanager.devopsinfrastructure.models.ResourcePredictionsProfile;
18+
import com.azure.resourcemanager.devopsinfrastructure.models.UserAssignedIdentity;
19+
import java.util.HashMap;
20+
import java.util.Map;
21+
import org.junit.jupiter.api.Assertions;
22+
23+
public final class PoolUpdateTests {
24+
@org.junit.jupiter.api.Test
25+
public void testDeserialize() throws Exception {
26+
PoolUpdate model = BinaryData.fromString(
27+
"{\"identity\":{\"principalId\":\"yip\",\"tenantId\":\"sqwpgrjb\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"shurzafbljjgpbto\":{\"principalId\":\"jxvsnbyxqabn\",\"clientId\":\"cpc\"},\"kudjkrlkhb\":{\"principalId\":\"jmkljavbqidtqajz\",\"clientId\":\"l\"},\"scpai\":{\"principalId\":\"fepgzgq\",\"clientId\":\"zloc\"},\"onpimexgstxg\":{\"principalId\":\"hhbcsglummajtjao\",\"clientId\":\"obnbdxkqpxokaj\"}}},\"tags\":{\"aajrm\":\"dg\",\"clwhijcoejctbz\":\"djwzrlov\",\"bkbfkgukdkex\":\"qsqsy\",\"ocjjxhvpmouexh\":\"ppofmxaxcfjpgdd\"},\"properties\":{\"provisioningState\":\"Succeeded\",\"maximumConcurrency\":1730783579,\"organizationProfile\":{\"kind\":\"OrganizationProfile\"},\"agentProfile\":{\"kind\":\"AgentProfile\",\"resourcePredictions\":{},\"resourcePredictionsProfile\":{\"kind\":\"ResourcePredictionsProfile\"}},\"fabricProfile\":{\"kind\":\"FabricProfile\"},\"devCenterProjectResourceId\":\"bzv\"}}")
28+
.toObject(PoolUpdate.class);
29+
Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_AND_USER_ASSIGNED, model.identity().type());
30+
Assertions.assertEquals("dg", model.tags().get("aajrm"));
31+
Assertions.assertEquals(ProvisioningState.SUCCEEDED, model.properties().provisioningState());
32+
Assertions.assertEquals(1730783579, model.properties().maximumConcurrency());
33+
Assertions.assertEquals("bzv", model.properties().devCenterProjectResourceId());
34+
}
35+
36+
@org.junit.jupiter.api.Test
37+
public void testSerialize() throws Exception {
38+
PoolUpdate model
39+
= new PoolUpdate()
40+
.withIdentity(
41+
new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_AND_USER_ASSIGNED)
42+
.withUserAssignedIdentities(mapOf("shurzafbljjgpbto", new UserAssignedIdentity(), "kudjkrlkhb",
43+
new UserAssignedIdentity(), "scpai", new UserAssignedIdentity(), "onpimexgstxg",
44+
new UserAssignedIdentity())))
45+
.withTags(mapOf("aajrm", "dg", "clwhijcoejctbz", "djwzrlov", "bkbfkgukdkex", "qsqsy", "ocjjxhvpmouexh",
46+
"ppofmxaxcfjpgdd"))
47+
.withProperties(new PoolUpdateProperties().withProvisioningState(ProvisioningState.SUCCEEDED)
48+
.withMaximumConcurrency(1730783579)
49+
.withOrganizationProfile(new OrganizationProfile())
50+
.withAgentProfile(new AgentProfile().withResourcePredictions(new ResourcePredictions())
51+
.withResourcePredictionsProfile(new ResourcePredictionsProfile()))
52+
.withFabricProfile(new FabricProfile())
53+
.withDevCenterProjectResourceId("bzv"));
54+
model = BinaryData.fromObject(model).toObject(PoolUpdate.class);
55+
Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_AND_USER_ASSIGNED, model.identity().type());
56+
Assertions.assertEquals("dg", model.tags().get("aajrm"));
57+
Assertions.assertEquals(ProvisioningState.SUCCEEDED, model.properties().provisioningState());
58+
Assertions.assertEquals(1730783579, model.properties().maximumConcurrency());
59+
Assertions.assertEquals("bzv", model.properties().devCenterProjectResourceId());
60+
}
61+
62+
// Use "Map.of" if available
63+
@SuppressWarnings("unchecked")
64+
private static <T> Map<String, T> mapOf(Object... inputs) {
65+
Map<String, T> map = new HashMap<>();
66+
for (int i = 0; i < inputs.length; i += 2) {
67+
String key = (String) inputs[i];
68+
T value = (T) inputs[i + 1];
69+
map.put(key, value);
70+
}
71+
return map;
72+
}
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
// Code generated by Microsoft (R) TypeSpec Code Generator.
4+
5+
package com.azure.resourcemanager.devopsinfrastructure.generated;
6+
7+
import com.azure.core.credential.AccessToken;
8+
import com.azure.core.http.HttpClient;
9+
import com.azure.core.management.AzureEnvironment;
10+
import com.azure.core.management.profile.AzureProfile;
11+
import com.azure.core.test.http.MockHttpResponse;
12+
import com.azure.resourcemanager.devopsinfrastructure.DevOpsInfrastructureManager;
13+
import com.azure.resourcemanager.devopsinfrastructure.models.AgentProfile;
14+
import com.azure.resourcemanager.devopsinfrastructure.models.FabricProfile;
15+
import com.azure.resourcemanager.devopsinfrastructure.models.ManagedServiceIdentity;
16+
import com.azure.resourcemanager.devopsinfrastructure.models.ManagedServiceIdentityType;
17+
import com.azure.resourcemanager.devopsinfrastructure.models.OrganizationProfile;
18+
import com.azure.resourcemanager.devopsinfrastructure.models.Pool;
19+
import com.azure.resourcemanager.devopsinfrastructure.models.PoolProperties;
20+
import com.azure.resourcemanager.devopsinfrastructure.models.ProvisioningState;
21+
import com.azure.resourcemanager.devopsinfrastructure.models.ResourcePredictions;
22+
import com.azure.resourcemanager.devopsinfrastructure.models.ResourcePredictionsProfile;
23+
import com.azure.resourcemanager.devopsinfrastructure.models.UserAssignedIdentity;
24+
import java.nio.charset.StandardCharsets;
25+
import java.time.OffsetDateTime;
26+
import java.util.HashMap;
27+
import java.util.Map;
28+
import org.junit.jupiter.api.Assertions;
29+
import org.junit.jupiter.api.Test;
30+
import reactor.core.publisher.Mono;
31+
32+
public final class PoolsCreateOrUpdateMockTests {
33+
@Test
34+
public void testCreateOrUpdate() throws Exception {
35+
String responseStr
36+
= "{\"properties\":{\"provisioningState\":\"Succeeded\",\"maximumConcurrency\":1068546777,\"organizationProfile\":{\"kind\":\"OrganizationProfile\"},\"agentProfile\":{\"kind\":\"AgentProfile\",\"resourcePredictions\":{},\"resourcePredictionsProfile\":{\"kind\":\"ResourcePredictionsProfile\"}},\"fabricProfile\":{\"kind\":\"FabricProfile\"},\"devCenterProjectResourceId\":\"eddgssofw\"},\"identity\":{\"principalId\":\"qal\",\"tenantId\":\"mnjijpxacqqudf\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{\"evfdnwnwm\":{\"principalId\":\"aaabjyvayff\",\"clientId\":\"rzrtuzqogsex\"},\"thzvaytdwkqbrqu\":{\"principalId\":\"zsyyceuzso\",\"clientId\":\"judpfrxt\"},\"oaxoruzfgsqu\":{\"principalId\":\"axhexiilivp\",\"clientId\":\"iirqtd\"}}},\"location\":\"xrxxlep\",\"tags\":{\"wxuqlcvydypatdoo\":\"mxjezwlw\",\"kooebwnu\":\"ojknio\",\"vdkcrodtj\":\"hemms\"},\"id\":\"nfwjlfltkacjvefk\",\"name\":\"lfoakg\",\"type\":\"kfpagao\"}";
37+
38+
HttpClient httpClient
39+
= response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8)));
40+
DevOpsInfrastructureManager manager = DevOpsInfrastructureManager.configure()
41+
.withHttpClient(httpClient)
42+
.authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)),
43+
new AzureProfile("", "", AzureEnvironment.AZURE));
44+
45+
Pool response
46+
= manager.pools()
47+
.define("dxbjhwuaanozj")
48+
.withRegion("varmywdmj")
49+
.withExistingResourceGroup("abfatkl")
50+
.withTags(mapOf("rw", "bjhhyx"))
51+
.withProperties(new PoolProperties().withProvisioningState(ProvisioningState.DELETING)
52+
.withMaximumConcurrency(1082355314)
53+
.withOrganizationProfile(new OrganizationProfile())
54+
.withAgentProfile(new AgentProfile().withResourcePredictions(new ResourcePredictions())
55+
.withResourcePredictionsProfile(new ResourcePredictionsProfile()))
56+
.withFabricProfile(new FabricProfile())
57+
.withDevCenterProjectResourceId("l"))
58+
.withIdentity(
59+
new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_AND_USER_ASSIGNED)
60+
.withUserAssignedIdentities(mapOf("jhdgqggebdunyga", new UserAssignedIdentity(), "rxcyjmoad",
61+
new UserAssignedIdentity())))
62+
.create();
63+
64+
Assertions.assertEquals("xrxxlep", response.location());
65+
Assertions.assertEquals("mxjezwlw", response.tags().get("wxuqlcvydypatdoo"));
66+
Assertions.assertEquals(ProvisioningState.SUCCEEDED, response.properties().provisioningState());
67+
Assertions.assertEquals(1068546777, response.properties().maximumConcurrency());
68+
Assertions.assertEquals("eddgssofw", response.properties().devCenterProjectResourceId());
69+
Assertions.assertEquals(ManagedServiceIdentityType.USER_ASSIGNED, response.identity().type());
70+
}
71+
72+
// Use "Map.of" if available
73+
@SuppressWarnings("unchecked")
74+
private static <T> Map<String, T> mapOf(Object... inputs) {
75+
Map<String, T> map = new HashMap<>();
76+
for (int i = 0; i < inputs.length; i += 2) {
77+
String key = (String) inputs[i];
78+
T value = (T) inputs[i + 1];
79+
map.put(key, value);
80+
}
81+
return map;
82+
}
83+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
// Code generated by Microsoft (R) TypeSpec Code Generator.
4+
5+
package com.azure.resourcemanager.devopsinfrastructure.generated;
6+
7+
import com.azure.core.credential.AccessToken;
8+
import com.azure.core.http.HttpClient;
9+
import com.azure.core.http.rest.PagedIterable;
10+
import com.azure.core.management.AzureEnvironment;
11+
import com.azure.core.management.profile.AzureProfile;
12+
import com.azure.core.test.http.MockHttpResponse;
13+
import com.azure.resourcemanager.devopsinfrastructure.DevOpsInfrastructureManager;
14+
import com.azure.resourcemanager.devopsinfrastructure.models.ManagedServiceIdentityType;
15+
import com.azure.resourcemanager.devopsinfrastructure.models.Pool;
16+
import com.azure.resourcemanager.devopsinfrastructure.models.ProvisioningState;
17+
import java.nio.charset.StandardCharsets;
18+
import java.time.OffsetDateTime;
19+
import org.junit.jupiter.api.Assertions;
20+
import org.junit.jupiter.api.Test;
21+
import reactor.core.publisher.Mono;
22+
23+
public final class PoolsListByResourceGroupMockTests {
24+
@Test
25+
public void testListByResourceGroup() throws Exception {
26+
String responseStr
27+
= "{\"value\":[{\"properties\":{\"provisioningState\":\"Updating\",\"maximumConcurrency\":613432064,\"organizationProfile\":{\"kind\":\"OrganizationProfile\"},\"agentProfile\":{\"kind\":\"AgentProfile\",\"resourcePredictions\":{},\"resourcePredictionsProfile\":{\"kind\":\"ResourcePredictionsProfile\"}},\"fabricProfile\":{\"kind\":\"FabricProfile\"},\"devCenterProjectResourceId\":\"ibzyhwitsmyp\"},\"identity\":{\"principalId\":\"pcdpumnz\",\"tenantId\":\"wznm\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"lkdmtncvokotllxd\":{\"principalId\":\"sorgj\",\"clientId\":\"bldtlww\"}}},\"location\":\"gsyocogj\",\"tags\":{\"oocrkvcikhnv\":\"tbnnha\",\"gxk\":\"amqgxqquezikyw\"},\"id\":\"lla\",\"name\":\"melwuipiccjz\",\"type\":\"z\"}]}";
28+
29+
HttpClient httpClient
30+
= response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8)));
31+
DevOpsInfrastructureManager manager = DevOpsInfrastructureManager.configure()
32+
.withHttpClient(httpClient)
33+
.authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)),
34+
new AzureProfile("", "", AzureEnvironment.AZURE));
35+
36+
PagedIterable<Pool> response
37+
= manager.pools().listByResourceGroup("ysuiizynkedya", com.azure.core.util.Context.NONE);
38+
39+
Assertions.assertEquals("gsyocogj", response.iterator().next().location());
40+
Assertions.assertEquals("tbnnha", response.iterator().next().tags().get("oocrkvcikhnv"));
41+
Assertions.assertEquals(ProvisioningState.UPDATING,
42+
response.iterator().next().properties().provisioningState());
43+
Assertions.assertEquals(613432064, response.iterator().next().properties().maximumConcurrency());
44+
Assertions.assertEquals("ibzyhwitsmyp", response.iterator().next().properties().devCenterProjectResourceId());
45+
Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_AND_USER_ASSIGNED,
46+
response.iterator().next().identity().type());
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
// Code generated by Microsoft (R) TypeSpec Code Generator.
4+
5+
package com.azure.resourcemanager.devopsinfrastructure.generated;
6+
7+
import com.azure.core.util.BinaryData;
8+
import com.azure.resourcemanager.devopsinfrastructure.models.CachingType;
9+
import com.azure.resourcemanager.devopsinfrastructure.models.DataDisk;
10+
import com.azure.resourcemanager.devopsinfrastructure.models.OsDiskStorageAccountType;
11+
import com.azure.resourcemanager.devopsinfrastructure.models.StorageAccountType;
12+
import com.azure.resourcemanager.devopsinfrastructure.models.StorageProfile;
13+
import java.util.Arrays;
14+
import org.junit.jupiter.api.Assertions;
15+
16+
public final class StorageProfileTests {
17+
@org.junit.jupiter.api.Test
18+
public void testDeserialize() throws Exception {
19+
StorageProfile model = BinaryData.fromString(
20+
"{\"osDiskStorageAccountType\":\"StandardSSD\",\"dataDisks\":[{\"caching\":\"None\",\"diskSizeGiB\":103063252,\"storageAccountType\":\"StandardSSD_LRS\",\"driveLetter\":\"zw\"}]}")
21+
.toObject(StorageProfile.class);
22+
Assertions.assertEquals(OsDiskStorageAccountType.STANDARD_SSD, model.osDiskStorageAccountType());
23+
Assertions.assertEquals(CachingType.NONE, model.dataDisks().get(0).caching());
24+
Assertions.assertEquals(103063252, model.dataDisks().get(0).diskSizeGiB());
25+
Assertions.assertEquals(StorageAccountType.STANDARD_SSDLRS, model.dataDisks().get(0).storageAccountType());
26+
Assertions.assertEquals("zw", model.dataDisks().get(0).driveLetter());
27+
}
28+
29+
@org.junit.jupiter.api.Test
30+
public void testSerialize() throws Exception {
31+
StorageProfile model = new StorageProfile().withOsDiskStorageAccountType(OsDiskStorageAccountType.STANDARD_SSD)
32+
.withDataDisks(Arrays.asList(new DataDisk().withCaching(CachingType.NONE)
33+
.withDiskSizeGiB(103063252)
34+
.withStorageAccountType(StorageAccountType.STANDARD_SSDLRS)
35+
.withDriveLetter("zw")));
36+
model = BinaryData.fromObject(model).toObject(StorageProfile.class);
37+
Assertions.assertEquals(OsDiskStorageAccountType.STANDARD_SSD, model.osDiskStorageAccountType());
38+
Assertions.assertEquals(CachingType.NONE, model.dataDisks().get(0).caching());
39+
Assertions.assertEquals(103063252, model.dataDisks().get(0).diskSizeGiB());
40+
Assertions.assertEquals(StorageAccountType.STANDARD_SSDLRS, model.dataDisks().get(0).storageAccountType());
41+
Assertions.assertEquals("zw", model.dataDisks().get(0).driveLetter());
42+
}
43+
}

0 commit comments

Comments
 (0)