Skip to content

Commit c7d9d75

Browse files
authored
code and test (Azure#31574)
Co-authored-by: azure-sdk <PythonSdkPipelines>
1 parent cf9067b commit c7d9d75

File tree

12 files changed

+119
-92
lines changed

12 files changed

+119
-92
lines changed

sdk/resourceconnector/azure-mgmt-resourceconnector/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Release History
22

3+
## 1.0.0 (2023-08-18)
4+
5+
### Features Added
6+
7+
- Operation AppliancesOperations.list_keys has a new optional parameter artifact_type
8+
39
## 1.0.0b4 (2023-04-24)
410

511
### Breaking Changes
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "0de386a47454f277f89563c616992d6defa0bf98",
2+
"commit": "990705d56b53a74758ce7018d1dad684bc5cf592",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4-
"autorest": "3.9.2",
4+
"autorest": "3.9.7",
55
"use": [
6-
"@autorest/python@6.4.7",
7-
"@autorest/modelerfour@4.24.3"
6+
"@autorest/python@6.7.1",
7+
"@autorest/modelerfour@4.26.2"
88
],
9-
"autorest_command": "autorest specification/resourceconnector/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.4.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False",
9+
"autorest_command": "autorest specification/resourceconnector/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False",
1010
"readme": "specification/resourceconnector/resource-manager/readme.md"
1111
}

sdk/resourceconnector/azure-mgmt-resourceconnector/azure/mgmt/resourceconnector/_serialization.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,9 @@ def _serialize(self, target_obj, data_type=None, **kwargs):
662662
_serialized.update(_new_attr) # type: ignore
663663
_new_attr = _new_attr[k] # type: ignore
664664
_serialized = _serialized[k]
665-
except ValueError:
666-
continue
665+
except ValueError as err:
666+
if isinstance(err, SerializationError):
667+
raise
667668

668669
except (AttributeError, KeyError, TypeError) as err:
669670
msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj))
@@ -741,6 +742,8 @@ def query(self, name, data, data_type, **kwargs):
741742
742743
:param data: The data to be serialized.
743744
:param str data_type: The type to be serialized from.
745+
:keyword bool skip_quote: Whether to skip quote the serialized result.
746+
Defaults to False.
744747
:rtype: str
745748
:raises: TypeError if serialization fails.
746749
:raises: ValueError if data is None
@@ -749,10 +752,8 @@ def query(self, name, data, data_type, **kwargs):
749752
# Treat the list aside, since we don't want to encode the div separator
750753
if data_type.startswith("["):
751754
internal_data_type = data_type[1:-1]
752-
data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data]
753-
if not kwargs.get("skip_quote", False):
754-
data = [quote(str(d), safe="") for d in data]
755-
return str(self.serialize_iter(data, internal_data_type, **kwargs))
755+
do_quote = not kwargs.get("skip_quote", False)
756+
return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs))
756757

