Skip to content

Commit

Permalink
Docs: Lifecycle Management of Counters and Lists in REST (#3560)
Browse files Browse the repository at this point in the history
* Docs: Lifecycle Management of Counters and Lists in REST

* Review changes

---------

Co-authored-by: igooch <[email protected]>
  • Loading branch information
Kalaiselvi84 and igooch authored Jan 18, 2024
1 parent 5fb9f1b commit e52f20a
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 2 deletions.
17 changes: 17 additions & 0 deletions site/content/en/docs/Guides/Client SDKs/local.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ You should see output similar to the following:
{"message":"gameserver update received","severity":"info","time":"2019-10-30T21:46:18.179459+03:00"}
```

### Enabling Feature Gates

For development and testing purposes, you might want to enable specific [features gates]({{% ref "/docs/Guides/feature-stages.md#feature-gates" %}}) in the local SDK Server.

To do this, you can either set the `FEATURE_GATES` environment variable or use the `--feature-gates` command line parameter like so, with the same format as utilised when [configuring it on a Helm install]({{< ref "/docs/Installation/Install Agones/helm.md#configuration" >}}).

For example:

```bash
./sdk-server.linux.amd64 --local --feature-gates Example=true
```
or
```bash
FEATURE_GATES=Example=true ./sdk-server.linux.amd64 --local
```

## Providing your own `GameServer` configuration for local development

By default, the local sdk-server will create a default `GameServer` configuration that is used for `GameServer()`
Expand Down Expand Up @@ -207,6 +223,7 @@ go run cmd/sdk-server/main.go --local

Commandline flags (e.g. `--local`) are exactly the same as command line flags when utilising a pre-built binary.


## Next Steps:

- Learn how to connect your local development game server binary into a running Agones Kubernetes cluster for even more live development options with an [out of cluster dev server]({{< ref "/docs/Advanced/out-of-cluster-dev-server.md" >}}).
103 changes: 101 additions & 2 deletions site/content/en/docs/Guides/Client SDKs/rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,105 @@ Apply an Annotation with the prefix "agones.dev/sdk-" to the backing `GameServer
curl -d '{"key": "foo", "value": "bar"}' -H "Content-Type: application/json" -X PUT http://localhost:${AGONES_SDK_HTTP_PORT}/metadata/annotation
```

### Counters and Lists

{{< alpha title="Counters and Lists" gate="CountsAndLists" >}}

#### Counters

In all the Counter examples, we retrieve the counter under the key `rooms` as if it was previously defined in [`GameServer.Spec.counters[room]`]({{< ref "/docs/Reference/agones_crd_api_reference.html#agones.dev/v1.GameServerSpec" >}}).

For your own Counter REST requests, replace the value `rooms` with your own key in the path.

##### Alpha: GetCounter
This function retrieves a specified counter by its key, `rooms`, and returns its information.

###### Example

```bash
curl -H "Content-Type: application/json" -X GET http://localhost:${AGONES_SDK_HTTP_PORT}/v1alpha1/counters/rooms
```

Response:
```json
{"name":"rooms", "count":"1", "capacity":"10"}
```

##### Alpha: UpdateCounter
This function updates the properties of the counter with the key `rooms`, such as its count and capacity, and returns the updated counter details.

###### Example

```bash
curl -d '{"count": "5", "capacity": "11"}' -H "Content-Type: application/json" -X PATCH http://localhost:${AGONES_SDK_HTTP_PORT}/v1alpha1/counters/rooms
```

Response:
```json
{"name":"rooms", "count":"5", "capacity":"11"}
```

#### Lists

In all the List examples, we retrieve the list under the key `players` as if it was previously defined in [`GameServer.Spec.lists[players]`]({{< ref "/docs/Reference/agones_crd_api_reference.html#agones.dev/v1.GameServerSpec" >}}).

For your own List REST based requests, replace the value `players` with your own key in the path.

##### Alpha: GetList
This function retrieves the list's properties with the key `players`, returns the list's information.

###### Example
```bash
curl -H "Content-Type: application/json" -X GET http://localhost:${AGONES_SDK_HTTP_PORT}/v1alpha1/lists/players
```

Response:
```json
{"name":"players", "capacity":"100", "values":["player0", "player1", "player2"]}
```

##### Alpha: UpdateList
This function updates the list's properties with the key `players`, such as its capacity and values, returns the updated list details. This will overwrite all existing List.Values with the update list request values. Use addValue or removeValue for modifying the List.Values field.

###### Example

```bash
curl -d '{"capacity": "120", "values": ["player3", "player4"]}' -H "Content-Type: application/json" -X PATCH http://localhost:${AGONES_SDK_HTTP_PORT}/v1alpha1/lists/players
```

Response:
```json
{"name":"players", "capacity":"120", "values":["player3", "player4"]}
```

##### Alpha: AddListValue
This function adds a new value to a list with the key `players` and returns the list with this addition.

###### Example

```bash
curl -d '{"value": "player9"}' -H "Content-Type: application/json" -X POST http://localhost:${AGONES_SDK_HTTP_PORT}/v1alpha1/lists/players:addValue
```

Response:
```json
{"name":"players", "capacity":"120", "values":["player3", "player4", "player9"]}
```

##### Alpha: RemoveListValue
This function removes a value from the list with the key `players` and returns updated list.

###### Example

```bash
curl -d '{"value": "player3"}' -H "Content-Type: application/json" -X POST http://localhost:${AGONES_SDK_HTTP_PORT}/v1alpha1/lists/players:removeValue
```

Response:
```json
{"name":"players", "capacity":"120", "values":["player4", "player9"]}
```

### Player Tracking

{{< alpha title="Player Tracking" gate="PlayerTracking" >}}
Expand Down Expand Up @@ -305,6 +404,8 @@ Response:
This function retrieves the current player count.
This is always accurate from what has been set through this SDK, even if the value has yet to be updated on the GameServer status resource.

##### Example

```bash
curl -H "Content-Type: application/json" -X GET http://localhost:${AGONES_SDK_HTTP_PORT}/alpha/player/count
```
Expand All @@ -314,8 +415,6 @@ Response:
{"count":"2"}
```

##### Example

#### Alpha: IsPlayerConnected

This function returns if the playerID is currently connected to the GameServer. This is always accurate from what has
Expand Down

0 comments on commit e52f20a

Please sign in to comment.