|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + Kubeflow Trainer OpenAPI Spec |
| 5 | +
|
| 6 | + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) |
| 7 | +
|
| 8 | + The version of the OpenAPI document: unversioned |
| 9 | + Generated by OpenAPI Generator (https://openapi-generator.tech) |
| 10 | +
|
| 11 | + Do not edit the class manually. |
| 12 | +""" # noqa: E501 |
| 13 | + |
| 14 | + |
| 15 | +from __future__ import annotations |
| 16 | +import pprint |
| 17 | +import re # noqa: F401 |
| 18 | +import json |
| 19 | + |
| 20 | +from pydantic import BaseModel, ConfigDict, Field, StrictStr |
| 21 | +from typing import Any, ClassVar, Dict, List |
| 22 | +from kubeflow_trainer_api.models.io_k8s_api_autoscaling_v2_metric_value_status import IoK8sApiAutoscalingV2MetricValueStatus |
| 23 | +from typing import Optional, Set |
| 24 | +from typing_extensions import Self |
| 25 | + |
| 26 | +class IoK8sApiAutoscalingV2ContainerResourceMetricStatus(BaseModel): |
| 27 | + """ |
| 28 | + ContainerResourceMetricStatus indicates the current value of a resource metric known to Kubernetes, as specified in requests and limits, describing a single container in each pod in the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source. |
| 29 | + """ # noqa: E501 |
| 30 | + container: StrictStr = Field(description="container is the name of the container in the pods of the scaling target") |
| 31 | + current: IoK8sApiAutoscalingV2MetricValueStatus = Field(description="current contains the current value for the given metric") |
| 32 | + name: StrictStr = Field(description="name is the name of the resource in question.") |
| 33 | + __properties: ClassVar[List[str]] = ["container", "current", "name"] |
| 34 | + |
| 35 | + model_config = ConfigDict( |
| 36 | + populate_by_name=True, |
| 37 | + validate_assignment=True, |
| 38 | + protected_namespaces=(), |
| 39 | + ) |
| 40 | + |
| 41 | + |
| 42 | + def to_str(self) -> str: |
| 43 | + """Returns the string representation of the model using alias""" |
| 44 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 45 | + |
| 46 | + def to_json(self) -> str: |
| 47 | + """Returns the JSON representation of the model using alias""" |
| 48 | + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead |
| 49 | + return json.dumps(self.to_dict()) |
| 50 | + |
| 51 | + @classmethod |
| 52 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 53 | + """Create an instance of IoK8sApiAutoscalingV2ContainerResourceMetricStatus from a JSON string""" |
| 54 | + return cls.from_dict(json.loads(json_str)) |
| 55 | + |
| 56 | + def to_dict(self) -> Dict[str, Any]: |
| 57 | + """Return the dictionary representation of the model using alias. |
| 58 | +
|
| 59 | + This has the following differences from calling pydantic's |
| 60 | + `self.model_dump(by_alias=True)`: |
| 61 | +
|
| 62 | + * `None` is only added to the output dict for nullable fields that |
| 63 | + were set at model initialization. Other fields with value `None` |
| 64 | + are ignored. |
| 65 | + """ |
| 66 | + excluded_fields: Set[str] = set([ |
| 67 | + ]) |
| 68 | + |
| 69 | + _dict = self.model_dump( |
| 70 | + by_alias=True, |
| 71 | + exclude=excluded_fields, |
| 72 | + exclude_none=True, |
| 73 | + ) |
| 74 | + # override the default output from pydantic by calling `to_dict()` of current |
| 75 | + if self.current: |
| 76 | + _dict['current'] = self.current.to_dict() |
| 77 | + return _dict |
| 78 | + |
| 79 | + @classmethod |
| 80 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 81 | + """Create an instance of IoK8sApiAutoscalingV2ContainerResourceMetricStatus from a dict""" |
| 82 | + if obj is None: |
| 83 | + return None |
| 84 | + |
| 85 | + if not isinstance(obj, dict): |
| 86 | + return cls.model_validate(obj) |
| 87 | + |
| 88 | + _obj = cls.model_validate({ |
| 89 | + "container": obj.get("container") if obj.get("container") is not None else '', |
| 90 | + "current": IoK8sApiAutoscalingV2MetricValueStatus.from_dict(obj["current"]) if obj.get("current") is not None else None, |
| 91 | + "name": obj.get("name") if obj.get("name") is not None else '' |
| 92 | + }) |
| 93 | + return _obj |
| 94 | + |
| 95 | + |
0 commit comments