757758
# Not a list, regular serialization
758759
output = self.serialize_data(data, data_type, **kwargs)
@@ -891,6 +892,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs):
891892
not be None or empty.
892893
:param str div: If set, this str will be used to combine the elements
893894
in the iterable into a combined string. Default is 'None'.
895+
:keyword bool do_quote: Whether to quote the serialized result of each iterable element.
896+
Defaults to False.
894897
:rtype: list, str
895898
"""
896899
if isinstance(data, str):
@@ -903,9 +906,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs):
903906
for d in data:
904907
try:
905908
serialized.append(self.serialize_data(d, iter_type, **kwargs))
906-
except ValueError:
909+
except ValueError as err:
910+
if isinstance(err, SerializationError):
911+
raise
907912
serialized.append(None)
908913

914+
if kwargs.get("do_quote", False):
915+
serialized = ["" if s is None else quote(str(s), safe="") for s in serialized]
916+
909917
if div:
910918
serialized = ["" if s is None else str(s) for s in serialized]
911919
serialized = div.join(serialized)
@@ -950,7 +958,9 @@ def serialize_dict(self, attr, dict_type, **kwargs):
950958
for key, value in attr.items():
951959
try:
952960
serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs)
953-
except ValueError:
961+
except ValueError as err:
962+
if isinstance(err, SerializationError):
963+
raise
954964
serialized[self.serialize_unicode(key)] = None
955965

956966
if "xml" in serialization_ctxt:

sdk/resourceconnector/azure-mgmt-resourceconnector/azure/mgmt/resourceconnector/_vendor.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
66
# --------------------------------------------------------------------------
77

8-
from typing import List, cast
9-
108
from azure.core.pipeline.transport import HttpRequest
119

1210

@@ -16,15 +14,3 @@ def _convert_request(request, files=None):
1614
if files:
1715
request.set_formdata_body(files)
1816
return request
19-
20-
21-
def _format_url_section(template, **kwargs):
22-
components = template.split("/")
23-
while components:
24-
try:
25-
return template.format(**kwargs)
26-
except KeyError as key:
27-
# Need the cast, as for some reasons "split" is typed as list[str | Any]
28-
formatted_components = cast(List[str], template.split("/"))
29-
components = [c for c in formatted_components if "{}".format(key.args[0]) not in c]
30-
template = "/".join(components)

sdk/resourceconnector/azure-mgmt-resourceconnector/azure/mgmt/resourceconnector/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "1.0.0b4"
9+
VERSION = "1.0.0"

sdk/resourceconnector/azure-mgmt-resourceconnector/azure/mgmt/resourceconnector/aio/operations/_appliances_operations.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Code generated by Microsoft (R) AutoRest Code Generator.
77
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
88
# --------------------------------------------------------------------------
9+
from io import IOBase
910
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
1011
import urllib.parse
1112

@@ -468,7 +469,7 @@ async def _create_or_update_initial(
468469
content_type = content_type or "application/json"
469470
_json = None
470471
_content = None
471-
if isinstance(parameters, (IO, bytes)):
472+
if isinstance(parameters, (IOBase, bytes)):
472473
_content = parameters
473474
else:
474475
_json = self._serialize.body(parameters, "Appliance")
@@ -936,7 +937,7 @@ async def list_cluster_user_credential(
936937

937938
@distributed_trace_async
938939
async def list_keys(
939-
self, resource_group_name: str, resource_name: str, **kwargs: Any
940+
self, resource_group_name: str, resource_name: str, artifact_type: Optional[str] = None, **kwargs: Any
940941
) -> _models.ApplianceListKeysResults:
941942
"""Gets the management config.
942943
@@ -947,6 +948,9 @@ async def list_keys(
947948
:type resource_group_name: str
948949
:param resource_name: Appliances name. Required.
949950
:type resource_name: str
951+
:param artifact_type: This sets the type of artifact being returned, when empty no artifact
952+
endpoint is returned. Default value is None.
953+
:type artifact_type: str
950954
:keyword callable cls: A custom type or function that will be passed the direct response
951955
:return: ApplianceListKeysResults or the result of cls(response)
952956
:rtype: ~azure.mgmt.resourceconnector.models.ApplianceListKeysResults
@@ -970,6 +974,7 @@ async def list_keys(
970974
resource_group_name=resource_group_name,
971975
resource_name=resource_name,
972976
subscription_id=self._config.subscription_id,
977+
artifact_type=artifact_type,
973978
api_version=api_version,
974979
template_url=self.list_keys.metadata["url"],
975980
headers=_headers,

sdk/resourceconnector/azure-mgmt-resourceconnector/azure/mgmt/resourceconnector/models/_models_py3.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,12 @@ class Appliance(TrackedResource): # pylint: disable=too-many-instance-attribute
149149
:vartype public_key: str
150150
:ivar status: Appliance’s health and state of connection to on-prem. Known values are:
151151
"WaitingForHeartbeat", "Validating", "Connecting", "Connected", "Running",
152-
"PreparingForUpgrade", "UpgradePrerequisitesCompleted", "PreUpgrade", "UpgradingKVAIO",
153-
"WaitingForKVAIO", "ImagePending", "ImageProvisioning", "ImageProvisioned", "ImageDownloading",
154-
"ImageDownloaded", "ImageDeprovisioning", "ImageUnknown", "UpdatingCloudOperator",
155-
"WaitingForCloudOperator", "UpdatingCAPI", "UpdatingCluster", "PostUpgrade", "UpgradeComplete",
152+
"PreparingForUpgrade", "ETCDSnapshotFailed", "UpgradePrerequisitesCompleted",
153+
"ValidatingSFSConnectivity", "ValidatingImageDownload", "ValidatingImageUpload",
154+
"ValidatingETCDHealth", "PreUpgrade", "UpgradingKVAIO", "WaitingForKVAIO", "ImagePending",
155+
"ImageProvisioning", "ImageProvisioned", "ImageDownloading", "ImageDownloaded",
156+
"ImageDeprovisioning", "ImageUnknown", "UpdatingCloudOperator", "WaitingForCloudOperator",
157+
"UpdatingCAPI", "UpdatingCluster", "PostUpgrade", "UpgradeComplete",
156158
"UpgradeClusterExtensionFailedToDelete", "UpgradeFailed", "Offline", and "None".
157159
:vartype status: str or ~azure.mgmt.resourceconnector.models.Status
158160
:ivar version: Version of the Appliance.
@@ -462,7 +464,7 @@ class AppliancePropertiesInfrastructureConfig(_serialization.Model):
462464
"""Contains infrastructure information about the Appliance.
463465
464466
:ivar provider: Information about the connected appliance. Known values are: "VMWare", "HCI",
465-
"SCVMM", "KubeVirt", and "OpenStack".
467+
and "SCVMM".
466468
:vartype provider: str or ~azure.mgmt.resourceconnector.models.Provider
467469
"""
468470

@@ -473,7 +475,7 @@ class AppliancePropertiesInfrastructureConfig(_serialization.Model):
473475
def __init__(self, *, provider: Optional[Union[str, "_models.Provider"]] = None, **kwargs: Any) -> None:
474476
"""
475477
:keyword provider: Information about the connected appliance. Known values are: "VMWare",
476-
"HCI", "SCVMM", "KubeVirt", and "OpenStack".
478+
"HCI", and "SCVMM".
477479
:paramtype provider: str or ~azure.mgmt.resourceconnector.models.Provider
478480
"""
479481
super().__init__(**kwargs)

sdk/resourceconnector/azure-mgmt-resourceconnector/azure/mgmt/resourceconnector/models/_resource_connector_mgmt_client_enums.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ class Provider(str, Enum, metaclass=CaseInsensitiveEnumMeta):
4444
VM_WARE = "VMWare"
4545
HCI = "HCI"
4646
SCVMM = "SCVMM"
47-
KUBE_VIRT = "KubeVirt"
48-
OPEN_STACK = "OpenStack"
4947

5048

5149
class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
@@ -73,7 +71,12 @@ class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta):
7371
CONNECTED = "Connected"
7472
RUNNING = "Running"
7573
PREPARING_FOR_UPGRADE = "PreparingForUpgrade"
74+
ETCD_SNAPSHOT_FAILED = "ETCDSnapshotFailed"
7675
UPGRADE_PREREQUISITES_COMPLETED = "UpgradePrerequisitesCompleted"
76+
VALIDATING_SFS_CONNECTIVITY = "ValidatingSFSConnectivity"
77+
VALIDATING_IMAGE_DOWNLOAD = "ValidatingImageDownload"
78+
VALIDATING_IMAGE_UPLOAD = "ValidatingImageUpload"
79+
VALIDATING_ETCD_HEALTH = "ValidatingETCDHealth"
7780
PRE_UPGRADE = "PreUpgrade"
7881
UPGRADING_KVAIO = "UpgradingKVAIO"
7982
WAITING_FOR_KVAIO = "WaitingForKVAIO"

sdk/resourceconnector/azure-mgmt-resourceconnector/azure/mgmt/resourceconnector/operations/_appliances_operations.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Code generated by Microsoft (R) AutoRest Code Generator.
77
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
88
# --------------------------------------------------------------------------
9+
from io import IOBase
910
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
1011
import urllib.parse
1112

@@ -29,7 +30,7 @@
2930

3031
from .. import models as _models
3132
from .._serialization import Serializer
32-
from .._vendor import _convert_request, _format_url_section
33+
from .._vendor import _convert_request
3334

3435
T = TypeVar("T")
3536
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
@@ -72,7 +73,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H
7273
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
7374
}
7475

