Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
175d7eb
regenerate, remove some broken code
vagruchi Dec 9, 2024
fbcd646
refactor: everything new
vagruchi Jan 22, 2025
3c1a4ca
fix: remove commit lint
vagruchi Jan 22, 2025
8fc4ff1
fix: formatting
vagruchi Jan 22, 2025
b9bedcb
chore: ci update
vagruchi Jan 22, 2025
f7f7100
update gradle commands
vagruchi Jan 22, 2025
c36fac2
update java
vagruchi Jan 22, 2025
fe89353
fix: format
vagruchi Jan 22, 2025
0c25558
refactor initialisation
vagruchi Jan 24, 2025
0b45a7c
fix
vagruchi Jan 24, 2025
3fb5cba
better msg
vagruchi Jan 24, 2025
d5ad0e5
generate token only once
vagruchi Jan 24, 2025
d725c31
change env names
vagruchi Jan 24, 2025
1a1740f
lint
vagruchi Jan 24, 2025
130fa86
fix tests
vagruchi Jan 27, 2025
ac261d7
format
vagruchi Jan 27, 2025
1a50bc7
better null handler
vagruchi Jan 27, 2025
a3c6ee2
regenerate
vagruchi Jan 27, 2025
f004458
remove gradle setting
vagruchi Jan 27, 2025
070a9f0
update ci settings
vagruchi Jan 27, 2025
200efe5
wip
vagruchi Jan 27, 2025
11bcd2d
use vars
vagruchi Jan 27, 2025
9b16336
api key debug
vagruchi Jan 27, 2025
4054a83
format
vagruchi Jan 27, 2025
57e8b2e
set environment
vagruchi Jan 27, 2025
366d3dd
remove debug prints
vagruchi Jan 27, 2025
ca1034f
info
vagruchi Jan 27, 2025
acf96a6
remove test cleanup
vagruchi Jan 27, 2025
529c503
disable update app tests
vagruchi Jan 27, 2025
8ebd80a
disable doctest
vagruchi Jan 27, 2025
44c9bb7
Update readme
vagruchi Jan 27, 2025
e4fe678
update readme
vagruchi Jan 27, 2025
6501e15
Merge branch 'main' into regen-from-master
vagruchi Jan 27, 2025
b6a0891
remove retrofit
vagruchi Feb 3, 2025
1e2554a
helpers
vagruchi Feb 3, 2025
2d42483
fix template
vagruchi Feb 4, 2025
1894a04
fix token generation. reshape client
vagruchi Feb 4, 2025
4fd5831
update structure and doc tests
vagruchi Feb 4, 2025
329e87c
fix formatting
vagruchi Feb 4, 2025
3651188
test passing locally
vagruchi Feb 4, 2025
e45f66e
not null for secondary methods
vagruchi Feb 4, 2025
d84f0af
generate comment
vagruchi Feb 10, 2025
b5a3058
use master generator
vagruchi Feb 12, 2025
46e429a
disable all call type related tests
vagruchi Feb 12, 2025
b96bc70
disable teardown
vagruchi Feb 12, 2025
cda0fd4
apply
vagruchi Feb 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 17 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,31 @@ concurrency:
jobs:
ci:
name: 🧪 Test & lint
environment: ci
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Commit message lint
uses: wagoid/commitlint-github-action@v4
# - name: Commit message lint
# uses: wagoid/commitlint-github-action@v4

- name: Setup JDK 17
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '17'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Test
env:
STREAM_KEY: ${{ secrets.STREAM_KEY }}
STREAM_SECRET: ${{ secrets.STREAM_SECRET }}
STREAM_BASE_URL: ${{ vars.STREAM_BASE_URL }}
STREAM_API_KEY: ${{ vars.STREAM_API_KEY }}
STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }}
run: |
./gradlew spotlessCheck --no-daemon
./gradlew jacocoTestReport --no-daemon
./gradlew build --info --no-daemon
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_SECRET_KEY_RING_FILE'"
./gradlew publishReleasePublicationToSonatypeRepository --no-daemon --max-workers 1 closeAndReleaseSonatypeStagingRepository
env:
STREAM_KEY: ${{ secrets.STREAM_KEY }}
STREAM_SECRET: ${{ secrets.STREAM_SECRET }}
STREAM_API_KEY: ${{ vars.STREAM_API_KEY }}
STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }}
GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scheduled_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:

- name: Run tests
env:
STREAM_KEY: ${{ secrets.STREAM_KEY }}
STREAM_SECRET: ${{ secrets.STREAM_SECRET }}
STREAM_API_KEY: ${{ vars.STREAM_API_KEY }}
STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }}
run: |
# Retry 3 times because tests can be flaky
for _ in 1 2 3;
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ gradle-app.setting
.classpath

## project specific
/local.properties
/local.properties

.idea
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

16 changes: 0 additions & 16 deletions .idea/compiler.xml

This file was deleted.

20 changes: 0 additions & 20 deletions .idea/jarRepositories.xml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/misc.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/modules.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules/lib/stream-sdk-java.lib.main.iml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules/lib/stream-sdk-java.lib.test.iml

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ They are data objects. They correspond to the formats of the API responses.

