|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + CDN API |
| 5 | +
|
| 6 | + API used to create and manage your CDN distributions. |
| 7 | +
|
| 8 | + The version of the OpenAPI document: 1beta.0.0 |
| 9 | + Generated by OpenAPI Generator (https://openapi-generator.tech) |
| 10 | +
|
| 11 | + Do not edit the class manually. |
| 12 | +""" # noqa: E501 docstring might be too long |
| 13 | + |
| 14 | +from __future__ import annotations |
| 15 | + |
| 16 | +import json |
| 17 | +import pprint |
| 18 | +from datetime import datetime |
| 19 | +from typing import Any, ClassVar, Dict, List, Optional, Set |
| 20 | + |
| 21 | +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr |
| 22 | +from typing_extensions import Annotated, Self |
| 23 | + |
| 24 | + |
| 25 | +class DistributionLogsRecord(BaseModel): |
| 26 | + """ |
| 27 | + DistributionLogsRecord |
| 28 | + """ |
| 29 | + |
| 30 | + cache_hit: StrictBool = Field(alias="cacheHit") |
| 31 | + data_center_region: StrictStr = Field(alias="dataCenterRegion") |
| 32 | + distribution_id: StrictStr = Field(alias="distributionID") |
| 33 | + host: StrictStr |
| 34 | + path: StrictStr |
| 35 | + request_country_code: Annotated[str, Field(min_length=2, strict=True, max_length=2)] = Field( |
| 36 | + description="ISO 3166-1 A2 compliant country code", alias="requestCountryCode" |
| 37 | + ) |
| 38 | + size: Annotated[int, Field(strict=True, ge=0)] |
| 39 | + status_code: StrictInt = Field(alias="statusCode") |
| 40 | + timestamp: datetime |
| 41 | + __properties: ClassVar[List[str]] = [ |
| 42 | + "cacheHit", |
| 43 | + "dataCenterRegion", |
| 44 | + "distributionID", |
| 45 | + "host", |
| 46 | + "path", |
| 47 | + "requestCountryCode", |
| 48 | + "size", |
| 49 | + "statusCode", |
| 50 | + "timestamp", |
| 51 | + ] |
| 52 | + |
| 53 | + model_config = ConfigDict( |
| 54 | + populate_by_name=True, |
| 55 | + validate_assignment=True, |
| 56 | + protected_namespaces=(), |
| 57 | + ) |
| 58 | + |
| 59 | + def to_str(self) -> str: |
| 60 | + """Returns the string representation of the model using alias""" |
| 61 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 62 | + |
| 63 | + def to_json(self) -> str: |
| 64 | + """Returns the JSON representation of the model using alias""" |
| 65 | + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead |
| 66 | + return json.dumps(self.to_dict()) |
| 67 | + |
| 68 | + @classmethod |
| 69 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 70 | + """Create an instance of DistributionLogsRecord from a JSON string""" |
| 71 | + return cls.from_dict(json.loads(json_str)) |
| 72 | + |
| 73 | + def to_dict(self) -> Dict[str, Any]: |
| 74 | + """Return the dictionary representation of the model using alias. |
| 75 | +
|
| 76 | + This has the following differences from calling pydantic's |
| 77 | + `self.model_dump(by_alias=True)`: |
| 78 | +
|
| 79 | + * `None` is only added to the output dict for nullable fields that |
| 80 | + were set at model initialization. Other fields with value `None` |
| 81 | + are ignored. |
| 82 | + """ |
| 83 | + excluded_fields: Set[str] = set([]) |
| 84 | + |
| 85 | + _dict = self.model_dump( |
| 86 | + by_alias=True, |
| 87 | + exclude=excluded_fields, |
| 88 | + exclude_none=True, |
| 89 | + ) |
| 90 | + return _dict |
| 91 | + |
| 92 | + @classmethod |
| 93 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 94 | + """Create an instance of DistributionLogsRecord from a dict""" |
| 95 | + if obj is None: |
| 96 | + return None |
| 97 | + |
| 98 | + if not isinstance(obj, dict): |
| 99 | + return cls.model_validate(obj) |
| 100 | + |
| 101 | + _obj = cls.model_validate( |
| 102 | + { |
| 103 | + "cacheHit": obj.get("cacheHit"), |
| 104 | + "dataCenterRegion": obj.get("dataCenterRegion"), |
| 105 | + "distributionID": obj.get("distributionID"), |
| 106 | + "host": obj.get("host"), |
| 107 | + "path": obj.get("path"), |
| 108 | + "requestCountryCode": obj.get("requestCountryCode"), |
| 109 | + "size": obj.get("size"), |
| 110 | + "statusCode": obj.get("statusCode"), |
| 111 | + "timestamp": obj.get("timestamp"), |
| 112 | + } |
| 113 | + ) |
| 114 | + return _obj |
0 commit comments