75-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
76+
_url: str = _url.format(**path_format_arguments) # type: ignore
7677

7778
# Construct parameters
7879
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -98,7 +99,7 @@ def build_get_telemetry_config_request(subscription_id: str, **kwargs: Any) -> H
9899
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
99100
}
100101

101-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
102+
_url: str = _url.format(**path_format_arguments) # type: ignore
102103

103104
# Construct parameters
104105
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -128,7 +129,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_
128129
),
129130
}
130131

131-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
132+
_url: str = _url.format(**path_format_arguments) # type: ignore
132133

133134
# Construct parameters
134135
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -166,7 +167,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription
166167
),
167168
}
168169

169-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
170+
_url: str = _url.format(**path_format_arguments) # type: ignore
170171

171172
# Construct parameters
172173
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -207,7 +208,7 @@ def build_create_or_update_request(
207208
),
208209
}
209210

210-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
211+
_url: str = _url.format(**path_format_arguments) # type: ignore
211212

212213
# Construct parameters
213214
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -249,7 +250,7 @@ def build_delete_request(
249250
),
250251
}
251252

252-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
253+
_url: str = _url.format(**path_format_arguments) # type: ignore
253254

254255
# Construct parameters
255256
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -290,7 +291,7 @@ def build_update_request(
290291
),
291292
}
292293

