Coverage for ocp_resources/endpoints.py: 0%
14 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 Endpoints(NamespacedResource):
6 """
7 Endpoints object. API reference:
8 https://docs.openshift.com/container-platform/4.12/rest_api/network_apis/endpoints-v1.html#endpoints-v1
9 """
11 api_version = NamespacedResource.ApiVersion.V1
13 def __init__(
14 self,
15 name=None,
16 namespace=None,
17 client=None,
18 addresses=None,
19 ports=None,
20 teardown=True,
21 yaml_file=None,
22 delete_timeout=TIMEOUT_4MINUTES,
23 **kwargs,
24 ):
25 """
26 Args:
27 name (str): Name of the endpoints resource
28 namespace (str): Namespace of endpoints resource
29 client: (DynamicClient): DynamicClient for api calls
30 addresses (list): List of ip addresses which offers the related ports that are marked as ready
31 ports (list): List of port numbers available on the related ip addresses
32 teardown (bool): Indicates if the resource should be torn down at the end
33 yaml_file (str): yaml file for the resource.
34 delete_timeout (int): timeout associated with delete action
35 """
36 super().__init__(
37 name=name,
38 namespace=namespace,
39 client=client,
40 teardown=teardown,
41 yaml_file=yaml_file,
42 delete_timeout=delete_timeout,
43 **kwargs,
44 )
45 self.addresses = addresses
46 self.ports = ports
48 def to_dict(self) -> None:
49 super().to_dict()
50 if not self.kind_dict and not self.yaml_file:
51 if not (self.addresses and self.ports):
52 raise MissingRequiredArgumentError(argument="'addresses' and 'ports")
54 self.res.update({
55 "subsets": {
56 "addresses": self.addresses,
57 "ports": self.ports,
58 }
59 })