From 78e0d25b38bf109b694e2ffd710eb345de321820 Mon Sep 17 00:00:00 2001 From: LeaveMyYard Date: Tue, 10 Oct 2023 14:49:17 +0300 Subject: Patch fix for proxy not working from kubeconfig --- robusta_krr/core/integrations/kubernetes.py | 379 -------------------- .../core/integrations/kubernetes/__init__.py | 380 +++++++++++++++++++++ .../core/integrations/kubernetes/config_patch.py | 37 ++ .../core/integrations/kubernetes/rollout.py | 340 ++++++++++++++++++ robusta_krr/core/integrations/rollout.py | 340 ------------------ 5 files changed, 757 insertions(+), 719 deletions(-) delete mode 100644 robusta_krr/core/integrations/kubernetes.py create mode 100644 robusta_krr/core/integrations/kubernetes/__init__.py create mode 100644 robusta_krr/core/integrations/kubernetes/config_patch.py create mode 100644 robusta_krr/core/integrations/kubernetes/rollout.py delete mode 100644 robusta_krr/core/integrations/rollout.py diff --git a/robusta_krr/core/integrations/kubernetes.py b/robusta_krr/core/integrations/kubernetes.py deleted file mode 100644 index db85fb9..0000000 --- a/robusta_krr/core/integrations/kubernetes.py +++ /dev/null @@ -1,379 +0,0 @@ -import asyncio -from concurrent.futures import ThreadPoolExecutor -from typing import AsyncGenerator, AsyncIterator, Callable, Optional, Union - -import aiostream -from kubernetes import client, config # type: ignore -from kubernetes.client import ApiException -from kubernetes.client.models import ( - V1Container, - V1DaemonSet, - V1Deployment, - V1HorizontalPodAutoscalerList, - V1Job, - V1LabelSelector, - V1Pod, - V1StatefulSet, - V2HorizontalPodAutoscaler, - V2HorizontalPodAutoscalerList, -) - -from robusta_krr.core.models.objects import HPAData, K8sObjectData, KindLiteral -from robusta_krr.core.models.result import ResourceAllocations -from robusta_krr.utils.configurable import Configurable - -from .rollout import RolloutAppsV1Api - -AnyKubernetesAPIObject = Union[V1Deployment, V1DaemonSet, V1StatefulSet, V1Pod, V1Job] -HPAKey = tuple[str, str, str] - - -class ClusterLoader(Configurable): - def __init__(self, cluster: Optional[str], *args, **kwargs): - super().__init__(*args, **kwargs) - - self.cluster = cluster - # This executor will be running requests to Kubernetes API - self.executor = ThreadPoolExecutor(self.config.max_workers) - self.api_client = ( - config.new_client_from_config(context=cluster, config_file=self.config.kubeconfig) - if cluster is not None - else None - ) - self.apps = client.AppsV1Api(api_client=self.api_client) - self.rollout = RolloutAppsV1Api(api_client=self.api_client) - self.batch = client.BatchV1Api(api_client=self.api_client) - self.core = client.CoreV1Api(api_client=self.api_client) - self.autoscaling_v1 = client.AutoscalingV1Api(api_client=self.api_client) - self.autoscaling_v2 = client.AutoscalingV2Api(api_client=self.api_client) - - self.__rollouts_available = True - - async def list_scannable_objects(self) -> AsyncGenerator[K8sObjectData, None]: - """List all scannable objects. - - Returns: - A list of scannable objects. - """ - - self.info(f"Listing scannable objects in {self.cluster}") - self.debug(f"Namespaces: {self.config.namespaces}") - self.debug(f"Resources: {self.config.resources}") - - self.__hpa_list = await self._try_list_hpa() - - # https://stackoverflow.com/questions/55299564/join-multiple-async-generators-in-python - # This will merge all the streams from all the cluster loaders into a single stream - objects_combined = aiostream.stream.merge( - self._list_deployments(), - self._list_rollouts(), - self._list_all_statefulsets(), - self._list_all_daemon_set(), - self._list_all_jobs(), - ) - - async with objects_combined.stream() as streamer: - async for object in streamer: - # NOTE: By default we will filter out kube-system namespace - if self.config.namespaces == "*" and object.namespace == "kube-system": - continue - yield object - - @staticmethod - def _get_match_expression_filter(expression) -> str: - if expression.operator.lower() == "exists": - return expression.key - elif expression.operator.lower() == "doesnotexist": - return f"!{expression.key}" - - values = ",".join(expression.values) - return f"{expression.key} {expression.operator} ({values})" - - @staticmethod - def _build_selector_query(selector: V1LabelSelector) -> Union[str, None]: - label_filters = [f"{label[0]}={label[1]}" for label in selector.match_labels.items()] - - if selector.match_expressions is not None: - label_filters.extend( - [ClusterLoader._get_match_expression_filter(expression) for expression in selector.match_expressions] - ) - - return ",".join(label_filters) - - def __build_obj( - self, item: AnyKubernetesAPIObject, container: V1Container, kind: Optional[str] = None - ) -> K8sObjectData: - name = item.metadata.name - namespace = item.metadata.namespace - kind = kind or item.__class__.__name__[2:] - - return K8sObjectData( - cluster=self.cluster, - namespace=namespace, - name=name, - kind=kind, - container=container.name, - allocations=ResourceAllocations.from_container(container), - hpa=self.__hpa_list.get((namespace, kind, name)), - ) - - def _should_list_resource(self, resource: str): - if self.config.resources == "*": - return True - return resource.lower() in self.config.resources - - async def _list_workflows( - self, kind: KindLiteral, all_namespaces_request: Callable, namespaced_request: Callable - ) -> AsyncIterator[K8sObjectData]: - if not self._should_list_resource(kind): - self.debug(f"Skipping {kind}s in {self.cluster}") - return - - if kind == "Rollout" and not self.__rollouts_available: - return - - self.debug(f"Listing {kind}s in {self.cluster}") - loop = asyncio.get_running_loop() - - try: - if self.config.namespaces == "*": - ret_multi = await loop.run_in_executor( - self.executor, - lambda: all_namespaces_request( - watch=False, - label_selector=self.config.selector, - ), - ) - self.debug(f"Found {len(ret_multi.items)} {kind} in {self.cluster}") - for item in ret_multi.items: - for container in item.spec.template.spec.containers: - yield self.__build_obj(item, container, kind) - else: - tasks = [ - loop.run_in_executor( - self.executor, - lambda: namespaced_request( - namespace=namespace, - watch=False, - label_selector=self.config.selector, - ), - ) - for namespace in self.config.namespaces - ] - - total_items = 0 - for task in asyncio.as_completed(tasks): - ret_single = await task - total_items += len(ret_single.items) - for item in ret_single.items: - for container in item.spec.template.spec.containers: - yield self.__build_obj(item, container, kind) - - self.debug(f"Found {total_items} {kind} in {self.cluster}") - except ApiException as e: - if kind == "Rollout" and e.status in [400, 401, 403, 404]: - if self.__rollouts_available: - self.debug(f"Rollout API not available in {self.cluster}") - self.__rollouts_available = False - else: - self.error(f"Error {e.status} listing {kind} in cluster {self.cluster}: {e.reason}") - self.debug_exception() - self.error("Will skip this object type and continue.") - - def _list_deployments(self) -> AsyncIterator[K8sObjectData]: - return self._list_workflows( - kind="Deployment", - all_namespaces_request=self.apps.list_deployment_for_all_namespaces, - namespaced_request=self.apps.list_namespaced_deployment, - ) - - def _list_rollouts(self) -> AsyncIterator[K8sObjectData]: - return self._list_workflows( - kind="Rollout", - all_namespaces_request=self.rollout.list_rollout_for_all_namespaces, - namespaced_request=self.rollout.list_namespaced_rollout, - ) - - def _list_all_statefulsets(self) -> AsyncIterator[K8sObjectData]: - return self._list_workflows( - kind="StatefulSet", - all_namespaces_request=self.apps.list_stateful_set_for_all_namespaces, - namespaced_request=self.apps.list_namespaced_stateful_set, - ) - - def _list_all_daemon_set(self) -> AsyncIterator[K8sObjectData]: - return self._list_workflows( - kind="DaemonSet", - all_namespaces_request=self.apps.list_daemon_set_for_all_namespaces, - namespaced_request=self.apps.list_namespaced_daemon_set, - ) - - def _list_all_jobs(self) -> AsyncIterator[K8sObjectData]: - return self._list_workflows( - kind="Job", - all_namespaces_request=self.batch.list_job_for_all_namespaces, - namespaced_request=self.batch.list_namespaced_job, - ) - - async def __list_hpa_v1(self) -> dict[HPAKey, HPAData]: - loop = asyncio.get_running_loop() - - res: V1HorizontalPodAutoscalerList = await loop.run_in_executor( - self.executor, lambda: self.autoscaling_v1.list_horizontal_pod_autoscaler_for_all_namespaces(watch=False) - ) - - return { - ( - hpa.metadata.namespace, - hpa.spec.scale_target_ref.kind, - hpa.spec.scale_target_ref.name, - ): HPAData( - min_replicas=hpa.spec.min_replicas, - max_replicas=hpa.spec.max_replicas, - current_replicas=hpa.status.current_replicas, - desired_replicas=hpa.status.desired_replicas, - target_cpu_utilization_percentage=hpa.spec.target_cpu_utilization_percentage, - target_memory_utilization_percentage=None, - ) - for hpa in res.items - } - - async def __list_hpa_v2(self) -> dict[HPAKey, HPAData]: - loop = asyncio.get_running_loop() - - res: V2HorizontalPodAutoscalerList = await loop.run_in_executor( - self.executor, - lambda: self.autoscaling_v2.list_horizontal_pod_autoscaler_for_all_namespaces(watch=False), - ) - - def __get_metric(hpa: V2HorizontalPodAutoscaler, metric_name: str) -> Optional[float]: - return next( - ( - metric.resource.target.average_utilization - for metric in hpa.spec.metrics - if metric.type == "Resource" and metric.resource.name == metric_name - ), - None, - ) - - return { - ( - hpa.metadata.namespace, - hpa.spec.scale_target_ref.kind, - hpa.spec.scale_target_ref.name, - ): HPAData( - min_replicas=hpa.spec.min_replicas, - max_replicas=hpa.spec.max_replicas, - current_replicas=hpa.status.current_replicas, - desired_replicas=hpa.status.desired_replicas, - target_cpu_utilization_percentage=__get_metric(hpa, "cpu"), - target_memory_utilization_percentage=__get_metric(hpa, "memory"), - ) - for hpa in res.items - } - - # TODO: What should we do in case of other metrics bound to the HPA? - async def __list_hpa(self) -> dict[HPAKey, HPAData]: - """List all HPA objects in the cluster. - - Returns: - dict[tuple[str, str], HPAData]: A dictionary of HPA objects, indexed by scaleTargetRef (kind, name). - """ - - try: - # Try to use V2 API first - return await self.__list_hpa_v2() - except ApiException as e: - if e.status != 404: - # If the error is other than not found, then re-raise it. - raise - - # If V2 API does not exist, fall back to V1 - return await self.__list_hpa_v1() - - async def _try_list_hpa(self) -> dict[HPAKey, HPAData]: - try: - return await self.__list_hpa() - except Exception as e: - self.error(f"Error trying to list hpa in cluster {self.cluster}: {e}") - self.debug_exception() - self.error( - "Will assume that there are no HPA. " - "Be careful as this may lead to inaccurate results if object actually has HPA." - ) - return {} - - -class KubernetesLoader(Configurable): - async def list_clusters(self) -> Optional[list[str]]: - """List all clusters. - - Returns: - A list of clusters. - """ - - if self.config.inside_cluster: - self.debug("Working inside the cluster") - return None - - try: - contexts, current_context = config.list_kube_config_contexts(self.config.kubeconfig) - except config.ConfigException: - if self.config.clusters is not None and self.config.clusters != "*": - self.warning("Could not load context from kubeconfig.") - self.warning(f"Falling back to clusters from CLI: {self.config.clusters}") - return self.config.clusters - else: - self.error( - "Could not load context from kubeconfig. " - "Please check your kubeconfig file or pass -c flag with the context name." - ) - return None - - self.debug(f"Found {len(contexts)} clusters: {', '.join([context['name'] for context in contexts])}") - self.debug(f"Current cluster: {current_context['name']}") - - self.debug(f"Configured clusters: {self.config.clusters}") - - # None, empty means current cluster - if not self.config.clusters: - return [current_context["name"]] - - # * means all clusters - if self.config.clusters == "*": - return [context["name"] for context in contexts] - - return [context["name"] for context in contexts if context["name"] in self.config.clusters] - - def _try_create_cluster_loader(self, cluster: Optional[str]) -> Optional[ClusterLoader]: - try: - return ClusterLoader(cluster=cluster, config=self.config) - except Exception as e: - self.error(f"Could not load cluster {cluster} and will skip it: {e}") - return None - - async def list_scannable_objects(self, clusters: Optional[list[str]]) -> AsyncIterator[K8sObjectData]: - """List all scannable objects. - - Yields: - Each scannable object as it is loaded. - """ - if clusters is None: - _cluster_loaders = [self._try_create_cluster_loader(None)] - else: - _cluster_loaders = [self._try_create_cluster_loader(cluster) for cluster in clusters] - - cluster_loaders = [cl for cl in _cluster_loaders if cl is not None] - if cluster_loaders == []: - self.error("Could not load any cluster.") - return - - # https://stackoverflow.com/questions/55299564/join-multiple-async-generators-in-python - # This will merge all the streams from all the cluster loaders into a single stream - objects_combined = aiostream.stream.merge( - *[cluster_loader.list_scannable_objects() for cluster_loader in cluster_loaders] - ) - - async with objects_combined.stream() as streamer: - async for object in streamer: - yield object diff --git a/robusta_krr/core/integrations/kubernetes/__init__.py b/robusta_krr/core/integrations/kubernetes/__init__.py new file mode 100644 index 0000000..8bb89a1 --- /dev/null +++ b/robusta_krr/core/integrations/kubernetes/__init__.py @@ -0,0 +1,380 @@ +import asyncio +from concurrent.futures import ThreadPoolExecutor +from typing import AsyncGenerator, AsyncIterator, Callable, Optional, Union + +import aiostream +from kubernetes import client, config # type: ignore +from kubernetes.client import ApiException +from kubernetes.client.models import ( + V1Container, + V1DaemonSet, + V1Deployment, + V1HorizontalPodAutoscalerList, + V1Job, + V1LabelSelector, + V1Pod, + V1StatefulSet, + V2HorizontalPodAutoscaler, + V2HorizontalPodAutoscalerList, +) + +from robusta_krr.core.models.objects import HPAData, K8sObjectData, KindLiteral +from robusta_krr.core.models.result import ResourceAllocations +from robusta_krr.utils.configurable import Configurable + +from . import config_patch as _ +from .rollout import RolloutAppsV1Api + +AnyKubernetesAPIObject = Union[V1Deployment, V1DaemonSet, V1StatefulSet, V1Pod, V1Job] +HPAKey = tuple[str, str, str] + + +class ClusterLoader(Configurable): + def __init__(self, cluster: Optional[str], *args, **kwargs): + super().__init__(*args, **kwargs) + + self.cluster = cluster + # This executor will be running requests to Kubernetes API + self.executor = ThreadPoolExecutor(self.config.max_workers) + self.api_client = ( + config.new_client_from_config(context=cluster, config_file=self.config.kubeconfig) + if cluster is not None + else None + ) + self.apps = client.AppsV1Api(api_client=self.api_client) + self.rollout = RolloutAppsV1Api(api_client=self.api_client) + self.batch = client.BatchV1Api(api_client=self.api_client) + self.core = client.CoreV1Api(api_client=self.api_client) + self.autoscaling_v1 = client.AutoscalingV1Api(api_client=self.api_client) + self.autoscaling_v2 = client.AutoscalingV2Api(api_client=self.api_client) + + self.__rollouts_available = True + + async def list_scannable_objects(self) -> AsyncGenerator[K8sObjectData, None]: + """List all scannable objects. + + Returns: + A list of scannable objects. + """ + + self.info(f"Listing scannable objects in {self.cluster}") + self.debug(f"Namespaces: {self.config.namespaces}") + self.debug(f"Resources: {self.config.resources}") + + self.__hpa_list = await self._try_list_hpa() + + # https://stackoverflow.com/questions/55299564/join-multiple-async-generators-in-python + # This will merge all the streams from all the cluster loaders into a single stream + objects_combined = aiostream.stream.merge( + self._list_deployments(), + self._list_rollouts(), + self._list_all_statefulsets(), + self._list_all_daemon_set(), + self._list_all_jobs(), + ) + + async with objects_combined.stream() as streamer: + async for object in streamer: + # NOTE: By default we will filter out kube-system namespace + if self.config.namespaces == "*" and object.namespace == "kube-system": + continue + yield object + + @staticmethod + def _get_match_expression_filter(expression) -> str: + if expression.operator.lower() == "exists": + return expression.key + elif expression.operator.lower() == "doesnotexist": + return f"!{expression.key}" + + values = ",".join(expression.values) + return f"{expression.key} {expression.operator} ({values})" + + @staticmethod + def _build_selector_query(selector: V1LabelSelector) -> Union[str, None]: + label_filters = [f"{label[0]}={label[1]}" for label in selector.match_labels.items()] + + if selector.match_expressions is not None: + label_filters.extend( + [ClusterLoader._get_match_expression_filter(expression) for expression in selector.match_expressions] + ) + + return ",".join(label_filters) + + def __build_obj( + self, item: AnyKubernetesAPIObject, container: V1Container, kind: Optional[str] = None + ) -> K8sObjectData: + name = item.metadata.name + namespace = item.metadata.namespace + kind = kind or item.__class__.__name__[2:] + + return K8sObjectData( + cluster=self.cluster, + namespace=namespace, + name=name, + kind=kind, + container=container.name, + allocations=ResourceAllocations.from_container(container), + hpa=self.__hpa_list.get((namespace, kind, name)), + ) + + def _should_list_resource(self, resource: str): + if self.config.resources == "*": + return True + return resource.lower() in self.config.resources + + async def _list_workflows( + self, kind: KindLiteral, all_namespaces_request: Callable, namespaced_request: Callable + ) -> AsyncIterator[K8sObjectData]: + if not self._should_list_resource(kind): + self.debug(f"Skipping {kind}s in {self.cluster}") + return + + if kind == "Rollout" and not self.__rollouts_available: + return + + self.debug(f"Listing {kind}s in {self.cluster}") + loop = asyncio.get_running_loop() + + try: + if self.config.namespaces == "*": + ret_multi = await loop.run_in_executor( + self.executor, + lambda: all_namespaces_request( + watch=False, + label_selector=self.config.selector, + ), + ) + self.debug(f"Found {len(ret_multi.items)} {kind} in {self.cluster}") + for item in ret_multi.items: + for container in item.spec.template.spec.containers: + yield self.__build_obj(item, container, kind) + else: + tasks = [ + loop.run_in_executor( + self.executor, + lambda: namespaced_request( + namespace=namespace, + watch=False, + label_selector=self.config.selector, + ), + ) + for namespace in self.config.namespaces + ] + + total_items = 0 + for task in asyncio.as_completed(tasks): + ret_single = await task + total_items += len(ret_single.items) + for item in ret_single.items: + for container in item.spec.template.spec.containers: + yield self.__build_obj(item, container, kind) + + self.debug(f"Found {total_items} {kind} in {self.cluster}") + except ApiException as e: + if kind == "Rollout" and e.status in [400, 401, 403, 404]: + if self.__rollouts_available: + self.debug(f"Rollout API not available in {self.cluster}") + self.__rollouts_available = False + else: + self.error(f"Error {e.status} listing {kind} in cluster {self.cluster}: {e.reason}") + self.debug_exception() + self.error("Will skip this object type and continue.") + + def _list_deployments(self) -> AsyncIterator[K8sObjectData]: + return self._list_workflows( + kind="Deployment", + all_namespaces_request=self.apps.list_deployment_for_all_namespaces, + namespaced_request=self.apps.list_namespaced_deployment, + ) + + def _list_rollouts(self) -> AsyncIterator[K8sObjectData]: + return self._list_workflows( + kind="Rollout", + all_namespaces_request=self.rollout.list_rollout_for_all_namespaces, + namespaced_request=self.rollout.list_namespaced_rollout, + ) + + def _list_all_statefulsets(self) -> AsyncIterator[K8sObjectData]: + return self._list_workflows( + kind="StatefulSet", + all_namespaces_request=self.apps.list_stateful_set_for_all_namespaces, + namespaced_request=self.apps.list_namespaced_stateful_set, + ) + + def _list_all_daemon_set(self) -> AsyncIterator[K8sObjectData]: + return self._list_workflows( + kind="DaemonSet", + all_namespaces_request=self.apps.list_daemon_set_for_all_namespaces, + namespaced_request=self.apps.list_namespaced_daemon_set, + ) + + def _list_all_jobs(self) -> AsyncIterator[K8sObjectData]: + return self._list_workflows( + kind="Job", + all_namespaces_request=self.batch.list_job_for_all_namespaces, + namespaced_request=self.batch.list_namespaced_job, + ) + + async def __list_hpa_v1(self) -> dict[HPAKey, HPAData]: + loop = asyncio.get_running_loop() + + res: V1HorizontalPodAutoscalerList = await loop.run_in_executor( + self.executor, lambda: self.autoscaling_v1.list_horizontal_pod_autoscaler_for_all_namespaces(watch=False) + ) + + return { + ( + hpa.metadata.namespace, + hpa.spec.scale_target_ref.kind, + hpa.spec.scale_target_ref.name, + ): HPAData( + min_replicas=hpa.spec.min_replicas, + max_replicas=hpa.spec.max_replicas, + current_replicas=hpa.status.current_replicas, + desired_replicas=hpa.status.desired_replicas, + target_cpu_utilization_percentage=hpa.spec.target_cpu_utilization_percentage, + target_memory_utilization_percentage=None, + ) + for hpa in res.items + } + + async def __list_hpa_v2(self) -> dict[HPAKey, HPAData]: + loop = asyncio.get_running_loop() + + res: V2HorizontalPodAutoscalerList = await loop.run_in_executor( + self.executor, + lambda: self.autoscaling_v2.list_horizontal_pod_autoscaler_for_all_namespaces(watch=False), + ) + + def __get_metric(hpa: V2HorizontalPodAutoscaler, metric_name: str) -> Optional[float]: + return next( + ( + metric.resource.target.average_utilization + for metric in hpa.spec.metrics + if metric.type == "Resource" and metric.resource.name == metric_name + ), + None, + ) + + return { + ( + hpa.metadata.namespace, + hpa.spec.scale_target_ref.kind, + hpa.spec.scale_target_ref.name, + ): HPAData( + min_replicas=hpa.spec.min_replicas, + max_replicas=hpa.spec.max_replicas, + current_replicas=hpa.status.current_replicas, + desired_replicas=hpa.status.desired_replicas, + target_cpu_utilization_percentage=__get_metric(hpa, "cpu"), + target_memory_utilization_percentage=__get_metric(hpa, "memory"), + ) + for hpa in res.items + } + + # TODO: What should we do in case of other metrics bound to the HPA? + async def __list_hpa(self) -> dict[HPAKey, HPAData]: + """List all HPA objects in the cluster. + + Returns: + dict[tuple[str, str], HPAData]: A dictionary of HPA objects, indexed by scaleTargetRef (kind, name). + """ + + try: + # Try to use V2 API first + return await self.__list_hpa_v2() + except ApiException as e: + if e.status != 404: + # If the error is other than not found, then re-raise it. + raise + + # If V2 API does not exist, fall back to V1 + return await self.__list_hpa_v1() + + async def _try_list_hpa(self) -> dict[HPAKey, HPAData]: + try: + return await self.__list_hpa() + except Exception as e: + self.error(f"Error trying to list hpa in cluster {self.cluster}: {e}") + self.debug_exception() + self.error( + "Will assume that there are no HPA. " + "Be careful as this may lead to inaccurate results if object actually has HPA." + ) + return {} + + +class KubernetesLoader(Configurable): + async def list_clusters(self) -> Optional[list[str]]: + """List all clusters. + + Returns: + A list of clusters. + """ + + if self.config.inside_cluster: + self.debug("Working inside the cluster") + return None + + try: + contexts, current_context = config.list_kube_config_contexts(self.config.kubeconfig) + except config.ConfigException: + if self.config.clusters is not None and self.config.clusters != "*": + self.warning("Could not load context from kubeconfig.") + self.warning(f"Falling back to clusters from CLI: {self.config.clusters}") + return self.config.clusters + else: + self.error( + "Could not load context from kubeconfig. " + "Please check your kubeconfig file or pass -c flag with the context name." + ) + return None + + self.debug(f"Found {len(contexts)} clusters: {', '.join([context['name'] for context in contexts])}") + self.debug(f"Current cluster: {current_context['name']}") + + self.debug(f"Configured clusters: {self.config.clusters}") + + # None, empty means current cluster + if not self.config.clusters: + return [current_context["name"]] + + # * means all clusters + if self.config.clusters == "*": + return [context["name"] for context in contexts] + + return [context["name"] for context in contexts if context["name"] in self.config.clusters] + + def _try_create_cluster_loader(self, cluster: Optional[str]) -> Optional[ClusterLoader]: + try: + return ClusterLoader(cluster=cluster, config=self.config) + except Exception as e: + self.error(f"Could not load cluster {cluster} and will skip it: {e}") + return None + + async def list_scannable_objects(self, clusters: Optional[list[str]]) -> AsyncIterator[K8sObjectData]: + """List all scannable objects. + + Yields: + Each scannable object as it is loaded. + """ + if clusters is None: + _cluster_loaders = [self._try_create_cluster_loader(None)] + else: + _cluster_loaders = [self._try_create_cluster_loader(cluster) for cluster in clusters] + + cluster_loaders = [cl for cl in _cluster_loaders if cl is not None] + if cluster_loaders == []: + self.error("Could not load any cluster.") + return + + # https://stackoverflow.com/questions/55299564/join-multiple-async-generators-in-python + # This will merge all the streams from all the cluster loaders into a single stream + objects_combined = aiostream.stream.merge( + *[cluster_loader.list_scannable_objects() for cluster_loader in cluster_loaders] + ) + + async with objects_combined.stream() as streamer: + async for object in streamer: + yield object diff --git a/robusta_krr/core/integrations/kubernetes/config_patch.py b/robusta_krr/core/integrations/kubernetes/config_patch.py new file mode 100644 index 0000000..5f294bc --- /dev/null +++ b/robusta_krr/core/integrations/kubernetes/config_patch.py @@ -0,0 +1,37 @@ +# NOTE: This is a workaround for the issue described here: +# https://github.com/kubernetes-client/python/pull/1863 + +from __future__ import annotations + +from kubernetes.client import configuration +from kubernetes.config import kube_config + + +class KubeConfigLoader(kube_config.KubeConfigLoader): + def _load_cluster_info(self): + super()._load_cluster_info() + + if "proxy-url" in self._cluster: + self.proxy = self._cluster["proxy-url"] + + def _set_config(self, client_configuration: Configuration): + super()._set_config(client_configuration) + + key = "proxy" + if key in self.__dict__: + setattr(client_configuration, key, getattr(self, key)) + + +class Configuration(configuration.Configuration): + def __init__( + self, + proxy: str | None = None, + **kwargs, + ): + super().__init__(**kwargs) + + self.proxy = proxy + + +configuration.Configuration = Configuration +kube_config.KubeConfigLoader = KubeConfigLoader diff --git a/robusta_krr/core/integrations/kubernetes/rollout.py b/robusta_krr/core/integrations/kubernetes/rollout.py new file mode 100644 index 0000000..389c65b --- /dev/null +++ b/robusta_krr/core/integrations/kubernetes/rollout.py @@ -0,0 +1,340 @@ +import six +from kubernetes import client +from kubernetes.client.exceptions import ApiTypeError, ApiValueError + + +class RolloutAppsV1Api(client.AppsV1Api): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + def list_rollout_for_all_namespaces(self, **kwargs): # noqa: E501 + """list_rollout_for_all_namespaces # noqa: E501 + + list or watch objects of kind Deployment # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.list_rollout_for_all_namespaces(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param bool allow_watch_bookmarks: allowWatchBookmarks requests watch events with type \"BOOKMARK\". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. + :param str _continue: The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the \"next key\". This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. + :param str field_selector: A selector to restrict the list of returned objects by their fields. Defaults to everything. + :param str label_selector: A selector to restrict the list of returned objects by their labels. Defaults to everything. + :param int limit: limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. + :param str pretty: If 'true', then the output is pretty printed. + :param str resource_version: resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset + :param str resource_version_match: resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset + :param int timeout_seconds: Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. + :param bool watch: Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion. + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: V1RolloutList + If the method is called asynchronously, + returns the request thread. + """ + kwargs["_return_http_data_only"] = True + return self.list_rollout_for_all_namespaces_with_http_info(**kwargs) # noqa: E501 + + def list_rollout_for_all_namespaces_with_http_info(self, **kwargs): # noqa: E501 + """list_rollout_for_all_namespaces # noqa: E501 + + list or watch objects of kind Deployment # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.list_deployment_for_all_namespaces_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param bool allow_watch_bookmarks: allowWatchBookmarks requests watch events with type \"BOOKMARK\". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. + :param str _continue: The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the \"next key\". This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. + :param str field_selector: A selector to restrict the list of returned objects by their fields. Defaults to everything. + :param str label_selector: A selector to restrict the list of returned objects by their labels. Defaults to everything. + :param int limit: limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. + :param str pretty: If 'true', then the output is pretty printed. + :param str resource_version: resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset + :param str resource_version_match: resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset + :param int timeout_seconds: Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. + :param bool watch: Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion. + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: tuple(V1DeploymentList, status_code(int), headers(HTTPHeaderDict)) + If the method is called asynchronously, + returns the request thread. + """ + + local_var_params = locals() + + all_params = [ + "allow_watch_bookmarks", + "_continue", + "field_selector", + "label_selector", + "limit", + "pretty", + "resource_version", + "resource_version_match", + "timeout_seconds", + "watch", + ] + all_params.extend(["async_req", "_return_http_data_only", "_preload_content", "_request_timeout"]) + + for key, val in six.iteritems(local_var_params["kwargs"]): + if key not in all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_deployment_for_all_namespaces" % key + ) + local_var_params[key] = val + del local_var_params["kwargs"] + + collection_formats = {} + + path_params = {} + + query_params = [] + if ( + "allow_watch_bookmarks" in local_var_params and local_var_params["allow_watch_bookmarks"] is not None + ): # noqa: E501 + query_params.append(("allowWatchBookmarks", local_var_params["allow_watch_bookmarks"])) # noqa: E501 + if "_continue" in local_var_params and local_var_params["_continue"] is not None: # noqa: E501 + query_params.append(("continue", local_var_params["_continue"])) # noqa: E501 + if "field_selector" in local_var_params and local_var_params["field_selector"] is not None: # noqa: E501 + query_params.append(("fieldSelector", local_var_params["field_selector"])) # noqa: E501 + if "label_selector" in local_var_params and local_var_params["label_selector"] is not None: # noqa: E501 + query_params.append(("labelSelector", local_var_params["label_selector"])) # noqa: E501 + if "limit" in local_var_params and local_var_params["limit"] is not None: # noqa: E501 + query_params.append(("limit", local_var_params["limit"])) # noqa: E501 + if "pretty" in local_var_params and local_var_params["pretty"] is not None: # noqa: E501 + query_params.append(("pretty", local_var_params["pretty"])) # noqa: E501 + if "resource_version" in local_var_params and local_var_params["resource_version"] is not None: # noqa: E501 + query_params.append(("resourceVersion", local_var_params["resource_version"])) # noqa: E501 + if ( + "resource_version_match" in local_var_params and local_var_params["resource_version_match"] is not None + ): # noqa: E501 + query_params.append(("resourceVersionMatch", local_var_params["resource_version_match"])) # noqa: E501 + if "timeout_seconds" in local_var_params and local_var_params["timeout_seconds"] is not None: # noqa: E501 + query_params.append(("timeoutSeconds", local_var_params["timeout_seconds"])) # noqa: E501 + if "watch" in local_var_params and local_var_params["watch"] is not None: # noqa: E501 + query_params.append(("watch", local_var_params["watch"])) # noqa: E501 + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params["Accept"] = self.api_client.select_header_accept( + [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf", + "application/json;stream=watch", + "application/vnd.kubernetes.protobuf;stream=watch", + ] + ) # noqa: E501 + + # Authentication setting + auth_settings = ["BearerToken"] # noqa: E501 + + return self.api_client.call_api( + "/apis/argoproj.io/v1alpha1/rollouts", + "GET", + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type="V1DeploymentList", # noqa: E501 + auth_settings=auth_settings, + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get("_return_http_data_only"), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) + + def list_namespaced_rollout(self, namespace, **kwargs): # noqa: E501 + """list_namespaced_rollout # noqa: E501 + + list or watch objects of kind ControllerRevision # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.list_namespaced_rollout(namespace, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str namespace: object name and auth scope, such as for teams and projects (required) + :param str pretty: If 'true', then the output is pretty printed. + :param bool allow_watch_bookmarks: allowWatchBookmarks requests watch events with type \"BOOKMARK\". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. + :param str _continue: The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the \"next key\". This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. + :param str field_selector: A selector to restrict the list of returned objects by their fields. Defaults to everything. + :param str label_selector: A selector to restrict the list of returned objects by their labels. Defaults to everything. + :param int limit: limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. + :param str resource_version: resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset + :param str resource_version_match: resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset + :param int timeout_seconds: Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. + :param bool watch: Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion. + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: V1ControllerRevisionList + If the method is called asynchronously, + returns the request thread. + """ + kwargs["_return_http_data_only"] = True + return self.list_namespaced_rollout_with_http_info(namespace, **kwargs) # noqa: E501 + + def list_namespaced_rollout_with_http_info(self, namespace, **kwargs): # noqa: E501 + """list_namespaced_rollout # noqa: E501 + + list or watch objects of kind ControllerRevision # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.list_namespaced_rollout_with_http_info(namespace, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str namespace: object name and auth scope, such as for teams and projects (required) + :param str pretty: If 'true', then the output is pretty printed. + :param bool allow_watch_bookmarks: allowWatchBookmarks requests watch events with type \"BOOKMARK\". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. + :param str _continue: The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the \"next key\". This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. + :param str field_selector: A selector to restrict the list of returned objects by their fields. Defaults to everything. + :param str label_selector: A selector to restrict the list of returned objects by their labels. Defaults to everything. + :param int limit: limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. + :param str resource_version: resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset + :param str resource_version_match: resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset + :param int timeout_seconds: Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. + :param bool watch: Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion. + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: tuple(V1ControllerRevisionList, status_code(int), headers(HTTPHeaderDict)) + If the method is called asynchronously, + returns the request thread. + """ + + local_var_params = locals() + + all_params = [ + "namespace", + "pretty", + "allow_watch_bookmarks", + "_continue", + "field_selector", + "label_selector", + "limit", + "resource_version", + "resource_version_match", + "timeout_seconds", + "watch", + ] + all_params.extend(["async_req", "_return_http_data_only", "_preload_content", "_request_timeout"]) + + for key, val in six.iteritems(local_var_params["kwargs"]): + if key not in all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_namespaced_controller_revision" % key + ) + local_var_params[key] = val + del local_var_params["kwargs"] + # verify the required parameter 'namespace' is set + if self.api_client.client_side_validation and ( + "namespace" not in local_var_params or local_var_params["namespace"] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `namespace` when calling `list_namespaced_controller_revision`" + ) # noqa: E501 + + collection_formats = {} + + path_params = {} + if "namespace" in local_var_params: + path_params["namespace"] = local_var_params["namespace"] # noqa: E501 + + query_params = [] + if "pretty" in local_var_params and local_var_params["pretty"] is not None: # noqa: E501 + query_params.append(("pretty", local_var_params["pretty"])) # noqa: E501 + if ( + "allow_watch_bookmarks" in local_var_params and local_var_params["allow_watch_bookmarks"] is not None + ): # noqa: E501 + query_params.append(("allowWatchBookmarks", local_var_params["allow_watch_bookmarks"])) # noqa: E501 + if "_continue" in local_var_params and local_var_params["_continue"] is not None: # noqa: E501 + query_params.append(("continue", local_var_params["_continue"])) # noqa: E501 + if "field_selector" in local_var_params and local_var_params["field_selector"] is not None: # noqa: E501 + query_params.append(("fieldSelector", local_var_params["field_selector"])) # noqa: E501 + if "label_selector" in local_var_params and local_var_params["label_selector"] is not None: # noqa: E501 + query_params.append(("labelSelector", local_var_params["label_selector"])) # noqa: E501 + if "limit" in local_var_params and local_var_params["limit"] is not None: # noqa: E501 + query_params.append(("limit", local_var_params["limit"])) # noqa: E501 + if "resource_version" in local_var_params and local_var_params["resource_version"] is not None: # noqa: E501 + query_params.append(("resourceVersion", local_var_params["resource_version"])) # noqa: E501 + if ( + "resource_version_match" in local_var_params and local_var_params["resource_version_match"] is not None + ): # noqa: E501 + query_params.append(("resourceVersionMatch", local_var_params["resource_version_match"])) # noqa: E501 + if "timeout_seconds" in local_var_params and local_var_params["timeout_seconds"] is not None: # noqa: E501 + query_params.append(("timeoutSeconds", local_var_params["timeout_seconds"])) # noqa: E501 + if "watch" in local_var_params and local_var_params["watch"] is not None: # noqa: E501 + query_params.append(("watch", local_var_params["watch"])) # noqa: E501 + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params["Accept"] = self.api_client.select_header_accept( + [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf", + "application/json;stream=watch", + "application/vnd.kubernetes.protobuf;stream=watch", + ] + ) # noqa: E501 + + # Authentication setting + auth_settings = ["BearerToken"] # noqa: E501 + + return self.api_client.call_api( + "/apis/argoproj.io/v1alpha1/namespaces/{namespace}/rollouts", + "GET", + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type="V1DeploymentList", # noqa: E501 + auth_settings=auth_settings, + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get("_return_http_data_only"), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) diff --git a/robusta_krr/core/integrations/rollout.py b/robusta_krr/core/integrations/rollout.py deleted file mode 100644 index 389c65b..0000000 --- a/robusta_krr/core/integrations/rollout.py +++ /dev/null @@ -1,340 +0,0 @@ -import six -from kubernetes import client -from kubernetes.client.exceptions import ApiTypeError, ApiValueError - - -class RolloutAppsV1Api(client.AppsV1Api): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - def list_rollout_for_all_namespaces(self, **kwargs): # noqa: E501 - """list_rollout_for_all_namespaces # noqa: E501 - - list or watch objects of kind Deployment # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_rollout_for_all_namespaces(async_req=True) - >>> result = thread.get() - - :param async_req bool: execute request asynchronously - :param bool allow_watch_bookmarks: allowWatchBookmarks requests watch events with type \"BOOKMARK\". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. - :param str _continue: The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the \"next key\". This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. - :param str field_selector: A selector to restrict the list of returned objects by their fields. Defaults to everything. - :param str label_selector: A selector to restrict the list of returned objects by their labels. Defaults to everything. - :param int limit: limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. - :param str pretty: If 'true', then the output is pretty printed. - :param str resource_version: resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset - :param str resource_version_match: resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset - :param int timeout_seconds: Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. - :param bool watch: Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion. - :param _preload_content: if False, the urllib3.HTTPResponse object will - be returned without reading/decoding response - data. Default is True. - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: V1RolloutList - If the method is called asynchronously, - returns the request thread. - """ - kwargs["_return_http_data_only"] = True - return self.list_rollout_for_all_namespaces_with_http_info(**kwargs) # noqa: E501 - - def list_rollout_for_all_namespaces_with_http_info(self, **kwargs): # noqa: E501 - """list_rollout_for_all_namespaces # noqa: E501 - - list or watch objects of kind Deployment # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_deployment_for_all_namespaces_with_http_info(async_req=True) - >>> result = thread.get() - - :param async_req bool: execute request asynchronously - :param bool allow_watch_bookmarks: allowWatchBookmarks requests watch events with type \"BOOKMARK\". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. - :param str _continue: The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the \"next key\". This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. - :param str field_selector: A selector to restrict the list of returned objects by their fields. Defaults to everything. - :param str label_selector: A selector to restrict the list of returned objects by their labels. Defaults to everything. - :param int limit: limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. - :param str pretty: If 'true', then the output is pretty printed. - :param str resource_version: resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset - :param str resource_version_match: resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset - :param int timeout_seconds: Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. - :param bool watch: Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion. - :param _return_http_data_only: response data without head status code - and headers - :param _preload_content: if False, the urllib3.HTTPResponse object will - be returned without reading/decoding response - data. Default is True. - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: tuple(V1DeploymentList, status_code(int), headers(HTTPHeaderDict)) - If the method is called asynchronously, - returns the request thread. - """ - - local_var_params = locals() - - all_params = [ - "allow_watch_bookmarks", - "_continue", - "field_selector", - "label_selector", - "limit", - "pretty", - "resource_version", - "resource_version_match", - "timeout_seconds", - "watch", - ] - all_params.extend(["async_req", "_return_http_data_only", "_preload_content", "_request_timeout"]) - - for key, val in six.iteritems(local_var_params["kwargs"]): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" " to method list_deployment_for_all_namespaces" % key - ) - local_var_params[key] = val - del local_var_params["kwargs"] - - collection_formats = {} - - path_params = {} - - query_params = [] - if ( - "allow_watch_bookmarks" in local_var_params and local_var_params["allow_watch_bookmarks"] is not None - ): # noqa: E501 - query_params.append(("allowWatchBookmarks", local_var_params["allow_watch_bookmarks"])) # noqa: E501 - if "_continue" in local_var_params and local_var_params["_continue"] is not None: # noqa: E501 - query_params.append(("continue", local_var_params["_continue"])) # noqa: E501 - if "field_selector" in local_var_params and local_var_params["field_selector"] is not None: # noqa: E501 - query_params.append(("fieldSelector", local_var_params["field_selector"])) # noqa: E501 - if "label_selector" in local_var_params and local_var_params["label_selector"] is not None: # noqa: E501 - query_params.append(("labelSelector", local_var_params["label_selector"])) # noqa: E501 - if "limit" in local_var_params and local_var_params["limit"] is not None: # noqa: E501 - query_params.append(("limit", local_var_params["limit"])) # noqa: E501 - if "pretty" in local_var_params and local_var_params["pretty"] is not None: # noqa: E501 - query_params.append(("pretty", local_var_params["pretty"])) # noqa: E501 - if "resource_version" in local_var_params and local_var_params["resource_version"] is not None: # noqa: E501 - query_params.append(("resourceVersion", local_var_params["resource_version"])) # noqa: E501 - if ( - "resource_version_match" in local_var_params and local_var_params["resource_version_match"] is not None - ): # noqa: E501 - query_params.append(("resourceVersionMatch", local_var_params["resource_version_match"])) # noqa: E501 - if "timeout_seconds" in local_var_params and local_var_params["timeout_seconds"] is not None: # noqa: E501 - query_params.append(("timeoutSeconds", local_var_params["timeout_seconds"])) # noqa: E501 - if "watch" in local_var_params and local_var_params["watch"] is not None: # noqa: E501 - query_params.append(("watch", local_var_params["watch"])) # noqa: E501 - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - [ - "application/json", - "application/yaml", - "application/vnd.kubernetes.protobuf", - "application/json;stream=watch", - "application/vnd.kubernetes.protobuf;stream=watch", - ] - ) # noqa: E501 - - # Authentication setting - auth_settings = ["BearerToken"] # noqa: E501 - - return self.api_client.call_api( - "/apis/argoproj.io/v1alpha1/rollouts", - "GET", - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type="V1DeploymentList", # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) - - def list_namespaced_rollout(self, namespace, **kwargs): # noqa: E501 - """list_namespaced_rollout # noqa: E501 - - list or watch objects of kind ControllerRevision # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_namespaced_rollout(namespace, async_req=True) - >>> result = thread.get() - - :param async_req bool: execute request asynchronously - :param str namespace: object name and auth scope, such as for teams and projects (required) - :param str pretty: If 'true', then the output is pretty printed. - :param bool allow_watch_bookmarks: allowWatchBookmarks requests watch events with type \"BOOKMARK\". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. - :param str _continue: The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the \"next key\". This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. - :param str field_selector: A selector to restrict the list of returned objects by their fields. Defaults to everything. - :param str label_selector: A selector to restrict the list of returned objects by their labels. Defaults to everything. - :param int limit: limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. - :param str resource_version: resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset - :param str resource_version_match: resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset - :param int timeout_seconds: Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. - :param bool watch: Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion. - :param _preload_content: if False, the urllib3.HTTPResponse object will - be returned without reading/decoding response - data. Default is True. - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: V1ControllerRevisionList - If the method is called asynchronously, - returns the request thread. - """ - kwargs["_return_http_data_only"] = True - return self.list_namespaced_rollout_with_http_info(namespace, **kwargs) # noqa: E501 - - def list_namespaced_rollout_with_http_info(self, namespace, **kwargs): # noqa: E501 - """list_namespaced_rollout # noqa: E501 - - list or watch objects of kind ControllerRevision # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_namespaced_rollout_with_http_info(namespace, async_req=True) - >>> result = thread.get() - - :param async_req bool: execute request asynchronously - :param str namespace: object name and auth scope, such as for teams and projects (required) - :param str pretty: If 'true', then the output is pretty printed. - :param bool allow_watch_bookmarks: allowWatchBookmarks requests watch events with type \"BOOKMARK\". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. - :param str _continue: The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the \"next key\". This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. - :param str field_selector: A selector to restrict the list of returned objects by their fields. Defaults to everything. - :param str label_selector: A selector to restrict the list of returned objects by their labels. Defaults to everything. - :param int limit: limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. - :param str resource_version: resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset - :param str resource_version_match: resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset - :param int timeout_seconds: Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. - :param bool watch: Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion. - :param _return_http_data_only: response data without head status code - and headers - :param _preload_content: if False, the urllib3.HTTPResponse object will - be returned without reading/decoding response - data. Default is True. - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: tuple(V1ControllerRevisionList, status_code(int), headers(HTTPHeaderDict)) - If the method is called asynchronously, - returns the request thread. - """ - - local_var_params = locals() - - all_params = [ - "namespace", - "pretty", - "allow_watch_bookmarks", - "_continue", - "field_selector", - "label_selector", - "limit", - "resource_version", - "resource_version_match", - "timeout_seconds", - "watch", - ] - all_params.extend(["async_req", "_return_http_data_only", "_preload_content", "_request_timeout"]) - - for key, val in six.iteritems(local_var_params["kwargs"]): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" " to method list_namespaced_controller_revision" % key - ) - local_var_params[key] = val - del local_var_params["kwargs"] - # verify the required parameter 'namespace' is set - if self.api_client.client_side_validation and ( - "namespace" not in local_var_params or local_var_params["namespace"] is None # noqa: E501 - ): # noqa: E501 - raise ApiValueError( - "Missing the required parameter `namespace` when calling `list_namespaced_controller_revision`" - ) # noqa: E501 - - collection_formats = {} - - path_params = {} - if "namespace" in local_var_params: - path_params["namespace"] = local_var_params["namespace"] # noqa: E501 - - query_params = [] - if "pretty" in local_var_params and local_var_params["pretty"] is not None: # noqa: E501 - query_params.append(("pretty", local_var_params["pretty"])) # noqa: E501 - if ( - "allow_watch_bookmarks" in local_var_params and local_var_params["allow_watch_bookmarks"] is not None - ): # noqa: E501 - query_params.append(("allowWatchBookmarks", local_var_params["allow_watch_bookmarks"])) # noqa: E501 - if "_continue" in local_var_params and local_var_params["_continue"] is not None: # noqa: E501 - query_params.append(("continue", local_var_params["_continue"])) # noqa: E501 - if "field_selector" in local_var_params and local_var_params["field_selector"] is not None: # noqa: E501 - query_params.append(("fieldSelector", local_var_params["field_selector"])) # noqa: E501 - if "label_selector" in local_var_params and local_var_params["label_selector"] is not None: # noqa: E501 - query_params.append(("labelSelector", local_var_params["label_selector"])) # noqa: E501 - if "limit" in local_var_params and local_var_params["limit"] is not None: # noqa: E501 - query_params.append(("limit", local_var_params["limit"])) # noqa: E501 - if "resource_version" in local_var_params and local_var_params["resource_version"] is not None: # noqa: E501 - query_params.append(("resourceVersion", local_var_params["resource_version"])) # noqa: E501 - if ( - "resource_version_match" in local_var_params and local_var_params["resource_version_match"] is not None - ): # noqa: E501 - query_params.append(("resourceVersionMatch", local_var_params["resource_version_match"])) # noqa: E501 - if "timeout_seconds" in local_var_params and local_var_params["timeout_seconds"] is not None: # noqa: E501 - query_params.append(("timeoutSeconds", local_var_params["timeout_seconds"])) # noqa: E501 - if "watch" in local_var_params and local_var_params["watch"] is not None: # noqa: E501 - query_params.append(("watch", local_var_params["watch"])) # noqa: E501 - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - [ - "application/json", - "application/yaml", - "application/vnd.kubernetes.protobuf", - "application/json;stream=watch", - "application/vnd.kubernetes.protobuf;stream=watch", - ] - ) # noqa: E501 - - # Authentication setting - auth_settings = ["BearerToken"] # noqa: E501 - - return self.api_client.call_api( - "/apis/argoproj.io/v1alpha1/namespaces/{namespace}/rollouts", - "GET", - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type="V1DeploymentList", # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get("_return_http_data_only"), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) -- cgit v1.2.3