manager

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

README

manager-sdk-go

Go SDK for the babelforce manager APIs — auth, user & agent management, call reporting, metrics, and task automations.

One client, configured once, exposes resource namespaces over the API. Authentication, paging, and error handling are handled for you.

📖 Docs: https://babelforce.github.io/manager-sdk/

Install

go get github.com/babelforce/manager-sdk-go
import manager "github.com/babelforce/manager-sdk-go"

Usage

mgr, err := manager.Connect(ctx, manager.Options{
    Environment: manager.Production,
    Auth:        manager.APIKey(accessID, accessToken), // or manager.Password(user, pass)
})
if err != nil {
    log.Fatal(err)
}

// list users (auto-paginated)
for user, err := range mgr.Users.List(ctx, manager.ListUsersQuery{}) {
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(user.Email)
}

_, err = mgr.Users.Create(ctx, manager.CreateManagedUserRequest{Email: "new.user@acme.com"})
Authentication
  • manager.APIKey(id, token) — sends X-Auth-Access-Id / X-Auth-Access-Token.
  • manager.Bearer(token) — a token you already hold.
  • manager.Password(user, pass) — OAuth2 password grant with transparent refresh.
Errors

Non-2xx responses return a typed *manager.APIError (Status, Code, Message, Body).

Custom host
manager.Connect(ctx, manager.Options{
    BaseURL: "https://acme.babelforce.com",
    Auth:    manager.Bearer(token),
})

License

Apache-2.0

Documentation

Overview

Package manager is the babelforce manager SDK for Go.

It provides an intuitive, hand-written client over the babelforce manager APIs — auth, user & agent management, call reporting, metrics, and task automations. Configure one ManagerClient with Connect, authenticate once, and use its resource namespaces.

mgr, err := manager.Connect(ctx, manager.Options{
    Environment: manager.Production,
    Auth:        manager.APIKey(accessID, accessToken),
})
for user, err := range mgr.Users.List(ctx, manager.ListUsersQuery{}) {
    if err != nil { return err }
    fmt.Println(user.Email)
}

The low-level clients under gen/ are generated from the OpenAPI specs and are an internal detail; this package is the public surface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	// Status is the HTTP status code.
	Status int
	// Code is the API error code, when the body carries one.
	Code string
	// Message is a human-readable message (from the body when available, else the status text).
	Message string
	// Body is the raw response body.
	Body []byte
}

APIError is returned when the manager API responds with a non-2xx status.

func (*APIError) Error

func (e *APIError) Error() string

type AgentGroupsResource added in v0.3.0

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

AgentGroupsResource is the agent-groups namespace (/api/v2/agents/groups).

func (*AgentGroupsResource) AddAgent added in v0.3.0

func (r *AgentGroupsResource) AddAgent(ctx context.Context, groupID, agentID string) (*managerapi.AgentGroupAdditionResponse, error)

AddAgent adds an agent (by id) to a group.

func (*AgentGroupsResource) Create added in v0.3.0

Create creates an agent group.

func (*AgentGroupsResource) Delete added in v0.3.0

func (r *AgentGroupsResource) Delete(ctx context.Context, id string) error

Delete deletes an agent group by id.

func (*AgentGroupsResource) Get added in v0.3.0

Get returns an agent group by id.

func (*AgentGroupsResource) List added in v0.3.0

List returns an iterator over agent groups, auto-paginating across pages.

func (*AgentGroupsResource) ListAll added in v0.3.0

func (r *AgentGroupsResource) ListAll(ctx context.Context, pageSize int) ([]managerapi.AgentGroup, error)

ListAll collects every agent group into a slice (convenience over List).

func (*AgentGroupsResource) Update added in v0.3.0

Update updates an agent group.

type AgentsResource added in v0.3.0

type AgentsResource struct {

	// Groups is the agent-groups sub-namespace (/api/v2/agents/groups).
	Groups *AgentGroupsResource
	// contains filtered or unexported fields
}

AgentsResource is the agent-management namespace (/api/v2/agents).

func (*AgentsResource) Create added in v0.3.0

Create creates an agent.

func (*AgentsResource) Delete added in v0.3.0

func (r *AgentsResource) Delete(ctx context.Context, id string) error

Delete deletes an agent by id.

func (*AgentsResource) Get added in v0.3.0

Get returns an agent by id.

func (*AgentsResource) List added in v0.3.0

List returns an iterator over agents, auto-paginating across pages.

for agent, err := range mgr.Agents.List(ctx, manager.ListAgentsQuery{}) {
    if err != nil { return err }
    fmt.Println(agent.Name)
}

