Skip to content

Commit 19eeddc

Browse files
Support enable sso for compute instance in python sdk v2 (#36358)
* re-add workspace default app insights, fix project ARM template (#36325) (#36336) * re-add workspace default app insights, fix project ARM template * move cl lines to right place * cl wording * add method to enable sso * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md --------- Co-authored-by: MilesHolland <108901744+MilesHolland@users.noreply.github.com>
1 parent 8b6e24d commit 19eeddc

File tree

6 files changed

+228
-1
lines changed

6 files changed

+228
-1
lines changed

sdk/ml/azure-ai-ml/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
### Features Added
1111

1212
- Expose `public_ip_address` in `AmlComputeNodeInfo`, to get the public ip address with the ssh port when calling `ml_client.compute.list_nodes`
13+
- Support `update_sso_settings` in `ComputeOperations`, to enable or disable single sign-on settings of a compute instance.
1314

1415
### Bugs Fixed
1516
- InputTypes exported in constants module

sdk/ml/azure-ai-ml/azure/ai/ml/_restclient/v2024_04_01_preview/aio/operations/_compute_operations.py

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
from ... import models as _models
2323
from ..._vendor import _convert_request
24-
from ...operations._compute_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_allowed_resize_sizes_request, build_get_request, build_list_keys_request, build_list_nodes_request, build_list_request, build_resize_request_initial, build_restart_request_initial, build_start_request_initial, build_stop_request_initial, build_update_custom_services_request, build_update_data_mounts_request, build_update_idle_shutdown_setting_request, build_update_request_initial
24+
from ...operations._compute_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_allowed_resize_sizes_request, build_get_request, build_list_keys_request, build_list_nodes_request, build_list_request, build_resize_request_initial, build_restart_request_initial, build_start_request_initial, build_stop_request_initial, build_update_custom_services_request, build_update_data_mounts_request, build_update_idle_shutdown_setting_request, build_update_sso_settings_request, build_update_request_initial
2525
T = TypeVar('T')
2626
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
2727

@@ -1276,6 +1276,72 @@ async def update_idle_shutdown_setting( # pylint: disable=inconsistent-return-s
12761276
update_idle_shutdown_setting.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}/updateIdleShutdownSetting"} # type: ignore
12771277

12781278

1279+
@distributed_trace_async
1280+
async def update_sso_settings( # pylint: disable=inconsistent-return-statements
1281+
self,
1282+
resource_group_name: str,
1283+
workspace_name: str,
1284+
compute_name: str,
1285+
parameters: "_models.SsoSetting",
1286+
**kwargs: Any
1287+
) -> None:
1288+
"""Update single sign-on settings of the compute instance.
1289+
1290+
:param resource_group_name: The name of the resource group. The name is case insensitive.
1291+
:type resource_group_name: str
1292+
:param workspace_name: Name of Azure Machine Learning workspace.
1293+
:type workspace_name: str
1294+
:param compute_name: Name of the Azure Machine Learning compute.
1295+
:type compute_name: str
1296+
:param parameters: The object for updating sso setting of specified ComputeInstance.
1297+
:type parameters: ~azure.mgmt.machinelearningservices.models.SsoSetting
1298+
:keyword callable cls: A custom type or function that will be passed the direct response
1299+
:return: None, or the result of cls(response)
1300+
:rtype: None
1301+
:raises: ~azure.core.exceptions.HttpResponseError
1302+
"""
1303+
cls = kwargs.pop('cls', None) # type: ClsType[None]
1304+
error_map = {
1305+
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1306+
}
1307+
error_map.update(kwargs.pop('error_map', {}))
1308+
1309+
api_version = kwargs.pop('api_version', "2024-04-01-preview") # type: str
1310+
content_type = kwargs.pop('content_type', "application/json") # type: Optional[str]
1311+
1312+
_json = self._serialize.body(parameters, 'SsoSetting')
1313+
1314+
request = build_update_sso_settings_request(
1315+
subscription_id=self._config.subscription_id,
1316+
resource_group_name=resource_group_name,
1317+
workspace_name=workspace_name,
1318+
compute_name=compute_name,
1319+
api_version=api_version,
1320+
content_type=content_type,
1321+
json=_json,
1322+
template_url=self.update_sso_settings.metadata['url'],
1323+
)
1324+
request = _convert_request(request)
1325+
request.url = self._client.format_url(request.url)
1326+
1327+
pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access
1328+
request,
1329+
stream=False,
1330+
**kwargs
1331+
)
1332+
response = pipeline_response.http_response
1333+
1334+
if response.status_code not in [200]:
1335+
map_error(status_code=response.status_code, response=response, error_map=error_map)
1336+
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
1337+
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1338+
1339+
if cls:
1340+
return cls(pipeline_response, None, {})
1341+
1342+
update_sso_settings.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}/enableSso"} # type: ignore
1343+
1344+
12791345
@distributed_trace_async
12801346
async def get_allowed_resize_sizes(
12811347
self,

sdk/ml/azure-ai-ml/azure/ai/ml/_restclient/v2024_04_01_preview/models/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@
594594
from ._models_py3 import SpeechEndpointDeploymentResourceProperties
595595
from ._models_py3 import SpeechEndpointResourceProperties
596596
from ._models_py3 import SslConfiguration
597+
from ._models_py3 import SsoSetting
597598
from ._models_py3 import StackEnsembleSettings
598599
from ._models_py3 import StaticInputData
599600
from ._models_py3 import StatusMessage
@@ -1265,6 +1266,7 @@
12651266
from ._models import SpeechEndpointDeploymentResourceProperties # type: ignore
12661267
from ._models import SpeechEndpointResourceProperties # type: ignore
12671268
from ._models import SslConfiguration # type: ignore
1269+
from ._models import SsoSetting # type: ignore
12681270
from ._models import StackEnsembleSettings # type: ignore
12691271
from ._models import StaticInputData # type: ignore
12701272
from ._models import StatusMessage # type: ignore
@@ -2151,6 +2153,7 @@
21512153
'SpeechEndpointDeploymentResourceProperties',
21522154
'SpeechEndpointResourceProperties',
21532155
'SslConfiguration',
2156+
'SsoSetting',
21542157
'StackEnsembleSettings',
21552158
'StaticInputData',
21562159
'StatusMessage',

sdk/ml/azure-ai-ml/azure/ai/ml/_restclient/v2024_04_01_preview/models/_models.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16369,6 +16369,29 @@ def __init__(
1636916369
self.idle_time_before_shutdown = kwargs.get('idle_time_before_shutdown', None)
1637016370

1637116371

16372+
class SsoSetting(msrest.serialization.Model):
16373+
"""Single sign-on settings of the compute instance.
16374+
16375+
:ivar enable_sso: The value of sso settings.
16376+
:vartype enable_sso: bool
16377+
"""
16378+
16379+
_attribute_map = {
16380+
'enable_sso': {'key': 'enableSSO', 'type': 'bool'},
16381+
}
16382+
16383+
def __init__(
16384+
self,
16385+
**kwargs
16386+
):
16387+
"""
16388+
:keyword enable_sso: The value of sso settings.
16389+
:paramtype enable_sso: bool
16390+
"""
16391+
super(SsoSetting, self).__init__(**kwargs)
16392+
self.enable_sso = kwargs.get('enable_sso', True)
16393+
16394+
1637216395
class Image(msrest.serialization.Model):
1637316396
"""Image.
1637416397

sdk/ml/azure-ai-ml/azure/ai/ml/_restclient/v2024_04_01_preview/models/_models_py3.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17662,6 +17662,31 @@ def __init__(
1766217662
self.idle_time_before_shutdown = idle_time_before_shutdown
1766317663

1766417664

17665+
class SsoSetting(msrest.serialization.Model):
17666+
"""Single sign-on settings of the compute instance.
17667+
17668+
:ivar enable_sso: The value of sso settings.
17669+
:vartype enable_sso: bool
17670+
"""
17671+
17672+
_attribute_map = {
17673+
'enable_sso': {'key': 'enableSSO', 'type': 'bool'},
17674+
}
17675+
17676+
def __init__(
17677+
self,
17678+
*,
17679+
enable_sso: Optional[bool] = True,
17680+
**kwargs
17681+
):
17682+
"""
17683+
:keyword enable_sso: The value of sso settings.
17684+
:paramtype enable_sso: bool
17685+
"""
17686+
super(SsoSetting, self).__init__(**kwargs)
17687+
self.enable_sso = enable_sso
17688+
17689+
1766517690
class Image(msrest.serialization.Model):
1766617691
"""Image.
1766717692

sdk/ml/azure-ai-ml/azure/ai/ml/_restclient/v2024_04_01_preview/operations/_compute_operations.py

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,48 @@ def build_update_idle_shutdown_setting_request(
558558
)
559559

560560

561+
def build_update_sso_settings_request(
562+
subscription_id, # type: str
563+
resource_group_name, # type: str
564+
workspace_name, # type: str
565+
compute_name, # type: str
566+
**kwargs # type: Any
567+
):
568+
# type: (...) -> HttpRequest
569+
api_version = kwargs.pop('api_version', "2024-04-01-preview") # type: str
570+
content_type = kwargs.pop('content_type', None) # type: Optional[str]
571+
572+
accept = "application/json"
573+
# Construct URL
574+
_url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}/enableSso") # pylint: disable=line-too-long
575+
path_format_arguments = {
576+
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1),
577+
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1),
578+
"workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str', pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]{2,32}$'),
579+
"computeName": _SERIALIZER.url("compute_name", compute_name, 'str', pattern=r'^[a-zA-Z](?![a-zA-Z0-9-]*-\d+$)[a-zA-Z0-9\-]{2,23}$'),
580+
}
581+
582+
_url = _format_url_section(_url, **path_format_arguments)
583+
584+
# Construct parameters
585+
_query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any]
586+
_query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str')
587+
588+
# Construct headers
589+
_header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
590+
if content_type is not None:
591+
_header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
592+
_header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
593+
594+
return HttpRequest(
595+
method="POST",
596+
url=_url,
597+
params=_query_parameters,
598+
headers=_header_parameters,
599+
**kwargs
600+
)
601+
602+
561603
def build_get_allowed_resize_sizes_request(
562604
subscription_id, # type: str
563605
resource_group_name, # type: str
@@ -1909,6 +1951,73 @@ def update_idle_shutdown_setting( # pylint: disable=inconsistent-return-stateme
19091951
update_idle_shutdown_setting.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}/updateIdleShutdownSetting"} # type: ignore
19101952

19111953

1954+
@distributed_trace
1955+
def update_sso_settings( # pylint: disable=inconsistent-return-statements
1956+
self,
1957+
resource_group_name, # type: str
1958+
workspace_name, # type: str
1959+
compute_name, # type: str
1960+
parameters, # type: "_models.SsoSetting"
1961+
**kwargs # type: Any
1962+
):
1963+
# type: (...) -> None
1964+
"""Update single sign-on settings of the compute instance.
1965+
1966+
:param resource_group_name: The name of the resource group. The name is case insensitive.
1967+
:type resource_group_name: str
1968+
:param workspace_name: Name of Azure Machine Learning workspace.
1969+
:type workspace_name: str
1970+
:param compute_name: Name of the Azure Machine Learning compute.
1971+
:type compute_name: str
1972+
:param parameters: The object for updating sso setting of specified ComputeInstance.
1973+
:type parameters: ~azure.mgmt.machinelearningservices.models.SsoSetting
1974+
:keyword callable cls: A custom type or function that will be passed the direct response
1975+
:return: None, or the result of cls(response)
1976+
:rtype: None
1977+
:raises: ~azure.core.exceptions.HttpResponseError
1978+
"""
1979+
cls = kwargs.pop('cls', None) # type: ClsType[None]
1980+
error_map = {
1981+
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
1982+
}
1983+
error_map.update(kwargs.pop('error_map', {}))
1984+
1985+
api_version = kwargs.pop('api_version', "2024-01-01-preview") # type: str
1986+
content_type = kwargs.pop('content_type', "application/json") # type: Optional[str]
1987+
1988+
_json = self._serialize.body(parameters, 'SsoSetting')
1989+
1990+
request = build_update_sso_settings_request(
1991+
subscription_id=self._config.subscription_id,
1992+
resource_group_name=resource_group_name,
1993+
workspace_name=workspace_name,
1994+
compute_name=compute_name,
1995+
api_version=api_version,
1996+
content_type=content_type,
1997+
json=_json,
1998+
template_url=self.update_sso_settings.metadata['url'],
1999+
)
2000+
request = _convert_request(request)
2001+
request.url = self._client.format_url(request.url)
2002+
2003+
pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access
2004+
request,
2005+
stream=False,
2006+
**kwargs
2007+
)
2008+
response = pipeline_response.http_response
2009+
2010+
if response.status_code not in [200]:
2011+
map_error(status_code=response.status_code, response=response, error_map=error_map)
2012+
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
2013+
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
2014+
2015+
if cls:
2016+
return cls(pipeline_response, None, {})
2017+
2018+
update_sso_settings.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}/enableSso"} # type: ignore
2019+
2020+
19122021
@distributed_trace
19132022
def get_allowed_resize_sizes(
19142023
self,

0 commit comments

Comments
 (0)