Common package for Microsoft Teams
Project description
[!CAUTION] This project is in public preview. We’ll do our best to maintain compatibility, but there may be breaking changes in upcoming releases.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file microsoft_teams_common-2.0.0a31.tar.gz.
File metadata
- Download URL: microsoft_teams_common-2.0.0a31.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: RestSharp/106.13.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
961a784a4ff7c46bc408f93e190cbcf0b2a0697721d7b58aa0ff2034ba12c730
|
|
| MD5 |
683a53d7fc8d8dcca75959933e4c8e2b
|
|
| BLAKE2b-256 |
f315cc76874c600a67a734d13748efc9bc62134801d7f5a003f936e1d6c38683
|
File details
Details for the file microsoft_teams_common-2.0.0a31-py3-none-any.whl.
File metadata
- Download URL: microsoft_teams_common-2.0.0a31-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: RestSharp/106.13.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65b5558d927cdec90562c4ecdcdefd6214faa76d0525ca3d1efa11a6858d7465
|
|
| MD5 |
7f121e9ee6132685ac72f9aabe43bc16
|
|
| BLAKE2b-256 |
1c5de8ad1d244192641edf9531cda353e742c1d5c6ffc43bd18f3ce22357c3a0
|