func (*AgentsResource) ListAll added in v0.3.0

ListAll collects every agent into a slice (convenience over List).

func (*AgentsResource) Update added in v0.3.0

Update updates an agent.

func (*AgentsResource) UpdateStatus added in v0.3.0

UpdateStatus updates an agent's status (enabled flag and/or presence).

type AppActionsResource added in v0.4.0

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

AppActionsResource is the per-application actions (local automations) namespace (/api/v2/applications/{applicationId}/actions).

func (*AppActionsResource) Create added in v0.4.0

Create creates an action in an application.

func (*AppActionsResource) Delete added in v0.4.0

func (r *AppActionsResource) Delete(ctx context.Context, applicationID, id string) error

Delete deletes one of an application's actions.

func (*AppActionsResource) Get added in v0.4.0

Get returns one of an application's actions by id.

func (*AppActionsResource) List added in v0.4.0

func (r *AppActionsResource) List(ctx context.Context, applicationID string, pageSize int) iter.Seq2[managerapi.LocalAutomation, error]

List returns an iterator over an application's actions, auto-paginating across pages.

func (*AppActionsResource) ListAll added in v0.4.0

func (r *AppActionsResource) ListAll(ctx context.Context, applicationID string, pageSize int) ([]managerapi.LocalAutomation, error)

ListAll collects every action of an application into a slice (convenience over List).

func (*AppActionsResource) Update added in v0.4.0

Update updates one of an application's actions.

type ApplicationsResource added in v0.4.0

type ApplicationsResource struct {

	// Actions is the per-application actions (local automations) sub-namespace
	// (/api/v2/applications/{applicationId}/actions).
	Actions *AppActionsResource
	// contains filtered or unexported fields
}

ApplicationsResource is the application (IVR) management namespace (/api/v2/applications).

func (*ApplicationsResource) Create added in v0.4.0

Create creates an application.

func (*ApplicationsResource) Delete added in v0.4.0

func (r *ApplicationsResource) Delete(ctx context.Context, id string) error

Delete deletes an application by id.

func (*ApplicationsResource) DeleteMany added in v0.4.0

DeleteMany bulk-deletes applications by id.

func (*ApplicationsResource) Dispatch added in v0.4.0

Dispatch dispatches the local automations configured at a position in an application.

func (*ApplicationsResource) Get added in v0.4.0

Get returns an application by id.

func (*ApplicationsResource) List added in v0.4.0

List returns an iterator over applications, auto-paginating across pages.

for app, err := range mgr.Applications.List(ctx, manager.ListApplicationsQuery{}) {
    if err != nil { return err }
    fmt.Println(app.Id, app.Name)
}

func (*ApplicationsResource) ListAll added in v0.4.0

ListAll collects every application into a slice (convenience over List).

func (*ApplicationsResource) ListModules added in v0.4.0

ListModules lists the available IVR modules (the building blocks of applications).

func (*ApplicationsResource) Update added in v0.4.0

Update updates an application.

type AuditSettings added in v0.4.0

AuditSettings groups the `audit` settings.

type Auth

type Auth interface {
	// contains filtered or unexported methods
}

Auth describes how the SDK authenticates. Construct one with APIKey, Bearer, or Password.

func APIKey

func APIKey(accessID, accessToken string) Auth

APIKey authenticates with the X-Auth-Access-Id / X-Auth-Access-Token header pair (the primary server-to-server mode).

func Bearer

func Bearer(token string) Auth

Bearer authenticates with a bearer token you already hold.

func Password

func Password(user, pass string) Auth

Password authenticates via the OAuth2 password grant against /oauth/token. The token is fetched lazily on first use and refreshed transparently before it expires. Convenience for interactive/dev use.

type CallsResource added in v0.3.0

type CallsResource struct {
	// Reporting is the call-reporting sub-namespace (/api/v2/calls/reporting).
	Reporting *ReportingResource
}

CallsResource is the call namespace (/api/v2/calls). Today it exposes call reporting; call control may follow.

type Environment

type Environment int

Environment selects a named babelforce host. Target other (e.g. per-customer or non-production) hosts with Options.BaseURL.

const (
	// Production targets https://services.babelforce.com.
	Production Environment = iota
)

type InterruptTarget added in v0.2.0

InterruptTarget is the state a manager-interrupt transitions a task to.

type ListAgentsQuery added in v0.3.0

