HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/uaclient/api/u/apt_news/current_news/v1.py
from typing import Optional

from uaclient.api.api import APIEndpoint
from uaclient.api.data_types import AdditionalInfo
from uaclient.config import UAConfig
from uaclient.data_types import DataObject, Field, StringDataValue
from uaclient.files.state_files import apt_news_raw_file


class CurrentNewsResult(DataObject, AdditionalInfo):
    fields = [
        Field("current_news", StringDataValue, required=False),
    ]

    def __init__(self, *, current_news: Optional[str]):
        self.current_news = current_news


def current_news() -> CurrentNewsResult:
    return _current_news(UAConfig())


def _current_news(cfg: UAConfig) -> CurrentNewsResult:
    return CurrentNewsResult(current_news=apt_news_raw_file.read())


endpoint = APIEndpoint(
    version="v1",
    name="CurrentNews",
    fn=_current_news,
    options_cls=None,
)