293-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
294+
_url: str = _url.format(**path_format_arguments) # type: ignore
294295

295296
# Construct parameters
296297
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -332,7 +333,7 @@ def build_list_cluster_user_credential_request(
332333
),
333334
}
334335

335-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
336+
_url: str = _url.format(**path_format_arguments) # type: ignore
336337

337338
# Construct parameters
338339
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -344,7 +345,12 @@ def build_list_cluster_user_credential_request(
344345

345346

346347
def build_list_keys_request(
347-
resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any
348+
resource_group_name: str,
349+
resource_name: str,
350+
subscription_id: str,
351+
*,
352+
artifact_type: Optional[str] = None,
353+
**kwargs: Any
348354
) -> HttpRequest:
349355
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
350356
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
@@ -372,10 +378,12 @@ def build_list_keys_request(
372378
),
373379
}
374380

375-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
381+
_url: str = _url.format(**path_format_arguments) # type: ignore
376382

377383
# Construct parameters
378384
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
385+
if artifact_type is not None:
386+
_params["artifactType"] = _SERIALIZER.query("artifact_type", artifact_type, "str")
379387

380388
# Construct headers
381389
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
@@ -413,7 +421,7 @@ def build_get_upgrade_graph_request(
413421
"upgradeGraph": _SERIALIZER.url("upgrade_graph", upgrade_graph, "str"),
414422
}
415423

416-
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
424+
_url: str = _url.format(**path_format_arguments) # type: ignore
417425

418426
# Construct parameters
419427
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
@@ -843,7 +851,7 @@ def _create_or_update_initial(
843851
content_type = content_type or "application/json"
844852
_json = None
845853
_content = None
846-
if isinstance(parameters, (IO, bytes)):
854+
if isinstance(parameters, (IOBase, bytes)):
847855
_content = parameters
848856
else:
849857
_json = self._serialize.body(parameters, "Appliance")
@@ -1306,7 +1314,7 @@ def list_cluster_user_credential(
13061314

13071315
@distributed_trace
13081316
def list_keys(
1309-
self, resource_group_name: str, resource_name: str, **kwargs: Any
1317+
self, resource_group_name: str, resource_name: str, artifact_type: Optional[str] = None, **kwargs: Any
13101318
) -> _models.ApplianceListKeysResults:
13111319
"""Gets the management config.
13121320
@@ -1317,6 +1325,9 @@ def list_keys(
13171325
:type resource_group_name: str
13181326
:param resource_name: Appliances name. Required.
13191327
:type resource_name: str
1328+
:param artifact_type: This sets the type of artifact being returned, when empty no artifact
1329+
endpoint is returned. Default value is None.
1330+
:type artifact_type: str
13201331
:keyword callable cls: A custom type or function that will be passed the direct response
13211332
:return: ApplianceListKeysResults or the result of cls(response)
13221333
:rtype: ~azure.mgmt.resourceconnector.models.ApplianceListKeysResults
@@ -1340,6 +1351,7 @@ def list_keys(
13401351
resource_group_name=resource_group_name,
13411352
resource_name=resource_name,
13421353
subscription_id=self._config.subscription_id,
1354+
artifact_type=artifact_type,
13431355
api_version=api_version,
13441356
template_url=self.list_keys.metadata["url"],
13451357
headers=_headers,

0 commit comments

Comments
 (0)