Coverage for ocp_resources/endpoint_slice.py: 0%
17 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-30 10:48 +0200
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-30 10:48 +0200
1from ocp_resources.utils.constants import TIMEOUT_4MINUTES
2from ocp_resources.resource import MissingRequiredArgumentError, NamespacedResource
5class EndpointSlice(NamespacedResource):
6 """
7 EndpointSlice object. API reference:
8 https://kubernetes.io/docs/reference/kubernetes-api/service-resources/endpoint-slice-v1/
9 """
11 api_group = NamespacedResource.ApiGroup.DISCOVERY_K8S_IO
13 def __init__(
14 self,
15 name=None,
16 namespace=None,
17 client=None,
18 address_type=None,
19 endpoints=None,
20 ports=None,
21 teardown=True,
22 yaml_file=None,
23 delete_timeout=TIMEOUT_4MINUTES,
24 **kwargs,
25 ):
26 """
27 Args:
28 name (str): Name of the EndpointSlice resource
29 namespace (str): Namespace of EndpointSlice resource
30 client: (DynamicClient): DynamicClient for api calls
31 address_type (string): Type of address carried by this endpoint
32 endpoints (list): List of unique endpoints in this slice
33 ports (list, optional): List of port numbers available on the related ip addresses
34 teardown (bool): Indicates if the resource should be torn down at the end
35 yaml_file (str): yaml file for the resource.
36 delete_timeout (int): timeout associated with delete action
37 """
38 super().__init__(
39 name=name,
40 namespace=namespace,
41 client=client,
42 teardown=teardown,
43 yaml_file=yaml_file,
44 delete_timeout=delete_timeout,
45 **kwargs,
46 )
47 self.address_type = address_type
48 self.endpoints = endpoints
49 self.ports = ports
51 def to_dict(self) -> None:
52 super().to_dict()
53 if not self.kind_dict and not self.yaml_file:
54 if not (self.address_type and self.endpoints):
55 raise MissingRequiredArgumentError(argument="'address_type' and 'endpoints'")
57 self.res.update({
58 "addressTypes": self.address_type,
59 "endpoints": self.endpoints,
60 })
61 if self.ports:
62 self.res["ports"] = self.ports