### Service interfaces

They are Retrofit service interfaces, that describe the API endpoints.
They are the interfaces that define the API endpoints.

### The StreamServiceGenerator class

Expand Down
145 changes: 64 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,119 +14,102 @@ Check out our:

## Installation

To install the Stream Client Library, run the following command:

```sh
pip install getstream
```gradle
dependencies {
implementation "io.getstream:stream-sdk-java:$stream_version"
}
```

## Usage
## ✨ Getting started

To get started, you need to import the `Stream` class from the library and create a new instance with your API key and secret:
### Configuration

```python
from getstream import Stream
To configure the SDK you need to provide required properties.

client = Stream(api_key="your_api_key", api_secret="your_api_secret")
```
| Property | ENV | Default | Required |
| ---------------------- |--------------------|------------------------------| -------- |
| io.getstream.apiKey | STREAM_API_KEY | - | Yes |
| io.getstream.apiSecret | STREAM_API_SECRET | - | Yes |
| io.getstream.timeout | STREAM_API_TIMEOUT | 10000 | No |

### Users and Authentication

```python
from getstream.models import UserRequest

# sync two users using the update_users method, both users will get insert or updated
client.upsert_users(
UserRequest(
id="tommaso-id", name="tommaso", role="admin", custom={"country": "NL"}
),
UserRequest(
id="thierry-id", name="thierry", role="admin", custom={"country": "US"}
),
)

# Create a JWT token for the user to connect client-side (e.g. browser/mobile app)
token = client.create_token("tommaso-id")
```java
import io.getstream.models.UserRequest;

// sync two users using the UpdateUsers method, both users will get inserted or updated
List<UserRequest> userRequests =
List.of(
UserRequest.builder()
.id("tommaso-id")
.name("tommaso")
.role("admin")
.custom(Map.of("country", "NL"))
.build(),
UserRequest.builder()
.id("thierry-id")
.name("thierry")
.custom(Map.of("country", "US"))
.build());

UpdateUsersRequest updateUsersRequest =
UpdateUsersRequest.builder()
.users(userRequests.stream().collect(Collectors.toMap(UserRequest::getId, x -> x)))
.build();

client.common().UpdateUsers(updateUsersRequest).request();

// Create a JWT token for the user to connect client-side (e.g. browser/mobile app)
// token expires in 24 hours
String token = createToken(userId, 24*60*60);
```

### Video API - Calls

To create a video call, use the `client.video.call` method:

```python
import uuid
from getstream.models import (
CallRequest,
MemberRequest,
)

call = client.video.call("default", uuid.uuid4())
call.get_or_create(
data=CallRequest(
created_by_id="tommaso-id",
members=[
MemberRequest(user_id="thierry-id"),
MemberRequest(user_id="tommaso-id"),
],
),
)
```

### App configuration

```python
# Video: update settings for a call type

# Chat: update settings for a channel type
// Token does not expire
String token = createToken(userId);
```

### Video API - Calls

### Chat API - Channels

To work with chat sessions, use the `client.chat` object and implement the desired chat methods in the `Chat` class:

```python
chat_instance = client.chat
To create a video call, use the `client.video.call` method:

# TODO: implement and call chat-related methods with chat_instance
```java
var testCall = new Call("default", UUID.randomUUID().toString());

// create call if it doesn't exist or get the existing one
call.getOrCreate(
GetOrCreateCallRequest.builder()
.data(
CallRequest.builder()
.createdByID("sacha")
.members(members)
.custom(Map.of("color", "blue"))
.build())
.build());
```

## Development

We use poetry to manage dependencies and run tests. It's a package manager for Python that allows you to declare the libraries your project depends on and manage them.
To install the development dependencies, run the following command:
To run tests, create the `local.properties` file using the `local.properties.example` and adjust it to have valid API credentials:

```sh
poetry install
pre-commit install
cp local.properties.example local.properties
```

To activate the virtual environment, run the following command:

```sh
poetry shell
```
Then run the tests:

To run tests, create a `.env` using the `.env.example` and adjust it to have valid API credentials
```sh
poetry run pytest tests/ getstream/
./gradlew test
```

Before pushing changes make sure to have git hooks installed correctly, so that you get linting done locally `pre-commit install`

You can also run the code formatting yourself if needed:
Format the code:

```sh
poetry run ruff format getstream/ tests/
./gradlew spotlessApply
```

### Writing new tests

pytest is used to run tests and to inject fixtures, simple tests can be written as simple python functions making assert calls. Make sure to have a look at the available test fixtures under `tests/fixtures.py`

### Generate code from spec

To regenerate the Python source from OpenAPI, just run the `./generate.sh` script from this repo.
To regenerate the Java source from OpenAPI, just run the `./generate.sh` script from this repo.

> [!NOTE]
> Code generation currently relies on tooling that is not publicly available, only Stream devs can regenerate SDK source code from the OpenAPI spec.
Expand Down
2 changes: 1 addition & 1 deletion generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ set -ex
# format generated code
./gradlew spotlessApply

./gradlew build
./gradlew build -x test
Loading