Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@azure-tools/typespec-java"
---

Re-enable the ARM resource identifier emitter test.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-java"
---

Sync core to microsoft/typespec commit `1a1583554b`. Fix management generation to omit models and enums configured with `remove-model` (core [#11698](https://github.com/microsoft/typespec/pull/11698)).
15 changes: 14 additions & 1 deletion packages/typespec-java/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# Change Log - @azure-tools/typespec-java

## 0.46.0

### Features

- Sync core to microsoft/typespec commit `27b39b71b`. Support removing models from management clients with the `remove-model` emitter option (core [#11658](https://github.com/microsoft/typespec/pull/11658)).

### Bug Fixes

- Fix Fluent Premium samples to use the correct service client for resource metadata suffixes (core [#11633](https://github.com/microsoft/typespec/pull/11633)).
- Preserve existing properties files for applicable libraries during SDK integration (core [#11635](https://github.com/microsoft/typespec/pull/11635)).
- Document response headers in protocol API Javadocs (core [#11610](https://github.com/microsoft/typespec/pull/11610)).


## 0.45.13

### Features

- [#5138](https://github.com/Azure/typespec-azure/pull/5138) Sync core to microsoft/typespec commit `2e1649b83`. Includes support for nested property paths and XML payloads in Azure pageable responses (core [#11504](https://github.com/microsoft/typespec/pull/11504)).
- Sync core to microsoft/typespec commit `2e1649b83`. Includes support for nested property paths and XML payloads in Azure pageable responses (core [#11504](https://github.com/microsoft/typespec/pull/11504)).


## 0.45.12
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-java/core-commit.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "sha": "fbd68c68652b13a5c2a0c6e2375f06fdcb09d370" }
{ "sha": "1a1583554b6b3b9b98155002f10e696d1c1ffa85" }
14 changes: 0 additions & 14 deletions packages/typespec-java/core.test.patch
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,3 @@ index f002da96..fae8d01b 100644
}

public static byte[] getJpgBytes() {
diff --git a/src/test/java/azure/resourcemanager/commonproperties/CommonPropertiesTests.java b/src/test/java/azure/resourcemanager/commonproperties/CommonPropertiesTests.java
--- a/src/test/java/azure/resourcemanager/commonproperties/CommonPropertiesTests.java
+++ b/src/test/java/azure/resourcemanager/commonproperties/CommonPropertiesTests.java
@@ -18,5 +18,6 @@ import com.azure.core.management.exception.ManagementException;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.utils.ArmUtils;
@@ -98,2 +99,3 @@ public class CommonPropertiesTests {
@Test
+ @Disabled("Requires an unreleased azure-http-specs ARM resource identifier feature")
public void testArmResourceIdentifiers() {
1 change: 1 addition & 0 deletions packages/typespec-java/emitter-tests/spector.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ specs:
azure/resource-manager/operation-templates: { options: { generate-tests: false } }
azure/resource-manager/resources: { options: { generate-tests: false } }
azure/resource-manager/service-group: { options: { generate-tests: false } }
azure/resource-manager/service-group-extension: true
azure/special-headers/client-request-id: true
azure/special-headers/conditional-request: true
azure/versioning/previewVersion: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package azure.clientgenerator.core.apiversion.clientapiversions;

import org.junit.jupiter.api.Test;

public class ClientApiVersionsTests {

@Test
public void sendExtendedClientApiVersion() {
ClientApiVersionsClient client
= new ClientApiVersionsClientBuilder().serviceVersion(ClientApiVersionsServiceVersion.V2022_10_01)
.buildClient();

client.sendApiVersion();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.utils.ArmUtils;

Expand Down Expand Up @@ -97,14 +96,16 @@ public void testError() {
}

@Test
@Disabled("Requires an unreleased azure-http-specs ARM resource identifier feature")
public void testArmResourceIdentifiers() {
final String subscriptionId = "00000000-0000-0000-0000-000000000000";
final String resourceGroup = "test-rg";
final String simpleArmId = "/subscriptions/" + subscriptionId + "/resourceGroups/" + resourceGroup
+ "/providers/Microsoft.Network/virtualNetworks/myVnet";
final String armIdWithAllScopes = "/subscriptions/" + subscriptionId + "/resourceGroups/" + resourceGroup
+ "/providers/Microsoft.Compute/virtualMachines/myVm";
final String armIdWithGroupScope
= "/providers/Microsoft.Management/serviceGroups/test-sg/providers/Microsoft.Authorization/roleDefinitions/"
+ "00000000-0000-0000-0000-000000000000";

// Create
ArmResourceIdentifierResource resource = manager.armResourceIdentifiers()
Expand All @@ -114,7 +115,8 @@ public void testArmResourceIdentifiers() {
.withProperties(new ArmResourceIdentifierResourceProperties().withSimpleArmId(simpleArmId)
.withArmIdWithType(simpleArmId)
.withArmIdWithTypeAndScope(simpleArmId)
.withArmIdWithAllScopes(armIdWithAllScopes))
.withArmIdWithAllScopes(armIdWithAllScopes)
.withArmIdWithGroupScope(armIdWithGroupScope))
.create();
Assertions.assertNotNull(resource);
Assertions.assertEquals("armId", resource.name());
Expand All @@ -124,6 +126,7 @@ public void testArmResourceIdentifiers() {
Assertions.assertEquals(simpleArmId, resource.properties().armIdWithType());
Assertions.assertEquals(simpleArmId, resource.properties().armIdWithTypeAndScope());
Assertions.assertEquals(armIdWithAllScopes, resource.properties().armIdWithAllScopes());
Assertions.assertEquals(armIdWithGroupScope, resource.properties().armIdWithGroupScope());

// Get
resource = manager.armResourceIdentifiers().getByResourceGroup(resourceGroup, "armId");
Expand All @@ -132,6 +135,9 @@ public void testArmResourceIdentifiers() {
Assertions.assertNotNull(resource.properties());
Assertions.assertEquals(ResourceProvisioningState.SUCCEEDED, resource.properties().provisioningState());
Assertions.assertEquals(simpleArmId, resource.properties().simpleArmId());
Assertions.assertEquals(simpleArmId, resource.properties().armIdWithType());
Assertions.assertEquals(simpleArmId, resource.properties().armIdWithTypeAndScope());
Assertions.assertEquals(armIdWithAllScopes, resource.properties().armIdWithAllScopes());
Assertions.assertEquals(armIdWithGroupScope, resource.properties().armIdWithGroupScope());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package azure.resourcemanager.operationtemplates;

import azure.resourcemanager.operationtemplates.fluent.models.ConfigurationInner;
import azure.resourcemanager.operationtemplates.fluent.models.WidgetInner;
import azure.resourcemanager.operationtemplates.models.ActionRequest;
import azure.resourcemanager.operationtemplates.models.ActionResult;
Expand All @@ -12,8 +13,14 @@
import azure.resourcemanager.operationtemplates.models.CheckNameAvailabilityReason;
import azure.resourcemanager.operationtemplates.models.CheckNameAvailabilityRequest;
import azure.resourcemanager.operationtemplates.models.CheckNameAvailabilityResponse;
import azure.resourcemanager.operationtemplates.models.Collection;
import azure.resourcemanager.operationtemplates.models.Configuration;
import azure.resourcemanager.operationtemplates.models.ConfigurationProperties;
import azure.resourcemanager.operationtemplates.models.DiagnosticInfo;
import azure.resourcemanager.operationtemplates.models.ExportRequest;
import azure.resourcemanager.operationtemplates.models.ExportResult;
import azure.resourcemanager.operationtemplates.models.LogStatusRequest;
import azure.resourcemanager.operationtemplates.models.MonitoredResource;
import azure.resourcemanager.operationtemplates.models.Operation;
import azure.resourcemanager.operationtemplates.models.OperationDisplay;
import azure.resourcemanager.operationtemplates.models.Order;
Expand Down Expand Up @@ -167,6 +174,64 @@ public void testExportArray() {
Assertions.assertEquals("order2,product2,2", result2.content());
}

@Test
public void testLegacyRoutedGet() {
DiagnosticInfo diagnostic = manager.legacies().routedGet("test-rg", "default", "memory");

Assertions.assertEquals("memory", diagnostic.name());
Assertions.assertEquals("healthy", diagnostic.status());
}

@Test
public void testLegacyCreateWithBody() {
Configuration configuration = manager.legacies()
.define("default")
.withRegion(Region.US_EAST)
.withExistingResourceGroup("test-rg")
.withProperties(new ConfigurationProperties().withConfigValue("custom-value"))
.create();

Assertions.assertEquals("default", configuration.name());
Assertions.assertEquals("eastus", configuration.location());
Assertions.assertEquals("custom-value", configuration.properties().configValue());
Assertions.assertEquals("Succeeded", configuration.properties().provisioningState());
}

@Test
public void testLegacyCreateWithoutBody() {
ConfigurationInner configuration
= manager.serviceClient().getLegacies().createOrReplaceOptionalBody("test-rg", "default");

Assertions.assertEquals("default", configuration.name());
Assertions.assertEquals("eastus", configuration.location());
Assertions.assertEquals("default-value", configuration.properties().configValue());
Assertions.assertEquals("Succeeded", configuration.properties().provisioningState());
}

@Test
public void testPostActionPaging() {
List<MonitoredResource> resources = manager.pagings()
.postActionPaging("test-rg", "monitor1", new LogStatusRequest().withFilter("status eq 'active'"),
Context.NONE)
.stream()
.collect(Collectors.toList());

Assertions.assertTrue(resources.get(0).id().endsWith("/virtualMachines/vm1"));
Assertions.assertTrue(resources.get(0).sendingMetrics());
}

@Test
public void testMarkAsPageable() {
List<Collection> collections
= manager.pagings().markAsPageable("test-rg", "monitor1").stream().collect(Collectors.toList());

Assertions.assertEquals(2, collections.size());
Assertions.assertEquals("collection1", collections.get(0).name());
Assertions.assertEquals("Test Collection", collections.get(0).properties().displayName());
Assertions.assertEquals("collection2", collections.get(1).name());
Assertions.assertEquals("Another Collection", collections.get(1).properties().displayName());
}

// for LRO operations, we need to override default poll interval
private static OperationTemplatesManager buildManager() {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package azure.resourcemanager.servicegroupextension;

import azure.resourcemanager.servicegroupextension.fluent.models.ServiceGroupExtensionResourceInner;
import azure.resourcemanager.servicegroupextension.models.ProvisioningState;
import azure.resourcemanager.servicegroupextension.models.ServiceGroupExtensionResource;
import azure.resourcemanager.servicegroupextension.models.ServiceGroupExtensionResourceProperties;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.utils.ArmUtils;

public class ServiceGroupExtensionTests {

private static final String SERVICE_GROUP_ID = "test-sg";
private static final String RESOURCE_NAME = "resource";
private static final String RESOURCE_TYPE = "Microsoft.ServiceGroupExtension/serviceGroupExtensionResources";

private final ServiceGroupExtensionManager manager
= ServiceGroupExtensionManager.authenticate(ArmUtils.createTestHttpPipeline(), ArmUtils.getAzureProfile());

@Test
public void testGet() {
assertResource(manager.serviceGroupExtensionResources().get(SERVICE_GROUP_ID, RESOURCE_NAME), "valid");
}

@Test
public void testCreateOrUpdate() {
ServiceGroupExtensionResource resource = manager.serviceGroupExtensionResources()
.createOrUpdate(SERVICE_GROUP_ID, RESOURCE_NAME, createResource("valid"));

assertResource(resource, "valid");
}

@Test
public void testUpdate() {
ServiceGroupExtensionResource resource = manager.serviceGroupExtensionResources()
.update(SERVICE_GROUP_ID, RESOURCE_NAME, createResource("valid2"));

assertResource(resource, "valid2");
}

@Test
public void testDelete() {
manager.serviceGroupExtensionResources().deleteByResourceGroup(SERVICE_GROUP_ID, RESOURCE_NAME);
}

@Test
public void testListByServiceGroup() {
List<ServiceGroupExtensionResource> resources = manager.serviceGroupExtensionResources()
.listByServiceGroup(SERVICE_GROUP_ID)
.stream()
.collect(Collectors.toList());

Assertions.assertEquals(1, resources.size());
assertResource(resources.get(0), "valid");
}

private static ServiceGroupExtensionResourceInner createResource(String description) {
return new ServiceGroupExtensionResourceInner()
.withProperties(new ServiceGroupExtensionResourceProperties().withDescription(description));
}

private static void assertResource(ServiceGroupExtensionResource resource, String description) {
Assertions.assertNotNull(resource);
Assertions.assertEquals(RESOURCE_NAME, resource.name());
Assertions.assertEquals(RESOURCE_TYPE, resource.type());
Assertions.assertNotNull(resource.properties());
Assertions.assertEquals(description, resource.properties().description());
Assertions.assertEquals(ProvisioningState.SUCCEEDED, resource.properties().provisioningState());
}
}
2 changes: 1 addition & 1 deletion packages/typespec-java/eng/scripts/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async function compile(typeSpecFile: string, options: string[], timeout: number)
const command = `pnpm ${arguments_.join(" ")}`;
const start = performance.now();
const result = await execa("pnpm", arguments_, {
cwd: emitterTestsRoot,
cwd: packageRoot,
reject: false,
timeout,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-java/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure-tools/typespec-java",
"version": "0.45.13",
"version": "0.46.0",
"description": "TypeSpec library for emitting Java client from the TypeSpec REST protocol binding",
"keywords": [
"TypeSpec"
Expand Down
7 changes: 7 additions & 0 deletions packages/typespec-java/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ export const EmitterOptionsSchema: JSONSchemaType<EmitterOptions> = {
// items: { type: "string" },
// nullable: true,
// },
// "remove-model": {
// type: ["string", "array"],
// description:
// "Do not generate the model classes. Format should be in array form. This option is for management-plane SDK.",
// items: { type: "string" },
// nullable: true,
// },
// "preserve-model": {
// type: ["string", "array"],
// description:
Expand Down
Loading