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 @@ -31,6 +31,12 @@ public class DeleteStateRequest {

private StateOptions stateOptions;

/**
* Constructor for DeleteStateRequest.
*
* @param storeName Name of the state store
* @param key Key present in the state store
*/
public DeleteStateRequest(String storeName, String key) {
this.stateStoreName = storeName;
this.key = key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
import java.util.List;
import java.util.Map;

/**
* A request for executing state transaction operations.
*/
public class ExecuteStateTransactionRequest {

/**
Expand All @@ -34,6 +37,11 @@ public class ExecuteStateTransactionRequest {
*/
private Map<String, String> metadata;

/**
* Constructor for ExecuteStateTransactionRequest.
*
* @param stateStoreName Name of the state store
*/
public ExecuteStateTransactionRequest(String stateStoreName) {
this.stateStoreName = stateStoreName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public class GetBulkSecretRequest {

private Map<String, String> metadata;

/**
* Constructor for GetBulkSecretRequest.
*
* @param storeName Name of the secret store
*/
public GetBulkSecretRequest(String storeName) {
this.storeName = storeName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public class GetBulkStateRequest {

private int parallelism = 1;

/**
* Constructor for GetBulkStateRequest.
*
* @param storeName Name of the state store
* @param keys keys for the state objects
*/
public GetBulkStateRequest(String storeName, List<String> keys) {
this.storeName = storeName;
this.keys = keys == null ? null : Collections.unmodifiableList(keys);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public class GetConfigurationRequest {
private final List<String> keys;
private Map<String, String> metadata;

/**
* Constructor for GetConfigurationRequest.
*
* @param storeName Name of the configuration store
* @param keys Keys for the configuration objects
*/
public GetConfigurationRequest(String storeName, List<String> keys) {
this.storeName = storeName;
this.keys = keys == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(keys);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public class GetSecretRequest {

private final String key;

/**
* Constructor for GetSecretRequest.
*
* @param storeName Name of the Secret Store
* @param key Key for retrieving the secret
*/
public GetSecretRequest(String storeName, String key) {
this.storeName = storeName;
this.key = key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public class GetStateRequest {

private StateOptions stateOptions;

/**
* Constructor for GetStateRequest.
*
* @param storeName Name of the state store
* @param key Key of the state object
*/
public GetStateRequest(String storeName, String key) {
this.storeName = storeName;
this.key = key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public class InvokeBindingRequest {

private Map<String, String> metadata;

/**
* Constructor for InvokeBindingRequest.
*
* @param bindingName Name of the binding
* @param operation Name of the binding operation
*/
public InvokeBindingRequest(String bindingName, String operation) {
this.name = bindingName;
this.operation = operation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public class InvokeMethodRequest {

private String contentType;

/**
* Constructor for InvokeMethodRequest.
*
* @param appId ID of the Dapr application
* @param method Name of the method to be invoked
*/
public InvokeMethodRequest(String appId, String method) {
this.appId = appId;
this.method = method;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public class SaveStateRequest {

private List<State<?>> states;

/**
* Constructor for SaveStateRequest.
*
* @param storeName Name of the state store
*/
public SaveStateRequest(String storeName) {
this.storeName = storeName;
}
Expand Down
9 changes: 9 additions & 0 deletions sdk/src/main/java/io/dapr/client/domain/StateOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
import java.util.Map;
import java.util.Optional;

/**
* A class representing the state options for Dapr state API.
*/
public class StateOptions {
private final Consistency consistency;
private final Concurrency concurrency;
Expand Down Expand Up @@ -70,6 +73,9 @@ public Map<String, String> getStateOptionsAsMap() {
return Collections.unmodifiableMap(Optional.ofNullable(mapOptions).orElse(Collections.EMPTY_MAP));
}

/**
* Options for Consistency.
*/
public enum Consistency {
EVENTUAL("eventual"),
STRONG("strong");
Expand All @@ -91,6 +97,9 @@ public static Consistency fromValue(String value) {
}
}

/**
* Options for Concurrency.
*/
public enum Concurrency {
FIRST_WRITE("first-write"),
LAST_WRITE("last-write");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public class SubscribeConfigurationRequest {
private final List<String> keys;
private Map<String, String> metadata;

/**
* Constructor for SubscribeConfigurationRequest.
*
* @param storeName Name of the configuration store
* @param keys Keys of the configurations values to subscribe to
*/
public SubscribeConfigurationRequest(String storeName, List<String> keys) {
this.storeName = storeName;
this.keys = keys == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(keys);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

import java.util.Objects;

/**
* Class to represent transactional state operations.
* @param <T> Type of the state value
*/
public class TransactionalStateOperation<T> {

/**
Expand Down Expand Up @@ -73,6 +77,9 @@ public String toString() {
+ '}';
}

/**
* Options for type of operation.
*/
public enum OperationType {
@JsonProperty("upsert") UPSERT,
@JsonProperty("delete") DELETE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
import java.util.List;
import java.util.Map;

/**
* A class to represent request for transactional state.
* @param <T> Type of state value in TransactionalStateOperation
*/
public class TransactionalStateRequest<T> {

/**
Expand Down
11 changes: 11 additions & 0 deletions sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@


import io.dapr.client.domain.ConfigurationItem;
import io.dapr.client.domain.GetConfigurationRequest;
import io.dapr.client.domain.SubscribeConfigurationRequest;
import io.dapr.serializer.DefaultObjectSerializer;
import io.dapr.v1.CommonProtos;
import io.dapr.v1.DaprGrpc;
Expand Down Expand Up @@ -73,6 +75,10 @@ public void getConfigurationTestErrorScenario() {
assertThrows(IllegalArgumentException.class, () -> {
previewClient.getConfiguration("", "key").block();
});
GetConfigurationRequest req = new GetConfigurationRequest(CONFIG_STORE_NAME, null);
assertThrows(IllegalArgumentException.class, () -> {
previewClient.getConfiguration(req).block();
});
}

@Test
Expand Down Expand Up @@ -223,6 +229,11 @@ public void subscribeConfigurationWithErrorTest() {
assertThrows(IllegalArgumentException.class, () -> {
previewClient.subscribeToConfiguration("", "key").blockFirst();
});

SubscribeConfigurationRequest req = new SubscribeConfigurationRequest(CONFIG_STORE_NAME, null);
assertThrows(IllegalArgumentException.class, () -> {
previewClient.subscribeToConfiguration(req).blockFirst();
});
}

private DaprProtos.GetConfigurationResponse getSingleMockResponse() {
Expand Down