App Context API for Go SDK
This page describes App Context (formerly Objects v2). To upgrade from Objects v1, refer to the migration guide.
App Context provides easy-to-use, serverless storage for user and channel data you need to build innovative, reliable, scalable applications. Use App Context to store metadata about your application users and channels, and their membership associations, without the need to stand up your own databases.
PubNub also triggers events when object data is changed: set, updated, or removed from the database. Making a request to set the same data that already exists doesn't trigger an event. Clients can receive these events in real time and update their front-end application accordingly.
User
Get metadata for all users
Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each.
Method(s)
To Get All UUID Metadata you can use the following method(s) in the Go SDK:
1pn.GetAllUUIDMetadata().
2 Include([]pubnub.PNUUIDMetadataIncludeCustom).
3 Sort(sort).
4 Limit(int).
5 Count(bool).
6 Start(string).
7 End(string).
8 Filter(string).
9 Execute()
| Parameter | Description |
|---|---|
IncludeType: []pubnub.PNUUIDMetadataInclude | List of additional/complex UUID attributes to include in response. Omit this parameter if you don't want to retrieve additional attributes. Available values: pubnub.PNUUIDMetadataIncludeCustom |
SortType: Array | Sort by id, name, updated with asc/desc for sort direction (for example, {name: 'asc'}). |
LimitType: int | Number of objects to return. Default/Max: 100. |
CountType: bool | Whether to include the total count in the paginated response. Default is false. |
StartType: string | Cursor-based pagination. |
EndType: string | Cursor-based pagination. |
FilterType: string | Filter expression. Only matching objects are returned. See filtering. |
Sample code
Reference code
1
Response
The GetAllUUIDMetadata() operation returns a PNGetAllChannelMetadataResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | []PNUUID | Details of type PNUUID are here |
TotalCount | int | Total count of objects without pagination. |
Next | string | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
Prev | string | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the Next parameter is supplied. |
Get user metadata
Returns metadata for the specified UUID, optionally including the custom data object for each.
Method(s)
To Get UUID Metadata you can use the following method(s) in the Go SDK:
1pn.PNUUIDMetadataInclude().
2 Include([]pubnub.PNUUIDMetadataIncludeCustom).
3 Sort(sort).
4 ID(string).
5 Execute()
| Parameter | Description |
|---|---|
IncludeType: []pubnub.PNUUIDMetadataIncludeCustom | List of additional/complex UUID attributes to include in response. Omit this parameter if you don't want to retrieve additional attributes. Available values pubnub.PNUUIDMetadataIncludeCustom |
SortType: Array | Sort by id, name, updated with asc/desc for sort direction (for example, {name: 'asc'}). |
ID *Type: string | UUID. If not supplied, the current user's UUID is used. |
Sample code
1
Response
The GetUUIDMetadata() operation returns a PNGetUUIDMetadataResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | PNUUID | Details of type PNUUID are here |
Set user metadata
Unsupported partial updates of custom metadata
The value of the custom metadata parameter sent in this method always overwrites the value stored on PubNub servers. If you want to add new custom data to an existing one, you must:
- Get the existing metadata and store it locally.
- Append the new custom metadata to the existing one.
- Set the entire updated custom object.
Set metadata for a UUID in the database, optionally including the custom data object for each.
Method(s)
To Set UUID Metadata you can use the following method(s) in the Go SDK:
1pn.SetUUIDMetadata().
2 Include([]pubnub.PNUUIDMetadataIncludeCustom).
3 Sort(sort).
4 ID(id).
5 Name(string).
6 ExternalID(string).
7 ProfileURL(string).
8 Email(string).
9 Custom(map[string]interface{}).
10 IfMatchETag(string).
11 Execute()
| Parameter | Description |
|---|---|
IncludeType: []pubnub.PNUUIDMetadataInclude | List of additional/complex UUID attributes to include in response. Omit this parameter if you don't want to retrieve additional attributes. Available values: pubnub.PNUUIDMetadataIncludeCustom |
ID *Type: string | Unique user identifier. If not supplied then current user's uuid is used. |
SortType: Array | Sort by id, name, updated with asc/desc for sort direction (for example, {name: 'asc'}). |
Name *Type: string | Display name for the user. |
ExternalIDType: string | User's identifier in an external system |
ProfileURLType: string | The URL of the user's profile picture |
EmailType: string | The user's email address. |
CustomType: map[string]interface{} | Custom JSON values. Can be strings, numbers, or booleans. Filtering by Custom isn't supported. |
IfMatchETagType: string | The entity tag to be used to ensure updates only happen if the object hasn't been modified since it was read. Use the eTag you received from an applicable get metadata method to check against the server entity tag. If the eTags don't match, an HTTP 412 error is thrown. |
API limits
To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.
Sample code
1
Response
The SetUUIDMetadata() operation returns a PNSetUUIDMetadataResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | PNUUID | Details of type PNUUID are here |
PNUUID
| Property Name | Type | Description |
|---|---|---|
ID | string | Unique user identifier. If not supplied then current user's uuid is used. |
Name | string | Display name for the user. |
ExternalID | string | User's identifier in an external system |
ProfileURL | string | The URL of the user's profile picture |
Email | string | The user's email address. |
Custom | map[string]interface | Custom JSON values. Can be strings, numbers, or booleans. |
Updated | string | Last updated date. |
ETag | string | The ETag. |
Status | string | User status. Max. 50 characters. |
Type | string | User type. Max. 50 characters. |
Remove user metadata
Removes the metadata from a specified UUID.
Method(s)
To Remove UUID Metadata you can use the following method(s) in the Go SDK:
1pn.RemoveUUIDMetadata().
2 ID(string).
3 Execute()
| Parameter | Description |
|---|---|
ID *Type: string | Unique user identifier. If not supplied then current user's uuid is used. |
Sample code
1
Response
The RemoveUUIDMetadata() operation returns a PNRemoveUUIDMetadataResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | interface | Returns an empty interface. |
Channel
Get metadata for all channels
Returns a paginated list of Channel Metadata objects, optionally including the custom data object for each.
Method(s)
To Get All Channel Metadata you can use the following method(s) in the Go SDK:
1pn.GetAllChannelMetadata().
2 Include([]pubnub.PNChannelMetadataInclude).
3 Sort(sort).
4 Limit(int).
5 Count(bool).
6 Start(string).
7 End(string).
8 Filter(string).
9 Execute()
| Parameter | Description |
|---|---|
IncludeType: []pubnub.PNChannelMetadataInclude | List of additional/complex space attributes to include in response. Omit this parameter if you don't want to retrieve additional attributes. Available values pubnub.PNChannelMetadataIncludeCustom |
SortType: Array | Sort by id, name, updated with asc/desc for sort direction (for example, {name: 'asc'}). |
LimitType: int | Number of objects to return. Default/Max: 100. |
CountType: bool | Whether to include the total count in the paginated response. Default is false. |
StartType: string | Cursor-based pagination. |
EndType: string | Cursor-based pagination. |
FilterType: string | Filter expression. Only matching objects are returned. See filtering. |
Sample code
1
Response
The GetAllChannelMetadata() operation returns a PNGetAllChannelMetadataResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | []PNChannel | Details of type PNChannel are here |
TotalCount | int | Total count of objects without pagination. |
Next | string | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
Prev | string | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the Next parameter is supplied. |
Get channel metadata
Returns metadata for the specified Channel, optionally including the custom data object for each.
Method(s)
To Get Channel Metadata you can use the following method(s) in the Go SDK:
1pn.GetChannelMetadata().
2 Include([]pubnub.PNChannelMetadataInclude).
3 Sort(sort).
4 ID(string).
5 Execute()
| Parameter | Description |
|---|---|
IncludeType: []pubnub.PNChannelMetadataInclude | List of additional/complex space attributes to include in response. Omit this parameter if you don't want to retrieve additional attributes. Available values pubnub.PNChannelMetadataIncludeCustom |
SortType: Array | Sort by id, name, updated with asc/desc for sort direction (for example, {name: 'asc'}). |
ID *Type: string | UUID. If not supplied, the current user's UUID is used. |
Sample code
1
Response
The GetChannelMetadata() operation returns a PNGetChannelMetadataResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | PNChannel | Details of type PNChannel are here |
Set channel metadata
Unsupported partial updates of custom metadata
The value of the custom metadata parameter sent in this method always overwrites the value stored on PubNub servers. If you want to add new custom data to an existing one, you must:
- Get the existing metadata and store it locally.
- Append the new custom metadata to the existing one.
- Set the entire updated custom object.
Set metadata for a Channel in the database, optionally including the custom data object for each.
Method(s)
To Set Channel Metadata you can use the following method(s) in the Go SDK:
1pn.SetChannelMetadata().
2 Include([]pubnub.PNChannelMetadataInclude).
3 Sort(sort).
4 ID(string).
5 Name(string).
6 Description(string).
7 Custom(map[string]interface{}).
8 IfMatchETag(string).
9 Execute()
| Parameter | Description |
|---|---|
IncludeType: []pubnub.PNChannelMetadataInclude | List of additional/complex space attributes to include in response. Omit this parameter if you don't want to retrieve additional attributes. Available values pubnub.PNChannelMetadataIncludeCustom |
SortType: Array | Sort by id, name, updated with asc/desc for sort direction (for example, {name: 'asc'}). |
ID *Type: string | Unique user identifier. If not supplied then current user's uuid is used. |
Name *Type: string | Name of a channel. |
DescriptionType: string | Description of a channel. |
CustomType: map[string]interface | Custom JSON values. Can be strings, numbers, or booleans. Filtering by Custom isn't supported. |
IfMatchETagType: string | The entity tag to be used to ensure updates only happen if the object hasn't been modified since it was read. Use the eTag you received from an applicable get metadata method to check against the server entity tag. If the eTags don't match, an HTTP 412 error is thrown. |
API limits
To learn about the maximum length of parameters used to set channel metadata, refer to REST API docs.
Sample code
1
Response
The SetChannelMetadata() operation returns a PNSetChannelMetadataResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | PNChannel | Details of type PNChannel are here |
PNChannel
| Property Name | Type | Description |
|---|---|---|
ID | string | Unique user identifier. If not supplied then current user's uuid is used. |
Name | string | Display name for the user. |
Description | string | Description of a channel. |
Custom | map[string]interface | Custom JSON values. Can be strings, numbers, or booleans. |
Updated | string | Last updated date. |
ETag | string | The ETag. |
Status | string | Channel status. Max. 50 characters. |
Type | string | Channel type. Max. 50 characters. |
Other examples
Iteratively update existing user metadata
1
Iteratively update existing channel metadata
1
Remove channel metadata
Removes the metadata from a specified channel.
Method(s)
To Remove Channel Metadata you can use the following method(s) in the Go SDK:
1pn.RemoveChannelMetadata().
2 ID(string).
3 Execute()
| Parameter | Description |
|---|---|
ID *Type: string | Unique user identifier. If not supplied then current user's uuid is used. |
Sample code
1
Response
The RemoveChannelMetadata() operation returns a PNRemoveChannelMetadataResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | interface | Returns an empty interface. |
Channel memberships
Get channel memberships
The method returns a list of channel memberships for a user. This method doesn't return a user's subscriptions.
Method(s)
To Get Memberships you can use the following method(s) in the Go SDK:
1pn.GetMemberships().
2 UUID(string).
3 Include([]pubnub.PNMembershipsInclude).
4 Sort(sort).
5 Limit(int).
6 Count(bool).
7 Start(string).
8 End(string).
9 Filter(string).
10 Execute()
| Parameter | Description |
|---|---|
UUID *Type: string | UUID. If not supplied, the current user's UUID is used. |
IncludeType: []pubnub.PNMembershipsInclude | List of additional/complex attributes to include in response. Omit this parameter if you don't want to retrieve additional attributes. Available values pubnub.PNMembershipsIncludeCustom, pubnub.PNMembershipsIncludeChannel, pubnub.PNMembershipsIncludeChannelCustom |
SortType: Array | Sort by id, name, updated with asc/desc for sort direction (for example, {name: 'asc'}). |
LimitType: int | Number of objects to return. Default/Max: 100. |
CountType: bool | Whether to include the total count in the paginated response. Default is false. |
StartType: string | Cursor-based pagination. |
EndType: string | Cursor-based pagination. |
FilterType: string | Filter expression. Only matching objects are returned. See filtering. |
Sample code
1
Response
The GetMemberships() operation returns a PNGetMembershipsResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | []PNMemberships | Details of type PNMemberships are here |
TotalCount | int | Total count of objects without pagination. |
Next | string | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
Prev | string | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the Next parameter is supplied. |
PNMemberships
| Property Name | Type | Description |
|---|---|---|
ID | string | Unique user identifier. If not supplied then current user's uuid is used. |
Channel | PNChannel | Details of type PNChannel are here |
Custom | map[string]interface | Custom JSON values. Can be strings, numbers, or booleans. |
Updated | string | Last updated date. |
ETag | string | The ETag. |
Status | string | Status of the membership. Max. 50 characters. |
Type | string | Type of the membership. Max. 50 characters. |
Set channel memberships
Set channel memberships for a UUID.
Method(s)
To Set Memberships you can use the following method(s) in the Go SDK:
1pn.SetMemberships().
2 UUID(string).
3 Set([]pubnub.PNMembershipsSet).
4 Include([]pubnub.PNMembershipsInclude).
5 Sort(sort).
6 Limit(int).
7 Count(bool).
8 Start(string).
9 End(string).
10 Execute()
| Parameter | Description |
|---|---|
UUID *Type: string | UUID. If not supplied, the current user's UUID is used. |
SetType: pubnub.PNMembershipsSet | Struct of type pubnub.PNMembershipsSet to be added for the specified UUID. In PNMembershipsSet you can set the Channel (of type PNMembershipsChannel - consisting of an ID of string type ) and a Custom map. |
IncludeType: []pubnub.PNMembershipsInclude | List of additional/complex attributes to include in response. Omit this parameter if you don't want to retrieve additional attributes. Available values pubnub.PNMembershipsIncludeCustom, pubnub.PNMembershipsIncludeChannel, pubnub.PNMembershipsIncludeChannelCustom |
SortType: Array | Sort by id, name, updated with asc/desc for sort direction (for example, {name: 'asc'}). |
LimitType: int | Number of objects to return. Default/Max: 100. |
CountType: bool | Whether to include the total count in the paginated response. Default is false. |
StartType: string | Cursor-based pagination. |
EndType: string | Cursor-based pagination. |
API limits
To learn about the maximum length of parameters used to set channel membership metadata, refer to REST API docs.
Sample code
1
Response
The SetMemberships() operation returns a PNSetMembershipsResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | []PNMemberships | Details of type PNMemberships are here |
TotalCount | int | Total count of objects without pagination. |
Next | string | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
Prev | string | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the Next parameter is supplied. |
Remove channel memberships
Remove channel memberships for a UUID.
Method(s)
To Remove Memberships you can use the following method(s) in the Go SDK:
1pn.RemoveMemberships().
2 UUID(string).
3 Remove([]pubnub.PNMembershipsRemove).
4 Include([]pubnub.PNMembershipsInclude).
5 Limit(int).
6 Count(bool).
7 Start(string).
8 End(string).
9 Execute()
| Parameter | Description |
|---|---|
UUID *Type: string | UUID. If not supplied, the current user's UUID is used. |
RemoveType: pubnub.PNMembershipsRemove | Struct of type pubnub.PNMembershipsRemove to be added for the specified UUID. In PNMembershipsRemove you can set the Channel (of type PNMembershipsChannel - consisting of an ID of string type ) and a Custom map. |
IncludeType: []pubnub.PNMembershipsInclude | List of additional/complex attributes to include in response. Omit this parameter if you don't want to retrieve additional attributes. Available values pubnub.PNMembershipsIncludeCustom, pubnub.PNMembershipsIncludeChannel, pubnub.PNMembershipsIncludeChannelCustom |
LimitType: int | Number of objects to return. Default/Max: 100. |
CountType: bool | Whether to include the total count in the paginated response. Default is false. |
StartType: string | Cursor-based pagination. |
EndType: string | Cursor-based pagination. |
Sample code
1
Response
The RemoveMemberships() operation returns a PNRemoveMembershipsResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | []PNMemberships | Details of type PNMemberships are here |
TotalCount | int | Total count of objects without pagination. |
Next | string | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
Prev | string | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the Next parameter is supplied. |
Manage channel memberships
Manage the specified UUID's memberships. You can Add, Remove, and Update a UUID's memberships.
Method(s)
To Manage Memberships you can use the following method(s) in the Go SDK:
1pn.ManageMemberships().
2 UUID(string).
3 Set([]pubnub.PNMembershipsSet).
4 Remove([]pubnub.PNMembershipsRemove).
5 Include([]pubnub.PNMembershipsInclude).
6 Sort(sort).
7 Limit(int).
8 Count(bool).
9 Start(string).
10 End(string).
11 Execute()
| Parameter | Description |
|---|---|
UUIDType: string | Unique user identifier. If not supplied then current user's Uuid is used. |
SetType: pubnub.PNMembershipsSet | Struct of type pubnub.PNMembershipsSet to be added for the specified UUID. In PNMembershipsSet you can set the Channel (of type PNMembershipsChannel - consisting of an ID of string type ) and a Custom map. |
RemoveType: pubnub.PNMembershipsRemove | Struct of type pubnub.PNMembershipsRemove to be added for the specified UUID. In PNMembershipsRemove you can set the Channel (of type PNMembershipsChannel - consisting of an ID of string type ) |
IncludeType: []pubnub.PNMembershipsInclude | List of additional/complex attributes to include in response. Omit this parameter if you don't want to retrieve additional attributes. Available values pubnub.PNMembershipsIncludeCustom, pubnub.PNMembershipsIncludeChannel, pubnub.PNMembershipsIncludeChannelCustom |
SortType: Array | Sort by id, name, updated with asc/desc for sort direction (for example, {name: 'asc'}). |
LimitType: int | Number of objects to return. Default/Max: 100. |
CountType: bool | Whether to include the total count in the paginated response. Default is false. |
StartType: string | Cursor-based pagination. |
EndType: string | Cursor-based pagination. |
Sample code
1
Response
The ManageMemberships() operation returns a PNManageMembershipsResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | []PNMemberships | Details of type PNMemberships are here |
TotalCount | int | Total count of objects without pagination. |
Next | string | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
Prev | string | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the Next parameter is supplied. |
Channel members
Get channel members
The method returns a list of members in a channel. The list will include user metadata for members that have additional metadata stored in the database.
Method(s)
To Get Channel Members you can use the following method(s) in the Go SDK:
1pn.GetChannelMembers().
2 Channel(string).
3 Include(PNChannelMembersInclude).
4 Sort(sort).
5 Limit(int).
6 Count(bool).
7 Start(string).
8 End(string).
9 Filter(string).
10 Execute()
| Parameter | Description |
|---|---|
Channel *Type: string | Channel name. |
IncludeType: []pubnub.PNChannelMembersInclude | List of additional/complex attributes to include in response. Omit this parameter if you don't want to retrieve additional attributes. Available values pubnub.PNChannelMembersIncludeCustom, pubnub.PNChannelMembersIncludeUUID, pubnub.PNChannelMembersIncludeUUIDCustom |
SortType: Array | List of criteria (name of field) which should be used for sorting. Available options are id, name, and updated. Use asc or desc to specify sort direction. For example: {name: 'asc'} |
LimitType: int | Number of objects to return. Default/Max: 100. |
CountType: bool | Whether to include the total count in the paginated response. Default is false. |
StartType: string | Cursor-based pagination. |
EndType: string | Cursor-based pagination. |
FilterType: string | Filter expression. Only matching objects are returned. See filtering. |
Sample code
1
Response
The GetChannelMembers() operation returns a PNGetChannelMembersResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | []PNChannelMembers | Details of type PNChannelMembers are here |
TotalCount | int | Total count of objects without pagination. |
Next | string | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
Prev | string | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the Next parameter is supplied. |
PNChannelMembers
| Property Name | Type | Description |
|---|---|---|
ID | string | Unique user identifier. If not supplied then current user's uuid is used. |
UUID | PNUUID | Details of type PNUUID are here |
Custom | map[string]interface | Custom JSON values. Can be strings, numbers, or booleans. |
Updated | string | Last updated date. |
ETag | string | The ETag. |
Status | string | Status of the member. Max. 50 characters. |
Type | string | Type of the member. Max. 50 characters. |
Set channel members
This method sets members in a channel.
Method(s)
To Set Channel Members you can use the following method(s) in the Go SDK:
1pn.SetChannelMembers().
2 Channel(string).
3 Set([]pubnub.PNChannelMembersSet).
4 Include([]pubnub.PNChannelMembersInclude).
5 Sort(sort).
6 Limit(int).
7 Count(bool).
8 Start(string).
9 End(string).
10 Execute()
| Parameter | Description |
|---|---|
Channel *Type: string | Channel name. |
SetType: pubnub.PNChannelMembersSet | Struct of type pubnub.PNChannelMembersSet to be added for the specified space. In PNChannelMembersSet you can set the UUID (of type PNChannelMembersUUID - consisting of an ID of string type ) and a Custom map. |
IncludeType: []pubnub.PNChannelMembersInclude | List of additional/complex attributes to include in response. Omit this parameter if you don't want to retrieve additional attributes. Available values pubnub.PNChannelMembersIncludeCustom, pubnub.PNChannelMembersIncludeUUID, pubnub.PNChannelMembersIncludeUUIDCustom |
SortType: Array | Sort by id, name, updated with asc/desc for sort direction (for example, {name: 'asc'}). |
LimitType: int | Number of objects to return. Default/Max: 100. |
CountType: bool | Whether to include the total count in the paginated response. Default is false. |
StartType: string | Cursor-based pagination. |
EndType: string | Cursor-based pagination. |
API limits
To learn about the maximum length of parameters used to set channel members metadata, refer to REST API docs.
Sample code
1
Response
The SetChannelMembers() operation returns a PNSetChannelMembersResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | []PNChannelMembers | Details of type PNChannelMembers are here |
TotalCount | int | Total count of objects without pagination. |
Next | string | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
Prev | string | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the Next parameter is supplied. |
Remove channel members
Remove members from a Channel.
Method(s)
To Remove Channel Members you can use the following method(s) in the Go SDK:
1pn.RemoveChannelMembers().
2 Channel(string).
3 Remove([]pubnub.PNChannelMembersRemove{}).
4 Include([]pubnub.PNChannelMembersInclude).
5 Limit(int).
6 Count(bool).
7 Start(string).
8 End(string).
9 Execute()
| Parameter | Description |
|---|---|
channel *Type: String Default: n/a | Name of channel from which members should be fetched. |
uuids *Type: Array Default: n/a | List of UUIDs for which metadata associated with each of them in context of channel should be set. Each entry is dictionary with UUID and optional custom fields. custom should be dictionary with simple objects: String and Integer. |
sortType: Array Default: n/a | List of criteria (name of field) which should be used for sorting. Available options are id, name, and updated. Use asc or desc to specify sort direction. For example: {name: 'asc'} |
includeType: Object Default: { count: true } | Additional information which should be included in response. Available options:
|
filterType: String Default: n/a | Expression to filter out results basing on specified criteria. For more details on the supported grammar, check here |
startType: String Default: n/a | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
endType: String Default: n/a | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the start parameter is supplied. |
limitType: Integer Default: 100 | Number of objects to return in response. Default is 100, which is also the maximum value. |
http_syncType: Boolean Default: false | Method will be executed asynchronously and will return future, to get its value you can use value method. If set to true, method will return array of envelopes (even if there's only one envelope). For sync methods Envelope object will be returned. |
callbackType: Lambda accepting one parameter Default: n/a | Callback that will be called for each envelope. For async methods future will be returned, to retrieve value Envelope object you have to call value method (thread will be locked until the value is returned). |
Sample code
1
Response
The RemoveChannelMembers() operation returns a PNRemoveChannelMembersResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | []PNChannelMembers | Details of type PNChannelMembers are here |
TotalCount | int | Total count of objects without pagination. |
Next | string | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
Prev | string | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the Next parameter is supplied. |
Manage channel members
The method Set and Remove channel memberships for a user.
Method(s)
To Manage Channel Members you can use the following method(s) in the Go SDK:
1pn.ManageChannelMembers().
2 Channel(string).
3 Set([]pubnub.PNChannelMembersSet).
4 Remove([]pubnub.PNChannelMembersRemove{}).
5 Include([]pubnub.PNChannelMembersInclude).
6 Sort(sort).
7 Limit(int).
8 Count(bool).
9 Start(string).
10 End(string).
11 Execute()
| Parameter | Description |
|---|---|
Channel *Type: string | Channel Name. |
SetType: pubnub.PNChannelMembersSet | Struct of type pubnub.PNChannelMembersSet to be added for the specified space. In PNChannelMembersSet you can set the UUID (of type PNChannelMembersUUID - consisting of an ID of string type ) and a Custom map. |
RemoveType: pubnub.PNChannelMembersRemove | Struct of type pubnub.PNChannelMembersRemove to be removed for the specified space. In PNChannelMembersRemove you can set the UUID (of type PNChannelMembersUUID - consisting of an ID of string type ) |
LimitType: int | Maximum number of results to return per page. Default 100. |
CountType: bool | Whether to include the total count in the paginated response. Default is false. |
StartType: string | Cursor-based pagination. |
EndType: string | Cursor-based pagination. |
SortType: Array | Sort by id, name, updated with asc/desc for sort direction (for example, {name: 'asc'}). |
IncludeType: []pubnub.PNChannelMembersInclude | List of additional/complex attributes to include in response. Omit this parameter if you don't want to retrieve additional attributes. Available values pubnub.PNChannelMembersIncludeCustom, pubnub.PNChannelMembersIncludeUUID, pubnub.PNChannelMembersIncludeUUIDCustom |
Sample code
1
Response
The ManageChannelMembers() operation returns a PNManageMembersResponse which contains the following parameters:
| Property Name | Type | Description |
|---|---|---|
Data | []PNChannelMembers | Details of type PNChannelMembers are here |
TotalCount | int | Total count of objects without pagination. |
Next | string | Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off. |
Prev | string | Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the Next parameter is supplied. |