def __init__( self, egress: typing.List["NetworkPolicyEgressRule"] = None, ingress: typing.List["NetworkPolicyIngressRule"] = None, pod_selector: "LabelSelector" = None, policy_types: typing.List[str] = None, ): """Create NetworkPolicySpec instance.""" super(NetworkPolicySpec, self).__init__( api_version="networking/v1", kind="NetworkPolicySpec" ) self._properties = { "egress": egress if egress is not None else [], "ingress": ingress if ingress is not None else [], "podSelector": pod_selector if pod_selector is not None else LabelSelector(), "policyTypes": policy_types if policy_types is not None else [], } self._types = { "egress": (list, NetworkPolicyEgressRule), "ingress": (list, NetworkPolicyIngressRule), "podSelector": (LabelSelector, None), "policyTypes": (list, str), }
def selector(self, value: typing.Union["LabelSelector", dict]): """ A label query over pods that should match the pod count. Normally, the system sets this field for you. More info: https://kubernetes.io/docs/concepts/overview/working-with- objects/labels/#label-selectors """ if isinstance(value, dict): value = typing.cast( LabelSelector, LabelSelector().from_dict(value), ) self._properties["selector"] = value
def __init__( self, ip_block: "IPBlock" = None, namespace_selector: "LabelSelector" = None, pod_selector: "LabelSelector" = None, ): """Create NetworkPolicyPeer instance.""" super(NetworkPolicyPeer, self).__init__( api_version="networking/v1", kind="NetworkPolicyPeer" ) self._properties = { "ipBlock": ip_block if ip_block is not None else IPBlock(), "namespaceSelector": namespace_selector if namespace_selector is not None else LabelSelector(), "podSelector": pod_selector if pod_selector is not None else LabelSelector(), } self._types = { "ipBlock": (IPBlock, None), "namespaceSelector": (LabelSelector, None), "podSelector": (LabelSelector, None), }
def pod_selector(self, value: typing.Union["LabelSelector", dict]): """ Selects the pods to which this NetworkPolicy object applies. The array of ingress rules is applied to any pods selected by this field. Multiple network policies can select the same set of pods. In this case, the ingress rules for each are combined additively. This field is NOT optional and follows standard label selector semantics. An empty podSelector matches all pods in this namespace. """ if isinstance(value, dict): value = typing.cast( LabelSelector, LabelSelector().from_dict(value), ) self._properties["podSelector"] = value
def pod_selector(self, value: typing.Union["LabelSelector", dict]): """ This is a label selector which selects Pods. This field follows standard label selector semantics; if present but empty, it selects all pods. If NamespaceSelector is also set, then the NetworkPolicyPeer as a whole selects the Pods matching PodSelector in the Namespaces selected by NamespaceSelector. Otherwise it selects the Pods matching PodSelector in the policy's own Namespace. """ if isinstance(value, dict): value = typing.cast( LabelSelector, LabelSelector().from_dict(value), ) self._properties["podSelector"] = value
def namespace_selector(self, value: typing.Union["LabelSelector", dict]): """ Selects Namespaces using cluster-scoped labels. This field follows standard label selector semantics; if present but empty, it selects all namespaces. If PodSelector is also set, then the NetworkPolicyPeer as a whole selects the Pods matching PodSelector in the Namespaces selected by NamespaceSelector. Otherwise it selects all Pods in the Namespaces selected by NamespaceSelector. """ if isinstance(value, dict): value = typing.cast( LabelSelector, LabelSelector().from_dict(value), ) self._properties["namespaceSelector"] = value
def __init__( self, active_deadline_seconds: int = None, backoff_limit: int = None, completions: int = None, manual_selector: bool = None, parallelism: int = None, selector: "LabelSelector" = None, template: "PodTemplateSpec" = None, ttl_seconds_after_finished: int = None, ): """Create JobSpec instance.""" super(JobSpec, self).__init__(api_version="batch/v1", kind="JobSpec") self._properties = { "activeDeadlineSeconds": active_deadline_seconds if active_deadline_seconds is not None else None, "backoffLimit": backoff_limit if backoff_limit is not None else None, "completions": completions if completions is not None else None, "manualSelector": manual_selector if manual_selector is not None else None, "parallelism": parallelism if parallelism is not None else None, "selector": selector if selector is not None else LabelSelector(), "template": template if template is not None else PodTemplateSpec(), "ttlSecondsAfterFinished": ttl_seconds_after_finished if ttl_seconds_after_finished is not None else None, } self._types = { "activeDeadlineSeconds": (int, None), "backoffLimit": (int, None), "completions": (int, None), "manualSelector": (bool, None), "parallelism": (int, None), "selector": (LabelSelector, None), "template": (PodTemplateSpec, None), "ttlSecondsAfterFinished": (int, None), }