Skip to content

lib

import "github.com/pzsp-teams/lib"

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 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.

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.

type Client struct {
    Channels channels.Service
    Teams    teams.Service
    Chats    chats.Service
}

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).

Generated by gomarkdoc