Skip to main content

Common package for Microsoft Teams

Project description

Microsoft Teams Common Utilities

Shared utilities including HTTP client, logging, storage, and event handling. Provides common functionality used across other Teams SDK packages.

Features

  • HTTP Client: Async HTTP client with token support and interceptors
  • Event System: Type-safe event emitter for application lifecycle management
  • Storage: Local storage implementations for key-value and list data
  • Logging: Console logging with formatting and filtering

HTTP Client

from microsoft_teams.common import Client, ClientOptions

# Create HTTP client
client = Client(ClientOptions(
    base_url="https://api.example.com",
    headers={"User-Agent": "Teams-Bot/1.0"}
))

# Make requests
response = await client.get("/users/me")
data = await client.post("/messages", json={"text": "Hello"})

Event System

from microsoft_teams.common import EventEmitter

# Create type-safe event emitter
emitter = EventEmitter[str]()

# Register handler
def handle_message(data: str):
    print(f"Received: {data}")

subscription_id = emitter.on("message", handle_message)

# Emit event
emitter.emit("message", "Hello World")

# Remove handler
emitter.off(subscription_id)

Storage

from microsoft_teams.common import LocalStorage, ListLocalStorage

# Key-value storage
storage = LocalStorage[str]()
storage.set("key", {"data": "value"})
data = storage.get("key")

# Async operations
await storage.async_set("key", {"data": "value"})
data = await storage.async_get("key")

# List storage
list_storage = ListLocalStorage[str]()
list_storage.append("new-item")
items = list_storage.items()

Logging

The SDK uses Python's standard logging module. The library doesn't configure logging - your application should.

import logging

# Configure logging once at application startup
logging.getLogger().setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(ConsoleFormatter())
logging.getLogger().addHandler(stream_handler)

# Use module-level loggers in your code
logger = logging.getLogger(__name__)
logger.info("Application started")

Custom Filtering

The SDK provides optional filtering as well:

stream_handler.addFilter(ConsoleFilter("microsoft_teams.*"))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

microsoft_teams_common-2.0.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

microsoft_teams_common-2.0.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file microsoft_teams_common-2.0.0.tar.gz.

File metadata

  • Download URL: microsoft_teams_common-2.0.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: RestSharp/106.13.0.0

File hashes

Hashes for microsoft_teams_common-2.0.0.tar.gz
Algorithm Hash digest
SHA256 4b7fb2c7e10577b4b264f9fadb6541d6727cda4a0c9d01f3f536907e4a5e6be9
MD5 c6c53d1add6e5f996715b1da7d9f6328
BLAKE2b-256 20521f6904b45e9f21b487deb182383428d4818b0dc00292e9aece58f56304b4

See more details on using hashes here.

File details

Details for the file microsoft_teams_common-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for microsoft_teams_common-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8907449e2fdcfaa4e7a824befe6dffd47eae82d6480e337a9a5e4502b4af84d
MD5 b13a6dd8c7591bdfee9b1c1bd23d50bb
BLAKE2b-256 3d08f464b1b3a7e614b53127ef4d4899d4ead824c0daade0c5e81297605e6968

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page