type ListAgentsQuery struct {
	// Q searches name, group name, number, email, sourceId and integration label at once.
	Q *string
	// Enabled restricts to enabled (true) or disabled (false) agents.
	Enabled *bool
	// Name filters by agent name.
	Name *string
	// Number filters by the agent's number.
	Number *string
	// SourceId filters by integration source id.
	SourceId *string
	// State filters by line status.
	State *managerapi.AgentLineStatus
	// Source filters by source integration.
	Source *string
	// GroupIds restricts to agents in these group id(s).
	GroupIds []string
	// PageSize is the page size (the API's max). Zero uses the server default.
	PageSize int
}

ListAgentsQuery filters an agent listing.

type ListApplicationsQuery added in v0.4.0

type ListApplicationsQuery struct {
	// PageSize is the page size (the API's max). Zero uses the server default.
	PageSize int
}

ListApplicationsQuery filters an application listing.

type ListTasksQuery added in v0.2.0

type ListTasksQuery struct {
	// Filter is a server-side filter expression.
	Filter *string
	// PageSize is the page size (1..100); defaults to 100.
	PageSize int
}

ListTasksQuery filters a task listing.

type ListUsersQuery

type ListUsersQuery struct {
	// Email filters by email address.
	Email *string
}

ListUsersQuery filters a user listing.

type ManagerClient

type ManagerClient struct {
	// Users is the user-management namespace (/api/v2/users).
	Users *UsersResource
	// Agents is the agent-management namespace (/api/v2/agents).
	Agents *AgentsResource
	// Calls is the call namespace (/api/v2/calls), including call reporting.
	Calls *CallsResource
	// Metrics is the metrics namespace (/api/v2/metrics).
	Metrics *MetricsResource
	// Applications is the application (IVR) management namespace (/api/v2/applications).
	Applications *ApplicationsResource
	// Settings is the global-settings namespace (/api/v2/settings).
	Settings *SettingsResource
	// Tasks is the task-automation namespace (/api/v3/tasks).
	Tasks *TasksResource
}

ManagerClient is the babelforce manager SDK client. Create one with Connect.

func Connect

func Connect(_ context.Context, opts Options) (*ManagerClient, error)

Connect creates and configures a client.

type MetricsResource added in v0.3.0

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

MetricsResource is the metrics namespace (/api/v2/metrics).

func (*MetricsResource) Describe added in v0.3.0

Describe returns a metric's definition by id.

func (*MetricsResource) Get added in v0.3.0

Get returns a metric's current value by id.

func (*MetricsResource) ListIds added in v0.3.0

ListIds lists the available metric ids.

func (*MetricsResource) Push added in v0.3.0

Push triggers a metrics push.

func (*MetricsResource) Reset added in v0.3.0

Reset resets the metric counters.

type Options

type Options struct {
	// Environment selects a named host. Ignored when BaseURL is set. Defaults to Production.
	Environment Environment
	// BaseURL overrides the host explicitly (e.g. a per-customer URL).
	BaseURL string
	// Auth is how the client authenticates. Required.
	Auth Auth
	// HTTPClient is the underlying HTTP client. Defaults to http.DefaultClient.
	HTTPClient *http.Client
}

Options configures a ManagerClient.

type ReportingResource added in v0.3.0

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

ReportingResource is the call-reporting namespace (/api/v2/calls/reporting).

The list methods take the generated parameter structs directly (every filter is an optional pointer field); the Page field is managed by the auto-paginator, so leave it unset.

func (*ReportingResource) List added in v0.3.0

List returns an iterator over the detailed call report, auto-paginating across pages.

for call, err := range mgr.Calls.Reporting.List(ctx, managerapi.ListReportingCallsParams{}) {
    if err != nil { return err }
    fmt.Println(call.Id)
}

func (*ReportingResource) ListAll added in v0.3.0

ListAll collects every call from the detailed report into a slice (convenience over List).

func (*ReportingResource) Simple added in v0.3.0

Simple returns an iterator over the simple call report across all report types (/api/v2/calls/reporting/simple), auto-paginating across pages.

func (*ReportingResource) SimpleAll added in v0.3.0

SimpleAll collects every call from the simple report into a slice (convenience over Simple).

func (*ReportingResource) SimpleAllByType added in v0.3.0

SimpleAllByType collects every call from a single report type into a slice.

func (*ReportingResource) SimpleByType added in v0.3.0

SimpleByType returns an iterator over the simple call report for a single report type (/api/v2/calls/reporting/simple/{reportType}), auto-paginating across pages.

type RetentionSettings added in v0.4.0

RetentionSettings groups the `retention` settings.

type Setting added in v0.4.0

type Setting[TGet any, TUpd any] struct {
	// contains filtered or unexported fields
}

