Skip to content
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 @@ -467,11 +467,6 @@ public static CosmosAsyncPermission createCosmosAsyncPermission(String id, Cosmo
return new CosmosAsyncPermission(id, user);
}

@Warning(value = INTERNAL_USE_ONLY_WARNING)
public static CosmosAsyncStoredProcedure createCosmosAsyncStoredProcedure(String id, CosmosAsyncContainer cosmosContainer) {
return new CosmosAsyncStoredProcedure(id, cosmosContainer);
}

@Warning(value = INTERNAL_USE_ONLY_WARNING)
public static CosmosAsyncTrigger createCosmosAsyncTrigger(String id, CosmosAsyncContainer container) {
return new CosmosAsyncTrigger(id, container);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.azure.cosmos.implementation.StoredProcedure;
import com.azure.cosmos.implementation.Trigger;
import com.azure.cosmos.implementation.UserDefinedFunction;
import com.azure.cosmos.models.CosmosAsyncStoredProcedureResponse;
import com.azure.cosmos.models.CosmosStoredProcedureResponse;
import com.azure.cosmos.models.CosmosAsyncTriggerResponse;
import com.azure.cosmos.models.CosmosAsyncUserDefinedFunctionResponse;
import com.azure.cosmos.models.CosmosStoredProcedureProperties;
Expand Down Expand Up @@ -46,7 +46,7 @@ public class CosmosAsyncScripts {
* @param properties the cosmos stored procedure properties.
* @return an {@link Mono} containing the single cosmos stored procedure resource response or an error.
*/
public Mono<CosmosAsyncStoredProcedureResponse> createStoredProcedure(CosmosStoredProcedureProperties properties) {
public Mono<CosmosStoredProcedureResponse> createStoredProcedure(CosmosStoredProcedureProperties properties) {
return this.createStoredProcedure(properties, new CosmosStoredProcedureRequestOptions());
}

Expand All @@ -62,7 +62,7 @@ public Mono<CosmosAsyncStoredProcedureResponse> createStoredProcedure(CosmosStor
* @param options the stored procedure request options.
* @return an {@link Mono} containing the single cosmos stored procedure resource response or an error.
*/
public Mono<CosmosAsyncStoredProcedureResponse> createStoredProcedure(
public Mono<CosmosStoredProcedureResponse> createStoredProcedure(
CosmosStoredProcedureProperties properties,
CosmosStoredProcedureRequestOptions options) {
if (options == null) {
Expand All @@ -73,7 +73,7 @@ public Mono<CosmosAsyncStoredProcedureResponse> createStoredProcedure(
sProc.setBody(properties.getBody());
return database.getDocClientWrapper()
.createStoredProcedure(container.getLink(), sProc, ModelBridgeInternal.toRequestOptions(options))
.map(response -> ModelBridgeInternal.createCosmosAsyncStoredProcedureResponse(response, this.container))
.map(response -> ModelBridgeInternal.createCosmosStoredProcedureResponse(response))
.single();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import com.azure.cosmos.implementation.Paths;
import com.azure.cosmos.implementation.StoredProcedure;
import com.azure.cosmos.models.CosmosAsyncStoredProcedureResponse;
import com.azure.cosmos.models.CosmosStoredProcedureResponse;
import com.azure.cosmos.models.CosmosStoredProcedureProperties;
import com.azure.cosmos.models.CosmosStoredProcedureRequestOptions;
import com.azure.cosmos.models.ModelBridgeInternal;
Expand Down Expand Up @@ -56,7 +56,7 @@ CosmosAsyncStoredProcedure setId(String id) {
*
* @return an {@link Mono} containing the single resource response with the read stored procedure or an error.
*/
public Mono<CosmosAsyncStoredProcedureResponse> read() {
public Mono<CosmosStoredProcedureResponse> read() {
return read(null);
}

Expand All @@ -71,13 +71,13 @@ public Mono<CosmosAsyncStoredProcedureResponse> read() {
* @param options the request options.
* @return an {@link Mono} containing the single resource response with the read stored procedure or an error.
*/
public Mono<CosmosAsyncStoredProcedureResponse> read(CosmosStoredProcedureRequestOptions options) {
public Mono<CosmosStoredProcedureResponse> read(CosmosStoredProcedureRequestOptions options) {
if (options == null) {
options = new CosmosStoredProcedureRequestOptions();
}
return cosmosContainer.getDatabase().getDocClientWrapper().readStoredProcedure(getLink(),
ModelBridgeInternal.toRequestOptions(options))
.map(response -> ModelBridgeInternal.createCosmosAsyncStoredProcedureResponse(response, cosmosContainer)).single();
.map(response -> ModelBridgeInternal.createCosmosStoredProcedureResponse(response)).single();
}

/**
Expand All @@ -90,7 +90,7 @@ public Mono<CosmosAsyncStoredProcedureResponse> read(CosmosStoredProcedureReques
*
* @return an {@link Mono} containing the single resource response for the deleted stored procedure or an error.
*/
public Mono<CosmosAsyncStoredProcedureResponse> delete() {
public Mono<CosmosStoredProcedureResponse> delete() {
return delete(null);
}

Expand All @@ -105,14 +105,14 @@ public Mono<CosmosAsyncStoredProcedureResponse> delete() {
* @param options the request options.
* @return an {@link Mono} containing the single resource response for the deleted stored procedure or an error.
*/
public Mono<CosmosAsyncStoredProcedureResponse> delete(CosmosStoredProcedureRequestOptions options) {
public Mono<CosmosStoredProcedureResponse> delete(CosmosStoredProcedureRequestOptions options) {
if (options == null) {
options = new CosmosStoredProcedureRequestOptions();
}
return cosmosContainer.getDatabase()
.getDocClientWrapper()
.deleteStoredProcedure(getLink(), ModelBridgeInternal.toRequestOptions(options))
.map(response -> ModelBridgeInternal.createCosmosAsyncStoredProcedureResponse(response, cosmosContainer))
.map(response -> ModelBridgeInternal.createCosmosStoredProcedureResponse(response))
.single();
}

Expand All @@ -128,15 +128,15 @@ public Mono<CosmosAsyncStoredProcedureResponse> delete(CosmosStoredProcedureRequ
* @param options the request options.
* @return an {@link Mono} containing the single resource response with the stored procedure response or an error.
*/
public Mono<CosmosAsyncStoredProcedureResponse> execute(List<Object> procedureParams,
CosmosStoredProcedureRequestOptions options) {
public Mono<CosmosStoredProcedureResponse> execute(List<Object> procedureParams,
CosmosStoredProcedureRequestOptions options) {
if (options == null) {
options = new CosmosStoredProcedureRequestOptions();
}
return cosmosContainer.getDatabase()
.getDocClientWrapper()
.executeStoredProcedure(getLink(), ModelBridgeInternal.toRequestOptions(options), procedureParams)
.map(response -> ModelBridgeInternal.createCosmosAsyncStoredProcedureResponse(response, cosmosContainer, this.id))
.map(response -> ModelBridgeInternal.createCosmosStoredProcedureResponse(response))
.single();
}

Expand All @@ -151,7 +151,7 @@ public Mono<CosmosAsyncStoredProcedureResponse> execute(List<Object> procedurePa
* @param storedProcedureSettings the stored procedure properties
* @return an {@link Mono} containing the single resource response with the replaced stored procedure or an error.
*/
public Mono<CosmosAsyncStoredProcedureResponse> replace(CosmosStoredProcedureProperties storedProcedureSettings) {
public Mono<CosmosStoredProcedureResponse> replace(CosmosStoredProcedureProperties storedProcedureSettings) {
return replace(storedProcedureSettings, null);
}

Expand All @@ -167,8 +167,8 @@ public Mono<CosmosAsyncStoredProcedureResponse> replace(CosmosStoredProcedurePro
* @param options the request options.
* @return an {@link Mono} containing the single resource response with the replaced stored procedure or an error.
*/
public Mono<CosmosAsyncStoredProcedureResponse> replace(CosmosStoredProcedureProperties storedProcedureSettings,
CosmosStoredProcedureRequestOptions options) {
public Mono<CosmosStoredProcedureResponse> replace(CosmosStoredProcedureProperties storedProcedureSettings,
CosmosStoredProcedureRequestOptions options) {
if (options == null) {
options = new CosmosStoredProcedureRequestOptions();
}
Expand All @@ -177,7 +177,7 @@ public Mono<CosmosAsyncStoredProcedureResponse> replace(CosmosStoredProcedurePro
.replaceStoredProcedure(new StoredProcedure(ModelBridgeInternal.toJsonFromJsonSerializable(
ModelBridgeInternal.getResource(storedProcedureSettings))),
ModelBridgeInternal.toRequestOptions(options))
.map(response -> ModelBridgeInternal.createCosmosAsyncStoredProcedureResponse(response, cosmosContainer))
.map(response -> ModelBridgeInternal.createCosmosStoredProcedureResponse(response))
.single();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@

package com.azure.cosmos;

import com.azure.cosmos.models.CosmosAsyncStoredProcedureResponse;
import com.azure.cosmos.models.CosmosStoredProcedureResponse;
import com.azure.cosmos.models.CosmosAsyncTriggerResponse;
import com.azure.cosmos.models.CosmosAsyncUserDefinedFunctionResponse;
import com.azure.cosmos.models.CosmosStoredProcedureProperties;
import com.azure.cosmos.models.CosmosStoredProcedureRequestOptions;
import com.azure.cosmos.models.CosmosStoredProcedureResponse;
import com.azure.cosmos.models.CosmosTriggerProperties;
import com.azure.cosmos.models.CosmosTriggerResponse;
import com.azure.cosmos.models.CosmosUserDefinedFunctionProperties;
Expand Down Expand Up @@ -243,11 +242,9 @@ public CosmosTrigger getTrigger(String id) {
* @return the cosmos sync stored procedure response
*/
CosmosStoredProcedureResponse mapStoredProcedureResponseAndBlock(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why isn't this needed anymore? in the absence of this method does the code throw the valid type of exception (if any failure)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will still throw the valid exception type. That was just wrapping the exception to CosmosException, which is what originally gets thrown by async APIs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have tests to validate that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted the change in the latest iteration to make sure we are consistent with exceptions across the SDK. Thanks for bringing this up.

Will also add tests to check the exception type.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In another follow up PR.

Mono<CosmosAsyncStoredProcedureResponse> storedProcedureResponseMono) {
Mono<CosmosStoredProcedureResponse> storedProcedureResponseMono) {
try {
return storedProcedureResponseMono
.map(this::convertResponse)
.block();
return storedProcedureResponseMono.block();
} catch (Exception ex) {
final Throwable throwable = Exceptions.unwrap(ex);
if (throwable instanceof CosmosException) {
Expand All @@ -258,20 +255,6 @@ CosmosStoredProcedureResponse mapStoredProcedureResponseAndBlock(
}
}

/**
* Convert response cosmos sync stored procedure response.
*
* @param response the response
* @return the cosmos sync stored procedure response
*/
CosmosStoredProcedureResponse convertResponse(CosmosAsyncStoredProcedureResponse response) {
if (response.getStoredProcedure() != null) {
return ModelBridgeInternal.createCosmosStoredProcedureResponse(response, getStoredProcedure(response.getStoredProcedure().getId()));
} else {
return ModelBridgeInternal.createCosmosStoredProcedureResponse(response, null);
}
}

/**
* Map udf response and block cosmos sync user defined function response.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

package com.azure.cosmos;

import com.azure.cosmos.models.CosmosStoredProcedureResponse;
import com.azure.cosmos.models.CosmosStoredProcedureProperties;
import com.azure.cosmos.models.CosmosStoredProcedureRequestOptions;
import com.azure.cosmos.models.CosmosStoredProcedureResponse;

import java.util.List;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class CosmosResponse<T> {
this.properties = properties;
}

// Only used in CosmosAsyncStoredProcedureResponse compatibility with StoredProcedureResponse
// Only used in CosmosStoredProcedureResponse compatibility with StoredProcedureResponse
CosmosResponse(StoredProcedureResponse response) {
this.resourceResponseWrapper = null;
}
Expand Down
Loading