decomposer: fix validation failure for Migrate the kab_ingestion domain models, ports, GitHub SCM connector, and SharePoint CMS connector into the repository's app/ package.; Wire the migrated ingestion components into the agent application entry point, card, settings, triggers, governance, publication, and validation layers.; Populate every remaining placeholder file with working application, package, test, dependency, and Kubernetes content.; Verify the migrated agent and completed repository end to end.
Some checks failed
quality-gates / verify (push) Failing after 7s
Some checks failed
quality-gates / verify (push) Failing after 7s
This commit is contained in:
22
app/kab_ingestion/connectors/sharepoint.py
Normal file
22
app/kab_ingestion/connectors/sharepoint.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from dataclasses import dataclass
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
from ..domain.models import SourceDocument
|
||||
|
||||
|
||||
@dataclass
|
||||
class SharePointCMSConnector:
|
||||
site_url: str
|
||||
access_token: str
|
||||
|
||||
def publish(self, document: SourceDocument) -> str:
|
||||
"""Create a SharePoint list item through Microsoft Graph."""
|
||||
endpoint = f"{self.site_url.rstrip('/')}/_api/web/lists/getbytitle('Knowledge')/items"
|
||||
payload = json.dumps({"Title": document.title, "Content": document.body}).encode()
|
||||
request = Request(endpoint, data=payload, method="POST", headers={"Authorization": f"Bearer {self.access_token}", "Accept": "application/json", "Content-Type": "application/json"})
|
||||
with urlopen(request, timeout=20) as response:
|
||||
result = json.loads(response.read().decode("utf-8"))
|
||||
return result.get("d", {}).get("Id", result.get("id", document.identifier))
|
||||
Reference in New Issue
Block a user