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 ¶
- type APIError
- type AgentGroupsResource
- func (r *AgentGroupsResource) AddAgent(ctx context.Context, groupID, agentID string) (*managerapi.AgentGroupAdditionResponse, error)
- func (r *AgentGroupsResource) Create(ctx context.Context, body managerapi.RestCreateAgentGroup) (*managerapi.AgentGroupItemResponse, error)
- func (r *AgentGroupsResource) Delete(ctx context.Context, id string) error
- func (r *AgentGroupsResource) Get(ctx context.Context, id string) (*managerapi.AgentGroupItemResponse, error)
- func (r *AgentGroupsResource) List(ctx context.Context, pageSize int) iter.Seq2[managerapi.AgentGroup, error]
- func (r *AgentGroupsResource) ListAll(ctx context.Context, pageSize int) ([]managerapi.AgentGroup, error)
- func (r *AgentGroupsResource) Update(ctx context.Context, id string, body managerapi.RestUpdateAgentGroup) (*managerapi.AgentGroupItemResponse, error)
- type AgentsResource
- func (r *AgentsResource) Create(ctx context.Context, body managerapi.RestCreateAgent) (*managerapi.AgentItemResponse, error)
- func (r *AgentsResource) Delete(ctx context.Context, id string) error
- func (r *AgentsResource) Get(ctx context.Context, id string) (*managerapi.AgentItemResponse, error)
- func (r *AgentsResource) List(ctx context.Context, q ListAgentsQuery) iter.Seq2[managerapi.Agent, error]
- func (r *AgentsResource) ListAll(ctx context.Context, q ListAgentsQuery) ([]managerapi.Agent, error)
- func (r *AgentsResource) Update(ctx context.Context, id string, body managerapi.RestUpdateAgent) (*managerapi.AgentItemResponse, error)
- func (r *AgentsResource) UpdateStatus(ctx context.Context, id string, status managerapi.UpdateAgentStatusRequest) (*managerapi.AgentStatus, error)
- type Auth
- type CallsResource
- type Environment
- type InterruptTarget
- type ListAgentsQuery
- type ListTasksQuery
- type ListUsersQuery
- type ManagerClient
- type MetricsResource
- func (r *MetricsResource) Describe(ctx context.Context, id string) (*managerapi.MetricDefinitionItemResponse, error)
- func (r *MetricsResource) Get(ctx context.Context, id string) (*managerapi.MetricResponse, error)
- func (r *MetricsResource) ListIds(ctx context.Context) (*managerapi.MetricIdItemsResponse, error)
- func (r *MetricsResource) Push(ctx context.Context) (*managerapi.MetricRequestPushResponse, error)
- func (r *MetricsResource) Reset(ctx context.Context) (*managerapi.MetricResetCountersResponse, error)
- type Options
- type ReportingResource
- func (r *ReportingResource) List(ctx context.Context, params managerapi.ListReportingCallsParams) iter.Seq2[managerapi.Call, error]
- func (r *ReportingResource) ListAll(ctx context.Context, params managerapi.ListReportingCallsParams) ([]managerapi.Call, error)
- func (r *ReportingResource) Simple(ctx context.Context, params managerapi.ListAllSimpleReportingCallsParams) iter.Seq2[managerapi.ReportingCall, error]
- func (r *ReportingResource) SimpleAll(ctx context.Context, params managerapi.ListAllSimpleReportingCallsParams) ([]managerapi.ReportingCall, error)
- func (r *ReportingResource) SimpleAllByType(ctx context.Context, reportType managerapi.SimpleReportingReportType, ...) ([]managerapi.ReportingCall, error)
- func (r *ReportingResource) SimpleByType(ctx context.Context, reportType managerapi.SimpleReportingReportType, ...) iter.Seq2[managerapi.ReportingCall, error]
- type TaskSchedulesResource
- func (r *TaskSchedulesResource) Create(ctx context.Context, schedule taskscheduleapi.SubmitTaskSchedule) error
- func (r *TaskSchedulesResource) Delete(ctx context.Context, name string) error
- func (r *TaskSchedulesResource) Get(ctx context.Context, name string) (*taskscheduleapi.TaskSchedule, error)
- func (r *TaskSchedulesResource) List(ctx context.Context) (*taskscheduleapi.TaskScheduleList, error)
- type TasksResource
- func (r *TasksResource) Create(ctx context.Context, task taskautomationapi.SubmitTask) (*taskautomationapi.Task, error)
- func (r *TasksResource) CreateFromTemplate(ctx context.Context, template string, ...) (*taskautomationapi.Task, error)
- func (r *TasksResource) Get(ctx context.Context, taskID string) (*taskautomationapi.Task, error)
- func (r *TasksResource) Interrupt(ctx context.Context, taskID string, target InterruptTarget, ...) error
- func (r *TasksResource) List(ctx context.Context, q ListTasksQuery) iter.Seq2[taskautomationapi.Task, error]
- func (r *TasksResource) ListAll(ctx context.Context, q ListTasksQuery) ([]taskautomationapi.Task, error)
- func (r *TasksResource) Update(ctx context.Context, taskID string, task taskautomationapi.Task) (*taskautomationapi.Task, error)
- type TokenResponse
- type UsersResource
- func (r *UsersResource) Create(ctx context.Context, user managerapi.CreateManagedUserRequest) (*managerapi.ManagedUserItemResponse, error)
- func (r *UsersResource) Delete(ctx context.Context, emails []string) error
- func (r *UsersResource) Disable(ctx context.Context, emails []string) error
- func (r *UsersResource) Enable(ctx context.Context, emails []string) error
- func (r *UsersResource) List(ctx context.Context, q ListUsersQuery) iter.Seq2[managerapi.ManagedUser, error]
- func (r *UsersResource) ListAll(ctx context.Context, q ListUsersQuery) ([]managerapi.ManagedUser, error)
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.
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
func (r *AgentGroupsResource) Create(ctx context.Context, body managerapi.RestCreateAgentGroup) (*managerapi.AgentGroupItemResponse, error)
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
func (r *AgentGroupsResource) Get(ctx context.Context, id string) (*managerapi.AgentGroupItemResponse, error)
Get returns an agent group by id.
func (*AgentGroupsResource) List ¶ added in v0.3.0
func (r *AgentGroupsResource) List(ctx context.Context, pageSize int) iter.Seq2[managerapi.AgentGroup, error]
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
func (r *AgentGroupsResource) Update(ctx context.Context, id string, body managerapi.RestUpdateAgentGroup) (*managerapi.AgentGroupItemResponse, error)
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
func (r *AgentsResource) Create(ctx context.Context, body managerapi.RestCreateAgent) (*managerapi.AgentItemResponse, error)
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
func (r *AgentsResource) Get(ctx context.Context, id string) (*managerapi.AgentItemResponse, error)
Get returns an agent by id.
func (*AgentsResource) List ¶ added in v0.3.0
func (r *AgentsResource) List(ctx context.Context, q ListAgentsQuery) iter.Seq2[managerapi.Agent, error]
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
func (r *AgentsResource) ListAll(ctx context.Context, q ListAgentsQuery) ([]managerapi.Agent, error)
ListAll collects every agent into a slice (convenience over List).
func (*AgentsResource) Update ¶ added in v0.3.0
func (r *AgentsResource) Update(ctx context.Context, id string, body managerapi.RestUpdateAgent) (*managerapi.AgentItemResponse, error)
Update updates an agent.
func (*AgentsResource) UpdateStatus ¶ added in v0.3.0
func (r *AgentsResource) UpdateStatus(ctx context.Context, id string, status managerapi.UpdateAgentStatusRequest) (*managerapi.AgentStatus, error)
UpdateStatus updates an agent's status (enabled flag and/or presence).
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 ¶
APIKey authenticates with the X-Auth-Access-Id / X-Auth-Access-Token header pair (the primary server-to-server mode).
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
type InterruptTarget = taskautomationapi.InterruptionTargetStates
InterruptTarget is the state a manager-interrupt transitions a task to.
const ( InterruptCancel InterruptTarget = taskautomationapi.InterruptionTargetStatesCanceled InterruptComplete InterruptTarget = taskautomationapi.InterruptionTargetStatesCompleted InterruptFail InterruptTarget = taskautomationapi.InterruptionTargetStatesFailed )
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 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
// Tasks is the task-automation namespace (/api/v3/tasks).
Tasks *TasksResource
}
ManagerClient is the babelforce manager SDK client. Create one with Connect.
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
func (r *MetricsResource) Describe(ctx context.Context, id string) (*managerapi.MetricDefinitionItemResponse, error)
Describe returns a metric's definition by id.
func (*MetricsResource) Get ¶ added in v0.3.0
func (r *MetricsResource) Get(ctx context.Context, id string) (*managerapi.MetricResponse, error)
Get returns a metric's current value by id.
func (*MetricsResource) ListIds ¶ added in v0.3.0
func (r *MetricsResource) ListIds(ctx context.Context) (*managerapi.MetricIdItemsResponse, error)
ListIds lists the available metric ids.
func (*MetricsResource) Push ¶ added in v0.3.0
func (r *MetricsResource) Push(ctx context.Context) (*managerapi.MetricRequestPushResponse, error)
Push triggers a metrics push.
func (*MetricsResource) Reset ¶ added in v0.3.0
func (r *MetricsResource) Reset(ctx context.Context) (*managerapi.MetricResetCountersResponse, error)
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
func (r *ReportingResource) List(ctx context.Context, params managerapi.ListReportingCallsParams) iter.Seq2[managerapi.Call, error]
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
func (r *ReportingResource) ListAll(ctx context.Context, params managerapi.ListReportingCallsParams) ([]managerapi.Call, error)
ListAll collects every call from the detailed report into a slice (convenience over List).
func (*ReportingResource) Simple ¶ added in v0.3.0
func (r *ReportingResource) Simple(ctx context.Context, params managerapi.ListAllSimpleReportingCallsParams) iter.Seq2[managerapi.ReportingCall, error]
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
func (r *ReportingResource) SimpleAll(ctx context.Context, params managerapi.ListAllSimpleReportingCallsParams) ([]managerapi.ReportingCall, error)
SimpleAll collects every call from the simple report into a slice (convenience over Simple).
func (*ReportingResource) SimpleAllByType ¶ added in v0.3.0
func (r *ReportingResource) SimpleAllByType(ctx context.Context, reportType managerapi.SimpleReportingReportType, params managerapi.ListSimpleReportingCallsParams) ([]managerapi.ReportingCall, error)
SimpleAllByType collects every call from a single report type into a slice.
func (*ReportingResource) SimpleByType ¶ added in v0.3.0
func (r *ReportingResource) SimpleByType(ctx context.Context, reportType managerapi.SimpleReportingReportType, params managerapi.ListSimpleReportingCallsParams) iter.Seq2[managerapi.ReportingCall, error]
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 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
func (r *TaskSchedulesResource) Create(ctx context.Context, schedule taskscheduleapi.SubmitTaskSchedule) error
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
func (r *TaskSchedulesResource) Get(ctx context.Context, name string) (*taskscheduleapi.TaskSchedule, error)
Get returns a task schedule by name.
func (*TaskSchedulesResource) List ¶ added in v0.2.0
func (r *TaskSchedulesResource) List(ctx context.Context) (*taskscheduleapi.TaskScheduleList, error)
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
func (r *TasksResource) Create(ctx context.Context, task taskautomationapi.SubmitTask) (*taskautomationapi.Task, error)
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
func (r *TasksResource) Get(ctx context.Context, taskID string) (*taskautomationapi.Task, error)
Get returns a task by id.
func (*TasksResource) Interrupt ¶ added in v0.2.0
func (r *TasksResource) Interrupt(ctx context.Context, taskID string, target InterruptTarget, action taskautomationapi.ManualActionRequest) error
Interrupt manager-interrupts a task, transitioning it to the given target state.
func (*TasksResource) List ¶ added in v0.2.0
func (r *TasksResource) List(ctx context.Context, q ListTasksQuery) iter.Seq2[taskautomationapi.Task, error]
List returns an iterator over tasks, auto-paginating across pages.
func (*TasksResource) ListAll ¶ added in v0.2.0
func (r *TasksResource) ListAll(ctx context.Context, q ListTasksQuery) ([]taskautomationapi.Task, error)
ListAll collects every task into a slice.
func (*TasksResource) Update ¶ added in v0.2.0
func (r *TasksResource) Update(ctx context.Context, taskID string, task taskautomationapi.Task) (*taskautomationapi.Task, error)
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 UsersResource ¶
type UsersResource struct {
// contains filtered or unexported fields
}
UsersResource is the user-management namespace (/api/v2/users).
func (*UsersResource) Create ¶
func (r *UsersResource) Create(ctx context.Context, user managerapi.CreateManagedUserRequest) (*managerapi.ManagedUserItemResponse, error)
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 ¶
func (r *UsersResource) List(ctx context.Context, q ListUsersQuery) iter.Seq2[managerapi.ManagedUser, error]
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 ¶
func (r *UsersResource) ListAll(ctx context.Context, q ListUsersQuery) ([]managerapi.ManagedUser, error)
ListAll collects every user into a slice (convenience over List).
Source Files
¶
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. |