observer
+ ) {
+ this.stub.updateCounter(
+ Alpha.UpdateCounterRequest
+ .newBuilder()
+ .setCounter(counter)
+ .setUpdateMask(updateMask)
+ .build(),
+ observer
+ );
+ }
+
+ /**
+ * returns the updated list. returns NOT_FOUND if the list does not exist (name cannot be updated).
+ *
+ * **THIS WILL OVERWRITE ALL EXISTING LIST.VALUES WITH ANY REQUEST LIST.VALUES**
+ *
+ * use addListValue() or removeListValue() for modifying the List.Values field.
+ * returns INVALID_ARGUMENT if the field mask path(s) are not field(s) of the list.
+ *
+ * @param observer the observer to update.
+ */
+ public void updateList(
+ @NotNull final Alpha.List list,
+ @NotNull final FieldMask updateMask,
+ @NotNull final StreamObserver observer
+ ) {
+ this.stub.updateList(
+ Alpha.UpdateListRequest
+ .newBuilder()
+ .setList(list)
+ .setUpdateMask(updateMask)
+ .build(),
+ observer
+ );
+ }
}
diff --git a/src/main/java/tr/com/infumia/agones4j/AgonesSdk.java b/src/main/java/tr/com/infumia/agones4j/AgonesSdk.java
index 7bf4234..850257a 100644
--- a/src/main/java/tr/com/infumia/agones4j/AgonesSdk.java
+++ b/src/main/java/tr/com/infumia/agones4j/AgonesSdk.java
@@ -47,6 +47,18 @@ public final class AgonesSdk implements Terminable {
@NotNull
SDKGrpc.SDKStub stub;
+ /**
+ * ctor.
+ *
+ * @param channel the channel.
+ */
+ public AgonesSdk(@NotNull final ManagedChannel channel) {
+ this.channel = channel;
+ this.stub = SDKGrpc.newStub(this.channel);
+ this.alpha = new AgonesAlphaSdk(this.channel);
+ this.beta = new AgonesBetaSdk(this.channel);
+ }
+
/**
* ctor.
*
@@ -54,14 +66,12 @@ public final class AgonesSdk implements Terminable {
* @param grpcPort the grpc port.
*/
public AgonesSdk(@NotNull final String grpcHost, final int grpcPort) {
- this.channel =
+ this(
ManagedChannelBuilder
.forAddress(grpcHost, grpcPort)
.usePlaintext()
- .build();
- this.stub = SDKGrpc.newStub(this.channel);
- this.alpha = new AgonesAlphaSdk(this.channel);
- this.beta = new AgonesBetaSdk(this.channel);
+ .build()
+ );
}
/**
diff --git a/src/main/proto/sdk/alpha/alpha.proto b/src/main/proto/sdk/alpha/alpha.proto
index e774b9d..d255923 100644
--- a/src/main/proto/sdk/alpha/alpha.proto
+++ b/src/main/proto/sdk/alpha/alpha.proto
@@ -18,6 +18,11 @@ package agones.dev.sdk.alpha;
option go_package = "./alpha";
import "google/api/annotations.proto";
+import "google/api/client.proto";
+import "google/api/field_behavior.proto";
+import "google/api/resource.proto";
+import "google/protobuf/empty.proto";
+import "google/protobuf/field_mask.proto";
import "grpc-gateway/protoc-gen-openapiv2/options/annotations.proto";
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
@@ -122,6 +127,68 @@ service SDK {
get: "/alpha/player/connected"
};
}
+
+ // Gets a Counter. Returns NOT_FOUND if the Counter does not exist.
+ rpc GetCounter(GetCounterRequest) returns (Counter) {
+ option (google.api.http) = {
+ get: "/v1alpha1/{name=counters/*}"
+ };
+ option (google.api.method_signature) = "name";
+ }
+
+ // UpdateCounter returns the updated Counter. Returns NOT_FOUND if the Counter does not exist (name cannot be updated).
+ // Returns OUT_OF_RANGE if the Count is out of range [0,Capacity].
+ // Returns INVALID_ARGUMENT if the field mask path(s) are not field(s) of the Counter.
+ // If a field mask path(s) is specified, but the value is not set in the request Counter object,
+ // then the default value for the variable will be set (i.e. 0 for "capacity" or "count").
+ rpc UpdateCounter(UpdateCounterRequest) returns (Counter) {
+ option (google.api.http) = {
+ patch: "/v1alpha1/{counter.name=counters/*}"
+ body: "counter"
+ };
+ option (google.api.method_signature) = "counter,update_mask";
+ }
+
+ // Gets a List. Returns NOT_FOUND if the List does not exist.
+ rpc GetList(GetListRequest) returns (List) {
+ option (google.api.http) = {
+ get: "/v1alpha1/{name=lists/*}"
+ };
+ option (google.api.method_signature) = "name";
+ }
+
+ // UpdateList returns the updated List. Returns NOT_FOUND if the List does not exist (name cannot be updated).
+ // **THIS WILL OVERWRITE ALL EXISTING LIST.VALUES WITH ANY REQUEST LIST.VALUES**
+ // Use AddListValue() or RemoveListValue() for modifying the List.Values field.
+ // Returns INVALID_ARGUMENT if the field mask path(s) are not field(s) of the List.
+ // If a field mask path(s) is specified, but the value is not set in the request List object,
+ // then the default value for the variable will be set (i.e. 0 for "capacity", empty list for "values").
+ rpc UpdateList(UpdateListRequest) returns (List) {
+ option (google.api.http) = {
+ patch: "/v1alpha1/{list.name=lists/*}"
+ body: "list"
+ };
+ option (google.api.method_signature) = "list,update_mask";
+ }
+
+ // Adds a value to a List and returns updated List. Returns NOT_FOUND if the List does not exist.
+ // Returns ALREADY_EXISTS if the value is already in the List.
+ // Returns OUT_OF_RANGE if the List is already at Capacity.
+ rpc AddListValue(AddListValueRequest) returns (List) {
+ option (google.api.http) = {
+ post: "/v1alpha1/{name=lists/*}:addValue"
+ body: "*"
+ };
+ }
+
+ // Removes a value from a List and returns updated List. Returns NOT_FOUND if the List does not exist.
+ // Returns NOT_FOUND if the value is not in the List.
+ rpc RemoveListValue(RemoveListValueRequest) returns (List) {
+ option (google.api.http) = {
+ post: "/v1alpha1/{name=lists/*}:removeValue"
+ body: "*"
+ };
+ }
}
// I am Empty
@@ -146,4 +213,100 @@ message PlayerID {
// List of Player IDs
message PlayerIDList {
repeated string list = 1;
-}
\ No newline at end of file
+}
+
+// A representation of a Counter.
+message Counter {
+ option (google.api.resource) = {
+ type: "agones.dev/Counter"
+ pattern: "counters/{counter}"
+ };
+ // The name of the Counter
+ string name = 1;
+ // The current count of the Counter
+ int64 count = 2;
+ // The maximum capacity of the Counter
+ int64 capacity = 3;
+}
+
+message GetCounterRequest {
+ // The name of the Counter to get
+ string name = 1 [
+ (google.api.field_behavior) = REQUIRED,
+ (google.api.resource_reference) = {
+ type: "agones.dev/Counter"
+ }];
+}
+
+message UpdateCounterRequest {
+ // The Counter to update
+ Counter counter = 1 [
+ (google.api.field_behavior) = REQUIRED,
+ (google.api.resource_reference) = {
+ type: "agones.dev/Counter"
+ }];
+
+ // Required. Mask (list) of fields to update.
+ // Fields are specified relative to the Counter
+ // (e.g. `count`, `capacity`; *not* `Counter.count` or `Counter.capacity`).
+ google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
+}
+
+// A representation of a List.
+message List {
+ option (google.api.resource) = {
+ type: "agones.dev/List"
+ pattern: "lists/{list}"
+ };
+ // The name of the List
+ string name = 1;
+ // The maximum capacity of the List
+ int64 capacity = 2;
+ // The array of items in the List ["v1", "v2", …]
+ repeated string values = 3;
+}
+
+message GetListRequest {
+ // The name of the List to get
+ string name = 1 [
+ (google.api.field_behavior) = REQUIRED,
+ (google.api.resource_reference) = {
+ type: "agones.dev/List"
+ }];
+}
+
+message UpdateListRequest {
+ // The List to update
+ List list = 1 [
+ (google.api.field_behavior) = REQUIRED,
+ (google.api.resource_reference) = {
+ type: "agones.dev/List"
+ }];
+
+ // Required. Mask (list) of fields to update.
+ // Fields are specified relative to the List
+ // (e.g. `capacity`, `values`; *not* `List.capacity` or `List.values`).
+ google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
+}
+
+message AddListValueRequest {
+ // The name of the List to add a value to.
+ string name = 1 [
+ (google.api.field_behavior) = REQUIRED,
+ (google.api.resource_reference) = {
+ type: "agones.dev/List"
+ }];
+
+ string value = 2 [(google.api.field_behavior) = REQUIRED];
+}
+
+message RemoveListValueRequest {
+ // The name of the List to remove a value from.
+ string name = 1 [
+ (google.api.field_behavior) = REQUIRED,
+ (google.api.resource_reference) = {
+ type: "agones.dev/List"
+ }];
+
+ string value = 2 [(google.api.field_behavior) = REQUIRED];
+}
diff --git a/src/main/proto/sdk/sdk.proto b/src/main/proto/sdk/sdk.proto
index aa5bb9e..df5b499 100644
--- a/src/main/proto/sdk/sdk.proto
+++ b/src/main/proto/sdk/sdk.proto
@@ -162,6 +162,20 @@ message GameServer {
repeated string ids = 3;
}
+ // [Stage:Alpha]
+ // [FeatureFlag:CountsAndLists]
+ message CounterStatus {
+ int64 count = 1;
+ int64 capacity = 2;
+ }
+
+ // [Stage:Alpha]
+ // [FeatureFlag:CountsAndLists]
+ message ListStatus {
+ int64 capacity = 1;
+ repeated string values = 2;
+ }
+
string state = 1;
string address = 2;
repeated Port ports = 3;
@@ -169,5 +183,13 @@ message GameServer {
// [Stage:Alpha]
// [FeatureFlag:PlayerTracking]
PlayerStatus players = 4;
+
+ // [Stage:Alpha]
+ // [FeatureFlag:CountsAndLists]
+ map counters = 5;
+
+ // [Stage:Alpha]
+ // [FeatureFlag:CountsAndLists]
+ map lists = 6;
}
}