Go V4 Objects API Reference for Realtime Apps
This page describes the new Objects v2. To upgrade from Objects v1, refer to the migration guide.
Objects provides easy-to-use, serverless storage for user and channel data you need to build innovative, reliable, scalable applications. Use Objects to easily 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 set or removed from the database. Clients can receive these events in realtime and update their front-end application accordingly.
User
Get Metadata for All Users
Description
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 V4 SDK:
pn.GetAllUUIDMetadata().Include([]pubnub.PNUUIDMetadataIncludeCustom).Limit(int).Count(bool).Start(string).End(string).Filter(string).Execute()
Parameter Type Required Description Limit
int Optional Number of objects to return in response. Default is 100
, which is also the maximum value.Count
bool Optional Request Count
to be included in paginated response. By default,Count
is omitted.Start
string Optional Previously-returned cursor bookmark for fetching the next page. End
string Optional Previously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter. Filter
string Optional Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here. In addition to custom attributes, the expressions can refer to attributes on associated entities one level deep (that is, the association and its target entities). Include
[]pubnub.PNUUIDMetadataInclude Optional 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
Basic Usage
incl := []pubnub.PNUUIDMetadataInclude{
pubnub.PNUUIDMetadataIncludeCustom,
}
res, status, err := pn.GetAllUUIDMetadata().Include(incl).Sort(sort).Limit(100).Count(true).Execute()
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 | Cursor bookmark for fetching next page. |
Prev | string | Cursor bookmark for fetching prev page. |
Get User Metadata
Description
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 V4 SDK:
pn.PNUUIDMetadataInclude().Include([]pubnub.PNUUIDMetadataIncludeCustom).ID(string).Execute()
Parameter Type Required Description ID
string Yes Unique user identifier. If not supplied then current user's uuid
is used.Include
[]pubnub.PNUUIDMetadataIncludeCustom Optional 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
Basic Usage
id := "testuuid"
incl := []pubnub.PNUUIDMetadataInclude{
pubnub.PNUUIDMetadataIncludeCustom,
}
res, status, err := pn.GetUUIDMetadata().UUID(id).Include(incl).Execute()
fmt.Println(res, status, err)
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
Description
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 V4 SDK:
pn.SetUUIDMetadata().Include([]pubnub.PNUUIDMetadataIncludeCustom).ID(id).Name(string).ExternalID(string).ProfileURL(string).Email(string).Custom(map[string]interface{}).Execute()
Parameter Type Required Description ID
string Yes Unique user identifier. If not supplied then current user's uuid
is used.Name
string Yes Display name for the user. Maximum 200 characters. ExternalID
string Optional User's identifier in an external system ProfileURL
string Optional The URL of the user's profile picture Email
string Optional The user's email address. Maximum 80 characters. Custom
map[string]interface{} Optional JSON object of key-value pairs with supported data types. Include
[]pubnub.PNUUIDMetadataInclude Optional 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
Basic Usage
id := "testuuid"
name := "name"
extid := "extid"
purl := "profileurl"
email := "email"
custom := make(map[string]interface{})
custom["a"] = "b"
custom["c"] = "d"
incl := []pubnub.PNUUIDMetadataInclude{
pubnub.PNUUIDMetadataIncludeCustom,
}
res, status, err := pn.SetUUIDMetadata().Include(incl).UUID(id).Name(name).ExternalID(extid).ProfileURL(purl).Email(email).Custom(custom).Execute()
fmt.Println(res, status, err)
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. Maximum 200 characters. |
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. Maximum 80 characters. |
Custom | map[string]interface | JSON object of key-value pairs with supported data types. |
Updated | string | Last updated date. |
ETag | string | The ETag. |
Remove User Metadata
Description
Removes the metadata from a specified UUID.
Method(s)
To Remove UUID Metadata
you can use the following method(s) in the Go V4 SDK:
pn.RemoveUUIDMetadata().ID(string).Execute()
Parameter Type Required Description ID
string Yes Unique user identifier. If not supplied then current user's uuid
is used.
Basic Usage
id := "testuuid"
res, status, err := pn.RemoveUUIDMetadata().UUID(id).Execute()
fmt.Println(res, status, err)
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
Description
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 V4 SDK:
pn.GetAllChannelMetadata().Include([]pubnub.PNChannelMetadataInclude).Limit(int).Count(bool).Start(string).End(string).Filter(string).Execute()
Parameter Type Required Description Limit
int Optional Number of objects to return in response. Default is 100
, which is also the maximum value.Count
bool Optional Request Count
to be included in paginated response. By default,Count
is omitted.Start
string Optional Previously-returned cursor bookmark for fetching the next page. End
string Optional Previously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter. Filter
string Optional Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here. In addition to custom attributes, the expressions can refer to attributes on associated entities one level deep (that is, the association and its target entities). Include
[]pubnub.PNChannelMetadataInclude Optional 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
Basic Usage
incl := []pubnub.PNChannelMetadataInclude{
pubnub.PNChannelMetadataIncludeCustom,
}
res, status, err := pn.GetAllChannelMetadata().Include(incl).Sort(sort).Limit(100).Count(true).Execute()
fmt.Println(res, status, err)
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 | Cursor bookmark for fetching next page. |
Prev | string | Cursor bookmark for fetching prev page. |
Get Channel Metadata
Description
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 V4 SDK:
pn.GetChannelMetadata().Include([]pubnub.PNChannelMetadataInclude).ID(string).Execute()
Parameter Type Required Description ID
string Yes Unique user identifier. If not supplied then current user's uuid
is used.Include
[]pubnub.PNChannelMetadataInclude Optional 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
Basic Usage
id := "testchannel"
incl := []pubnub.PNChannelMetadataInclude{
pubnub.PNChannelMetadataIncludeCustom,
}
res, status, err := pn.GetChannelMetadata().Include(incl).Channel(id).Execute()
fmt.Println(res, status, err)
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
Description
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 V4 SDK:
pn.SetChannelMetadata().Include([]pubnub.PNChannelMetadataInclude).ID(string).Name(string).Description(string).Custom(map[string]interface{}).Execute()
Parameter Type Required Description ID
string Yes Unique user identifier. If not supplied then current user's uuid
is used.Name
string Yes Name of a channel. Description
string Optional Description of a channel. Custom
map[string]interface{} Optional Map of string and interface with supported data types. Values must be scalar only; arrays or objects are not supported. Include
[]pubnub.PNChannelMetadataInclude Optional 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
Basic Usage
id := "testchannel"
name := "name"
desc := "desc"
custom := make(map[string]interface{}) custom["a"] = "b" custom["c"] = "d"
incl := []pubnub.PNChannelMetadataInclude{
pubnub.PNChannelMetadataIncludeCustom,
}
res, status, err := pn.SetChannelMetadata().Include(incl).Channel(id).Name(name).Description(desc).Custom(custom).Execute()
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. Maximum 200 characters. |
Description | string | Description of a channel. |
Custom | map[string]interface | Map of string and interface with supported data types. Values must be scalar only; arrays or objects are not supported. |
Updated | string | Last updated date. |
ETag | string | The ETag. |
Remove Channel Metadata
Description
Removes the metadata from a specified channel.
Method(s)
To Remove Channel Metadata
you can use the following method(s) in the Go V4 SDK:
pn.RemoveChannelMetadata().ID(string).Execute()
Parameter Type Required Description ID
string Yes Unique user identifier. If not supplied then current user's uuid
is used.
Basic Usage
id := "testchannel"
res, status, err := pn.RemoveChannelMetadata().Channel(id).Execute()
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
Description
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 V4 SDK:
pn.GetMemberships().UUID(string).Include([]pubnub.PNMembershipsInclude).Limit(int).Count(bool).Start(string).End(string).Filter(string).Execute()
Parameter Type Required Description UUID
string Yes Unique user identifier. If not supplied then current user's uuid
is used.Limit
int Optional Number of objects to return in response. Default is 100
, which is also the maximum value.Count
bool Optional Request Count
to be included in paginated response. By default,Count
is omitted.Start
string Optional Previously-returned cursor bookmark for fetching the next page. End
string Optional Previously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter. Filter
string Optional Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here. In addition to custom attributes, the expressions can refer to attributes on associated entities one level deep (that is, the association and its target entities). Include
[]pubnub.PNMembershipsInclude Optional 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
Basic Usage
inclMemberships := []pubnub.PNMembershipsInclude{
pubnub.PNMembershipsIncludeCustom,
pubnub.PNMembershipsIncludeChannel,
pubnub.PNMembershipsIncludeChannelCustom,
}
res, status, err := pn.GetMemberships().UUID("testuuid").Include(inclMemberships).Limit(100).Count(true).Execute()
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 | Cursor bookmark for fetching next page. |
Prev | string | Cursor bookmark for fetching prev page. |
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 | Map of string and interface with supported data types. |
Updated | string | Last updated date. |
ETag | string | The ETag. |
Set Channel Memberships
Description
Set channel memberships for a UUID.
Method(s)
To Set Memberships
you can use the following method(s) in the Go V4 SDK:
pn.SetMemberships().UUID(string).Set([]pubnub.PNMembershipsSet).Include([]pubnub.PNMembershipsInclude).Limit(int).Count(bool).Start(string).End(string).Execute()
Parameter Type Required Description UUID
string Yes Unique user identifier. If not supplied then current user's uuid
is used.Set
pubnub.PNMembershipsSet Optional Struct of type pubnub.PNMembershipsSet
to be added for the specifiedUUID
. InPNMembershipsSet
you can set the Channel (of typePNMembershipsChannel
- consisting of anID
ofstring
type ) and aCustom
map.Limit
int Optional Maximum number of results to return per page. Default 100. Count
bool Optional Request TotalCount to be included in paginated response. Default false
Start
string Optional Previously-returned cursor bookmark for fetching the next page. End
string Optional Previously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter. Include
[]pubnub.PNMembershipsInclude Optional 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
Basic Usage
inclMemberships := []pubnub.PNMembershipsInclude{
pubnub.PNMembershipsIncludeCustom,
pubnub.PNMembershipsIncludeChannel,
pubnub.PNMembershipsIncludeChannelCustom,
}
custom := make(map[string]interface{})
custom["a"] = "b"
custom["c"] = "d"
channel := pubnub.PNMembershipsChannel{
ID: "testchannel",
}
inMem := pubnub.PNMembershipsSet{
ID: channel,
Custom: custom,
}
inArrMem := []pubnub.PNMembershipsSet{
inMem,
}
res, status, err := pn.SetMemberships().UUID("testuuid").Set(inArrMem).Include(inclMemberships).Limit(100).Count(true).Execute()
fmt.Println(res, status, err)
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 | Cursor bookmark for fetching next page. |
Prev | string | Cursor bookmark for fetching prev page. |
Remove Channel Memberships
Description
Remove channel memberships for a UUID.
Method(s)
To Remove Memberships
you can use the following method(s) in the Go V4 SDK:
pn.RemoveMemberships().UUID(string).Remove([]pubnub.PNMembershipsRemove).Include([]pubnub.PNMembershipsInclude).Limit(int).Count(bool).Start(string).End(string).Execute()
Parameter Type Required Description UUID
string Yes Unique user identifier. If not supplied then current user's uuid
is used.Remove
pubnub.PNMembershipsRemove Optional Struct of type pubnub.PNMembershipsRemove
to be added for the specifiedUUID
. InPNMembershipsRemove
you can set the Channel (of typePNMembershipsChannel
- consisting of anID
ofstring
type ) and aCustom
map.Limit
int Optional Maximum number of results to return per page. Default 100. Count
bool Optional Request TotalCount to be included in paginated response. Default false
Start
string Optional Previously-returned cursor bookmark for fetching the next page. End
string Optional Previously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter. Include
[]pubnub.PNMembershipsInclude Optional 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
Basic Usage
inclMemberships := []pubnub.PNMembershipsInclude{
pubnub.PNMembershipsIncludeCustom,
pubnub.PNMembershipsIncludeChannel,
pubnub.PNMembershipsIncludeChannelCustom,
}
channel := pubnub.PNMembershipsChannel{
ID: "testchannel",
}
reMem := pubnub.PNMembershipsRemove{
ID: channel,
}
reArrMem := []pubnub.PNMembershipsRemove{
reMem,
}
res, status, err := pn.RemoveMemberships().UUID("testuuid").Remove(reArrMem).Include(inclMemberships).Limit(100).Count(true).Execute()
fmt.Println(res, status, err)
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 | Cursor bookmark for fetching next page. |
Prev | string | Cursor bookmark for fetching prev page. |
Manage Channel Memberships
Description
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 V4 SDK:
pn.ManageMemberships().UUID(string).Set([]pubnub.PNMembershipsSet).Remove([]pubnub.PNMembershipsRemove).Include([]pubnub.PNMembershipsInclude).Limit(int).Count(bool).Start(string).End(string).Execute()
Parameter Type Required Description UUID
string string Unique user identifier. If not supplied then current user's Uuid
is used.Set
pubnub.PNMembershipsSet Optional Struct of type pubnub.PNMembershipsSet
to be added for the specifiedUUID
. InPNMembershipsSet
you can set theChannel
(of typePNMembershipsChannel
- consisting of anID
ofstring
type ) and aCustom
map.Remove
pubnub.PNMembershipsRemove Optional Struct of type pubnub.PNMembershipsRemove
to be added for the specified UUID. InPNMembershipsRemove
you can set theChannel
(of typePNMembershipsChannel
- consisting of anID
ofstring
type )Limit
int Optional Maximum number of results to return per page. Default 100. Count
bool Optional Request TotalCount to be included in paginated response. Default false
Start
string Optional Previously-returned cursor bookmark for fetching the next page. End
string Optional Previously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter. Include
[]pubnub.PNMembershipsInclude Optional 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
Basic Usage
inclMemberships := []pubnub.PNMembershipsInclude{
pubnub.PNMembershipsIncludeCustom,
pubnub.PNMembershipsIncludeChannel,
pubnub.PNMembershipsIncludeChannelCustom,
}
custom := make(map[string]interface{})
custom["a"] = "b"
custom["c"] = "d"
channel := pubnub.PNMembershipsChannel{
ID: "testchannel",
}
inMem := pubnub.PNMembershipsSet{
ID: channel,
Custom: custom,
}
inArrMem := []pubnub.PNMembershipsSet{
inMem,
}
res, status, err := pn.ManageMemberships().UUID("testuuid").Set(inArrMem).Remove([]pubnub.PNMembershipsRemove{}).Include(inclMemberships).Limit(100).Count(true).Execute()
fmt.Println(res, status, err)
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 | Cursor bookmark for fetching next page. |
Prev | string | Cursor bookmark for fetching prev page. |
Channel Members
Get Channel Members
Description
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 V4 SDK:
pn.GetChannelMembers().Channel(string).Include(PNChannelMembersInclude).Limit(int).Count(bool).Start(string).End(string).Filter(string).Execute()
Parameter Type Required Description Channel
string Yes Channel name. Limit
int Optional Maximum number of results to return per page. Default 100. Count
bool Optional Request TotalCount to be included in paginated response. Default false
Start
string Optional Previously-returned cursor bookmark for fetching the next page. End
string Optional Previously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter. Filter
string Optional Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here. In addition to custom attributes, the expressions can refer to attributes on associated entities one level deep (that is, the association and its target entities). Include
[]pubnub.PNChannelMembersInclude Optional 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
Basic Usage
inclSm := []pubnub.PNChannelMembersInclude{
pubnub.PNChannelMembersIncludeCustom,
pubnub.PNChannelMembersIncludeUUID,
pubnub.PNChannelMembersIncludeUUIDCustom,
}
res, status, err := pn.GetChannelMembers().Channel("testchannel").Include(inclSm).Limit(100).Count(true).Execute()
fmt.Println(res, status, err)
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 | Cursor bookmark for fetching next page. |
Prev | string | Cursor bookmark for fetching prev page. |
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 | Map of string and interface with supported data types. |
Updated | string | Last updated date. |
ETag | string | The ETag. |
Set Channel Members
Description
This method sets members in a channel.
Method(s)
To Set Channel Members
you can use the following method(s) in the Go V4 SDK:
pn.SetChannelMembers().Channel(string).Set([]pubnub.PNChannelMembersSet).Include([]pubnub.PNChannelMembersInclude).Limit(int).Count(bool).Start(string).End(string).Execute()
Parameter Type Required Description Channel
string Yes Channel name. Set
pubnub.PNChannelMembersSet Optional Struct of type pubnub.PNChannelMembersSet
to be added for the specified space. InPNChannelMembersSet
you can set theUUID
(of typePNChannelMembersUUID
- consisting of anID
ofstring
type ) and aCustom
map.Limit
int Optional Maximum number of results to return per page. Default 100. Count
bool Optional Request TotalCount to be included in paginated response. Default false
Start
string Optional Previously-returned cursor bookmark for fetching the next page. End
string Optional Previously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter. Include
[]pubnub.PNChannelMembersInclude Optional 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
Basic Usage
inclSm := []pubnub.PNChannelMembersInclude{
pubnub.PNChannelMembersIncludeCustom,
pubnub.PNChannelMembersIncludeUUID,
pubnub.PNChannelMembersIncludeUUIDCustom,
}
custom := make(map[string]interface{})
custom["a"] = "b"
custom["c"] = "d"
uuid := pubnub.PNChannelMembersUUID{
ID: "testuuid",
}
inputUUID := pubnub.PNChannelMembersSet{
UUID: uuid,
Custom: custom,
}
inArrMem := []pubnub.PNChannelMembersSet{
inputUUID,
}
res, status, err := pn.SetChannelMembers().Channel("testchannel").Set(inArrMem).Include(inclSm).Limit(100).Count(true).Execute()
fmt.Println(res, status, err)
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 | Cursor bookmark for fetching next page. |
Prev | string | Cursor bookmark for fetching prev page. |
Remove Channel Members
Description
Remove members from a Channel.
Method(s)
To Remove Channel Members
you can use the following method(s) in the Go V4 SDK:
pn.RemoveChannelMembers().Channel(string).Remove([]pubnub.PNChannelMembersRemove{}).Include([]pubnub.PNChannelMembersInclude).Limit(int).Count(bool).Start(string).End(string).Execute()
Parameter Type Required Default Description channel
String Yes Name of channel from which members should be fetched. uuids
Array Yes List of UUIDs
for whichmetadata
associated with each of them in context ofchannel
should be set. Each entry is dictionary withUUID
and optionalcustom
fields.custom
should be dictionary with simple objects:String
andInteger
.sort
Array Optional List of criteria (name of field) which should be used for sorting in ascending order. To change sorting order, append :asc
(ascending used by default) ordesc
(descending) to field name.include
Object Optional { count: true }
Additional information which should be included in response. Available options: count
- include how many UUID has been associated with metadata.custom
- include field with additional information from metadata which has been used duringUUID
metadata set requests.
filter
String Optional Expression to filter out results basing on specified criteria. For more details on the supported grammar, check here start
String Optional Previously-returned cursor bookmark for fetching the next page. end
String Optional Previously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start
parameter.limit
Integer Optional 100 Number of objects to return in response. Default is 100
, which is also the maximum value.http_sync
Boolean Optional false Method will be executed asynchronously
and will return future, to get itsvalue
you can usevalue
method. If set totrue
, method will return array of envelopes (even if there's only oneenvelope
). Forsync
methodsEnvelope
object will be returned.callback
Lambda accepting one parameter Optional Callback
that will be called for each envelope. Forasync
methods future will be returned, to retrievevalue
Envelope
object you have to callvalue
method (thread will be locked until thevalue
is returned).
Basic Usage
inclSm := []pubnub.PNChannelMembersInclude{
pubnub.PNChannelMembersIncludeCustom,
pubnub.PNChannelMembersIncludeUUID,
pubnub.PNChannelMembersIncludeUUIDCustom,
}
uuid := pubnub.PNChannelMembersUUID{
ID: "testuuid",
}
re := pubnub.PNChannelMembersRemove{
UUID: uuid,
}
reArr := []pubnub.PNChannelMembersRemove{
re,
}
res, status, err := pn.RemoveChannelMembers().Channel("testchannel").Remove(reArr).Include(inclSm).Limit(100).Count(true).Execute()
fmt.Println(res, status, err)
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 | Cursor bookmark for fetching next page. |
Prev | string | Cursor bookmark for fetching prev page. |
Manage Channel Members
Description
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 V4 SDK:
pn.ManageChannelMembers().Channel(string).Set([]pubnub.PNChannelMembersSet).Remove([]pubnub.PNChannelMembersRemove{}).Include([]pubnub.PNChannelMembersInclude).Limit(int).Count(bool).Start(string).End(string).Execute()
Parameter Type Required Description Channel
string Yes Channel Name. Set
pubnub.PNChannelMembersSet Optional Struct of type pubnub.PNChannelMembersSet
to be added for the specified space. InPNChannelMembersSet
you can set theUUID
(of typePNChannelMembersUUID
- consisting of anID
ofstring
type ) and aCustom
map.Remove
pubnub.PNChannelMembersRemove Optional Struct of type pubnub.PNChannelMembersRemove
to be removed for the specified space. InPNChannelMembersRemove
you can set theUUID
(of typePNChannelMembersUUID
- consisting of anID
ofstring
type )Limit
int Optional Maximum number of results to return per page. Default 100. Count
bool Optional Request TotalCount to be included in paginated response. Default false
Start
string Optional Previously-returned cursor bookmark for fetching the next page. End
string Optional Previously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter. Include
[]pubnub.PNChannelMembersInclude Optional 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
Basic Usage
inclSm := []pubnub.PNChannelMembersInclude{
pubnub.PNChannelMembersIncludeCustom,
pubnub.PNChannelMembersIncludeUUID,
pubnub.PNChannelMembersIncludeUUIDCustom,
}
custom := make(map[string]interface{})
custom["a"] = "b"
custom["c"] = "d"
uuid := pubnub.PNChannelMembersUUID{
ID: "testuuid",
}
inputUUID := pubnub.PNChannelMembersSet{
UUID: uuid,
Custom: custom,
}
inArrMem := []pubnub.PNChannelMembersSet{
inputUUID,
}
res, status, err := pn.ManageChannelMembers().Channel("testchannel").Set(inArrMem).Remove([]pubnub.PNChannelMembersRemove{}).Include(inclSm).Limit(100).Count(true).Execute()
fmt.Println(res, status, err)
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 | Cursor bookmark for fetching next page. |
Prev | string | Cursor bookmark for fetching prev page. |
Objects Filtering Language Definition
The filtering language for Objects is similar to the stream filtering language.
Note the following:
- Date/time properties, such as
updated
, must be compared to valid date/time strings formatted according to ISO 8601. - Custom properties must have the same type as the value used in the expression; it is an error to compare a custom property of one type to a value of another type.
- Objects that do not have the referenced custom property at all are excluded regardless of the operator or value used in the expression. The
null
value can be used to filter out objects that do or do not have the referenced custom property. - The LIKE operator supports wildcards denoted by the
*
character. A wildcard matches any sequence of arbitrary Unicode characters, including the empty sequence. The literal asterisk is matched when escaped using the backslash (\
) character. - Values used with LIKE must be properly encoded just like any other string value. Thus, in order to escape an asterisk, the raw value must contain
\\*
. - The entire expression must be properly URL-encoded when used in the query string.
<expression> ::= <and_expression> ( "||" <and_expression> )*
<and_expression> ::= <binary_condition> ( "&&" <binary_condition> )*
<binary_condition> ::= "!" <binary_condition> | "(" <expression> ")" | <relational_condition>
<relational_condition> ::= <property_path> <relational_operator> <value>
<property_path> ::= <property_name> ( "." <property_name> )*
<property_name> ::= <identifier> | "[" <string> "]"
<value> ::= <string> | <number> | "true" | "false" | "null"
Tokens
<identifier> ::= <letter> | "$" | "_" ( <letter> | "$" | "_" | <digit> )*
<relational_operator> ::= "==" | "!=" | "<=" | ">=" | "<" | ">" | "LIKE"
<string> ::= <double_quote> ( "\" <double_quote> | "\" <special_char>
| "\" "u" <hex_digit> <hex_digit> <hex_digit> <hex_digit>
| <unicode_char> - <double_quote> - "\" )* <double_quote>
| "'" ( "\" "'" | "\" <special_char>
| "\" "u" <hex_digit> <hex_digit> <hex_digit> <hex_digit>
| <unicode_char> - "'" - "\" )* "'"
<number> ::= ( "+" | "-" )? ( <digit> )* ( "." )? <digit> ( <digit> )*
( "e" | "E" ( "+" | "-" )? <digit> ( <digit> )* )?
<letter> ::= Unicode Letter (category; any kind of letter from any language)
<digit> ::= "0" .. "9"
<hex_digit> ::= <digit> | "A" .. "F"
<double_quote> ::= the " character
<unicode_char> ::= any character in the Unicode range from U+0020 to U+10FFFF inclusive
<special_char> ::= "\" | "/" | "b" | "f" | "n" | "r" | "t"
Sample object filtering operations
The following simple expression returns results whose custom property named public
is equal to Boolean true
.
custom.public == true
The following date/time comparison returns results that were modified on or after August 31st, 2019 (UTC):
updated >= "2019-08-31T00:00:00Z"
The following compound expression returns results that don't have a description, but do have a non-empty custom label
or description
property:
description == null && (custom.label != "" || custom.description != "")
The following wildcard expression returns results whose name starts with the letter X:
name LIKE 'X*'
The following escaped wildcard expression returns results whose name contains an asterisk:
name LIKE '*\\**'