Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions providers/src/airflow/providers/microsoft/psrp/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
Changelog
---------

main
....

.. warning::
All deprecated classes, parameters and features have been removed from the Microsoft.PSRP provider package.
The following breaking changes were introduced:

* Passing kwargs to ``invoke_cmdlet`` was removed. Please use ``parameters`` instead.

2.8.0
.....

Expand Down
16 changes: 1 addition & 15 deletions providers/src/airflow/providers/microsoft/psrp/hooks/psrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
from copy import copy
from logging import DEBUG, ERROR, INFO, WARNING
from typing import TYPE_CHECKING, Any, Callable
from warnings import warn
from weakref import WeakKeyDictionary

from pypsrp.host import PSHost
from pypsrp.messages import MessageType
from pypsrp.powershell import PowerShell, PSInvocationState, RunspacePool
from pypsrp.wsman import WSMan

from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
from airflow.exceptions import AirflowException
from airflow.hooks.base import BaseHook

INFORMATIONAL_RECORD_LEVEL_MAP = {
Expand Down Expand Up @@ -229,21 +228,8 @@ def invoke_cmdlet(
use_local_scope: bool | None = None,
arguments: list[str] | None = None,
parameters: dict[str, str] | None = None,
**kwargs: str,
) -> PowerShell:
"""Invoke a PowerShell cmdlet and return session."""
if kwargs:
if parameters:
raise ValueError("**kwargs not allowed when 'parameters' is used at the same time.")
warn(
"Passing **kwargs to 'invoke_cmdlet' is deprecated "
"and will be removed in a future release. Please use 'parameters' "
"instead.",
AirflowProviderDeprecationWarning,
stacklevel=2,
)
parameters = kwargs

with self.invoke() as ps:
ps.add_cmdlet(name, use_local_scope=use_local_scope)
for argument in arguments or ():
Expand Down
12 changes: 1 addition & 11 deletions providers/tests/microsoft/psrp/hooks/test_psrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from pypsrp.messages import MessageType
from pypsrp.powershell import PSInvocationState

from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
from airflow.exceptions import AirflowException
from airflow.models import Connection
from airflow.providers.microsoft.psrp.hooks.psrp import PsrpHook

Expand Down Expand Up @@ -195,16 +195,6 @@ def test_invoke_cmdlet(self, *mocks):
assert [call({"bar": "1", "baz": "2"})] == ps.add_parameters.mock_calls
assert [call(arg) for arg in arguments] == ps.add_argument.mock_calls

def test_invoke_cmdlet_deprecated_kwargs(self, *mocks):
with PsrpHook(CONNECTION_ID) as hook:
with pytest.warns(
AirflowProviderDeprecationWarning,
match=r"Passing \*\*kwargs to 'invoke_cmdlet' is deprecated and will be removed in a future release. Please use 'parameters' instead.",
):
ps = hook.invoke_cmdlet("foo", bar="1", baz="2")
assert [call("foo", use_local_scope=None)] == ps.add_cmdlet.mock_calls
assert [call({"bar": "1", "baz": "2"})] == ps.add_parameters.mock_calls

def test_invoke_powershell(self, *mocks):
with PsrpHook(CONNECTION_ID) as hook:
ps = hook.invoke_powershell("foo")
Expand Down