MaksYermak commented on code in PR #38146:
URL: https://github.com/apache/airflow/pull/38146#discussion_r1530211011


##########
airflow/providers/cncf/kubernetes/operators/job.py:
##########
@@ -284,3 +286,71 @@ def reconcile_job_specs(
             return merge_objects(base_spec, client_spec)
 
         return None
+
+
+class KubernetesPatchJobOperator(BaseOperator):
+    """
+    Update a Kubernetes Job.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the 
guide:
+        :ref:`howto/operator:KubernetesPatchJobOperator`
+
+    :param name: name of the Job
+    :param namespace: the namespace to run within kubernetes
+    :param body: Job json object with parameters for update
+        
https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#job-v1-batch
+        e.g. ``{"spec": {"suspend": True}}``
+    :param kubernetes_conn_id: The :ref:`kubernetes connection id 
<howto/connection:kubernetes>`
+        for the Kubernetes cluster.
+    :param config_file: The path to the Kubernetes config file. (templated)
+        If not specified, default value is ``~/.kube/config``
+    :param in_cluster: run kubernetes client with in_cluster configuration.
+    :param cluster_context: context that points to kubernetes cluster.
+        Ignored when in_cluster is True. If None, current-context is used. 
(templated)
+    """
+
+    template_fields: Sequence[str] = (
+        "config_file",
+        "namespace",
+        "body",
+        "cluster_context",
+    )
+
+    def __init__(
+        self,
+        *,
+        name: str,
+        namespace: str,
+        body: object,
+        kubernetes_conn_id: str | None = KubernetesHook.default_conn_name,
+        config_file: str | None = None,
+        in_cluster: bool | None = None,
+        cluster_context: str | None = None,
+        **kwargs,
+    ) -> None:
+        super().__init__(**kwargs)
+        self.name = name
+        self.namespace = namespace
+        self.body = body
+        self.kubernetes_conn_id = kubernetes_conn_id
+        self.config_file = config_file
+        self.in_cluster = in_cluster
+        self.cluster_context = cluster_context
+
+    @cached_property
+    def hook(self) -> KubernetesHook:
+        return KubernetesHook(
+            conn_id=self.kubernetes_conn_id,
+            in_cluster=self.in_cluster,
+            config_file=self.config_file,
+            cluster_context=self.cluster_context,
+        )
+
+    def execute(self, context: Context):

Review Comment:
   @pankajastro good idea, I have added it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to