azwebpubsub

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 16 Imported by: 0

README

Azure Web PubSub service client library for Go

Azure Web PubSub service is an Azure-managed service that helps developers easily build web applications with real-time features and publish-subscribe pattern. Any scenario that requires real-time publish-subscribe messaging between server and clients or among clients can use Azure Web PubSub service. Traditional real-time features that often require polling from server or submitting HTTP requests can also use Azure Web PubSub service.

You can use this library in your app server side to manage the WebSocket client connections, as shown in below diagram:

overflow.

  • Send messages to hubs and groups.
  • Send messages to particular users and connections.
  • Organize users and connections into groups.
  • Close connections
  • Grant, revoke, and check permissions for an existing connection

Details about the terms used here are described in Key concepts section.

Key links:

Getting started

Install the package

Install the Azure Web PubSub service client module for Go with go get:

go get github.com/Azure/azure-sdk-for-go/sdk/messaging/azwebpubsub
Prerequisites
  • Go, version 1.18 or higher
  • An Azure subscription
  • An existing Azure Web PubSub service instance.
Authenticate the client

Web PubSub service clients are created using a TokenCredential from the Azure Identity package, like DefaultAzureCredential. You can also create a client using a connection string.

Using a service principal

Constructing the client requires your Web PubSub's endpoint URL, which you can get from the Azure Portal (Host name value on overview page with https scheme).

import (
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/messaging/azwebpubsub"
	"log"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}

	client, err := azwebpubsub.NewClient("<your Web PubSub's endpoint URL>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
}
Using a connection string

ConnectionString can be found in the Keys tab from your Web PubSub resource portal.

import (
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/messaging/azwebpubsub"
	"log"
)

