Moved devops related code to a separate package.

This commit is contained in:
2025-11-09 19:18:53 +01:00
parent 5412c3ea09
commit 2addc85e40
3 changed files with 1 additions and 9 deletions

1
devops/__init__.py Normal file
View File

@@ -0,0 +1 @@
# devops package

View File

@@ -4,15 +4,11 @@ import requests
import urllib.parse import urllib.parse
from uuid import UUID from uuid import UUID
import logging import logging
from sk.logger import log_entity_creation
DEVOPS_SCOPE = "https://app.vssps.visualstudio.com/.default" DEVOPS_SCOPE = "https://app.vssps.visualstudio.com/.default"
DEVOPS_API_VERSION = "7.1" DEVOPS_API_VERSION = "7.1"
# Get logger. It should be configured by the main application.
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
# log.setLevel(logging.DEBUG)
# log.propagate = False
# Define a class decorator # Define a class decorator
def auto_properties(mapping: dict[str,str]): def auto_properties(mapping: dict[str,str]):
@@ -83,7 +79,6 @@ class Organization():
self._org_url = org_url.rstrip("/") + "/" # Ensure trailing slash self._org_url = org_url.rstrip("/") + "/" # Ensure trailing slash
self._token = token self._token = token
self._api_version = api_version self._api_version = api_version
log_entity_creation(log, Organization, self._org_url)
def get_path(self, path: str, params: dict = {}) -> requests.Response: def get_path(self, path: str, params: dict = {}) -> requests.Response:
return get_url( return get_url(
@@ -131,8 +126,6 @@ class Project():
except ValueError: except ValueError:
raise ValueError(f"Invalid project ID: {self._id}") raise ValueError(f"Invalid project ID: {self._id}")
log_entity_creation(log, Project, self.id)
def get_auto_properties(self): def get_auto_properties(self):
r = get_url( r = get_url(
URL=f"{self._org._org_url}_apis/projects/{self._id}", URL=f"{self._org._org_url}_apis/projects/{self._id}",
@@ -195,7 +188,6 @@ class Repository():
# set other properties if provided # set other properties if provided
self.from_args(**kwargs) # type: ignore[attr-defined] self.from_args(**kwargs) # type: ignore[attr-defined]
log_entity_creation(log, Repository, self.id)
def get_auto_properties(self): def get_auto_properties(self):
id = self._id if hasattr(self, "_id") else self._name # type: ignore[attr-defined] id = self._id if hasattr(self, "_id") else self._name # type: ignore[attr-defined]
@@ -245,7 +237,6 @@ class Item():
self.from_args(**kwargs) # type: ignore[attr-defined] self.from_args(**kwargs) # type: ignore[attr-defined]
if "branch" in kwargs: if "branch" in kwargs:
self._branch = kwargs.get("branch") self._branch = kwargs.get("branch")
log_entity_creation(log, Item, self.path)
@property @property
def branch(self): def branch(self):