uranusjr commented on a change in pull request #19806:
URL: https://github.com/apache/airflow/pull/19806#discussion_r773546162



##########
File path: airflow/providers/microsoft/psrp/operators/psrp.py
##########
@@ -16,51 +16,129 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from typing import List, Optional
+from typing import Any, Dict, List, Optional
+
+from jinja2.nativetypes import NativeEnvironment
+from pypsrp.serializer import TaggedValue
 
 from airflow.exceptions import AirflowException
 from airflow.models import BaseOperator
 from airflow.providers.microsoft.psrp.hooks.psrp import PSRPHook
+from airflow.settings import json
 
 
 class PSRPOperator(BaseOperator):
     """PowerShell Remoting Protocol operator.
 
-    :param psrp_conn_id: connection id
+    Use one of the 'command', 'cmdlet', or 'powershell' arguments.
+
+    The 'securestring' template filter can be used to tag a value for
+    serialization into a `System.Security.SecureString` (applicable only
+    for DAGs which have `render_template_as_native_obj=True`).
+
+    The command output is converted to JSON by PowerShell such that the 
operator
+    return value is serializable to an XCom value.
+
+    :param psrp_conn_id: Connection id
     :type psrp_conn_id: str
-    :param command: command to execute on remote host. (templated)
+    :param command: Command to execute on remote host (templated).
     :type command: str
-    :param powershell: powershell to execute on remote host. (templated)
+    :param powershell: Powershell to execute on remote host (templated)
     :type powershell: str
+    :param cmdlet:
+        Cmdlet to execute on remote host (templated). Also used as the default
+        value for `task_id`.
+    :type cmdlet: str
+    :param parameters:
+        Parameters to provide to cmdlet (templated). This is allowed only if
+        the `cmdlet` parameter is also given.
+    :type parameters: dict
+    :param logging: If true (default), log command output and streams during 
execution.
+    :type logging: bool
+    :param runspace_options:
+        Optional dictionary which is passed when creating the runspace pool. 
See
+        :py:class:`~pypsrp.powershell.RunspacePool` for a description of the
+        available options.
+    :type runspace_options: dict
+    :param wsman_options:
+        Optional dictionary which is passed when creating the `WSMan` client. 
See
+        :py:class:`~pypsrp.wsman.WSMan` for a description of the available 
options.
+    :type wsman_options: dict
     """
 
     template_fields = (
+        "cmdlet",
         "command",
+        "parameters",
         "powershell",
     )
     template_fields_renderers = {"command": "powershell", "powershell": 
"powershell"}
-    ui_color = "#901dd2"
+    ui_color = "#c2e2ff"
 
     def __init__(
         self,
         *,
         psrp_conn_id: str,
         command: Optional[str] = None,
         powershell: Optional[str] = None,
+        cmdlet: Optional[str] = None,
+        parameters: Optional[Dict[str, str]] = None,
+        logging: bool = True,
+        runspace_options: Optional[Dict[str, Any]] = None,
+        wsman_options: Optional[Dict[str, Any]] = None,
         **kwargs,
     ) -> None:
+        args = {command, powershell, cmdlet}
+        if not len(list(filter(None, args))) == 1:
+            raise ValueError("Must provide either 'command', 'powershell', or 
'cmdlet'")

Review comment:
       Can this not use the same logic as `exactly_one`?
   
   In either case you want to change `not ... ==` to `!=`. Also the message 
should say “exactly one” instead of “either” (which implies it’s allowed to 
pass multiple of them).




-- 
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