Setting is one global-settings group: read its full value with Get, replace it with Update. TGet is the returned value type; TUpd is the (partial, all-optional) update payload type.

func (Setting[TGet, TUpd]) Get added in v0.4.0

func (s Setting[TGet, TUpd]) Get(ctx context.Context) (*TGet, error)

Get reads the current value of this settings group.

func (Setting[TGet, TUpd]) Update added in v0.4.0

func (s Setting[TGet, TUpd]) Update(ctx context.Context, data TUpd) (*TGet, error)

Update replaces this settings group and returns the new value.

type SettingsResource added in v0.4.0

type SettingsResource struct {
	App       AppSettings
	Telephony TelephonySettings
	Audit     AuditSettings
	Ui        UiSettings
	Retention RetentionSettings
}

SettingsResource is the global-settings namespace (/api/v2/settings), grouped by scope.

type TaskSchedulesResource added in v0.2.0

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

TaskSchedulesResource is the recurring task-schedule namespace (/api/v3/tasks/schedules).

func (*TaskSchedulesResource) Create added in v0.2.0

Create creates a task schedule.

func (*TaskSchedulesResource) Delete added in v0.2.0

func (r *TaskSchedulesResource) Delete(ctx context.Context, name string) error

Delete deletes a task schedule by name.

func (*TaskSchedulesResource) Get added in v0.2.0

Get returns a task schedule by name.

func (*TaskSchedulesResource) List added in v0.2.0

List returns all task schedules.

type TasksResource added in v0.2.0

type TasksResource struct {

	// Schedules is the recurring task-schedule namespace (/api/v3/tasks/schedules).
	Schedules *TaskSchedulesResource
	// contains filtered or unexported fields
}

TasksResource is the task-automation namespace (/api/v3/tasks).

func (*TasksResource) Create added in v0.2.0

Create creates a task.

func (*TasksResource) CreateFromTemplate added in v0.2.0

func (r *TasksResource) CreateFromTemplate(ctx context.Context, template string, overrides taskautomationapi.TemplateOverride) (*taskautomationapi.Task, error)

CreateFromTemplate creates a task from a template, with overrides.

func (*TasksResource) Get added in v0.2.0

Get returns a task by id.

func (*TasksResource) Interrupt added in v0.2.0

Interrupt manager-interrupts a task, transitioning it to the given target state.

func (*TasksResource) List added in v0.2.0

List returns an iterator over tasks, auto-paginating across pages.

func (*TasksResource) ListAll added in v0.2.0

ListAll collects every task into a slice.

func (*TasksResource) Update added in v0.2.0

Update updates a task.

type TokenResponse

type TokenResponse struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
	TokenType   string `json:"token_type"`
}

TokenResponse is the OAuth2 token endpoint response.

func PasswordGrant

func PasswordGrant(ctx context.Context, hc *http.Client, baseURL, user, pass, clientID string) (*TokenResponse, error)

PasswordGrant exchanges a username/password for a token via {baseURL}/oauth/token. Exposed for callers who want to manage tokens themselves.

type UiSettings added in v0.4.0

UiSettings groups the `ui` settings.

type UsersResource

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

UsersResource is the user-management namespace (/api/v2/users).

func (*UsersResource) Create

Create creates a user.

func (*UsersResource) Delete

func (r *UsersResource) Delete(ctx context.Context, emails []string) error

Delete deletes the given users (by email).

func (*UsersResource) Disable

func (r *UsersResource) Disable(ctx context.Context, emails []string) error

Disable disables the given users (by email).

func (*UsersResource) Enable

func (r *UsersResource) Enable(ctx context.Context, emails []string) error

Enable enables the given users (by email).

func (*UsersResource) List

List returns an iterator over users, auto-paginating across pages.

for user, err := range mgr.Users.List(ctx, manager.ListUsersQuery{}) {
    if err != nil { return err }
    fmt.Println(user.Email)
}

func (*UsersResource) ListAll

ListAll collects every user into a slice (convenience over List).

Directories

Path Synopsis
Command example lists users against a babelforce environment.
Command example lists users against a babelforce environment.
gen
manager
Package manager provides primitives to interact with the openapi HTTP API.
Package manager provides primitives to interact with the openapi HTTP API.
taskautomation
Package taskautomation provides primitives to interact with the openapi HTTP API.
Package taskautomation provides primitives to interact with the openapi HTTP API.
taskschedule
Package taskschedule provides primitives to interact with the openapi HTTP API.
Package taskschedule provides primitives to interact with the openapi HTTP API.
user
Package user provides primitives to interact with the openapi HTTP API.
Package user provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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