# coding: utf-8

"""
    Graphiant APIs

    Graphiant API documentation.

    The version of the OpenAPI document: 1.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from graphiant_sdk.models.v1_global_config_patch_request_traffic_policies_traffic_rulesets_value_ruleset_rules_value_rule_action_backup_circuit_label import V1GlobalConfigPatchRequestTrafficPoliciesTrafficRulesetsValueRulesetRulesValueRuleActionBackupCircuitLabel
from graphiant_sdk.models.v1_global_config_patch_request_traffic_policies_traffic_rulesets_value_ruleset_rules_value_rule_action_remark import V1GlobalConfigPatchRequestTrafficPoliciesTrafficRulesetsValueRulesetRulesValueRuleActionRemark
from graphiant_sdk.models.v1_global_config_patch_request_traffic_policies_traffic_rulesets_value_ruleset_rules_value_rule_action_set_sla_class import V1GlobalConfigPatchRequestTrafficPoliciesTrafficRulesetsValueRulesetRulesValueRuleActionSetSlaClass
from graphiant_sdk.models.v1_portal_apikeys_post_request import V1PortalApikeysPostRequest
from typing import Optional, Set
from typing_extensions import Self

class V1GlobalConfigPatchRequestTrafficPoliciesTrafficRulesetsValueRulesetRulesValueRuleAction(BaseModel):
    """
    V1GlobalConfigPatchRequestTrafficPoliciesTrafficRulesetsValueRulesetRulesValueRuleAction
    """ # noqa: E501
    backup_circuit: Optional[V1PortalApikeysPostRequest] = Field(default=None, alias="backupCircuit")
    backup_circuit_label: Optional[V1GlobalConfigPatchRequestTrafficPoliciesTrafficRulesetsValueRulesetRulesValueRuleActionBackupCircuitLabel] = Field(default=None, alias="backupCircuitLabel")
    egress: Optional[StrictStr] = None
    logging: Optional[StrictBool] = None
    primary_circuit: Optional[V1PortalApikeysPostRequest] = Field(default=None, alias="primaryCircuit")
    primary_circuit_label: Optional[V1GlobalConfigPatchRequestTrafficPoliciesTrafficRulesetsValueRulesetRulesValueRuleActionBackupCircuitLabel] = Field(default=None, alias="primaryCircuitLabel")
    remark: Optional[V1GlobalConfigPatchRequestTrafficPoliciesTrafficRulesetsValueRulesetRulesValueRuleActionRemark] = None
    set_sla_class: Optional[V1GlobalConfigPatchRequestTrafficPoliciesTrafficRulesetsValueRulesetRulesValueRuleActionSetSlaClass] = Field(default=None, alias="setSlaClass")
    __properties: ClassVar[List[str]] = ["backupCircuit", "backupCircuitLabel", "egress", "logging", "primaryCircuit", "primaryCircuitLabel", "remark", "setSlaClass"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of V1GlobalConfigPatchRequestTrafficPoliciesTrafficRulesetsValueRulesetRulesValueRuleAction from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of backup_circuit
        if self.backup_circuit:
            _dict['backupCircuit'] = self.backup_circuit.to_dict()
        # override the default output from pydantic by calling `to_dict()` of backup_circuit_label
        if self.backup_circuit_label:
            _dict['backupCircuitLabel'] = self.backup_circuit_label.to_dict()
        # override the default output from pydantic by calling `to_dict()` of primary_circuit
        if self.primary_circuit:
            _dict['primaryCircuit'] = self.primary_circuit.to_dict()
        # override the default output from pydantic by calling `to_dict()` of primary_circuit_label
        if self.primary_circuit_label:
            _dict['primaryCircuitLabel'] = self.primary_circuit_label.to_dict()
        # override the default output from pydantic by calling `to_dict()` of remark
        if self.remark:
            _dict['remark'] = self.remark.to_dict()
        # override the default output from pydantic by calling `to_dict()` of set_sla_class
        if self.set_sla_class:
            _dict['setSlaClass'] = self.set_sla_class.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of V1GlobalConfigPatchRequestTrafficPoliciesTrafficRulesetsValueRulesetRulesValueRuleAction from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "backupCircuit": V1PortalApikeysPostRequest.from_dict(obj["backupCircuit"]) if obj.get("backupCircuit") is not None else None,
            "backupCircuitLabel": V1GlobalConfigPatchRequestTrafficPoliciesTrafficRulesetsValueRulesetRulesValueRuleActionBackupCircuitLabel.from_dict(obj["backupCircuitLabel"]) if obj.get("backupCircuitLabel") is not None else None,
            "egress": obj.get("egress"),
            "logging": obj.get("logging"),
            "primaryCircuit": V1PortalApikeysPostRequest.from_dict(obj["primaryCircuit"]) if obj.get("primaryCircuit") is not None else None,
            "primaryCircuitLabel": V1GlobalConfigPatchRequestTrafficPoliciesTrafficRulesetsValueRulesetRulesValueRuleActionBackupCircuitLabel.from_dict(obj["primaryCircuitLabel"]) if obj.get("primaryCircuitLabel") is not None else None,
            "remark": V1GlobalConfigPatchRequestTrafficPoliciesTrafficRulesetsValueRulesetRulesValueRuleActionRemark.from_dict(obj["remark"]) if obj.get("remark") is not None else None,
            "setSlaClass": V1GlobalConfigPatchRequestTrafficPoliciesTrafficRulesetsValueRulesetRulesValueRuleActionSetSlaClass.from_dict(obj["setSlaClass"]) if obj.get("setSlaClass") is not None else None
        })
        return _obj


