Skip to content

[http-client-java] mgmt, fix delete rename #7629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 16, 2025
Merged
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
Expand Up @@ -3,6 +3,7 @@

package com.microsoft.typespec.http.client.generator.mgmt.model.clientmodel;

import com.microsoft.typespec.http.client.generator.core.extension.model.codemodel.RequestParameterLocation;
import com.microsoft.typespec.http.client.generator.core.extension.plugin.JavaSettings;
import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ClassType;
import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ClientMethod;
Expand Down Expand Up @@ -103,7 +104,11 @@ public FluentResourceCollection(MethodGroupClient groupClient) {
if (WellKnownMethodName.DELETE.getMethodName().equals(methodName)
&& (methodType == ClientMethodType.SimpleSync || methodType == ClientMethodType.LongRunningSync)
&& !existingMethodNames.contains(WellKnownMethodName.DELETE_BY_RESOURCE_GROUP.getMethodName())
&& methodParameters.size() == 2
// TODO(xiaofei) in mgmt on core-v2, also rename 2 params + Context method:
// https://github.com/Azure/azure-sdk-for-java/issues/45687
&& methodParameters.stream()
.filter(param -> param.getRequestParameterLocation() != RequestParameterLocation.HEADER)
.count() == 2
&& methodParameters.get(0).getClientType() == ClassType.STRING
&& methodParameters.get(1).getClientType() == ClassType.STRING) {
// Transform "delete(String, String)" into "deleteByResourceGroup(String, String)"
Expand All @@ -115,7 +120,9 @@ public FluentResourceCollection(MethodGroupClient groupClient) {
&& methodType == ClientMethodType.SimpleSyncRestResponse
&& !existingMethodNames.contains(
WellKnownMethodName.DELETE_BY_RESOURCE_GROUP.getMethodName() + Utils.METHOD_POSTFIX_WITH_RESPONSE)
&& methodParameters.size() == 3
&& methodParameters.stream()
.filter(param -> param.getRequestParameterLocation() != RequestParameterLocation.HEADER)
.count() == 3
&& methodParameters.get(0).getClientType() == ClassType.STRING
&& methodParameters.get(1).getClientType() == ClassType.STRING) {
// Transform "deleteWithResponse(String, String, ?)" into "deleteByResourceGroupWithResponse(String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.http.rest.Response;
import com.azure.core.management.polling.PollResult;
import com.azure.core.util.Context;
import com.azure.core.util.polling.SyncPoller;
import tsptest.armresourceprovider.fluent.models.ManagedMaintenanceWindowStatusInner;

/**
Expand Down Expand Up @@ -43,4 +45,63 @@ Response<ManagedMaintenanceWindowStatusInner> getByResourceGroupWithResponse(Str
@ServiceMethod(returns = ReturnType.SINGLE)
ManagedMaintenanceWindowStatusInner getByResourceGroup(String resourceGroupName,
String managedMaintenanceWindowStatusContentName);

/**
* Delete a ManagedMaintenanceWindowStatusContent.
*
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param managedMaintenanceWindowStatusContentName The name of the ManagedMaintenanceWindowStatusContent.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link SyncPoller} for polling of long-running operation.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
SyncPoller<PollResult<Void>, Void> beginDelete(String resourceGroupName,
String managedMaintenanceWindowStatusContentName);

/**
* Delete a ManagedMaintenanceWindowStatusContent.
*
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param managedMaintenanceWindowStatusContentName The name of the ManagedMaintenanceWindowStatusContent.
* @param ifMatch The request should only proceed if an entity matches this string.
* @param ifNoneMatch The request should only proceed if no entity matches this string.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link SyncPoller} for polling of long-running operation.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
SyncPoller<PollResult<Void>, Void> beginDelete(String resourceGroupName,
String managedMaintenanceWindowStatusContentName, String ifMatch, String ifNoneMatch, Context context);

/**
* Delete a ManagedMaintenanceWindowStatusContent.
*
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param managedMaintenanceWindowStatusContentName The name of the ManagedMaintenanceWindowStatusContent.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
void delete(String resourceGroupName, String managedMaintenanceWindowStatusContentName);

/**
* Delete a ManagedMaintenanceWindowStatusContent.
*
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param managedMaintenanceWindowStatusContentName The name of the ManagedMaintenanceWindowStatusContent.
* @param ifMatch The request should only proceed if an entity matches this string.
* @param ifNoneMatch The request should only proceed if no entity matches this string.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
void delete(String resourceGroupName, String managedMaintenanceWindowStatusContentName, String ifMatch,
String ifNoneMatch, Context context);
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,33 @@ Response<ModelInterfaceSameNameInner> getByResourceGroupWithResponse(String reso
*/
@ServiceMethod(returns = ReturnType.SINGLE)
ModelInterfaceSameNameInner getByResourceGroup(String resourceGroupName, String modelInterfaceDifferentNameName);

/**
* Delete a ModelInterfaceDifferentName.
*
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param modelInterfaceDifferentNameName The name of the ModelInterfaceDifferentName.
* @param ifMatch The request should only proceed if an entity matches this string.
* @param ifNoneMatch The request should only proceed if no entity matches this string.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
Response<Void> deleteWithResponse(String resourceGroupName, String modelInterfaceDifferentNameName, String ifMatch,
String ifNoneMatch, Context context);

/**
* Delete a ModelInterfaceDifferentName.
*
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param modelInterfaceDifferentNameName The name of the ModelInterfaceDifferentName.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
void delete(String resourceGroupName, String modelInterfaceDifferentNameName);
}
Loading
Loading