func main() {
	client, err := azwebpubsub.NewClientFromConnectionString("<your Web PubSub's connection string>", nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
}

Key concepts

Connection

A connection, also known as a client or a client connection, represents an individual WebSocket connection connected to the Web PubSub service. When successfully connected, a unique connection ID is assigned to this connection by the Web PubSub service.

Hub

A hub is a logical concept for a set of client connections. Usually you use one hub for one purpose, for example, a chat hub, or a notification hub. When a client connection is created, it connects to a hub, and during its lifetime, it belongs to that hub. Different applications can share one Azure Web PubSub service by using different hub names.

Group

A group is a subset of connections to the hub. You can add a client connection to a group, or remove the client connection from the group, anytime you want. For example, when a client joins a chat room, or when a client leaves the chat room, this chat room can be considered to be a group. A client can join multiple groups, and a group can contain multiple clients.

User

Connections to Web PubSub can belong to one user. A user might have multiple connections, for example when a single user is connected across multiple devices or multiple browser tabs.

Message

When the client is connected, it can send messages to the upstream application, or receive messages from the upstream application, through the WebSocket connection.

Examples

Examples for various scenarios can be found on pkg.go.dev or in the example*_test.go files in our GitHub repo for azwebpubsub.

Troubleshooting

Live Trace

Use Live Trace from the Web PubSub service portal to view the live traffic.

Logging

This module uses the classification-based logging implementation in azcore. To enable console logging for all SDK modules, set the environment variable AZURE_SDK_GO_LOGGING to all.

Use the azcore/log package to control log event output or to enable logs for azwebpubsub only. For example:

import (
  "fmt"
  azlog "github.com/Azure/azure-sdk-for-go/sdk/azcore/log"
)

// print log output to stdout
azlog.SetListener(func(event azlog.Event, s string) {
    fmt.Printf("[%s] %s\n", event, s)
})

// pick the set of events to log
azlog.SetEvents(
  azwebpubsub
)

Contributing

For details on contributing to this repository, see the contributing guide.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Many people all over the world have helped make this project better. You'll want to check out:

Reporting security issues and security bugs

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.

License

Azure SDK for Go is licensed under the MIT license.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddConnectionToGroupOptions

type AddConnectionToGroupOptions struct {
}

AddConnectionToGroupOptions contains the optional parameters for the Client.AddConnectionToGroup method.

type AddConnectionToGroupResponse

type AddConnectionToGroupResponse struct {
}

AddConnectionToGroupResponse contains the response from method Client.AddConnectionToGroup.

type AddConnectionsToGroupsOptions

type AddConnectionsToGroupsOptions struct {
}

AddConnectionsToGroupsOptions contains the optional parameters for the Client.AddConnectionsToGroups method.

type AddConnectionsToGroupsResponse

type AddConnectionsToGroupsResponse struct {
}

AddConnectionsToGroupsResponse contains the response from method Client.AddConnectionsToGroups.

type AddToGroupsRequest

type AddToGroupsRequest struct {
	// An OData filter which target connections satisfy
	Filter *string

	// A list of groups which target connections will be added into
	Groups []string
}

AddToGroupsRequest - The request object containing targets groups and a connection filter

func (AddToGroupsRequest) MarshalJSON

func (a AddToGroupsRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type AddToGroupsRequest.

func (*AddToGroupsRequest) UnmarshalJSON

func (a *AddToGroupsRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type AddToGroupsRequest.

type AddUserToGroupOptions

type AddUserToGroupOptions struct {
}

AddUserToGroupOptions contains the optional parameters for the Client.AddUserToGroup method.

type AddUserToGroupResponse

type AddUserToGroupResponse struct {
}

AddUserToGroupResponse contains the response from method Client.AddUserToGroup.

type CheckPermissionOptions

type CheckPermissionOptions struct {
	// The meaning of the target depends on the specific permission. For joinLeaveGroup and sendToGroup, targetName is a required
	// parameter standing for the group name.
	TargetName *string
}

CheckPermissionOptions contains the optional parameters for the Client.CheckPermission method.

type CheckPermissionResponse

type CheckPermissionResponse struct {
}

CheckPermissionResponse contains the response from method Client.CheckPermission.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client contains the methods for the WebPubSub group. Don't use this type directly, use a constructor function instead.

func NewClient

func NewClient(endpoint string, credential azcore.TokenCredential, options *ClientOptions) (*Client, error)

NewClient creates a client that manages Web PubSub service

Example

ExampleNewClient demonstrates how to create a new client with default Azure credentials.

package main

import (
	"log"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/messaging/azwebpubsub"
)

func main() {

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		// handle error
	}

	endpoint := os.Getenv("WEBPUBSUB_ENDPOINT")

	if endpoint == "" {
		return
	}

	hub := os.Getenv("WEBPUBSUB_HUB")
	if hub == "" {
		return
	}
	client, err := azwebpubsub.NewClient(endpoint, cred, nil)

	if err != nil {
		//  TODO: Update the following line with your application specific error handling logic
		log.Fatalf("ERROR: %s", err)
	}

	_ = client // ignore

}
Output:

func NewClientFromConnectionString

func NewClientFromConnectionString(connectionString string, options *ClientOptions) (*Client, error)

NewClientFromConnectionString creates a Client from a connection string

Example

ExampleNewClientFromConnectionString demonstrates how to create a new client with connection string.

package main

import (
	"log"
	"os"

	"github.com/Azure/azure-sdk-for-go/sdk/messaging/azwebpubsub"
)

func main() {
	connectionString := os.Getenv("WEBPUBSUB_CONNECTIONSTRING")
	if connectionString == "" {
		return
	}

	client, err := azwebpubsub.NewClientFromConnectionString(connectionString, nil)

	if err != nil {
		//  TODO: Update the following line with your application specific error handling logic
		log.Fatalf("ERROR: %s", err)
	}

	_ = client // ignore

}
Output:

func (*Client) AddConnectionToGroup

func (client *Client) AddConnectionToGroup(ctx context.Context, hub string, group string, connectionID string, options *AddConnectionToGroupOptions) (AddConnectionToGroupResponse, error)

AddConnectionToGroup - Add a connection to the target group. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • group - Target group name, which length should be greater than 0 and less than 1025.
  • connectionID - Target connection Id
  • options - AddConnectionToGroupOptions contains the optional parameters for the Client.AddConnectionToGroup method.

func (*Client) AddConnectionsToGroups

func (client *Client) AddConnectionsToGroups(ctx context.Context, hub string, groupsToAdd AddToGroupsRequest, options *AddConnectionsToGroupsOptions) (AddConnectionsToGroupsResponse, error)

AddConnectionsToGroups - Add filtered connections to multiple groups. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • groupsToAdd - Target groups and connection filter.
  • options - AddConnectionsToGroupsOptions contains the optional parameters for the Client.AddConnectionsToGroups method.

func (*Client) AddUserToGroup

func (client *Client) AddUserToGroup(ctx context.Context, hub string, group string, userID string, options *AddUserToGroupOptions) (AddUserToGroupResponse, error)

AddUserToGroup - Add a user to the target group. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • group - Target group name, which length should be greater than 0 and less than 1025.
  • userID - Target user Id.
  • options - AddUserToGroupOptions contains the optional parameters for the Client.AddUserToGroup method.

func (*Client) CloseAllConnections

func (client *Client) CloseAllConnections(ctx context.Context, hub string, options *CloseAllConnectionsOptions) (CloseAllConnectionsResponse, error)

CloseAllConnections - Close the connections in the hub. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • options - CloseAllConnectionsOptions contains the optional parameters for the Client.CloseAllConnections method.

func (*Client) CloseConnection

func (client *Client) CloseConnection(ctx context.Context, hub string, connectionID string, options *CloseConnectionOptions) (CloseConnectionResponse, error)

CloseConnection - Close the client connection. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • connectionID - Target connection Id.
  • options - CloseConnectionOptions contains the optional parameters for the Client.CloseConnection method.

func (*Client) CloseGroupConnections

func (client *Client) CloseGroupConnections(ctx context.Context, hub string, group string, options *CloseGroupConnectionsOptions) (CloseGroupConnectionsResponse, error)

CloseGroupConnections - Close connections in the specific group. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • group - Target group name, which length should be greater than 0 and less than 1025.
  • options - CloseGroupConnectionsOptions contains the optional parameters for the Client.CloseGroupConnections method.

func (*Client) CloseUserConnections

func (client *Client) CloseUserConnections(ctx context.Context, hub string, userID string, options *CloseUserConnectionsOptions) (CloseUserConnectionsResponse, error)

CloseUserConnections - Close connections for the specific user. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • userID - The user Id.
  • options - CloseUserConnectionsOptions contains the optional parameters for the Client.CloseUserConnections method.

func (*Client) GenerateClientAccessURL

func (c *Client) GenerateClientAccessURL(ctx context.Context, hub string, options *GenerateClientAccessURLOptions) (*GenerateClientAccessURLResponse, error)

GenerateClientAccessURL - generate URL for the WebSocket clients

  • hub - The hub name.
  • options - GenerateClientAccessUrlOptions contains the optional parameters for the Client.GenerateClientAccessURL method.

func (*Client) GrantPermission

func (client *Client) GrantPermission(ctx context.Context, hub string, permission Permission, connectionID string, options *GrantPermissionOptions) (GrantPermissionResponse, error)

GrantPermission - Grant permission to the connection. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • permission - The permission: current supported actions are joinLeaveGroup and sendToGroup.
  • connectionID - Target connection Id.
  • options - GrantPermissionOptions contains the optional parameters for the Client.GrantPermission method.

func (*Client) RemoveConnectionFromAllGroups

func (client *Client) RemoveConnectionFromAllGroups(ctx context.Context, hub string, connectionID string, options *RemoveConnectionFromAllGroupsOptions) (RemoveConnectionFromAllGroupsResponse, error)

RemoveConnectionFromAllGroups - Remove a connection from all groups. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • connectionID - Target connection Id.
  • options - RemoveConnectionFromAllGroupsOptions contains the optional parameters for the Client.RemoveConnectionFromAllGroups method.

func (*Client) RemoveConnectionFromGroup

func (client *Client) RemoveConnectionFromGroup(ctx context.Context, hub string, group string, connectionID string, options *RemoveConnectionFromGroupOptions) (RemoveConnectionFromGroupResponse, error)

RemoveConnectionFromGroup - Remove a connection from the target group. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • group - Target group name, which length should be greater than 0 and less than 1025.
  • connectionID - Target connection Id.
  • options - RemoveConnectionFromGroupOptions contains the optional parameters for the Client.RemoveConnectionFromGroup method.

func (*Client) RemoveConnectionsFromGroups

func (client *Client) RemoveConnectionsFromGroups(ctx context.Context, hub string, groupsToRemove RemoveFromGroupsRequest, options *RemoveConnectionsFromGroupsOptions) (RemoveConnectionsFromGroupsResponse, error)

RemoveConnectionsFromGroups - Remove filtered connections from multiple groups. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • groupsToRemove - Target groups and connection filter.
  • options - RemoveConnectionsFromGroupsOptions contains the optional parameters for the Client.RemoveConnectionsFromGroups method.

func (*Client) RemoveUserFromAllGroups

func (client *Client) RemoveUserFromAllGroups(ctx context.Context, hub string, userID string, options *RemoveUserFromAllGroupsOptions) (RemoveUserFromAllGroupsResponse, error)

RemoveUserFromAllGroups - Remove a user from all groups. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • userID - Target user Id.
  • options - RemoveUserFromAllGroupsOptions contains the optional parameters for the Client.RemoveUserFromAllGroups method.

func (*Client) RemoveUserFromGroup

func (client *Client) RemoveUserFromGroup(ctx context.Context, hub string, group string, userID string, options *RemoveUserFromGroupOptions) (RemoveUserFromGroupResponse, error)

RemoveUserFromGroup - Remove a user from the target group. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • group - Target group name, which length should be greater than 0 and less than 1025.
  • userID - Target user Id.
  • options - RemoveUserFromGroupOptions contains the optional parameters for the Client.RemoveUserFromGroup method.

func (*Client) RevokePermission

func (client *Client) RevokePermission(ctx context.Context, hub string, permission Permission, connectionID string, options *RevokePermissionOptions) (RevokePermissionResponse, error)

RevokePermission - Revoke permission for the connection. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • permission - The permission: current supported actions are joinLeaveGroup and sendToGroup.
  • connectionID - Target connection Id.
  • options - RevokePermissionOptions contains the optional parameters for the Client.RevokePermission method.

func (*Client) SendToAll

func (client *Client) SendToAll(ctx context.Context, hub string, contentType ContentType, message io.ReadSeekCloser, options *SendToAllOptions) (SendToAllResponse, error)

SendToAll - Broadcast content inside request body to all the connected client connections. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • contentType - Upload file type
  • message - The payload body.
  • options - SendToAllOptions contains the optional parameters for the Client.SendToAll method.

func (*Client) SendToConnection

func (client *Client) SendToConnection(ctx context.Context, hub string, connectionID string, contentType ContentType, message io.ReadSeekCloser, options *SendToConnectionOptions) (SendToConnectionResponse, error)

SendToConnection - Send content inside request body to the specific connection. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • connectionID - The connection Id.
  • contentType - Upload file type
  • message - The payload body.
  • options - SendToConnectionOptions contains the optional parameters for the Client.SendToConnection method.

func (*Client) SendToGroup

func (client *Client) SendToGroup(ctx context.Context, hub string, group string, contentType ContentType, message io.ReadSeekCloser, options *SendToGroupOptions) (SendToGroupResponse, error)

SendToGroup - Send content inside request body to a group of connections. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • group - Target group name, which length should be greater than 0 and less than 1025.
  • contentType - Upload file type
  • message - The payload body.
  • options - SendToGroupOptions contains the optional parameters for the Client.SendToGroup method.

func (*Client) SendToUser

func (client *Client) SendToUser(ctx context.Context, hub string, userID string, contentType ContentType, message io.ReadSeekCloser, options *SendToUserOptions) (SendToUserResponse, error)

SendToUser - Send content inside request body to the specific user. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2023-07-01

  • hub - Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
  • userID - The user Id.
  • contentType - Upload file type
  • message - The payload body.
  • options - SendToUserOptions contains the optional parameters for the Client.SendToUser method.

type ClientOptions

type ClientOptions struct {
	azcore.ClientOptions
}

ClientOptions contains optional settings for Client

type CloseAllConnectionsOptions

type CloseAllConnectionsOptions struct {
	// Exclude these connectionIds when closing the connections in the hub.
	Excluded []string

	// The reason closing the client connection.
	Reason *string
}

CloseAllConnectionsOptions contains the optional parameters for the Client.CloseAllConnections method.

type CloseAllConnectionsResponse

type CloseAllConnectionsResponse struct {
}

CloseAllConnectionsResponse contains the response from method Client.CloseAllConnections.

type CloseConnectionOptions

type CloseConnectionOptions struct {
	// The reason closing the client connection.
	Reason *string
}

CloseConnectionOptions contains the optional parameters for the Client.CloseConnection method.

type CloseConnectionResponse

type CloseConnectionResponse struct {
}

CloseConnectionResponse contains the response from method Client.CloseConnection.

type CloseGroupConnectionsOptions

type CloseGroupConnectionsOptions struct {
	// Exclude these connectionIds when closing the connections in the group.
	Excluded []string

	// The reason closing the client connection.
	Reason *string
}

CloseGroupConnectionsOptions contains the optional parameters for the Client.CloseGroupConnections method.

type CloseGroupConnectionsResponse

type CloseGroupConnectionsResponse struct {
}

CloseGroupConnectionsResponse contains the response from method Client.CloseGroupConnections.

type CloseUserConnectionsOptions

type CloseUserConnectionsOptions struct {
	// Exclude these connectionIds when closing the connections for the user.
	Excluded []string

	// The reason closing the client connection.
	Reason *string
}

CloseUserConnectionsOptions contains the optional parameters for the Client.CloseUserConnections method.

type CloseUserConnectionsResponse

type CloseUserConnectionsResponse struct {
}

CloseUserConnectionsResponse contains the response from method Client.CloseUserConnections.

type ConnectionExistsOptions

type ConnectionExistsOptions struct {
}

ConnectionExistsOptions contains the optional parameters for the Client.ConnectionExists method.

type ConnectionExistsResponse

type ConnectionExistsResponse struct {
}

ConnectionExistsResponse contains the response from method Client.ConnectionExists.

type ContentType

type ContentType string

ContentType - Content type for upload

const (
	// ContentTypeApplicationJSON - Content Type 'application/json'
	ContentTypeApplicationJSON ContentType = "application/json"
	// ContentTypeApplicationOctetStream - Content Type 'application/octet-stream'
	ContentTypeApplicationOctetStream ContentType = "application/octet-stream"
	// ContentTypeTextPlain - Content Type 'text/plain'
	ContentTypeTextPlain ContentType = "text/plain"
)

func PossibleContentTypeValues

func PossibleContentTypeValues() []ContentType

PossibleContentTypeValues returns the possible values for the ContentType const type.

type GenerateClientAccessURLOptions

type GenerateClientAccessURLOptions struct {
	// UserID is the user ID for the client.
	UserID string

	// Roles are the roles that the connection with the generated token will have.
	// Roles give the client initial permissions to leave, join, or publish to groups when using PubSub subprotocol.
	// Possible role values:
	// - webpubsub.joinLeaveGroup: the client can join or leave any group.
	// - webpubsub.sendToGroup: the client can send messages to any group.
	// - webpubsub.joinLeaveGroup.<group>: the client can join or leave group <group>.
	// - webpubsub.sendToGroup.<group>: the client can send messages to group <group>.
	// More info: https://azure.github.io/azure-webpubsub/references/pubsub-websocket-subprotocol#permissions
	Roles []string

	// ExpirationTimeInMinutes is the number of minutes until the token expires. Default value(60 minutes) is used if the value is 0.
	ExpirationTimeInMinutes int32

	// Groups are the groups to join when the client connects.
	Groups []string
}

GenerateClientAccessURLOptions represents the options for generating a client access url

type GenerateClientAccessURLResponse

type GenerateClientAccessURLResponse struct {
	// The client token
	Token string
	// The base URL for the client to connect to
	BaseURL string
	// The URL client connects to with access_token query string
	URL string
}

GenerateClientAccessURLResponse represents the response type for the generated client access url

type GenerateClientTokenOptions

type GenerateClientTokenOptions struct {
	// Groups that the connection will join when it connects.
	Group []string

	// The expire time of the generated token.
	MinutesToExpire *int32

	// Roles that the connection with the generated token will have.
	Role []string

	// User Id.
	UserID *string
}

GenerateClientTokenOptions contains the optional parameters for the Client.GenerateClientToken method.

type GenerateClientTokenResponse

type GenerateClientTokenResponse struct {
	// The response object containing the token for the client
	TokenResponse
}

GenerateClientTokenResponse contains the response from method Client.GenerateClientToken.

type GrantPermissionOptions

type GrantPermissionOptions struct {
	// The meaning of the target depends on the specific permission. For joinLeaveGroup and sendToGroup, targetName is a required
	// parameter standing for the group name.
	TargetName *string
}

GrantPermissionOptions contains the optional parameters for the Client.GrantPermission method.

type GrantPermissionResponse

type GrantPermissionResponse struct {
}

GrantPermissionResponse contains the response from method Client.GrantPermission.

type GroupExistsOptions

type GroupExistsOptions struct {
}

GroupExistsOptions contains the optional parameters for the Client.GroupExists method.

type GroupExistsResponse

type GroupExistsResponse struct {
}

GroupExistsResponse contains the response from method Client.GroupExists.

type Permission

type Permission string

Permission contains the allowed permissions

const (
	PermissionJoinLeaveGroup Permission = "joinLeaveGroup"
	PermissionSendToGroup    Permission = "sendToGroup"
)

func PossiblePermissionValues

func PossiblePermissionValues() []Permission

PossiblePermissionValues returns the possible values for the Permission const type.

type RemoveConnectionFromAllGroupsOptions

type RemoveConnectionFromAllGroupsOptions struct {
}

RemoveConnectionFromAllGroupsOptions contains the optional parameters for the Client.RemoveConnectionFromAllGroups method.

type RemoveConnectionFromAllGroupsResponse

type RemoveConnectionFromAllGroupsResponse struct {
}

RemoveConnectionFromAllGroupsResponse contains the response from method Client.RemoveConnectionFromAllGroups.

type RemoveConnectionFromGroupOptions

type RemoveConnectionFromGroupOptions struct {
}

RemoveConnectionFromGroupOptions contains the optional parameters for the Client.RemoveConnectionFromGroup method.

type RemoveConnectionFromGroupResponse

type RemoveConnectionFromGroupResponse struct {
}

RemoveConnectionFromGroupResponse contains the response from method Client.RemoveConnectionFromGroup.

type RemoveConnectionsFromGroupsOptions

type RemoveConnectionsFromGroupsOptions struct {
}

RemoveConnectionsFromGroupsOptions contains the optional parameters for the Client.RemoveConnectionsFromGroups method.

type RemoveConnectionsFromGroupsResponse

type RemoveConnectionsFromGroupsResponse struct {
}

RemoveConnectionsFromGroupsResponse contains the response from method Client.RemoveConnectionsFromGroups.

type RemoveFromGroupsRequest

type RemoveFromGroupsRequest struct {
	// An OData filter which target connections satisfy
	Filter *string

	// A list of groups which target connections will be removed from
	Groups []string
}

RemoveFromGroupsRequest - The request object containing targets groups and a connection filter

func (RemoveFromGroupsRequest) MarshalJSON

func (r RemoveFromGroupsRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type RemoveFromGroupsRequest.

func (*RemoveFromGroupsRequest) UnmarshalJSON

func (r *RemoveFromGroupsRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type RemoveFromGroupsRequest.

type RemoveUserFromAllGroupsOptions

type RemoveUserFromAllGroupsOptions struct {
}

RemoveUserFromAllGroupsOptions contains the optional parameters for the Client.RemoveUserFromAllGroups method.

type RemoveUserFromAllGroupsResponse

type RemoveUserFromAllGroupsResponse struct {
}

RemoveUserFromAllGroupsResponse contains the response from method Client.RemoveUserFromAllGroups.

type RemoveUserFromGroupOptions

type RemoveUserFromGroupOptions struct {
}

RemoveUserFromGroupOptions contains the optional parameters for the Client.RemoveUserFromGroup method.

type RemoveUserFromGroupResponse

type RemoveUserFromGroupResponse struct {
}

RemoveUserFromGroupResponse contains the response from method Client.RemoveUserFromGroup.

type RevokePermissionOptions

type RevokePermissionOptions struct {
	// The meaning of the target depends on the specific permission. For joinLeaveGroup and sendToGroup, targetName is a required
	// parameter standing for the group name.
	TargetName *string
}

RevokePermissionOptions contains the optional parameters for the Client.RevokePermission method.

type RevokePermissionResponse

type RevokePermissionResponse struct {
}

RevokePermissionResponse contains the response from method Client.RevokePermission.

type SendToAllOptions

type SendToAllOptions struct {
	// Excluded connection Ids.
	Excluded []string

	// Following OData filter syntax to filter out the subscribers receiving the messages.
	Filter *string

	// The time-to-live (TTL) value in seconds for messages sent to the service. 0 is the default value, which means the message
	// never expires. 300 is the maximum value. If this parameter is non-zero,
	// messages that are not consumed by the client within the specified TTL will be dropped by the service. This parameter can
	// help when the client's bandwidth is limited.
	MessageTTLSeconds *int32
}

SendToAllOptions contains the optional parameters for the Client.SendToAll method.

type SendToAllResponse

type SendToAllResponse struct {
}

SendToAllResponse contains the response from method Client.SendToAll.

type SendToConnectionOptions

type SendToConnectionOptions struct {
	// The time-to-live (TTL) value in seconds for messages sent to the service. 0 is the default value, which means the message
	// never expires. 300 is the maximum value. If this parameter is non-zero,
	// messages that are not consumed by the client within the specified TTL will be dropped by the service. This parameter can
	// help when the client's bandwidth is limited.
	MessageTTLSeconds *int32
}

SendToConnectionOptions contains the optional parameters for the Client.SendToConnection method.

type SendToConnectionResponse

type SendToConnectionResponse struct {
}

SendToConnectionResponse contains the response from method Client.SendToConnection.

type SendToGroupOptions

type SendToGroupOptions struct {
	// Excluded connection Ids
	Excluded []string

	// Following OData filter syntax to filter out the subscribers receiving the messages.
	Filter *string

	// The time-to-live (TTL) value in seconds for messages sent to the service. 0 is the default value, which means the message
	// never expires. 300 is the maximum value. If this parameter is non-zero,
	// messages that are not consumed by the client within the specified TTL will be dropped by the service. This parameter can
	// help when the client's bandwidth is limited.
	MessageTTLSeconds *int32
}

SendToGroupOptions contains the optional parameters for the Client.SendToGroup method.

type SendToGroupResponse

type SendToGroupResponse struct {
}

SendToGroupResponse contains the response from method Client.SendToGroup.

type SendToUserOptions

type SendToUserOptions struct {
	// Following OData filter syntax to filter out the subscribers receiving the messages.
	Filter *string

	// The time-to-live (TTL) value in seconds for messages sent to the service. 0 is the default value, which means the message
	// never expires. 300 is the maximum value. If this parameter is non-zero,
	// messages that are not consumed by the client within the specified TTL will be dropped by the service. This parameter can
	// help when the client's bandwidth is limited.
	MessageTTLSeconds *int32
}

SendToUserOptions contains the optional parameters for the Client.SendToUser method.

type SendToUserResponse

type SendToUserResponse struct {
}

SendToUserResponse contains the response from method Client.SendToUser.

type TokenResponse

type TokenResponse struct {
	// The token value for the WebSocket client to connect to the service
	Token *string
}

TokenResponse - The response object containing the token for the client

func (TokenResponse) MarshalJSON

func (c TokenResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type TokenResponse.

func (*TokenResponse) UnmarshalJSON

func (c *TokenResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type TokenResponse.

type UserExistsOptions

type UserExistsOptions struct {
}

UserExistsOptions contains the optional parameters for the Client.UserExists method.

type UserExistsResponse

type UserExistsResponse struct {
}

UserExistsResponse contains the response from method Client.UserExists.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL