# coding: utf-8

"""
    Kubernetes

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: release-1.29
    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 typing import Optional
from pydantic import BaseModel, Field, StrictStr
from .v1_label_selector import V1LabelSelector

class V1alpha1ParamRef(BaseModel):
    """
    ParamRef describes how to locate the params to be used as input to expressions of rules applied by a policy binding.  # noqa: E501
    """
    name: Optional[StrictStr] = Field(None, description="`name` is the name of the resource being referenced.  `name` and `selector` are mutually exclusive properties. If one is set, the other must be unset.")
    namespace: Optional[StrictStr] = Field(None, description="namespace is the namespace of the referenced resource. Allows limiting the search for params to a specific namespace. Applies to both `name` and `selector` fields.  A per-namespace parameter may be used by specifying a namespace-scoped `paramKind` in the policy and leaving this field empty.  - If `paramKind` is cluster-scoped, this field MUST be unset. Setting this field results in a configuration error.  - If `paramKind` is namespace-scoped, the namespace of the object being evaluated for admission will be used when this field is left unset. Take care that if this is left empty the binding must not match any cluster-scoped resources, which will result in an error.")
    parameter_not_found_action: Optional[StrictStr] = Field(None, alias="parameterNotFoundAction", description="`parameterNotFoundAction` controls the behavior of the binding when the resource exists, and name or selector is valid, but there are no parameters matched by the binding. If the value is set to `Allow`, then no matched parameters will be treated as successful validation by the binding. If set to `Deny`, then no matched parameters will be subject to the `failurePolicy` of the policy.  Allowed values are `Allow` or `Deny` Default to `Deny`")
    selector: Optional[V1LabelSelector] = None
    __properties = ["name", "namespace", "parameterNotFoundAction", "selector"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

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

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

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

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of selector
        if self.selector:
            _dict['selector'] = self.selector.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> V1alpha1ParamRef:
        """Create an instance of V1alpha1ParamRef from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return V1alpha1ParamRef.parse_obj(obj)

        _obj = V1alpha1ParamRef.parse_obj({
            "name": obj.get("name"),
            "namespace": obj.get("namespace"),
            "parameter_not_found_action": obj.get("parameterNotFoundAction"),
            "selector": V1LabelSelector.from_dict(obj.get("selector")) if obj.get("selector") is not None else None
        })
        return _obj


