diff --git a/docusaurus/video/docusaurus/docs/api/_common_/call-types-overview.mdx b/docusaurus/video/docusaurus/docs/api/_common_/call-types-overview.mdx index ac9f217b..f2fccde6 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/call-types-overview.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/call-types-overview.mdx @@ -3,6 +3,7 @@ Call types provide sensible default settings for different use-cases. We provide - **Default** (`default`) for 1:1 or group calls that use both video and audio - **Livestreaming** (`livestream`) to build ultra low latency livestreaming for your app on our global edge network. Broadcast from your phone or RTMP and scale to millions of participants. - **Audio room** (`audio_room`) to build audio experiences for your app. You can build basic calling or feature rich experience like Twitter spaces. Audio quality, reliability and scalability is far ahead of competing solutions. +- **Development** (`development`) This call type comes with almost all permission settings disabled so that it is simpler to get your initial implementation up and running. You should only use this call type early-on during development. Each of our [SDKs have tutorials specific for each call type](https://getstream.io/video/sdk/). If you want to know the default settings for each of the call types check out the [Built-in call types page](/api/call_types/builtin). diff --git a/docusaurus/video/docusaurus/docs/api/_common_/create-call.mdx b/docusaurus/video/docusaurus/docs/api/_common_/create-call.mdx index b8a5d7bc..ef28a34b 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/create-call.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/create-call.mdx @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem'; You can create a call by providing the call type and an ID: - The [call type](/api/call_types/builtin) controls which features are enabled and sets up permissions. Call type settings and permissions can be set from API, or using the [Stream Dashboard](https://dashboard.getstream.io/). -- Calls IDs can be reused, which means they can be joined multiple times, so it's possible to set up recurring calls. +- Calls can be used once or multiple times depending on your app. Unless you want to re-use the same call multiple times, the recommended way to pick a call ID is to use a uuid v4 so that each call gets a unique random ID. You can specify call members who can receive push notification about the call. @@ -69,20 +69,30 @@ call.create( ```go -members := []MemberRequest{ - {UserID: "john", Role: PtrTo("admin")}, - {UserID: "jack"}, - } - callRequest := GetOrCreateCallRequest{ - Data: &CallRequest{ - CreatedByID: PtrTo("sacha"), - Members: &members, - Custom: &map[string]any{ - "color": "blue", - }, - }, - } -_, err := call.GetOrCreate(ctx, &callRequest) + +import ( + "github.com/GetStream/getstream-go" + "github.com/google/uuid" +) + +call := client.Video().Call("default", uuid.NewString()) + +members := []getstream.MemberRequest{ + {UserID: "john", Role: getstream.PtrTo("admin")}, + {UserID: "jack"}, +} + +callRequest := getstream.GetOrCreateCallRequest{ + Data: &getstream.CallRequest{ + CreatedByID: getstream.PtrTo("sacha"), + Members: members, + Custom: map[string]any{ + "color": "blue", + }, + }, +} + +response, err := call.GetOrCreate(ctx, &callRequest) ``` diff --git a/docusaurus/video/docusaurus/docs/api/_common_/deactivate-reactivate.mdx b/docusaurus/video/docusaurus/docs/api/_common_/deactivate-reactivate.mdx index 6cb63088..98d3b2df 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/deactivate-reactivate.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/deactivate-reactivate.mdx @@ -10,12 +10,12 @@ client.deactivateUser({ user_id: '', }); -//reactivate +// reactivate client.reactivateUsers({ user_ids: [''], }); -// deactivativating users in bulk can take some time +// deactivating users in bulk is performed asynchronously const deactivateResponse = client.deactivateUsers({ user_ids: ['', ''...], }); @@ -31,7 +31,7 @@ client.deactivate_user(user_id=alice.id) # reactivates the user client.reactivate_user(user_id=alice.id) -# deactivates users in bulk, this is an async operation +# deactivating users in bulk is performed asynchronously response = client.deactivate_users(user_ids=[alice.id, bob.id]) ``` @@ -41,13 +41,15 @@ response = client.deactivate_users(user_ids=[alice.id, bob.id]) ```go // deactivate one user -client.DeactivateUser(ctx, alice.ID, &DeactivateUserRequest{}) +response, err := client.DeactivateUser(ctx, "alice", &getstream.DeactivateUserRequest{}) // reactivates the user -client.ReactivateUser(ctx, alice.ID, &ReactivateUserRequest{}) +_, err = client.ReactivateUser(ctx, "alice", &getstream.ReactivateUserRequest{}) // deactivates users in bulk, this is an async operation -response = client.DeactivateUsers(ctx, &DeactivateUsersRequest{UserIDs: []string{alice.ID, bob.ID}}) +_, err = client.DeactivateUsers(ctx, &getstream.DeactivateUsersRequest{ + UserIds: []string{"alice", "bob"}, +}) ``` @@ -81,4 +83,4 @@ Deactivating users in bulk can take some time, this is how you can check the pro -For more informiation, please refer to the [async operations guide](/api/misc/async) +For more information, please refer to the [async operations guide](/api/misc/async) diff --git a/docusaurus/video/docusaurus/docs/api/_common_/delete-users.mdx b/docusaurus/video/docusaurus/docs/api/_common_/delete-users.mdx index 9c71dc68..f4af5ffc 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/delete-users.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/delete-users.mdx @@ -2,20 +2,6 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import AsyncTasks from '../_common_/async-tasks.mdx'; -Deleting a user means: - -- the user can't connect to Stream API -- their data won't appear in user queries - -Delete has the following opitions: - -| Name | Type | Description | Optional | -| ---------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -| `user` | Enum (soft, pruning, hard) | - Soft: marks user as deleted and retains all user data.
- Pruning: marks user as deleted and nullifies user information.
- Hard: deletes user completely - this requires hard option for messages and conversation as well. | Yes | -| `conversations` | Enum (soft, hard) | - Soft: marks all conversation channels as deleted (same effect as Delete Channels with 'hard' option disabled).
- Hard: deletes channel and all its data completely including messages (same effect as Delete Channels with 'hard' option enabled). | Yes | -| `messages` | Enum (soft, pruning, hard) | - Soft: marks all user messages as deleted without removing any related message data.
- Pruning: marks all user messages as deleted, nullifies message information and removes some message data such as reactions and flags.
- Hard: deletes messages completely with all related information. | Yes | -| `new_channel_owner_id` | string | Channels owned by hard-deleted users will be transferred to this userID. If you doesn't provide a value, the channel owner will have a system generated ID like `delete-user-8219f6578a7395g` | Yes | -| `calls` | Enum (soft, hard) | - Soft: marks calls and related data as deleted.
- Hard: deletes calls and related data completely
Note that this applies only to 1:1 calls, not group calls | Yes | @@ -43,10 +29,10 @@ client.restore_users(user_ids=[""]) ```go -client.DeleteUsers(ctx, &DeleteUsersRequest{UserIDs: []string{""}}) +response, err := client.DeleteUsers(ctx, &getstream.DeleteUsersRequest{UserIds: []string{""}}) -# restore -client.RestoreUsers(ctx, &RestoreUsersRequest{UserIDs: []string{""}}) +// restore a soft-deleted user +_, err = client.RestoreUsers(ctx, &getstream.RestoreUsersRequest{UserIds: []string{""}}) ``` @@ -75,8 +61,18 @@ curl -X POST https://video.stream-io-api.com/api/v2/users/restore?api_key=${API_ +The delete users endpoints supports the following parameters to control which data needs to be deleted and how. By default users and their data are soft-deleted. + +| Name | Type | Description | Optional | +| ---------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | +| `user` | Enum (soft, pruning, hard) | - Soft: marks user as deleted and retains all user data.
- Pruning: marks user as deleted and nullifies user information.
- Hard: deletes user completely - this requires hard option for messages and conversation as well. | Yes | +| `conversations` | Enum (soft, hard) | - Soft: marks all conversation channels as deleted (same effect as Delete Channels with 'hard' option disabled).
- Hard: deletes channel and all its data completely including messages (same effect as Delete Channels with 'hard' option enabled). | Yes | +| `messages` | Enum (soft, pruning, hard) | - Soft: marks all user messages as deleted without removing any related message data.
- Pruning: marks all user messages as deleted, nullifies message information and removes some message data such as reactions and flags.
- Hard: deletes messages completely with all related information. | Yes | +| `new_channel_owner_id` | string | Channels owned by hard-deleted users will be transferred to this userID. If you doesn't provide a value, the channel owner will have a system generated ID like `delete-user-8219f6578a7395g` | Yes | +| `calls` | Enum (soft, hard) | - Soft: marks calls and related data as deleted.
- Hard: deletes calls and related data completely
Note that this applies only to 1:1 calls, not group calls | Yes | + Deleting and restoring users in bulk can take some time, this is how you can check the progress: -For more informiation, please refer to the [async operations guide](/api/misc/async) +For more information, please refer to the [async operations guide](/api/misc/async) diff --git a/docusaurus/video/docusaurus/docs/api/_common_/manage-call-members.mdx b/docusaurus/video/docusaurus/docs/api/_common_/manage-call-members.mdx index b570e34a..8cb5964f 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/manage-call-members.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/manage-call-members.mdx @@ -1,9 +1,13 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -You can provide a list of call members. Call members need to be existing users. Every call member has a call-level role, [you can configure roles](/api/call_types/permissions/) on the call type. +You can provide a list of call members, this can be done when you create a call or later on when the call already exists. Please note that call members need to be existing users. -Call members can receive [push notifications](/api/call_types/settings/#push-notifications-settings). +There are two reasons to use call members: + +- Call membership allows you to have more flexibility when it comes to permissions. The permission system allows you to grant different permissions to users and members, this way one user can be a member on one call or a member on another. +Membership also allows you to specify a role for user in a call. You can more information about the roles and permissions [here](/api/call_types/permissions/). +- Call members will receive [push notifications](/api/call_types/settings/#push-notifications-settings). @@ -35,13 +39,13 @@ call.update_call_members( ```go -// Call members need to be existing users +// Call members need to be existing users (use `client.UpdateUsers` for that) // You can also update the role of existing members -call.UpdateCallMembers(ctx, &UpdateCallMembersRequest{ - UpdateMembers: &[]MemberRequest{ - {UserID: "sara"}, - {UserID: "emily", Role: PtrTo("admin")}, - }, +response, err := call.UpdateCallMembers(ctx, &getstream.UpdateCallMembersRequest{ + UpdateMembers: []getstream.MemberRequest{ + {UserID: "sara"}, + {UserID: "emily", Role: getstream.PtrTo("admin")}, + }, }) ``` @@ -80,7 +84,18 @@ call.updateCallMembers({ ```py -call.update_call_members(remove_members=["jack", "sara"]) +call.update_call_members(remove_members=["sara"]) +``` + + + + +```go +response, err := call.UpdateCallMembers(ctx, &getstream.UpdateCallMembersRequest{ + RemoveMembers: []string{ + "sara", + }, +}) ``` diff --git a/docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx b/docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx index e17ef577..1e20c612 100644 --- a/docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx +++ b/docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx @@ -41,18 +41,18 @@ call.update( ```go // update some custom data for this call -call.Update(ctx, &UpdateCallRequest{ - Custom: &map[string]interface{}{"color": "red"}, +response, err := call.Update(ctx, &getstream.UpdateCallRequest{ + Custom: map[string]any{"color": "red"}, }) // update settings for this call -call.Update(ctx, &UpdateCallRequest{ - SettingsOverride: &CallSettingsRequest{ - Screensharing: &ScreensharingSettingsRequest{ - Enabled: PtrTo(true), - AccessRequestEnabled: PtrTo(true), +response, err = call.Update(ctx, &getstream.UpdateCallRequest{ + SettingsOverride: &getstream.CallSettingsRequest{ + Screensharing: &getstream.ScreensharingSettingsRequest{ + Enabled: getstream.PtrTo(true), + AccessRequestEnabled: getstream.PtrTo(true), + }, }, - }, }) ``` diff --git a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx index b2261558..7a53996e 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/authentication.mdx @@ -12,18 +12,18 @@ import DeleteUsers from '../_common_/delete-users.mdx'; ## Creating users -Stream Users require only an ID to be created. Users can be created with the role of user or admin. The role will be set to user if a value is not provided in the request. There are additional properties you can provide to further describe your users. - -The `name` and `image` fields are special fields that are supported by client-side SDKs. - -You can provide additional data for the user object using the `custom` field. +When creating users, there are a few important things to keep in mind: +- The `id` field is mandatory, in most cases you want this to be the same ID you use on your database. +- The `role` field is optional, by default it is set to `user` but you can specify any existing role. +- Custom data can be added to users in the `custom` field. +- `name` and `image` are optional and handled by all SDKs automatically to render users. ```js const newUser: UserRequest = { - id: 'userid', + id: 'user-id', role: 'user', custom: { color: 'red', @@ -55,19 +55,19 @@ client.upsert_users( ```go -client.UpdateUsers(ctx, &UpdateUsersRequest{ - Users: map[string]UserRequest{ - "user_id": { - Role: PtrTo("user"), - Custom: &map[string]interface{}{ - "color": "red", - }, - Name: PtrTo("This is a test user"), - Image: PtrTo("link/to/profile/image"), - }, - }, +response, err := client.UpdateUsers(ctx, &getstream.UpdateUsersRequest{ + Users: map[string]getstream.UserRequest{ + "user_id": { + ID: "user_id", + Role: getstream.PtrTo("admin"), + Custom: map[string]interface{}{ + "color": "red", + }, + Name: getstream.PtrTo("This is a test user"), + Image: getstream.PtrTo("link/to/profile/image"), + }, + }, }) - ``` @@ -93,36 +93,15 @@ curl -X POST https://video.stream-io-api.com/api/v2/users?api_key=${API_KEY} \ }' ``` - - - -```js -const userId = 'john'; -const newUser: UserRequest = { - id: userId, - role: 'user', - custom: { - color: 'red', - }, - name: 'John', - image: 'link/to/profile/image', -}; -await client.upsertUsers({ - users: { - [newUser.id]: newUser, - }, -}); -``` - ## Updating users -There are two ways to update user objects: +You can update users in two ways: -- Updating will replace the existing user object -- Partial update will let you choose which fields you want to change/unset +- Replace updates: replace the entire user object with the one provided to the API call +- Partial update: choose which fields you want to change @@ -132,7 +111,7 @@ const user: UserRequest = { id: 'userid', role: 'user', custom: { - color: 'red', + color: 'blue', }, name: 'This is a test user', image: 'link/to/profile/image', @@ -145,7 +124,7 @@ client.updateUsersPartial({ { id: user.id, set: { - color: 'blue', + 'new-field': 'value', }, unset: ['name'], }, @@ -161,7 +140,7 @@ client.upsert_users(UserRequest( id= 'userid', role= 'user', custom= { - "color": 'red', + "color": 'blue', }, name= 'This is a test user', image= 'link/to/profile/image', @@ -173,7 +152,7 @@ client.update_users_partial( UpdateUserPartialRequest( id="userid", set={ - "color": "blue", + "new-field": "value", }, unset=["name"], ) @@ -185,30 +164,31 @@ client.update_users_partial( ```go -client.UpdateUsers(ctx, &UpdateUsersRequest{ - Users: map[string]UserRequest{ - "user_id": { - Role: PtrTo("user"), - Custom: &map[string]interface{}{ - "color": "red", - }, - Name: PtrTo("This is a test user"), - Image: PtrTo("link/to/profile/image"), +response, err := client.UpdateUsers(ctx, &getstream.UpdateUsersRequest{ + Users: map[string]getstream.UserRequest{ + "user_id": { + ID: "user_id", + Role: getstream.PtrTo("user"), + Custom: map[string]any{ + "color": "blue", + }, + Name: getstream.PtrTo("This is a test user"), + Image: getstream.PtrTo("link/to/profile/image"), + }, }, - }, }) // or -client.UpdateUsersPartial(ctx, &UpdateUsersPartialRequest{ - Users: []UpdateUserPartialRequest{ - { - ID: "user_id", - Set: &map[string]interface{}{ - "color": "blue", - }, - Unset: &[]string{"name"}, +response, err = client.UpdateUsersPartial(ctx, &getstream.UpdateUsersPartialRequest{ + Users: []getstream.UpdateUserPartialRequest{ + { + ID: "user_id", + Set: map[string]interface{}{ + "new-field": "value", + }, + Unset: []string{"name"}, + }, }, - }, }) ``` @@ -253,39 +233,6 @@ curl -X PATCH https://video.stream-io-api.com/api/v2/users?api_key=${API_KEY} \ }' ``` - - - -```js -const user: UserRequest = { - id: 'userid', - role: 'user', - custom: { - color: 'red', - }, - name: 'This is a test user', - image: 'link/to/profile/image', -}; -client.upsertUsers({ - users: { - [user.id]: user, - }, -}); - -// or -client.updateUsersPartial({ - users: [ - { - id: user.id, - set: { - color: 'blue', - }, - unset: ['name'], - }, - ], -}); -``` - @@ -299,31 +246,43 @@ Guest users are temporary user accounts. You can use it to temporarily give some ## Deactivating and deleting users -While it is usually safer for data retention to deactivate a user, some use cases require completely deleting a user and their data. +Depending on your use-case, you can choose to delete users or de-activating them. There are some differences between these two approach. + +Deactivating users: -Deactivating a user means: +- the user will not be allowed to perform API requests / connect +- user data is retained on Stream's side and returned from API +- deactivated users can be re-activated -- the user can't connect to Stream API -- their data will be retained -- a deactivated user can be reactivated +Deleting users: +- the user will no longer be able to perform API requests / connect +- the user is deleted and by default not returned from API +- all data from the user is marked as deleted +- by default the data is retained and "soft" deleted, you can optionally request hard deletion +- deletion is not reversible + +Note: Both deletion and deactivation are performed asynchronously by Stream API. A task ID is returned and you can use that to check the status of its processing. + +### Deactivating users +### Deleting users ## User tokens -Stream uses JWT (JSON Web Tokens) to authenticate chat users, enabling them to log in. Knowing whether a user is authorized to perform certain actions is managed separately via a role-based permissions system. Tokens need to be generated server-side. +Stream uses JWT (JSON Web Tokens) to authenticate users, enabling them to log in. Knowing whether a user is authorized to perform certain actions is managed separately via a role-based permissions system. Tokens need to be generated server-side. -You can optionally provide an expiration time. By default, tokens are valid for 1 hour. +You can optionally provide an expiration time. ```js const userId = 'john'; -// validity is optional (by default the token is valid for an hour) -const validity = 60 * 60; +// validity is optional, in this case we set it to 1 day +const validity = 24 * 60 * 60; client.generateUserToken({ user_id: userId, validity_in_seconds: validity }); ``` @@ -343,8 +302,8 @@ def create_user_token(request): # The 'user_id' is retrieved from the request's user instance. user_id = request.user.id - # the token will be valid for 1 hour - exp = 3600 + # the token will be valid for 1 day + exp = 24 * 3600 # Here client is Stream client and it's called with the 'user_id' and the expiration time. token = client.create_token(user_id, expiration=exp) @@ -355,7 +314,14 @@ def create_user_token(request): ``` + + +```go +// the token will be valid for 1 day +token, err := client.CreateToken("user-id", getstream.WithExpiration(24*time.Hour)) +``` + ```bash @@ -370,16 +336,6 @@ SIGNATURE=$(echo -n ${HEADER}.${PAYLOAD} | openssl dgst -sha256 -hmac ${SECRET} echo "${HEADER}.${PAYLOAD}.${SIGNATURE}" ``` - - - -```js -const userId = 'john'; -// exp is optional (by default the token is valid for an hour) -const exp = Math.round(new Date().getTime() / 1000) + 60 * 60; -client.createToken(userId, exp); -``` - @@ -389,8 +345,6 @@ You need to provide the generated tokens to the client SDKs. Stream SDKs accept Call tokens contain a list of call IDs. When a user utilizes a call token, they will automatically be assigned the membership role for all the calls specified in the token’s claims. Additionally, the token may optionally include alternative roles, such as admin or moderator. -> **Note:** Call tokens are designed to grant additional access, not restrict it. Most call types let regular users join calls. If all users can access any call, call tokens won't change this. Remove call access from the user role and grant it to specific members instead. - @@ -425,17 +379,13 @@ client.create_call_token(user_id=user_id, expiration=exp, call_cids=call_cids) ```go -userID := "john" - -// exp and iat are optional, token will be valid for 1 hour -exp := time.Now().Add(1 * time.Hour) - -callCIDs := []string{"default:call1", "livestream:call2"} +// the list of call IDs this token applies to +tokenClaims := getstream.Claims{CallCIDs: []string{"default:call1", "livestream:call2"}} -client.CreateToken(userID, &StreamJWTClaims{ - Expire: &exp, - CallCIDs: callCIDs, -}) +token, err := client.CreateToken("john", + getstream.WithClaims(tokenClaims), + getstream.WithExpiration(24*time.Hour), +) ``` @@ -458,21 +408,7 @@ SIGNATURE=$(echo -n ${HEADER}.${PAYLOAD} | openssl dgst -sha256 -hmac ${SECRET} echo "${HEADER}.${PAYLOAD}.${SIGNATURE}" ``` - - - -```js -const userId = 'john'; -// exp is optional (by default the token is valid for an hour) -const exp = Math.round(new Date().getTime() / 1000) + 60 * 60; - -const call_cids = ['default:call1', 'livestream:call2']; - -client.createCallToken(userId, call_cids, exp); - -// Optionally provide a role for the call(s) -client.createCallToken({ user_id: userId, role: 'admin' }, call_cids); -``` - + +> **Note:** Call tokens are designed to grant additional access, not restrict it. Most call types let regular users join calls. If all users can access any call, call tokens won't change this. Remove call access from the user role and grant it to specific members instead. diff --git a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx index ed840d37..fa9f7942 100644 --- a/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx +++ b/docusaurus/video/docusaurus/docs/api/basics/get_started.mdx @@ -27,23 +27,22 @@ You can reference our [development roadmap](https://github.com/GetStream/protoco All official SDKs are available on package managers, full source code is available on the GetStream Github organization. - + ```bash -npm install @stream-io/node-sdk -// or using yarn -yarn add @stream-io/node-sdk +pip install getstream ``` - + ```bash -pip install getstream +npm install @stream-io/node-sdk +// or using yarn +yarn add @stream-io/node-sdk ``` - ```bash @@ -53,10 +52,11 @@ go get github.com/GetStream/getstream-go -Something doesn't work? You can open a GitHub issue: +The source code of our SDKs is available on Github. If you find issues with any SDK you can also create an issue on Github directly: - [Python SDK](https://github.com/GetStream/stream-py) - [Node SDK](https://github.com/GetStream/stream-node) +- [Golang SDK](https://github.com/GetStream/getstream-go) ## Creating client @@ -65,6 +65,15 @@ To create a server-side client, you'll need your **API key** and **secret**. Bot You can optionally pass a timeout for the API requests, the default timeout is 3000ms. + + +```py +from getstream import Stream + +client = Stream(api_key="your_api_key", api_secret="your_api_secret", timeout=3.0) +``` + + ```js @@ -82,12 +91,16 @@ client = new StreamClient(apiKey, secret, { timeout: 3000 }); ``` - + -```py -from getstream import Stream +```go +import "github.com/GetStream/getstream-go" -client = Stream(api_key="your_api_key", api_secret="your_api_secret", timeout=3.0) +client, err := getstream.NewClient( + apiKey, + apiSecret, + getstream.WithTimeout(10_000*time.Millisecond), +) ``` @@ -109,17 +122,6 @@ curl -X GET "https://video.stream-io-api.com/api/v2/app?api_key=${API_KEY}" \ -H "stream-auth-type: jwt" ``` - - - -```go -client, err := stream.NewClient(apiKey, apiSecret) -if err != nil { - fmt.Printf("Error initializing client: %v\n", err) - return -} -``` - @@ -173,21 +175,20 @@ client.create_token(user_id="tommaso-id", expiration=3600) ```go -_, err := client.UpdateUsers(ctx, &UpdateUsersRequest{ - Users: map[string]UserRequest{ - userID: { - ID: "tommaso-id", - Teams: &[]string{"red", "blue"}, - Name: PtrTo("tommaso"), - Role: PtrTo("admin"), - Custom: &map[string]any{"country": "NL"}, - }, - }, - }) - -// the token will be valid for 1 hour -oneHourTime := time.Now().Add(1 * time.Hour) -client.CreateToken("tommaso-id", &StreamJWTClaims{Expire: &oneHourTime}) +// optional values are passed as pointers, you can use `getstream.PtrTo` +// to get pointers from literals of any type +response, err := client.UpdateUsers(ctx, &getstream.UpdateUsersRequest{ + Users: map[string]getstream.UserRequest{ + "user-id": { + ID: "user-id", + Name: getstream.PtrTo("tommaso"), + Custom: map[string]any{"country": "NL"}, + }, + }, +}) + +// create a user token valid for 24 hours +token, err := client.CreateToken("tommaso-id", getstream.WithExpiration(24*time.Hour)) ``` @@ -214,32 +215,6 @@ curl -X POST https://video.stream-io-api.com/api/v2/users?api_key=${API_KEY} \ }' ``` - - - -```js -const userId = 'john'; -const newUser: UserRequest = { - id: userId, - role: 'user', - custom: { - color: 'red', - }, - name: 'John', - image: 'link/to/profile/image', -}; -await client.upsertUsers({ - users: { - [newUser.id]: newUser, - }, -}); - -// exp is optional (by default the token is valid for an hour) -const exp = Math.round(new Date().getTime() / 1000) + 60 * 60; - -client.createToken(userId, exp); -``` -