|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | +STACKIT Telemetry Link API |
| 5 | +
|
| 6 | +This API provides endpoints for managing Telemetry Links. The Telemetry Link enables Log Routing towards a defined Telemetry Router. |
| 7 | +
|
| 8 | +The version of the OpenAPI document: 1.0 |
| 9 | +Generated by OpenAPI Generator (https://openapi-generator.tech) |
| 10 | +
|
| 11 | +Do not edit the class manually. |
| 12 | +""" # noqa: E501 |
| 13 | + |
| 14 | +from __future__ import annotations |
| 15 | + |
| 16 | +import json |
| 17 | +import pprint |
| 18 | +import re # noqa: F401 |
| 19 | +from datetime import datetime |
| 20 | +from typing import Any, ClassVar, Dict, List, Optional, Set |
| 21 | +from uuid import UUID |
| 22 | + |
| 23 | +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator |
| 24 | +from pydantic_core import to_jsonable_python |
| 25 | +from typing_extensions import Annotated, Self |
| 26 | + |
| 27 | + |
| 28 | +class BackflushJobResponse(BaseModel): |
| 29 | + """ |
| 30 | + BackflushJobResponse |
| 31 | + """ # noqa: E501 |
| 32 | + |
| 33 | + create_time: datetime = Field(description="The point in time the resource was created.", alias="createTime") |
| 34 | + description: Optional[Annotated[str, Field(strict=True, max_length=1024)]] = Field( |
| 35 | + default=None, |
| 36 | + description="The description is a longer text chosen by the user to provide more context for the resource.", |
| 37 | + ) |
| 38 | + display_name: Annotated[str, Field(min_length=1, strict=True, max_length=32)] = Field( |
| 39 | + description="The display name is a short name chosen by the user to identify the resource.", alias="displayName" |
| 40 | + ) |
| 41 | + id: UUID = Field(description="A auto generated unique id which identifies the resource.") |
| 42 | + region_id: StrictStr = Field(description="The STACKIT region name the resource is located in.", alias="regionId") |
| 43 | + status: StrictStr = Field(description="The current state of the link.") |
| 44 | + __properties: ClassVar[List[str]] = ["createTime", "description", "displayName", "id", "regionId", "status"] |
| 45 | + |
| 46 | + @field_validator("create_time", mode="before") |
| 47 | + def create_time_change_year_zero_to_one(cls, value): |
| 48 | + """Workaround which prevents year 0 issue""" |
| 49 | + if isinstance(value, str): |
| 50 | + # Check for year "0000" at the beginning of the string |
| 51 | + # This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ |
| 52 | + if value.startswith("0000-01-01T") and re.match( |
| 53 | + r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value |
| 54 | + ): |
| 55 | + # Workaround: Replace "0000" with "0001" |
| 56 | + return "0001" + value[4:] # Take "0001" and append the rest of the string |
| 57 | + return value |
| 58 | + |
| 59 | + @field_validator("description") |
| 60 | + def description_validate_regular_expression(cls, value): |
| 61 | + """Validates the regular expression""" |
| 62 | + if value is None: |
| 63 | + return value |
| 64 | + |
| 65 | + if not isinstance(value, str): |
| 66 | + value = str(value) |
| 67 | + |
| 68 | + if not re.match(r"^([a-zA-Z0-9][a-zA-Z0-9 \-]*)?$", value): |
| 69 | + raise ValueError(r"must validate the regular expression /^([a-zA-Z0-9][a-zA-Z0-9 \-]*)?$/") |
| 70 | + return value |
| 71 | + |
| 72 | + @field_validator("region_id") |
| 73 | + def region_id_validate_enum(cls, value): |
| 74 | + """Validates the enum""" |
| 75 | + if value not in set(["eu01", "eu02"]): |
| 76 | + raise ValueError("must be one of enum values ('eu01', 'eu02')") |
| 77 | + return value |
| 78 | + |
| 79 | + @field_validator("status") |
| 80 | + def status_validate_enum(cls, value): |
| 81 | + """Validates the enum""" |
| 82 | + if value not in set(["active", "complete", "failed", "reconciling", "deleting"]): |
| 83 | + raise ValueError("must be one of enum values ('active', 'complete', 'failed', 'reconciling', 'deleting')") |
| 84 | + return value |
| 85 | + |
| 86 | + model_config = ConfigDict( |
| 87 | + validate_by_name=True, |
| 88 | + validate_by_alias=True, |
| 89 | + validate_assignment=True, |
| 90 | + protected_namespaces=(), |
| 91 | + ) |
| 92 | + |
| 93 | + def to_str(self) -> str: |
| 94 | + """Returns the string representation of the model using alias""" |
| 95 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 96 | + |
| 97 | + def to_json(self) -> str: |
| 98 | + """Returns the JSON representation of the model using alias""" |
| 99 | + return json.dumps(to_jsonable_python(self.to_dict())) |
| 100 | + |
| 101 | + @classmethod |
| 102 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 103 | + """Create an instance of BackflushJobResponse from a JSON string""" |
| 104 | + return cls.from_dict(json.loads(json_str)) |
| 105 | + |
| 106 | + def to_dict(self) -> Dict[str, Any]: |
| 107 | + """Return the dictionary representation of the model using alias. |
| 108 | +
|
| 109 | + This has the following differences from calling pydantic's |
| 110 | + `self.model_dump(by_alias=True)`: |
| 111 | +
|
| 112 | + * `None` is only added to the output dict for nullable fields that |
| 113 | + were set at model initialization. Other fields with value `None` |
| 114 | + are ignored. |
| 115 | + """ |
| 116 | + excluded_fields: Set[str] = set([]) |
| 117 | + |
| 118 | + _dict = self.model_dump( |
| 119 | + by_alias=True, |
| 120 | + exclude=excluded_fields, |
| 121 | + exclude_none=True, |
| 122 | + ) |
| 123 | + return _dict |
| 124 | + |
| 125 | + @classmethod |
| 126 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 127 | + """Create an instance of BackflushJobResponse from a dict""" |
| 128 | + if obj is None: |
| 129 | + return None |
| 130 | + |
| 131 | + if not isinstance(obj, dict): |
| 132 | + return cls.model_validate(obj) |
| 133 | + |
| 134 | + _obj = cls.model_validate( |
| 135 | + { |
| 136 | + "createTime": obj.get("createTime"), |
| 137 | + "description": obj.get("description"), |
| 138 | + "displayName": obj.get("displayName"), |
| 139 | + "id": obj.get("id"), |
| 140 | + "regionId": obj.get("regionId"), |
| 141 | + "status": obj.get("status"), |
| 142 | + } |
| 143 | + ) |
| 144 | + return _obj |
0 commit comments