33# ---------------------------------------------------------
44
55from typing import Dict , Iterable
6- from azure .ai .ml ._restclient .v2023_04_01_preview import AzureMachineLearningWorkspaces as ServiceClient122022Preview
6+ from azure .ai .ml ._restclient .v2023_04_01_preview import AzureMachineLearningWorkspaces as ServiceClient042023Preview
7+ from azure .ai .ml ._restclient .v2023_04_01_preview .models import OutboundRuleBasicResource
78from azure .ai .ml ._scope_dependent_operations import OperationsContainer , OperationScope
89
910from azure .ai .ml ._telemetry import ActivityType , monitor_with_activity
1819
1920
2021class WorkspaceOutboundRuleOperations :
22+ """WorkspaceOutboundRuleOperations.
23+
24+ You should not instantiate this class directly. Instead, you should create an MLClient instance that instantiates it
25+ for you and attaches it as an attribute.
26+ """
27+
2128 def __init__ (
2229 self ,
2330 operation_scope : OperationScope ,
24- service_client : ServiceClient122022Preview ,
31+ service_client : ServiceClient042023Preview ,
2532 all_operations : OperationsContainer ,
2633 credentials : TokenCredential = None ,
2734 ** kwargs : Dict ,
@@ -36,16 +43,92 @@ def __init__(
3643 self ._init_kwargs = kwargs
3744
3845 @monitor_with_activity (logger , "WorkspaceOutboundRule.Get" , ActivityType .PUBLICAPI )
39- def get (self , resource_group : str , ws_name : str , outbound_rule_name : str , ** kwargs ) -> OutboundRule :
40- workspace_name = self ._check_workspace_name (ws_name )
46+ def get (self , workspace_name : str , outbound_rule_name : str , ** kwargs ) -> OutboundRule :
47+ """Get a workspace OutboundRule by name.
48+
49+ :param workspace_name: Name of the workspace.
50+ :type workspace_name: str
51+ :param outbound_rule_name: Name of the outbound rule.
52+ :type outbound_rule_name: str
53+ :return: The OutboundRule with the provided name for the workspace.
54+ :rtype: OutboundRule
55+ """
56+
57+ workspace_name = self ._check_workspace_name (workspace_name )
4158 resource_group = kwargs .get ("resource_group" ) or self ._resource_group_name
4259
4360 obj = self ._rule_operation .get (resource_group , workspace_name , outbound_rule_name )
4461 return OutboundRule ._from_rest_object (obj .properties , name = obj .name ) # pylint: disable=protected-access
4562
63+ @monitor_with_activity (logger , "WorkspaceOutboundRule.BeginCreate" , ActivityType .PUBLICAPI )
64+ def begin_create (self , workspace_name : str , rule : OutboundRule , ** kwargs ) -> LROPoller [OutboundRule ]:
65+ """Create a Workspace OutboundRule.
66+
67+ :param workspace_name: Name of the workspace.
68+ :type workspace_name: str
69+ :param rule: OutboundRule definition (FqdnDestination, PrivateEndpointDestination, or ServiceTagDestination).
70+ :type rule: OutboundRule
71+ :return: An instance of LROPoller that returns an OutboundRule.
72+ :rtype: ~azure.core.polling.LROPoller[~azure.ai.ml.entities.OutboundRule]
73+ """
74+
75+ workspace_name = self ._check_workspace_name (workspace_name )
76+ resource_group = kwargs .get ("resource_group" ) or self ._resource_group_name
77+
78+ rule_params = OutboundRuleBasicResource (properties = rule ._to_rest_object ()) # pylint: disable=protected-access
79+
80+ # pylint: disable=unused-argument
81+ def callback (_ , deserialized , args ):
82+ properties = deserialized .properties
83+ name = deserialized .name
84+ return OutboundRule ._from_rest_object (properties , name = name ) # pylint: disable=protected-access
85+
86+ poller = self ._rule_operation .begin_create_or_update (
87+ resource_group , workspace_name , rule .name , rule_params , polling = True , cls = callback
88+ )
89+ module_logger .info ("Create request initiated for outbound rule with name: %s\n " , rule .name )
90+ return poller
91+
92+ @monitor_with_activity (logger , "WorkspaceOutboundRule.BeginUpdate" , ActivityType .PUBLICAPI )
93+ def begin_update (self , workspace_name : str , rule : OutboundRule , ** kwargs ) -> LROPoller [OutboundRule ]:
94+ """Update a Workspace OutboundRule.
95+
96+ :param workspace_name: Name of the workspace.
97+ :type workspace_name: str
98+ :param rule: OutboundRule definition (FqdnDestination, PrivateEndpointDestination, or ServiceTagDestination).
99+ :type rule: OutboundRule
100+ :return: An instance of LROPoller that returns an OutboundRule.
101+ :rtype: ~azure.core.polling.LROPoller[~azure.ai.ml.entities.OutboundRule]
102+ """
103+
104+ workspace_name = self ._check_workspace_name (workspace_name )
105+ resource_group = kwargs .get ("resource_group" ) or self ._resource_group_name
106+
107+ rule_params = OutboundRuleBasicResource (properties = rule ._to_rest_object ()) # pylint: disable=protected-access
108+
109+ # pylint: disable=unused-argument
110+ def callback (_ , deserialized , args ):
111+ properties = deserialized .properties
112+ name = deserialized .name
113+ return OutboundRule ._from_rest_object (properties , name = name ) # pylint: disable=protected-access
114+
115+ poller = self ._rule_operation .begin_create_or_update (
116+ resource_group , workspace_name , rule .name , rule_params , polling = True , cls = callback
117+ )
118+ module_logger .info ("Update request initiated for outbound rule with name: %s\n " , rule .name )
119+ return poller
120+
46121 @monitor_with_activity (logger , "WorkspaceOutboundRule.List" , ActivityType .PUBLICAPI )
47- def list (self , resource_group : str , ws_name : str , ** kwargs ) -> Iterable [OutboundRule ]:
48- workspace_name = self ._check_workspace_name (ws_name )
122+ def list (self , workspace_name : str , ** kwargs ) -> Iterable [OutboundRule ]:
123+ """List Workspace OutboundRules.
124+
125+ :param workspace_name: Name of the workspace.
126+ :type workspace_name: str
127+ :return: An Iterable of OutboundRule.
128+ :rtype: Iterable[OutboundRule]
129+ """
130+
131+ workspace_name = self ._check_workspace_name (workspace_name )
49132 resource_group = kwargs .get ("resource_group" ) or self ._resource_group_name
50133
51134 rest_rules = self ._rule_operation .list (resource_group , workspace_name )
@@ -57,8 +140,18 @@ def list(self, resource_group: str, ws_name: str, **kwargs) -> Iterable[Outbound
57140 return result
58141
59142 @monitor_with_activity (logger , "WorkspaceOutboundRule.Remove" , ActivityType .PUBLICAPI )
60- def begin_remove (self , resource_group : str , ws_name : str , outbound_rule_name : str , ** kwargs ) -> LROPoller [None ]:
61- workspace_name = self ._check_workspace_name (ws_name )
143+ def begin_remove (self , workspace_name : str , outbound_rule_name : str , ** kwargs ) -> LROPoller [None ]:
144+ """Remove a Workspace OutboundRule.
145+
146+ :param workspace_name: Name of the workspace.
147+ :type workspace_name: str
148+ :param outbound_rule_name: Name of the outbound rule to remove.
149+ :type outbound_rule_name: str
150+ :return: An Iterable of OutboundRule.
151+ :rtype: Iterable[OutboundRule]
152+ """
153+
154+ workspace_name = self ._check_workspace_name (workspace_name )
62155 resource_group = kwargs .get ("resource_group" ) or self ._resource_group_name
63156
64157 poller = self ._rule_operation .begin_delete (
0 commit comments