webexsdk

package
v2.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MPL-2.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseResponse

func ParseResponse(resp *http.Response, v interface{}) error

ParseResponse parses an HTTP response into the given interface

Types

type Client

type Client struct {

	// Base URL for API requests
	BaseURL *url.URL

	// Configuration for the client
	Config *Config
	// contains filtered or unexported fields
}

Client is the main Webex client struct

func NewClient

func NewClient(accessToken string, config *Config) (*Client, error)

NewClient creates a new Webex client with the given access token and optional configuration

func (*Client) GetAccessToken

func (c *Client) GetAccessToken() string

GetAccessToken returns the access token used for API authentication

func (*Client) GetHTTPClient

func (c *Client) GetHTTPClient() *http.Client

GetHTTPClient returns the HTTP client used for API requests

func (*Client) GetLogger

func (c *Client) GetLogger() Logger

GetLogger returns the logger used by the SDK.

func (*Client) GetPlugin

func (c *Client) GetPlugin(name string) (Plugin, bool)

GetPlugin returns a plugin by name

func (*Client) RegisterPlugin

func (c *Client) RegisterPlugin(plugin Plugin)

RegisterPlugin registers a plugin with the client

func (*Client) Request

func (c *Client) Request(method, path string, params url.Values, body interface{}) (*http.Response, error)

Request performs an HTTP request to the Webex API. The caller is responsible for closing the response body when done.

func (*Client) RequestMultipart

func (c *Client) RequestMultipart(path string, fields []MultipartField, files []MultipartFile) (*http.Response, error)

RequestMultipart performs a multipart/form-data POST request to the Webex API. This is required for local file uploads (e.g., sending messages with attachments). The caller is responsible for closing the response body when done.

func (*Client) RequestWithContext

func (c *Client) RequestWithContext(ctx context.Context, method, path string, params url.Values, body interface{}) (*http.Response, error)

RequestWithContext performs an HTTP request to the Webex API with the given context. The context can be used for per-request timeouts and cancellation. The caller is responsible for closing the response body when done.

func (*Client) RequestWithRetry

func (c *Client) RequestWithRetry(ctx context.Context, method, path string, params url.Values, body interface{}) (*http.Response, error)

RequestWithRetry performs an HTTP request with automatic retry for transient errors. It retries on HTTP 429 (Too Many Requests, respecting Retry-After header) and transient server errors (502, 503, 504) using exponential backoff. The caller is responsible for closing the response body when done.

type Config

type Config struct {
	// BaseURL is the base URL of the Webex API
	BaseURL string

	// Timeout for API requests
	Timeout time.Duration

	// Default headers to include in API requests
	DefaultHeaders map[string]string

	// Custom HTTP client to use instead of the default one
	// If nil, a default client will be created with the specified Timeout
	HttpClient *http.Client

	// MaxRetries is the maximum number of retries for transient errors (429, 502, 503, 504).
	// Set to 0 to disable retries. Default: 3.
	MaxRetries int

	// RetryBaseDelay is the initial delay between retries. Default: 1s.
	// Subsequent retries use exponential backoff (delay * 2^attempt).
	RetryBaseDelay time.Duration

	// Logger is the logger for SDK operations. If nil, the standard library's
	// default logger (log.Default()) is used.
	Logger Logger
}

Config holds the configuration for the Webex client

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default configuration for the Webex client

type Logger

type Logger interface {
	Printf(format string, v ...any)
}

Logger is the interface for SDK logging. Any logger that implements Printf (such as the standard library's *log.Logger) can be used.

type MultipartField

type MultipartField struct {
	Name  string
	Value string
}

MultipartField represents a text field in a multipart request.

type MultipartFile

type MultipartFile struct {
	FieldName string // Form field name (e.g., "files")
	FileName  string // Original filename (e.g., "report.pdf")
	Content   []byte // Raw file bytes
}

MultipartFile represents a file to upload in a multipart request.

type Page

type Page struct {
	Items    []json.RawMessage `json:"items"`
	NextPage string            `json:"nextPage,omitempty"`
	PrevPage string            `json:"prevPage,omitempty"`
	HasNext  bool              `json:"-"`
	HasPrev  bool              `json:"-"`
	Client   *Client           `json:"-"`
	Resource string            `json:"-"`
}

Page represents a paginated response from the Webex API

func NewPage

func NewPage(resp *http.Response, client *Client, resource string) (*Page, error)

NewPage creates a new Page from an HTTP response

func (*Page) Next

func (p *Page) Next() (*Page, error)

Next retrieves the next page of results

func (*Page) Prev

func (p *Page) Prev() (*Page, error)

Prev retrieves the previous page of results

type Plugin

type Plugin interface {
	// Name returns the name of the plugin
	Name() string
}

Plugin represents a Webex API plugin

Jump to

Keyboard shortcuts

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