Documentation
¶
Overview ¶
Package lib acts as the primary entry point for the Microsoft Teams API client library. It adopts a Facade pattern, aggregating specialized services (Teams, Channels, Chats) into a single, cohesive Client.
The package manages the complexity of:
- Authentication (via MSAL and Graph Token Providers).
- Dependency Injection (wiring APIs, Caches, and Resolvers).
- Caching strategies (transparently wrapping operations with caching layers).
Usage: Initialize the Client using NewClient for a standard setup. Alternatively, if you need only specific services, use:
- NewTeamServiceFromGraphClient for Teams service.
- NewChannelServiceFromGraphClient for Channels service.
- NewChatServiceFromGraphClient for Chats service.
Always ensure to call Close() upon application shutdown to flush any background cache operations.
Index ¶
- func Close()
- func NewChannelServiceFromGraphClient(ctx context.Context, authCfg *config.AuthConfig, ...) (channels.Service, error)
- func NewChatServiceFromGraphClient(ctx context.Context, authCfg *config.AuthConfig, ...) (chats.Service, error)
- func NewTeamServiceFromGraphClient(ctx context.Context, authCfg *config.AuthConfig, ...) (teams.Service, error)
- type Client
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close()
Close ensures a graceful shutdown of the library. It waits for any pending background operations (such as asynchronous cache updates) to complete before returning, preventing data loss or race conditions.
func NewChannelServiceFromGraphClient ¶
func NewChannelServiceFromGraphClient(ctx context.Context, authCfg *config.AuthConfig, senderCfg *config.SenderConfig, cacheCfg *config.CacheConfig) (channels.Service, error)
NewChannelServiceFromGraphClient creates a standalone service for Channel operations. Use this if you do not need the full Client wrapper and only want to interact with Channels.
func NewChatServiceFromGraphClient ¶
func NewChatServiceFromGraphClient(ctx context.Context, authCfg *config.AuthConfig, senderCfg *config.SenderConfig, cacheCfg *config.CacheConfig) (chats.Service, error)
NewChatServiceFromGraphClient creates a standalone service for Chat operations. Use this if you do not need the full Client wrapper and only want to interact with Chats.
func NewTeamServiceFromGraphClient ¶
func NewTeamServiceFromGraphClient(ctx context.Context, authCfg *config.AuthConfig, senderCfg *config.SenderConfig, cacheCfg *config.CacheConfig) (teams.Service, error)
NewTeamServiceFromGraphClient creates a standalone service for Team operations. Use this if you do not need the full Client wrapper and only want to interact with Teams.
Types ¶
type Client ¶
Client is the central hub for interacting with the Microsoft Teams ecosystem. It aggregates access to specific domains: Channels, Teams, and Chats, hiding the complexity of underlying Graph API calls and caching mechanisms.
func NewClient ¶
func NewClient(ctx context.Context, authCfg *config.AuthConfig, senderCfg *config.SenderConfig, cacheCfg *config.CacheConfig) (*Client, error)
NewClient initializes a new Client instance with fully configured internal services. It handles the authentication handshake using the provided authCfg and sets up sending and caching behaviors based on senderCfg and cacheCfg.
func NewClientFromGraphClient ¶
func NewClientFromGraphClient(graphClient *graph.GraphServiceClient, senderCfg *config.SenderConfig, cacheCfg *config.CacheConfig) (*Client, error)
NewClientFromGraphClient creates a Client using an existing, pre-configured GraphServiceClient. This is a separated exported constructor mainly for external testing purposes (via mocking Teams API by injection of GraphServiceClient).
It wires up all internal dependencies, including API clients, caching layers, and entity resolvers (e.g., resolving team names to IDs).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package channels provides various channel-related operations.
|
Package channels provides various channel-related operations. |
|
Package chats provides various chat-related operations.
|
Package chats provides various chat-related operations. |
|
Package config holds configuration structs used across the application.
|
Package config holds configuration structs used across the application. |
|
internal
|
|
|
adapter
Package adapter contains mapping helpers that convert Microsoft Graph SDK models into the library's simplified internal models.
|
Package adapter contains mapping helpers that convert Microsoft Graph SDK models into the library's simplified internal models. |
|
api
Package api provides interfaces and implementations for Microsoft Teams operations backed by Microsoft Graph.
|
Package api provides interfaces and implementations for Microsoft Teams operations backed by Microsoft Graph. |
|
auth
Package auth provides an Azure AD (MSAL) token provider implementation backed by a persistent MSAL cache.
|
Package auth provides an Azure AD (MSAL) token provider implementation backed by a persistent MSAL cache. |
|
cacher
Package cacher contains caching utilities for the library, including:
|
Package cacher contains caching utilities for the library, including: |
|
mentions
Package mentions provides helpers for building, validating, and mapping Microsoft Teams @mentions.
|
Package mentions provides helpers for building, validating, and mapping Microsoft Teams @mentions. |
|
pepper
Package pepper provides helpers for obtaining and persisting a secret "pepper" value.
|
Package pepper provides helpers for obtaining and persisting a secret "pepper" value. |
|
resolver
Package resolver provides helpers for resolving user-facing references into Microsoft Graph resource IDs.
|
Package resolver provides helpers for resolving user-facing references into Microsoft Graph resource IDs. |
|
sender
Package sender provides helpers for executing Microsoft Graph requests with retries and timeouts.
|
Package sender provides helpers for executing Microsoft Graph requests with retries and timeouts. |
|
testutil
Package testutil is a generated GoMock package.
|
Package testutil is a generated GoMock package. |
|
util
Package util contains shared helpers used across the project, including:
|
Package util contains shared helpers used across the project, including: |
|
Package models contains simplified Microsoft Teams domain types used by this library.
|
Package models contains simplified Microsoft Teams domain types used by this library. |
|
Package search provides types used to build message-search queries and to represent paginated search results returned from the messaging backend (e.g., Microsoft Graph).
|
Package search provides types used to build message-search queries and to represent paginated search results returned from the messaging backend (e.g., Microsoft Graph). |
|
Package setup provides setup utilities for the application.
|
Package setup provides setup utilities for the application. |
|
Package teams provides team-related operations and abstracts the underlying Microsoft Graph API calls.
|
Package teams provides team-related operations and abstracts the underlying Microsoft Graph API calls. |