diff --git a/sdk/devhub/azure-mgmt-devhub/README.md b/sdk/devhub/azure-mgmt-devhub/README.md index e090a7e97369..4dff8f0eadc0 100644 --- a/sdk/devhub/azure-mgmt-devhub/README.md +++ b/sdk/devhub/azure-mgmt-devhub/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Devhub Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -59,6 +59,3 @@ Code samples for this package can be found at: If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-devhub%2FREADME.png) diff --git a/sdk/devhub/azure-mgmt-devhub/_meta.json b/sdk/devhub/azure-mgmt-devhub/_meta.json index 86a43a25e50f..4cff105fc615 100644 --- a/sdk/devhub/azure-mgmt-devhub/_meta.json +++ b/sdk/devhub/azure-mgmt-devhub/_meta.json @@ -1,11 +1,11 @@ { - "commit": "5d2adf9b7fda669b4a2538c65e937ee74fe3f966", + "commit": "298087f29f5414863b26d273297e6a885c41d7dc", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.4.12", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/developerhub/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.12 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/developerhub/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/developerhub/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_configuration.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_configuration.py index 97d9c4391e82..af9bbb6cedd8 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_configuration.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class DevHubMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DevHubMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DevHubMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -27,16 +26,15 @@ class DevHubMgmtClientConfiguration(Configuration): # pylint: disable=too-many- :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-10-11-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(DevHubMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-10-11-preview") + api_version: str = kwargs.pop("api_version", "2024-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-devhub/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_dev_hub_mgmt_client.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_dev_hub_mgmt_client.py index f4a801ad9b00..68915d16ce49 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_dev_hub_mgmt_client.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_dev_hub_mgmt_client.py @@ -8,14 +8,17 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import DevHubMgmtClientConfiguration from ._serialization import Deserializer, Serializer -from .operations import DevHubMgmtClientOperationsMixin, Operations, WorkflowOperations +from .operations import DevHubMgmtClientOperationsMixin, IacProfilesOperations, Operations, WorkflowOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -29,13 +32,15 @@ class DevHubMgmtClient(DevHubMgmtClientOperationsMixin): # pylint: disable=clie :vartype operations: azure.mgmt.devhub.operations.Operations :ivar workflow: WorkflowOperations operations :vartype workflow: azure.mgmt.devhub.operations.WorkflowOperations + :ivar iac_profiles: IacProfilesOperations operations + :vartype iac_profiles: azure.mgmt.devhub.operations.IacProfilesOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-10-11-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -48,7 +53,25 @@ def __init__( **kwargs: Any ) -> None: self._config = DevHubMgmtClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -56,8 +79,9 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.workflow = WorkflowOperations(self._client, self._config, self._serialize, self._deserialize) + self.iac_profiles = IacProfilesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -77,12 +101,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "DevHubMgmtClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_serialization.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_serialization.py index 842ae727fbbc..8139854b97bb 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_serialization.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -170,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -295,7 +290,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -340,7 +335,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +346,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -390,7 +385,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -415,7 +410,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -445,7 +440,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -545,7 +540,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,7 +556,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -649,7 +644,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -662,12 +657,13 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -709,7 +705,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -729,6 +725,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -741,7 +738,9 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -749,10 +748,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -803,7 +800,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -823,7 +820,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -891,6 +888,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -903,9 +902,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -950,7 +954,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -983,7 +989,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1160,10 +1166,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1199,7 +1205,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1220,7 +1225,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1361,7 +1365,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1381,7 +1385,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1434,12 +1438,12 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1471,7 +1475,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1505,14 +1509,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1568,7 +1572,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1642,7 +1646,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1690,7 +1694,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1747,7 +1751,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1798,7 +1802,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1852,10 +1855,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1883,7 +1886,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1900,7 +1903,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1935,7 +1938,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1972,7 +1975,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1988,9 +1991,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_vendor.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_vendor.py index d844497cdd90..61f2a246e7bd 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_vendor.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/_vendor.py @@ -6,9 +6,7 @@ # -------------------------------------------------------------------------- from abc import ABC -from typing import List, TYPE_CHECKING, cast - -from azure.core.pipeline.transport import HttpRequest +from typing import TYPE_CHECKING from ._configuration import DevHubMgmtClientConfiguration @@ -19,26 +17,6 @@ from ._serialization import Deserializer, Serializer -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) - - class DevHubMgmtClientMixinABC(ABC): """DO NOT use this class. It is for internal typing use only.""" diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/_configuration.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/_configuration.py index bee509d49b56..b930f3da0005 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/_configuration.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class DevHubMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DevHubMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DevHubMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -27,16 +26,15 @@ class DevHubMgmtClientConfiguration(Configuration): # pylint: disable=too-many- :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-10-11-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(DevHubMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-10-11-preview") + api_version: str = kwargs.pop("api_version", "2024-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-devhub/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/_dev_hub_mgmt_client.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/_dev_hub_mgmt_client.py index 6c4575e2665b..bf667943c87e 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/_dev_hub_mgmt_client.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/_dev_hub_mgmt_client.py @@ -8,14 +8,17 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import DevHubMgmtClientConfiguration -from .operations import DevHubMgmtClientOperationsMixin, Operations, WorkflowOperations +from .operations import DevHubMgmtClientOperationsMixin, IacProfilesOperations, Operations, WorkflowOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -29,13 +32,15 @@ class DevHubMgmtClient(DevHubMgmtClientOperationsMixin): # pylint: disable=clie :vartype operations: azure.mgmt.devhub.aio.operations.Operations :ivar workflow: WorkflowOperations operations :vartype workflow: azure.mgmt.devhub.aio.operations.WorkflowOperations + :ivar iac_profiles: IacProfilesOperations operations + :vartype iac_profiles: azure.mgmt.devhub.aio.operations.IacProfilesOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-10-11-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -48,7 +53,25 @@ def __init__( **kwargs: Any ) -> None: self._config = DevHubMgmtClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -56,8 +79,11 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.workflow = WorkflowOperations(self._client, self._config, self._serialize, self._deserialize) + self.iac_profiles = IacProfilesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -77,12 +103,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "DevHubMgmtClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/_vendor.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/_vendor.py index 35d417b2441f..599a52b9225f 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/_vendor.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/_vendor.py @@ -8,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import DevHubMgmtClientConfiguration if TYPE_CHECKING: diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/__init__.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/__init__.py index ac5915775e4f..1332eee763bf 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/__init__.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/__init__.py @@ -9,6 +9,7 @@ from ._operations import Operations from ._dev_hub_mgmt_client_operations import DevHubMgmtClientOperationsMixin from ._workflow_operations import WorkflowOperations +from ._iac_profiles_operations import IacProfilesOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -18,6 +19,7 @@ "Operations", "DevHubMgmtClientOperationsMixin", "WorkflowOperations", + "IacProfilesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/_dev_hub_mgmt_client_operations.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/_dev_hub_mgmt_client_operations.py index 851a57c14c7a..634cf860a226 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/_dev_hub_mgmt_client_operations.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/_dev_hub_mgmt_client_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._dev_hub_mgmt_client_operations import ( build_generate_preview_artifacts_request, build_git_hub_o_auth_callback_request, @@ -34,11 +33,16 @@ ) from .._vendor import DevHubMgmtClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DevHubMgmtClientOperationsMixin(DevHubMgmtClientMixinABC): + @overload async def git_hub_o_auth( self, @@ -52,14 +56,13 @@ async def git_hub_o_auth( Gets GitHubOAuth info used to authenticate users with the Developer Hub GitHub App. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str :param parameters: Default value is None. :type parameters: ~azure.mgmt.devhub.models.GitHubOAuthCallRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GitHubOAuthInfoResponse or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.GitHubOAuthInfoResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -67,20 +70,24 @@ async def git_hub_o_auth( @overload async def git_hub_o_auth( - self, location: str, parameters: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + self, + location: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.GitHubOAuthInfoResponse: """Gets GitHubOAuth info used to authenticate users with the Developer Hub GitHub App. Gets GitHubOAuth info used to authenticate users with the Developer Hub GitHub App. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str :param parameters: Default value is None. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GitHubOAuthInfoResponse or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.GitHubOAuthInfoResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -88,25 +95,25 @@ async def git_hub_o_auth( @distributed_trace_async async def git_hub_o_auth( - self, location: str, parameters: Optional[Union[_models.GitHubOAuthCallRequest, IO]] = None, **kwargs: Any + self, + location: str, + parameters: Optional[Union[_models.GitHubOAuthCallRequest, IO[bytes]]] = None, + **kwargs: Any ) -> _models.GitHubOAuthInfoResponse: """Gets GitHubOAuth info used to authenticate users with the Developer Hub GitHub App. Gets GitHubOAuth info used to authenticate users with the Developer Hub GitHub App. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str - :param parameters: Is either a GitHubOAuthCallRequest type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.devhub.models.GitHubOAuthCallRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Is either a GitHubOAuthCallRequest type or a IO[bytes] type. Default value + is None. + :type parameters: ~azure.mgmt.devhub.models.GitHubOAuthCallRequest or IO[bytes] :return: GitHubOAuthInfoResponse or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.GitHubOAuthInfoResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,23 +139,21 @@ async def git_hub_o_auth( else: _json = None - request = build_git_hub_o_auth_request( + _request = build_git_hub_o_auth_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.git_hub_o_auth.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -158,16 +163,12 @@ async def git_hub_o_auth( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GitHubOAuthInfoResponse", pipeline_response) + deserialized = self._deserialize("GitHubOAuthInfoResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - git_hub_o_auth.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/githuboauth/default/getGitHubOAuthInfo" - } + return deserialized # type: ignore @distributed_trace_async async def git_hub_o_auth_callback( @@ -179,18 +180,17 @@ async def git_hub_o_auth_callback( Callback URL to hit once authenticated with GitHub App to have the service store the OAuth token. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str :param code: The code response from authenticating the GitHub App. Required. :type code: str :param state: The state response from authenticating the GitHub App. Required. :type state: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GitHubOAuthResponse or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.GitHubOAuthResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -204,22 +204,20 @@ async def git_hub_o_auth_callback( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GitHubOAuthResponse] = kwargs.pop("cls", None) - request = build_git_hub_o_auth_callback_request( + _request = build_git_hub_o_auth_callback_request( location=location, subscription_id=self._config.subscription_id, code=code, state=state, api_version=api_version, - template_url=self.git_hub_o_auth_callback.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -229,16 +227,12 @@ async def git_hub_o_auth_callback( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GitHubOAuthResponse", pipeline_response) + deserialized = self._deserialize("GitHubOAuthResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - git_hub_o_auth_callback.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/githuboauth/default" - } + return deserialized # type: ignore @distributed_trace_async async def list_git_hub_o_auth(self, location: str, **kwargs: Any) -> _models.GitHubOAuthListResponse: @@ -248,14 +242,13 @@ async def list_git_hub_o_auth(self, location: str, **kwargs: Any) -> _models.Git Callback URL to hit once authenticated with GitHub App to have the service store the OAuth token. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GitHubOAuthListResponse or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.GitHubOAuthListResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -269,20 +262,18 @@ async def list_git_hub_o_auth(self, location: str, **kwargs: Any) -> _models.Git api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GitHubOAuthListResponse] = kwargs.pop("cls", None) - request = build_list_git_hub_o_auth_request( + _request = build_list_git_hub_o_auth_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_git_hub_o_auth.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -292,16 +283,12 @@ async def list_git_hub_o_auth(self, location: str, **kwargs: Any) -> _models.Git error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GitHubOAuthListResponse", pipeline_response) + deserialized = self._deserialize("GitHubOAuthListResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_git_hub_o_auth.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/githuboauth" - } + return deserialized # type: ignore @overload async def generate_preview_artifacts( @@ -316,14 +303,13 @@ async def generate_preview_artifacts( Generate preview dockerfile and manifests. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str :param parameters: Required. :type parameters: ~azure.mgmt.devhub.models.ArtifactGenerationProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: dict mapping str to str or the result of cls(response) :rtype: dict[str, str] :raises ~azure.core.exceptions.HttpResponseError: @@ -331,20 +317,19 @@ async def generate_preview_artifacts( @overload async def generate_preview_artifacts( - self, location: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> Dict[str, str]: """Generate preview dockerfile and manifests. Generate preview dockerfile and manifests. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str :param parameters: Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: dict mapping str to str or the result of cls(response) :rtype: dict[str, str] :raises ~azure.core.exceptions.HttpResponseError: @@ -352,25 +337,21 @@ async def generate_preview_artifacts( @distributed_trace_async async def generate_preview_artifacts( - self, location: str, parameters: Union[_models.ArtifactGenerationProperties, IO], **kwargs: Any + self, location: str, parameters: Union[_models.ArtifactGenerationProperties, IO[bytes]], **kwargs: Any ) -> Dict[str, str]: """Generate preview dockerfile and manifests. Generate preview dockerfile and manifests. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str - :param parameters: Is either a ArtifactGenerationProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.devhub.models.ArtifactGenerationProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Is either a ArtifactGenerationProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.devhub.models.ArtifactGenerationProperties or IO[bytes] :return: dict mapping str to str or the result of cls(response) :rtype: dict[str, str] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -393,23 +374,21 @@ async def generate_preview_artifacts( else: _json = self._serialize.body(parameters, "ArtifactGenerationProperties") - request = build_generate_preview_artifacts_request( + _request = build_generate_preview_artifacts_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.generate_preview_artifacts.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -419,13 +398,9 @@ async def generate_preview_artifacts( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("{str}", pipeline_response) + deserialized = self._deserialize("{str}", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - generate_preview_artifacts.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/generatePreviewArtifacts" - } + return deserialized # type: ignore diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/_iac_profiles_operations.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/_iac_profiles_operations.py new file mode 100644 index 000000000000..6463c5b7bfe3 --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/_iac_profiles_operations.py @@ -0,0 +1,941 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._iac_profiles_operations import ( + build_create_or_update_request, + build_delete_request, + build_export_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_scale_request, + build_sync_request, + build_update_tags_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class IacProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.devhub.aio.DevHubMgmtClient`'s + :attr:`iac_profiles` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.IacProfile"]: + """Gets a list of IacProfiles associated with the specified subscription. + + Gets a list of IacProfiles associated with the specified subscription. + + :return: An iterator like instance of either IacProfile or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devhub.models.IacProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.IacProfileListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IacProfileListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.IacProfile"]: + """Gets a list of iacProfiles within a resource group. + + Gets a list of iacProfiles within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either IacProfile or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devhub.models.IacProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.IacProfileListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IacProfileListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, resource_group_name: str, iac_profile_name: str, **kwargs: Any) -> _models.IacProfile: + """Gets a IacProfile. + + Gets a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :return: IacProfile or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.IacProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.IacProfile] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + iac_profile_name=iac_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IacProfile", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: _models.IacProfile, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IacProfile: + """Creates or updates a IacProfile. + + Creates or updates a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.devhub.models.IacProfile + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IacProfile or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.IacProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IacProfile: + """Creates or updates a IacProfile. + + Creates or updates a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: IacProfile or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.IacProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: Union[_models.IacProfile, IO[bytes]], + **kwargs: Any + ) -> _models.IacProfile: + """Creates or updates a IacProfile. + + Creates or updates a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Is either a IacProfile type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.devhub.models.IacProfile or IO[bytes] + :return: IacProfile or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.IacProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IacProfile] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IacProfile") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + iac_profile_name=iac_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IacProfile", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, iac_profile_name: str, **kwargs: Any + ) -> None: + """Deletes a IacProfile. + + Deletes a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + iac_profile_name=iac_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def update_tags( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IacProfile: + """Updates tags on a IacProfile. + + Updates tags on a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Parameters supplied to the Update TagsObject Tags operation. Required. + :type parameters: ~azure.mgmt.devhub.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IacProfile or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.IacProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IacProfile: + """Updates tags on a IacProfile. + + Updates tags on a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Parameters supplied to the Update TagsObject Tags operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: IacProfile or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.IacProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: Union[_models.TagsObject, IO[bytes]], + **kwargs: Any + ) -> _models.IacProfile: + """Updates tags on a IacProfile. + + Updates tags on a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Parameters supplied to the Update TagsObject Tags operation. Is either a + TagsObject type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.devhub.models.TagsObject or IO[bytes] + :return: IacProfile or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.IacProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IacProfile] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + _request = build_update_tags_request( + resource_group_name=resource_group_name, + iac_profile_name=iac_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IacProfile", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def export( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrLinkResponse: + """Export a template. + + Export a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.devhub.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrLinkResponse or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.PrLinkResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrLinkResponse: + """Export a template. + + Export a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PrLinkResponse or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.PrLinkResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: Union[_models.ExportTemplateRequest, IO[bytes]], + **kwargs: Any + ) -> _models.PrLinkResponse: + """Export a template. + + Export a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Is either a ExportTemplateRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.devhub.models.ExportTemplateRequest or IO[bytes] + :return: PrLinkResponse or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.PrLinkResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrLinkResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") + + _request = build_export_request( + resource_group_name=resource_group_name, + iac_profile_name=iac_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrLinkResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def scale( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: _models.ScaleTemplateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrLinkResponse: + """Scale by template. + + Scale by template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.devhub.models.ScaleTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrLinkResponse or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.PrLinkResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def scale( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrLinkResponse: + """Scale by template. + + Scale by template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PrLinkResponse or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.PrLinkResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def scale( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: Union[_models.ScaleTemplateRequest, IO[bytes]], + **kwargs: Any + ) -> _models.PrLinkResponse: + """Scale by template. + + Scale by template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Is either a ScaleTemplateRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.devhub.models.ScaleTemplateRequest or IO[bytes] + :return: PrLinkResponse or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.PrLinkResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrLinkResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScaleTemplateRequest") + + _request = build_scale_request( + resource_group_name=resource_group_name, + iac_profile_name=iac_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrLinkResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def sync( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, iac_profile_name: str, **kwargs: Any + ) -> None: + """Sync template. + + Sync template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sync_request( + resource_group_name=resource_group_name, + iac_profile_name=iac_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/_operations.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/_operations.py index 3081a94e8fb5..65a75c4bc470 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/_operations.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,17 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request -from .._vendor import DevHubMgmtClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,12 +59,11 @@ async def list(self, **kwargs: Any) -> _models.OperationListResult: Returns list of operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationListResult or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.OperationListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -76,18 +77,16 @@ async def list(self, **kwargs: Any) -> _models.OperationListResult: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -97,11 +96,9 @@ async def list(self, **kwargs: Any) -> _models.OperationListResult: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationListResult", pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = {"url": "/providers/Microsoft.DevHub/operations"} + return deserialized # type: ignore diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/_workflow_operations.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/_workflow_operations.py index 169b948a74d6..67fc06bc6a08 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/_workflow_operations.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/aio/operations/_workflow_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._workflow_operations import ( build_create_or_update_request, build_delete_request, @@ -37,8 +36,11 @@ build_list_request, build_update_tags_request, ) -from .._vendor import DevHubMgmtClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +70,6 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Workflow"]: Gets a list of workflows associated with the specified subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workflow or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devhub.models.Workflow] :raises ~azure.core.exceptions.HttpResponseError: @@ -79,7 +80,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Workflow"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WorkflowListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,15 +91,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Workflow"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -110,13 +109,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkflowListResult", pipeline_response) @@ -126,11 +124,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -143,8 +141,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/workflows"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, managed_cluster_resource: Optional[str] = None, **kwargs: Any @@ -159,7 +155,6 @@ def list_by_resource_group( :param managed_cluster_resource: The ManagedCluster resource associated with the workflows. Default value is None. :type managed_cluster_resource: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workflow or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devhub.models.Workflow] :raises ~azure.core.exceptions.HttpResponseError: @@ -170,7 +165,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WorkflowListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -181,17 +176,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, managed_cluster_resource=managed_cluster_resource, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -203,13 +196,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkflowListResult", pipeline_response) @@ -219,11 +211,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -236,10 +228,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows" - } - @distributed_trace_async async def get(self, resource_group_name: str, workflow_name: str, **kwargs: Any) -> _models.Workflow: """Gets a workflow. @@ -251,12 +239,11 @@ async def get(self, resource_group_name: str, workflow_name: str, **kwargs: Any) :type resource_group_name: str :param workflow_name: The name of the workflow resource. Required. :type workflow_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workflow or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.Workflow :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -270,21 +257,19 @@ async def get(self, resource_group_name: str, workflow_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Workflow] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workflow_name=workflow_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -294,16 +279,12 @@ async def get(self, resource_group_name: str, workflow_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workflow", pipeline_response) + deserialized = self._deserialize("Workflow", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -329,7 +310,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workflow or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.Workflow :raises ~azure.core.exceptions.HttpResponseError: @@ -340,7 +320,7 @@ async def create_or_update( self, resource_group_name: str, workflow_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -355,11 +335,10 @@ async def create_or_update( :param workflow_name: The name of the workflow resource. Required. :type workflow_name: str :param parameters: Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workflow or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.Workflow :raises ~azure.core.exceptions.HttpResponseError: @@ -367,7 +346,11 @@ async def create_or_update( @distributed_trace_async async def create_or_update( - self, resource_group_name: str, workflow_name: str, parameters: Union[_models.Workflow, IO], **kwargs: Any + self, + resource_group_name: str, + workflow_name: str, + parameters: Union[_models.Workflow, IO[bytes]], + **kwargs: Any ) -> _models.Workflow: """Creates or updates a workflow. @@ -378,17 +361,13 @@ async def create_or_update( :type resource_group_name: str :param workflow_name: The name of the workflow resource. Required. :type workflow_name: str - :param parameters: Is either a Workflow type or a IO type. Required. - :type parameters: ~azure.mgmt.devhub.models.Workflow or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Is either a Workflow type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.devhub.models.Workflow or IO[bytes] :return: Workflow or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.Workflow :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -411,7 +390,7 @@ async def create_or_update( else: _json = self._serialize.body(parameters, "Workflow") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workflow_name=workflow_name, subscription_id=self._config.subscription_id, @@ -419,16 +398,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -438,21 +415,13 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Workflow", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workflow", pipeline_response) + deserialized = self._deserialize("Workflow", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}" - } - @distributed_trace_async async def delete( self, resource_group_name: str, workflow_name: str, **kwargs: Any @@ -466,12 +435,11 @@ async def delete( :type resource_group_name: str :param workflow_name: The name of the workflow resource. Required. :type workflow_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeleteWorkflowResponse or None or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.DeleteWorkflowResponse or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -485,21 +453,19 @@ async def delete( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.DeleteWorkflowResponse]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workflow_name=workflow_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -511,16 +477,12 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("DeleteWorkflowResponse", pipeline_response) + deserialized = self._deserialize("DeleteWorkflowResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}" - } + return deserialized # type: ignore @overload async def update_tags( @@ -546,7 +508,6 @@ async def update_tags( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workflow or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.Workflow :raises ~azure.core.exceptions.HttpResponseError: @@ -557,7 +518,7 @@ async def update_tags( self, resource_group_name: str, workflow_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -572,11 +533,10 @@ async def update_tags( :param workflow_name: The name of the workflow resource. Required. :type workflow_name: str :param parameters: Parameters supplied to the Update Workflow Tags operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workflow or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.Workflow :raises ~azure.core.exceptions.HttpResponseError: @@ -584,7 +544,11 @@ async def update_tags( @distributed_trace_async async def update_tags( - self, resource_group_name: str, workflow_name: str, parameters: Union[_models.TagsObject, IO], **kwargs: Any + self, + resource_group_name: str, + workflow_name: str, + parameters: Union[_models.TagsObject, IO[bytes]], + **kwargs: Any ) -> _models.Workflow: """Updates tags on a workflow. @@ -596,17 +560,13 @@ async def update_tags( :param workflow_name: The name of the workflow resource. Required. :type workflow_name: str :param parameters: Parameters supplied to the Update Workflow Tags operation. Is either a - TagsObject type or a IO type. Required. - :type parameters: ~azure.mgmt.devhub.models.TagsObject or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + TagsObject type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.devhub.models.TagsObject or IO[bytes] :return: Workflow or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.Workflow :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -629,7 +589,7 @@ async def update_tags( else: _json = self._serialize.body(parameters, "TagsObject") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, workflow_name=workflow_name, subscription_id=self._config.subscription_id, @@ -637,16 +597,14 @@ async def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -656,13 +614,9 @@ async def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workflow", pipeline_response) + deserialized = self._deserialize("Workflow", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}" - } + return deserialized # type: ignore diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/models/__init__.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/models/__init__.py index d0da7c01a394..6f37df07517a 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/models/__init__.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/models/__init__.py @@ -13,16 +13,25 @@ from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse +from ._models_py3 import ExportTemplateRequest from ._models_py3 import GitHubOAuthCallRequest from ._models_py3 import GitHubOAuthInfoResponse from ._models_py3 import GitHubOAuthListResponse from ._models_py3 import GitHubOAuthResponse from ._models_py3 import GitHubWorkflowProfileOidcCredentials +from ._models_py3 import IacProfile +from ._models_py3 import IacProfileListResult +from ._models_py3 import IacTemplateDetails +from ._models_py3 import IacTemplateProperties from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult +from ._models_py3 import PrLinkResponse from ._models_py3 import ProxyResource from ._models_py3 import Resource +from ._models_py3 import ScaleProperty +from ._models_py3 import ScaleTemplateRequest +from ._models_py3 import StageProperties from ._models_py3 import SystemData from ._models_py3 import TagsObject from ._models_py3 import TrackedResource @@ -40,6 +49,7 @@ from ._dev_hub_mgmt_client_enums import ManifestType from ._dev_hub_mgmt_client_enums import Origin from ._dev_hub_mgmt_client_enums import PullRequestStatus +from ._dev_hub_mgmt_client_enums import QuickStartTemplateType from ._dev_hub_mgmt_client_enums import WorkflowRunStatus from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -53,16 +63,25 @@ "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", + "ExportTemplateRequest", "GitHubOAuthCallRequest", "GitHubOAuthInfoResponse", "GitHubOAuthListResponse", "GitHubOAuthResponse", "GitHubWorkflowProfileOidcCredentials", + "IacProfile", + "IacProfileListResult", + "IacTemplateDetails", + "IacTemplateProperties", "Operation", "OperationDisplay", "OperationListResult", + "PrLinkResponse", "ProxyResource", "Resource", + "ScaleProperty", + "ScaleTemplateRequest", + "StageProperties", "SystemData", "TagsObject", "TrackedResource", @@ -79,6 +98,7 @@ "ManifestType", "Origin", "PullRequestStatus", + "QuickStartTemplateType", "WorkflowRunStatus", ] __all__.extend([p for p in _patch_all if p not in __all__]) diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/models/_dev_hub_mgmt_client_enums.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/models/_dev_hub_mgmt_client_enums.py index 5c25fd6dafec..07a1e01f9e8e 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/models/_dev_hub_mgmt_client_enums.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/models/_dev_hub_mgmt_client_enums.py @@ -126,6 +126,19 @@ class PullRequestStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Workflow no longer found within repository.""" +class QuickStartTemplateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Determines the authorization status of requests.""" + + NONE = "None" + """The template has not use quick start template""" + HCI = "HCI" + """The template use quick start template of HCI""" + HCIAKS = "HCIAKS" + """The template use quick start template of HCI and AKS""" + HCIARCVM = "HCIARCVM" + """The template use quick start template of HCI and ArcVM""" + + class WorkflowRunStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the status of the workflow run.""" diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/models/_models_py3.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/models/_models_py3.py index eb80b63ae6d8..a73d69a8ca1f 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/models/_models_py3.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/models/_models_py3.py @@ -354,6 +354,59 @@ def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: A self.error = error +class ExportTemplateRequest(_serialization.Model): + """ExportTemplateRequest. + + :ivar template_name: Template Name. + :vartype template_name: str + :ivar resource_group_ids: + :vartype resource_group_ids: list[str] + :ivar site_id: + :vartype site_id: str + :ivar instance_name: + :vartype instance_name: str + :ivar instance_stage: + :vartype instance_stage: str + """ + + _attribute_map = { + "template_name": {"key": "templateName", "type": "str"}, + "resource_group_ids": {"key": "resourceGroupIds", "type": "[str]"}, + "site_id": {"key": "siteId", "type": "str"}, + "instance_name": {"key": "instanceName", "type": "str"}, + "instance_stage": {"key": "instanceStage", "type": "str"}, + } + + def __init__( + self, + *, + template_name: Optional[str] = None, + resource_group_ids: Optional[List[str]] = None, + site_id: Optional[str] = None, + instance_name: Optional[str] = None, + instance_stage: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword template_name: Template Name. + :paramtype template_name: str + :keyword resource_group_ids: + :paramtype resource_group_ids: list[str] + :keyword site_id: + :paramtype site_id: str + :keyword instance_name: + :paramtype instance_name: str + :keyword instance_stage: + :paramtype instance_stage: str + """ + super().__init__(**kwargs) + self.template_name = template_name + self.resource_group_ids = resource_group_ids + self.site_id = site_id + self.instance_name = instance_name + self.instance_stage = instance_stage + + class GitHubOAuthCallRequest(_serialization.Model): """GitHubOAuth request object. @@ -427,8 +480,8 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -469,8 +522,8 @@ class ProxyResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -482,32 +535,14 @@ class ProxyResource(Resource): :vartype system_data: ~azure.mgmt.devhub.models.SystemData """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class GitHubOAuthResponse(ProxyResource): """Singleton response of GitHubOAuth containing. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -573,6 +608,346 @@ def __init__( self.azure_tenant_id = azure_tenant_id +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.devhub.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + + +class IacProfile(TrackedResource): # pylint: disable=too-many-instance-attributes + """Resource representation of a IacProfile. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.devhub.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str + :ivar stages: + :vartype stages: list[~azure.mgmt.devhub.models.StageProperties] + :ivar templates: + :vartype templates: list[~azure.mgmt.devhub.models.IacTemplateProperties] + :ivar storage_account_subscription: Terraform Storage Account Subscription. + :vartype storage_account_subscription: str + :ivar storage_account_resource_group: Terraform Storage Account Resource Group. + :vartype storage_account_resource_group: str + :ivar storage_account_name: Terraform Storage Account Name. + :vartype storage_account_name: str + :ivar storage_container_name: Terraform Container Name. + :vartype storage_container_name: str + :ivar repository_name: Repository Name. + :vartype repository_name: str + :ivar repository_main_branch: Repository Main Branch. + :vartype repository_main_branch: str + :ivar repository_owner: Repository Owner. + :vartype repository_owner: str + :ivar auth_status: Determines the authorization status of requests. Known values are: + "Authorized", "NotFound", and "Error". + :vartype auth_status: str or ~azure.mgmt.devhub.models.AuthorizationStatus + :ivar pull_number: The number associated with the submitted pull request. + :vartype pull_number: int + :ivar pr_status: The status of the Pull Request submitted against the users repository. Known + values are: "unknown", "submitted", "merged", and "removed". + :vartype pr_status: str or ~azure.mgmt.devhub.models.PullRequestStatus + :ivar branch_name: Repository Branch Name. + :vartype branch_name: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "etag": {"readonly": True}, + "auth_status": {"readonly": True}, + "pull_number": {"readonly": True}, + "pr_status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "stages": {"key": "properties.stages", "type": "[StageProperties]"}, + "templates": {"key": "properties.templates", "type": "[IacTemplateProperties]"}, + "storage_account_subscription": { + "key": "properties.terraformProfile.storageAccountSubscription", + "type": "str", + }, + "storage_account_resource_group": { + "key": "properties.terraformProfile.storageAccountResourceGroup", + "type": "str", + }, + "storage_account_name": {"key": "properties.terraformProfile.storageAccountName", "type": "str"}, + "storage_container_name": {"key": "properties.terraformProfile.storageContainerName", "type": "str"}, + "repository_name": {"key": "properties.githubProfile.repositoryName", "type": "str"}, + "repository_main_branch": {"key": "properties.githubProfile.repositoryMainBranch", "type": "str"}, + "repository_owner": {"key": "properties.githubProfile.repositoryOwner", "type": "str"}, + "auth_status": {"key": "properties.githubProfile.authStatus", "type": "str"}, + "pull_number": {"key": "properties.githubProfile.pullNumber", "type": "int"}, + "pr_status": {"key": "properties.githubProfile.prStatus", "type": "str"}, + "branch_name": {"key": "properties.githubProfile.branchName", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + stages: Optional[List["_models.StageProperties"]] = None, + templates: Optional[List["_models.IacTemplateProperties"]] = None, + storage_account_subscription: Optional[str] = None, + storage_account_resource_group: Optional[str] = None, + storage_account_name: Optional[str] = None, + storage_container_name: Optional[str] = None, + repository_name: Optional[str] = None, + repository_main_branch: Optional[str] = None, + repository_owner: Optional[str] = None, + branch_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword stages: + :paramtype stages: list[~azure.mgmt.devhub.models.StageProperties] + :keyword templates: + :paramtype templates: list[~azure.mgmt.devhub.models.IacTemplateProperties] + :keyword storage_account_subscription: Terraform Storage Account Subscription. + :paramtype storage_account_subscription: str + :keyword storage_account_resource_group: Terraform Storage Account Resource Group. + :paramtype storage_account_resource_group: str + :keyword storage_account_name: Terraform Storage Account Name. + :paramtype storage_account_name: str + :keyword storage_container_name: Terraform Container Name. + :paramtype storage_container_name: str + :keyword repository_name: Repository Name. + :paramtype repository_name: str + :keyword repository_main_branch: Repository Main Branch. + :paramtype repository_main_branch: str + :keyword repository_owner: Repository Owner. + :paramtype repository_owner: str + :keyword branch_name: Repository Branch Name. + :paramtype branch_name: str + """ + super().__init__(tags=tags, location=location, **kwargs) + self.etag = None + self.stages = stages + self.templates = templates + self.storage_account_subscription = storage_account_subscription + self.storage_account_resource_group = storage_account_resource_group + self.storage_account_name = storage_account_name + self.storage_container_name = storage_container_name + self.repository_name = repository_name + self.repository_main_branch = repository_main_branch + self.repository_owner = repository_owner + self.auth_status = None + self.pull_number = None + self.pr_status = None + self.branch_name = branch_name + + +class IacProfileListResult(_serialization.Model): + """IacProfileListResult. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of IacProfiles. + :vartype value: list[~azure.mgmt.devhub.models.IacProfile] + :ivar next_link: The URL to the next set of IacProfile results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[IacProfile]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.IacProfile"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of IacProfiles. + :paramtype value: list[~azure.mgmt.devhub.models.IacProfile] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class IacTemplateDetails(_serialization.Model): + """IacTemplateDetails. + + :ivar product_name: The name of the products. + :vartype product_name: str + :ivar count: Count of the product. + :vartype count: int + :ivar naming_convention: Naming convention of this product. + :vartype naming_convention: str + """ + + _attribute_map = { + "product_name": {"key": "productName", "type": "str"}, + "count": {"key": "count", "type": "int"}, + "naming_convention": {"key": "namingConvention", "type": "str"}, + } + + def __init__( + self, + *, + product_name: Optional[str] = None, + count: Optional[int] = None, + naming_convention: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword product_name: The name of the products. + :paramtype product_name: str + :keyword count: Count of the product. + :paramtype count: int + :keyword naming_convention: Naming convention of this product. + :paramtype naming_convention: str + """ + super().__init__(**kwargs) + self.product_name = product_name + self.count = count + self.naming_convention = naming_convention + + +class IacTemplateProperties(_serialization.Model): + """Properties of a IacTemplate. + + :ivar template_name: Template Name. + :vartype template_name: str + :ivar source_resource_id: the source store of the template. + :vartype source_resource_id: str + :ivar instance_stage: the source stage of the template. + :vartype instance_stage: str + :ivar instance_name: the sample instance name of the template. + :vartype instance_name: str + :ivar template_details: + :vartype template_details: list[~azure.mgmt.devhub.models.IacTemplateDetails] + :ivar quick_start_template_type: Determines the authorization status of requests. Known values + are: "None", "HCI", "HCIAKS", and "HCIARCVM". + :vartype quick_start_template_type: str or ~azure.mgmt.devhub.models.QuickStartTemplateType + """ + + _attribute_map = { + "template_name": {"key": "templateName", "type": "str"}, + "source_resource_id": {"key": "sourceResourceId", "type": "str"}, + "instance_stage": {"key": "instanceStage", "type": "str"}, + "instance_name": {"key": "instanceName", "type": "str"}, + "template_details": {"key": "templateDetails", "type": "[IacTemplateDetails]"}, + "quick_start_template_type": {"key": "quickStartTemplateType", "type": "str"}, + } + + def __init__( + self, + *, + template_name: Optional[str] = None, + source_resource_id: Optional[str] = None, + instance_stage: Optional[str] = None, + instance_name: Optional[str] = None, + template_details: Optional[List["_models.IacTemplateDetails"]] = None, + quick_start_template_type: Optional[Union[str, "_models.QuickStartTemplateType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword template_name: Template Name. + :paramtype template_name: str + :keyword source_resource_id: the source store of the template. + :paramtype source_resource_id: str + :keyword instance_stage: the source stage of the template. + :paramtype instance_stage: str + :keyword instance_name: the sample instance name of the template. + :paramtype instance_name: str + :keyword template_details: + :paramtype template_details: list[~azure.mgmt.devhub.models.IacTemplateDetails] + :keyword quick_start_template_type: Determines the authorization status of requests. Known + values are: "None", "HCI", "HCIAKS", and "HCIARCVM". + :paramtype quick_start_template_type: str or ~azure.mgmt.devhub.models.QuickStartTemplateType + """ + super().__init__(**kwargs) + self.template_name = template_name + self.source_resource_id = source_resource_id + self.instance_stage = instance_stage + self.instance_name = instance_name + self.template_details = template_details + self.quick_start_template_type = quick_start_template_type + + class Operation(_serialization.Model): """Details of a REST API operation, returned from the Resource Provider Operations API. @@ -694,6 +1069,136 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None +class PrLinkResponse(_serialization.Model): + """PrLinkResponse. + + :ivar pr_link: The link of the pull request. + :vartype pr_link: str + """ + + _attribute_map = { + "pr_link": {"key": "prLink", "type": "str"}, + } + + def __init__(self, *, pr_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword pr_link: The link of the pull request. + :paramtype pr_link: str + """ + super().__init__(**kwargs) + self.pr_link = pr_link + + +class ScaleProperty(_serialization.Model): + """ScaleProperty. + + :ivar region: The region of the store. + :vartype region: str + :ivar stage: The stage of the store. + :vartype stage: str + :ivar number_of_stores: Number of the store. + :vartype number_of_stores: int + """ + + _attribute_map = { + "region": {"key": "region", "type": "str"}, + "stage": {"key": "stage", "type": "str"}, + "number_of_stores": {"key": "numberOfStores", "type": "int"}, + } + + def __init__( + self, + *, + region: Optional[str] = None, + stage: Optional[str] = None, + number_of_stores: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword region: The region of the store. + :paramtype region: str + :keyword stage: The stage of the store. + :paramtype stage: str + :keyword number_of_stores: Number of the store. + :paramtype number_of_stores: int + """ + super().__init__(**kwargs) + self.region = region + self.stage = stage + self.number_of_stores = number_of_stores + + +class ScaleTemplateRequest(_serialization.Model): + """ScaleTemplateRequest. + + :ivar template_name: Template Name. + :vartype template_name: str + :ivar scale_properties: + :vartype scale_properties: list[~azure.mgmt.devhub.models.ScaleProperty] + """ + + _attribute_map = { + "template_name": {"key": "templateName", "type": "str"}, + "scale_properties": {"key": "scaleProperties", "type": "[ScaleProperty]"}, + } + + def __init__( + self, + *, + template_name: Optional[str] = None, + scale_properties: Optional[List["_models.ScaleProperty"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword template_name: Template Name. + :paramtype template_name: str + :keyword scale_properties: + :paramtype scale_properties: list[~azure.mgmt.devhub.models.ScaleProperty] + """ + super().__init__(**kwargs) + self.template_name = template_name + self.scale_properties = scale_properties + + +class StageProperties(_serialization.Model): + """Properties of a Stage. + + :ivar stage_name: Stage Name. + :vartype stage_name: str + :ivar dependencies: + :vartype dependencies: list[str] + :ivar git_environment: + :vartype git_environment: str + """ + + _attribute_map = { + "stage_name": {"key": "stageName", "type": "str"}, + "dependencies": {"key": "dependencies", "type": "[str]"}, + "git_environment": {"key": "gitEnvironment", "type": "str"}, + } + + def __init__( + self, + *, + stage_name: Optional[str] = None, + dependencies: Optional[List[str]] = None, + git_environment: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword stage_name: Stage Name. + :paramtype stage_name: str + :keyword dependencies: + :paramtype dependencies: list[str] + :keyword git_environment: + :paramtype git_environment: str + """ + super().__init__(**kwargs) + self.stage_name = stage_name + self.dependencies = dependencies + self.git_environment = git_environment + + class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. @@ -778,69 +1283,15 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> N self.tags = tags -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which - has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.devhub.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - """ - super().__init__(**kwargs) - self.tags = tags - self.location = location - - class Workflow(TrackedResource): # pylint: disable=too-many-instance-attributes """Resource representation of a workflow. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/__init__.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/__init__.py index ac5915775e4f..1332eee763bf 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/__init__.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/__init__.py @@ -9,6 +9,7 @@ from ._operations import Operations from ._dev_hub_mgmt_client_operations import DevHubMgmtClientOperationsMixin from ._workflow_operations import WorkflowOperations +from ._iac_profiles_operations import IacProfilesOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -18,6 +19,7 @@ "Operations", "DevHubMgmtClientOperationsMixin", "WorkflowOperations", + "IacProfilesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/_dev_hub_mgmt_client_operations.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/_dev_hub_mgmt_client_operations.py index 1da36434dcba..1166432d80ab 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/_dev_hub_mgmt_client_operations.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/_dev_hub_mgmt_client_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import DevHubMgmtClientMixinABC, _convert_request, _format_url_section +from .._vendor import DevHubMgmtClientMixinABC +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +43,7 @@ def build_git_hub_o_auth_request(location: str, subscription_id: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-11-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -49,11 +53,11 @@ def build_git_hub_o_auth_request(location: str, subscription_id: str, **kwargs: "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/githuboauth/default/getGitHubOAuthInfo", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "location": _SERIALIZER.url("location", location, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -72,7 +76,7 @@ def build_git_hub_o_auth_callback_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-11-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,11 +85,11 @@ def build_git_hub_o_auth_callback_request( "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/githuboauth/default", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "location": _SERIALIZER.url("location", location, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -102,7 +106,7 @@ def build_list_git_hub_o_auth_request(location: str, subscription_id: str, **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-11-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,11 +114,11 @@ def build_list_git_hub_o_auth_request(location: str, subscription_id: str, **kwa "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/githuboauth" ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "location": _SERIALIZER.url("location", location, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -129,7 +133,7 @@ def build_generate_preview_artifacts_request(location: str, subscription_id: str _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-11-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -139,11 +143,11 @@ def build_generate_preview_artifacts_request(location: str, subscription_id: str "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/generatePreviewArtifacts", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "location": _SERIALIZER.url("location", location, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -157,6 +161,7 @@ def build_generate_preview_artifacts_request(location: str, subscription_id: str class DevHubMgmtClientOperationsMixin(DevHubMgmtClientMixinABC): + @overload def git_hub_o_auth( self, @@ -170,14 +175,13 @@ def git_hub_o_auth( Gets GitHubOAuth info used to authenticate users with the Developer Hub GitHub App. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str :param parameters: Default value is None. :type parameters: ~azure.mgmt.devhub.models.GitHubOAuthCallRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GitHubOAuthInfoResponse or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.GitHubOAuthInfoResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -185,20 +189,24 @@ def git_hub_o_auth( @overload def git_hub_o_auth( - self, location: str, parameters: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + self, + location: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.GitHubOAuthInfoResponse: """Gets GitHubOAuth info used to authenticate users with the Developer Hub GitHub App. Gets GitHubOAuth info used to authenticate users with the Developer Hub GitHub App. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str :param parameters: Default value is None. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GitHubOAuthInfoResponse or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.GitHubOAuthInfoResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -206,25 +214,25 @@ def git_hub_o_auth( @distributed_trace def git_hub_o_auth( - self, location: str, parameters: Optional[Union[_models.GitHubOAuthCallRequest, IO]] = None, **kwargs: Any + self, + location: str, + parameters: Optional[Union[_models.GitHubOAuthCallRequest, IO[bytes]]] = None, + **kwargs: Any ) -> _models.GitHubOAuthInfoResponse: """Gets GitHubOAuth info used to authenticate users with the Developer Hub GitHub App. Gets GitHubOAuth info used to authenticate users with the Developer Hub GitHub App. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str - :param parameters: Is either a GitHubOAuthCallRequest type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.devhub.models.GitHubOAuthCallRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Is either a GitHubOAuthCallRequest type or a IO[bytes] type. Default value + is None. + :type parameters: ~azure.mgmt.devhub.models.GitHubOAuthCallRequest or IO[bytes] :return: GitHubOAuthInfoResponse or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.GitHubOAuthInfoResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -250,23 +258,21 @@ def git_hub_o_auth( else: _json = None - request = build_git_hub_o_auth_request( + _request = build_git_hub_o_auth_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.git_hub_o_auth.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -276,16 +282,12 @@ def git_hub_o_auth( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GitHubOAuthInfoResponse", pipeline_response) + deserialized = self._deserialize("GitHubOAuthInfoResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - git_hub_o_auth.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/githuboauth/default/getGitHubOAuthInfo" - } + return deserialized # type: ignore @distributed_trace def git_hub_o_auth_callback( @@ -297,18 +299,17 @@ def git_hub_o_auth_callback( Callback URL to hit once authenticated with GitHub App to have the service store the OAuth token. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str :param code: The code response from authenticating the GitHub App. Required. :type code: str :param state: The state response from authenticating the GitHub App. Required. :type state: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GitHubOAuthResponse or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.GitHubOAuthResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -322,22 +323,20 @@ def git_hub_o_auth_callback( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GitHubOAuthResponse] = kwargs.pop("cls", None) - request = build_git_hub_o_auth_callback_request( + _request = build_git_hub_o_auth_callback_request( location=location, subscription_id=self._config.subscription_id, code=code, state=state, api_version=api_version, - template_url=self.git_hub_o_auth_callback.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -347,16 +346,12 @@ def git_hub_o_auth_callback( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GitHubOAuthResponse", pipeline_response) + deserialized = self._deserialize("GitHubOAuthResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - git_hub_o_auth_callback.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/githuboauth/default" - } + return deserialized # type: ignore @distributed_trace def list_git_hub_o_auth(self, location: str, **kwargs: Any) -> _models.GitHubOAuthListResponse: @@ -366,14 +361,13 @@ def list_git_hub_o_auth(self, location: str, **kwargs: Any) -> _models.GitHubOAu Callback URL to hit once authenticated with GitHub App to have the service store the OAuth token. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GitHubOAuthListResponse or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.GitHubOAuthListResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -387,20 +381,18 @@ def list_git_hub_o_auth(self, location: str, **kwargs: Any) -> _models.GitHubOAu api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GitHubOAuthListResponse] = kwargs.pop("cls", None) - request = build_list_git_hub_o_auth_request( + _request = build_list_git_hub_o_auth_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_git_hub_o_auth.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -410,16 +402,12 @@ def list_git_hub_o_auth(self, location: str, **kwargs: Any) -> _models.GitHubOAu error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GitHubOAuthListResponse", pipeline_response) + deserialized = self._deserialize("GitHubOAuthListResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_git_hub_o_auth.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/githuboauth" - } + return deserialized # type: ignore @overload def generate_preview_artifacts( @@ -434,14 +422,13 @@ def generate_preview_artifacts( Generate preview dockerfile and manifests. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str :param parameters: Required. :type parameters: ~azure.mgmt.devhub.models.ArtifactGenerationProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: dict mapping str to str or the result of cls(response) :rtype: dict[str, str] :raises ~azure.core.exceptions.HttpResponseError: @@ -449,20 +436,19 @@ def generate_preview_artifacts( @overload def generate_preview_artifacts( - self, location: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> Dict[str, str]: """Generate preview dockerfile and manifests. Generate preview dockerfile and manifests. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str :param parameters: Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: dict mapping str to str or the result of cls(response) :rtype: dict[str, str] :raises ~azure.core.exceptions.HttpResponseError: @@ -470,25 +456,21 @@ def generate_preview_artifacts( @distributed_trace def generate_preview_artifacts( - self, location: str, parameters: Union[_models.ArtifactGenerationProperties, IO], **kwargs: Any + self, location: str, parameters: Union[_models.ArtifactGenerationProperties, IO[bytes]], **kwargs: Any ) -> Dict[str, str]: """Generate preview dockerfile and manifests. Generate preview dockerfile and manifests. - :param location: The name of Azure region. Required. + :param location: The name of the Azure region. Required. :type location: str - :param parameters: Is either a ArtifactGenerationProperties type or a IO type. Required. - :type parameters: ~azure.mgmt.devhub.models.ArtifactGenerationProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Is either a ArtifactGenerationProperties type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.devhub.models.ArtifactGenerationProperties or IO[bytes] :return: dict mapping str to str or the result of cls(response) :rtype: dict[str, str] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -511,23 +493,21 @@ def generate_preview_artifacts( else: _json = self._serialize.body(parameters, "ArtifactGenerationProperties") - request = build_generate_preview_artifacts_request( + _request = build_generate_preview_artifacts_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.generate_preview_artifacts.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -537,13 +517,9 @@ def generate_preview_artifacts( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("{str}", pipeline_response) + deserialized = self._deserialize("{str}", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - generate_preview_artifacts.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/locations/{location}/generatePreviewArtifacts" - } + return deserialized # type: ignore diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/_iac_profiles_operations.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/_iac_profiles_operations.py new file mode 100644 index 000000000000..dc8bd7c07707 --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/_iac_profiles_operations.py @@ -0,0 +1,1279 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/iacProfiles") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, iac_profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles/{iacProfileName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "iacProfileName": _SERIALIZER.url( + "iac_profile_name", + iac_profile_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, iac_profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles/{iacProfileName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "iacProfileName": _SERIALIZER.url( + "iac_profile_name", + iac_profile_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, iac_profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles/{iacProfileName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "iacProfileName": _SERIALIZER.url( + "iac_profile_name", + iac_profile_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_tags_request( + resource_group_name: str, iac_profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles/{iacProfileName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "iacProfileName": _SERIALIZER.url( + "iac_profile_name", + iac_profile_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_export_request( + resource_group_name: str, iac_profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles/{iacProfileName}/export", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "iacProfileName": _SERIALIZER.url( + "iac_profile_name", + iac_profile_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_scale_request( + resource_group_name: str, iac_profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles/{iacProfileName}/scale", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "iacProfileName": _SERIALIZER.url( + "iac_profile_name", + iac_profile_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sync_request( + resource_group_name: str, iac_profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/iacProfiles/{iacProfileName}/sync", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "iacProfileName": _SERIALIZER.url( + "iac_profile_name", + iac_profile_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IacProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.devhub.DevHubMgmtClient`'s + :attr:`iac_profiles` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.IacProfile"]: + """Gets a list of IacProfiles associated with the specified subscription. + + Gets a list of IacProfiles associated with the specified subscription. + + :return: An iterator like instance of either IacProfile or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.devhub.models.IacProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.IacProfileListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IacProfileListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IacProfile"]: + """Gets a list of iacProfiles within a resource group. + + Gets a list of iacProfiles within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either IacProfile or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.devhub.models.IacProfile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.IacProfileListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IacProfileListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, iac_profile_name: str, **kwargs: Any) -> _models.IacProfile: + """Gets a IacProfile. + + Gets a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :return: IacProfile or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.IacProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.IacProfile] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + iac_profile_name=iac_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IacProfile", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: _models.IacProfile, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IacProfile: + """Creates or updates a IacProfile. + + Creates or updates a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.devhub.models.IacProfile + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IacProfile or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.IacProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IacProfile: + """Creates or updates a IacProfile. + + Creates or updates a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: IacProfile or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.IacProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: Union[_models.IacProfile, IO[bytes]], + **kwargs: Any + ) -> _models.IacProfile: + """Creates or updates a IacProfile. + + Creates or updates a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Is either a IacProfile type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.devhub.models.IacProfile or IO[bytes] + :return: IacProfile or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.IacProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IacProfile] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IacProfile") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + iac_profile_name=iac_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IacProfile", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, iac_profile_name: str, **kwargs: Any + ) -> None: + """Deletes a IacProfile. + + Deletes a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + iac_profile_name=iac_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def update_tags( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: _models.TagsObject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IacProfile: + """Updates tags on a IacProfile. + + Updates tags on a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Parameters supplied to the Update TagsObject Tags operation. Required. + :type parameters: ~azure.mgmt.devhub.models.TagsObject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IacProfile or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.IacProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IacProfile: + """Updates tags on a IacProfile. + + Updates tags on a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Parameters supplied to the Update TagsObject Tags operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: IacProfile or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.IacProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: Union[_models.TagsObject, IO[bytes]], + **kwargs: Any + ) -> _models.IacProfile: + """Updates tags on a IacProfile. + + Updates tags on a IacProfile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Parameters supplied to the Update TagsObject Tags operation. Is either a + TagsObject type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.devhub.models.TagsObject or IO[bytes] + :return: IacProfile or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.IacProfile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IacProfile] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TagsObject") + + _request = build_update_tags_request( + resource_group_name=resource_group_name, + iac_profile_name=iac_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IacProfile", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def export( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: _models.ExportTemplateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrLinkResponse: + """Export a template. + + Export a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.devhub.models.ExportTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrLinkResponse or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.PrLinkResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrLinkResponse: + """Export a template. + + Export a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PrLinkResponse or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.PrLinkResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: Union[_models.ExportTemplateRequest, IO[bytes]], + **kwargs: Any + ) -> _models.PrLinkResponse: + """Export a template. + + Export a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Is either a ExportTemplateRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.devhub.models.ExportTemplateRequest or IO[bytes] + :return: PrLinkResponse or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.PrLinkResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrLinkResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExportTemplateRequest") + + _request = build_export_request( + resource_group_name=resource_group_name, + iac_profile_name=iac_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrLinkResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def scale( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: _models.ScaleTemplateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrLinkResponse: + """Scale by template. + + Scale by template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.devhub.models.ScaleTemplateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PrLinkResponse or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.PrLinkResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def scale( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrLinkResponse: + """Scale by template. + + Scale by template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PrLinkResponse or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.PrLinkResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def scale( + self, + resource_group_name: str, + iac_profile_name: str, + parameters: Union[_models.ScaleTemplateRequest, IO[bytes]], + **kwargs: Any + ) -> _models.PrLinkResponse: + """Scale by template. + + Scale by template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :param parameters: Is either a ScaleTemplateRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.devhub.models.ScaleTemplateRequest or IO[bytes] + :return: PrLinkResponse or the result of cls(response) + :rtype: ~azure.mgmt.devhub.models.PrLinkResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrLinkResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScaleTemplateRequest") + + _request = build_scale_request( + resource_group_name=resource_group_name, + iac_profile_name=iac_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrLinkResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def sync( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, iac_profile_name: str, **kwargs: Any + ) -> None: + """Sync template. + + Sync template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param iac_profile_name: The name of the IacProfile. Required. + :type iac_profile_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sync_request( + resource_group_name=resource_group_name, + iac_profile_name=iac_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/_operations.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/_operations.py index 3631f8046c79..fb1c60cb7174 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/_operations.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import DevHubMgmtClientMixinABC, _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +41,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-11-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,12 +81,11 @@ def list(self, **kwargs: Any) -> _models.OperationListResult: Returns list of operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationListResult or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.OperationListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,18 +99,16 @@ def list(self, **kwargs: Any) -> _models.OperationListResult: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -118,11 +118,9 @@ def list(self, **kwargs: Any) -> _models.OperationListResult: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationListResult", pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = {"url": "/providers/Microsoft.DevHub/operations"} + return deserialized # type: ignore diff --git a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/_workflow_operations.py b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/_workflow_operations.py index d9e1df2d1d86..bdc937610ccd 100644 --- a/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/_workflow_operations.py +++ b/sdk/devhub/azure-mgmt-devhub/azure/mgmt/devhub/operations/_workflow_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import DevHubMgmtClientMixinABC, _convert_request, _format_url_section +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,16 +44,16 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-11-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/workflows") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -67,7 +70,7 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-11-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,13 +79,13 @@ def build_list_by_resource_group_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -101,7 +104,7 @@ def build_get_request(resource_group_name: str, workflow_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-11-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,7 +113,7 @@ def build_get_request(resource_group_name: str, workflow_name: str, subscription "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -124,7 +127,7 @@ def build_get_request(resource_group_name: str, workflow_name: str, subscription ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -141,7 +144,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-11-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -151,7 +154,7 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -165,7 +168,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -184,7 +187,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-11-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -193,7 +196,7 @@ def build_delete_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -207,7 +210,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -224,7 +227,7 @@ def build_update_tags_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-11-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -234,7 +237,7 @@ def build_update_tags_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}", ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), @@ -248,7 +251,7 @@ def build_update_tags_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -286,7 +289,6 @@ def list(self, **kwargs: Any) -> Iterable["_models.Workflow"]: Gets a list of workflows associated with the specified subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workflow or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.devhub.models.Workflow] :raises ~azure.core.exceptions.HttpResponseError: @@ -297,7 +299,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Workflow"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WorkflowListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -308,15 +310,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Workflow"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -328,13 +328,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkflowListResult", pipeline_response) @@ -344,11 +343,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,8 +360,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DevHub/workflows"} - @distributed_trace def list_by_resource_group( self, resource_group_name: str, managed_cluster_resource: Optional[str] = None, **kwargs: Any @@ -377,7 +374,6 @@ def list_by_resource_group( :param managed_cluster_resource: The ManagedCluster resource associated with the workflows. Default value is None. :type managed_cluster_resource: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workflow or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.devhub.models.Workflow] :raises ~azure.core.exceptions.HttpResponseError: @@ -388,7 +384,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WorkflowListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,17 +395,15 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, managed_cluster_resource=managed_cluster_resource, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -421,13 +415,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkflowListResult", pipeline_response) @@ -437,11 +430,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -454,10 +447,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows" - } - @distributed_trace def get(self, resource_group_name: str, workflow_name: str, **kwargs: Any) -> _models.Workflow: """Gets a workflow. @@ -469,12 +458,11 @@ def get(self, resource_group_name: str, workflow_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param workflow_name: The name of the workflow resource. Required. :type workflow_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workflow or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.Workflow :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -488,21 +476,19 @@ def get(self, resource_group_name: str, workflow_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Workflow] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workflow_name=workflow_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -512,16 +498,12 @@ def get(self, resource_group_name: str, workflow_name: str, **kwargs: Any) -> _m error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workflow", pipeline_response) + deserialized = self._deserialize("Workflow", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -547,7 +529,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workflow or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.Workflow :raises ~azure.core.exceptions.HttpResponseError: @@ -558,7 +539,7 @@ def create_or_update( self, resource_group_name: str, workflow_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -573,11 +554,10 @@ def create_or_update( :param workflow_name: The name of the workflow resource. Required. :type workflow_name: str :param parameters: Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workflow or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.Workflow :raises ~azure.core.exceptions.HttpResponseError: @@ -585,7 +565,11 @@ def create_or_update( @distributed_trace def create_or_update( - self, resource_group_name: str, workflow_name: str, parameters: Union[_models.Workflow, IO], **kwargs: Any + self, + resource_group_name: str, + workflow_name: str, + parameters: Union[_models.Workflow, IO[bytes]], + **kwargs: Any ) -> _models.Workflow: """Creates or updates a workflow. @@ -596,17 +580,13 @@ def create_or_update( :type resource_group_name: str :param workflow_name: The name of the workflow resource. Required. :type workflow_name: str - :param parameters: Is either a Workflow type or a IO type. Required. - :type parameters: ~azure.mgmt.devhub.models.Workflow or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Is either a Workflow type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.devhub.models.Workflow or IO[bytes] :return: Workflow or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.Workflow :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -629,7 +609,7 @@ def create_or_update( else: _json = self._serialize.body(parameters, "Workflow") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workflow_name=workflow_name, subscription_id=self._config.subscription_id, @@ -637,16 +617,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -656,21 +634,13 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Workflow", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workflow", pipeline_response) + deserialized = self._deserialize("Workflow", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}" - } - @distributed_trace def delete( self, resource_group_name: str, workflow_name: str, **kwargs: Any @@ -684,12 +654,11 @@ def delete( :type resource_group_name: str :param workflow_name: The name of the workflow resource. Required. :type workflow_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeleteWorkflowResponse or None or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.DeleteWorkflowResponse or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -703,21 +672,19 @@ def delete( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.DeleteWorkflowResponse]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workflow_name=workflow_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -729,16 +696,12 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("DeleteWorkflowResponse", pipeline_response) + deserialized = self._deserialize("DeleteWorkflowResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}" - } + return deserialized # type: ignore @overload def update_tags( @@ -764,7 +727,6 @@ def update_tags( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workflow or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.Workflow :raises ~azure.core.exceptions.HttpResponseError: @@ -775,7 +737,7 @@ def update_tags( self, resource_group_name: str, workflow_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -790,11 +752,10 @@ def update_tags( :param workflow_name: The name of the workflow resource. Required. :type workflow_name: str :param parameters: Parameters supplied to the Update Workflow Tags operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workflow or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.Workflow :raises ~azure.core.exceptions.HttpResponseError: @@ -802,7 +763,11 @@ def update_tags( @distributed_trace def update_tags( - self, resource_group_name: str, workflow_name: str, parameters: Union[_models.TagsObject, IO], **kwargs: Any + self, + resource_group_name: str, + workflow_name: str, + parameters: Union[_models.TagsObject, IO[bytes]], + **kwargs: Any ) -> _models.Workflow: """Updates tags on a workflow. @@ -814,17 +779,13 @@ def update_tags( :param workflow_name: The name of the workflow resource. Required. :type workflow_name: str :param parameters: Parameters supplied to the Update Workflow Tags operation. Is either a - TagsObject type or a IO type. Required. - :type parameters: ~azure.mgmt.devhub.models.TagsObject or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + TagsObject type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.devhub.models.TagsObject or IO[bytes] :return: Workflow or the result of cls(response) :rtype: ~azure.mgmt.devhub.models.Workflow :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -847,7 +808,7 @@ def update_tags( else: _json = self._serialize.body(parameters, "TagsObject") - request = build_update_tags_request( + _request = build_update_tags_request( resource_group_name=resource_group_name, workflow_name=workflow_name, subscription_id=self._config.subscription_id, @@ -855,16 +816,14 @@ def update_tags( content_type=content_type, json=_json, content=_content, - template_url=self.update_tags.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -874,13 +833,9 @@ def update_tags( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Workflow", pipeline_response) + deserialized = self._deserialize("Workflow", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevHub/workflows/{workflowName}" - } + return deserialized # type: ignore diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/generate_preview_artifacts.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/generate_preview_artifacts.py index adec82b1dc45..fe2d2f22369f 100644 --- a/sdk/devhub/azure-mgmt-devhub/generated_samples/generate_preview_artifacts.py +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/generate_preview_artifacts.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.devhub import DevHubMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = DevHubMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionId1", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.generate_preview_artifacts( @@ -49,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/GeneratePreviewArtifacts.json +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/GeneratePreviewArtifacts.json if __name__ == "__main__": main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/git_hub_oauth.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/git_hub_oauth.py index 4e2462767927..cee3de8f48aa 100644 --- a/sdk/devhub/azure-mgmt-devhub/generated_samples/git_hub_oauth.py +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/git_hub_oauth.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.devhub import DevHubMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = DevHubMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionId1", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.git_hub_o_auth( @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/GitHubOAuth.json +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/GitHubOAuth.json if __name__ == "__main__": main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/git_hub_oauth_callback.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/git_hub_oauth_callback.py index 548c5fdc4b02..a14f94d03d17 100644 --- a/sdk/devhub/azure-mgmt-devhub/generated_samples/git_hub_oauth_callback.py +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/git_hub_oauth_callback.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.devhub import DevHubMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = DevHubMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionId1", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.git_hub_o_auth_callback( @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/GitHubOAuthCallback.json +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/GitHubOAuthCallback.json if __name__ == "__main__": main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/git_hub_oauth_list.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/git_hub_oauth_list.py index c970234d0f6e..14acb86b1191 100644 --- a/sdk/devhub/azure-mgmt-devhub/generated_samples/git_hub_oauth_list.py +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/git_hub_oauth_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.devhub import DevHubMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = DevHubMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionId1", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.list_git_hub_o_auth( @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/GitHubOAuth_List.json +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/GitHubOAuth_List.json if __name__ == "__main__": main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_create_or_update.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_create_or_update.py new file mode 100644 index 000000000000..3a11e790fdef --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_create_or_update.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.devhub import DevHubMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devhub +# USAGE + python iac_profile_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevHubMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="a0a37f63-7183-4e86-9ac7-ce8036a3ed31", + ) + + response = client.iac_profiles.create_or_update( + resource_group_name="resourceGroup1", + iac_profile_name="profile1", + parameters={ + "location": "eastus", + "properties": { + "githubProfile": {"repositoryName": "localtest", "repositoryOwner": "qfai"}, + "stages": [ + {"dependencies": [], "gitEnvironment": "Terraform", "stageName": "dev"}, + {"dependencies": ["dev"], "gitEnvironment": "Terraform", "stageName": "qa"}, + ], + "templates": [ + { + "instanceName": "quickinstance", + "instanceStage": "dev", + "quickStartTemplateType": "HCIAKS", + "templateName": "hciaksss", + } + ], + "terraformProfile": { + "storageAccountName": "iacbackend", + "storageAccountResourceGroup": "test", + "storageAccountSubscription": "586c20df-c465-4f10-8673-65aa4859e7ca", + "storageContainerName": "tfbackend", + }, + }, + }, + ) + print(response) + + +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/IacProfile_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_delete.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_delete.py new file mode 100644 index 000000000000..2c631006ff18 --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.devhub import DevHubMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devhub +# USAGE + python iac_profile_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevHubMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="a0a37f63-7183-4e86-9ac7-ce8036a3ed31", + ) + + client.iac_profiles.delete( + resource_group_name="resourceGroup1", + iac_profile_name="iacprofile", + ) + + +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/IacProfile_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_export_template.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_export_template.py new file mode 100644 index 000000000000..220e4f13fd29 --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_export_template.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.devhub import DevHubMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devhub +# USAGE + python iac_profile_export_template.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevHubMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="a0a37f63-7183-4e86-9ac7-ce8036a3ed31", + ) + + response = client.iac_profiles.export( + resource_group_name="resourceGroup1", + iac_profile_name="iacprofile", + parameters={ + "instanceName": "iac208", + "instanceStage": "dev", + "resourceGroupIds": ["/subscriptions/de3c4d5e-af08-451a-a873-438d86ab6f4b/resourceGroups/iac208-rg"], + "templateName": "test", + }, + ) + print(response) + + +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/IacProfile_ExportTemplate.json +if __name__ == "__main__": + main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_get.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_get.py new file mode 100644 index 000000000000..86db759a932f --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.devhub import DevHubMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devhub +# USAGE + python iac_profile_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevHubMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="a0a37f63-7183-4e86-9ac7-ce8036a3ed31", + ) + + response = client.iac_profiles.get( + resource_group_name="resourceGroup1", + iac_profile_name="iacprofile", + ) + print(response) + + +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/IacProfile_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_list.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_list.py new file mode 100644 index 000000000000..21c2d3533d7e --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_list.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.devhub import DevHubMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devhub +# USAGE + python iac_profile_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevHubMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="a0a37f63-7183-4e86-9ac7-ce8036a3ed31", + ) + + response = client.iac_profiles.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/IacProfile_List.json +if __name__ == "__main__": + main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_list_by_resource_group.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_list_by_resource_group.py new file mode 100644 index 000000000000..56336baa9be5 --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_list_by_resource_group.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.devhub import DevHubMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devhub +# USAGE + python iac_profile_list_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevHubMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="a0a37f63-7183-4e86-9ac7-ce8036a3ed31", + ) + + response = client.iac_profiles.list_by_resource_group( + resource_group_name="resourceGroup1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/IacProfile_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_scale_template.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_scale_template.py new file mode 100644 index 000000000000..65c43190f0b8 --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_scale_template.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.devhub import DevHubMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devhub +# USAGE + python iac_profile_scale_template.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevHubMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="a0a37f63-7183-4e86-9ac7-ce8036a3ed31", + ) + + response = client.iac_profiles.scale( + resource_group_name="resourceGroup1", + iac_profile_name="iacprofile", + parameters={ + "scaleProperties": [{"numberOfStores": 1, "region": "useast", "stage": "dev"}], + "templateName": "hciaksss", + }, + ) + print(response) + + +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/IacProfile_ScaleTemplate.json +if __name__ == "__main__": + main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_sync_template.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_sync_template.py new file mode 100644 index 000000000000..82cf1bdd294d --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_sync_template.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.devhub import DevHubMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devhub +# USAGE + python iac_profile_sync_template.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevHubMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="a0a37f63-7183-4e86-9ac7-ce8036a3ed31", + ) + + client.iac_profiles.sync( + resource_group_name="resourceGroup1", + iac_profile_name="iacprofile", + ) + + +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/IacProfile_SyncTemplate.json +if __name__ == "__main__": + main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_update_tags.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_update_tags.py new file mode 100644 index 000000000000..e6cf48b99064 --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/iac_profile_update_tags.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.devhub import DevHubMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-devhub +# USAGE + python iac_profile_update_tags.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DevHubMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="a0a37f63-7183-4e86-9ac7-ce8036a3ed31", + ) + + response = client.iac_profiles.update_tags( + resource_group_name="resourceGroup1", + iac_profile_name="iacprofile", + parameters={"tags": {"promote": "false", "resourceEnv": "testing"}}, + ) + print(response) + + +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/IacProfile_UpdateTags.json +if __name__ == "__main__": + main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/operation_list.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/operation_list.py index 4a1f40f45e22..905bb5c800fd 100644 --- a/sdk/devhub/azure-mgmt-devhub/generated_samples/operation_list.py +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/operation_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.devhub import DevHubMgmtClient """ @@ -33,6 +34,6 @@ def main(): print(response) -# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Operation_List.json +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/Operation_List.json if __name__ == "__main__": main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_create_or_update.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_create_or_update.py index 8afef1959ce8..6a3353e3d885 100644 --- a/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_create_or_update.py +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.devhub import DevHubMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = DevHubMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionId1", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.workflow.create_or_update( @@ -40,9 +41,9 @@ def main(): "acrRegistryName": "registry1", "acrRepositoryName": "repo1", "acrResourceGroup": "resourceGroup1", - "acrSubscriptionId": "subscriptionId1", + "acrSubscriptionId": "00000000-0000-0000-0000-000000000000", }, - "aksResourceId": "/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1", + "aksResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1", "branchName": "branch1", "deploymentProperties": { "kubeManifestLocations": ["/src/manifests/"], @@ -66,6 +67,6 @@ def main(): print(response) -# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Workflow_CreateOrUpdate.json +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/Workflow_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_create_or_update_with_artifact_gen.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_create_or_update_with_artifact_gen.py index ecfb1c28f4ed..f1f858d89b9f 100644 --- a/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_create_or_update_with_artifact_gen.py +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_create_or_update_with_artifact_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.devhub import DevHubMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = DevHubMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionId1", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.workflow.create_or_update( @@ -54,9 +55,9 @@ def main(): "acrRegistryName": "registry1", "acrRepositoryName": "repo1", "acrResourceGroup": "resourceGroup1", - "acrSubscriptionId": "subscriptionId1", + "acrSubscriptionId": "00000000-0000-0000-0000-000000000000", }, - "aksResourceId": "/subscriptions/subscriptionId1/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1", + "aksResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resourceGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1", "branchName": "branch1", "deploymentProperties": { "kubeManifestLocations": ["/src/manifests/"], @@ -79,6 +80,6 @@ def main(): print(response) -# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Workflow_CreateOrUpdate_WithArtifactGen.json +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/Workflow_CreateOrUpdate_WithArtifactGen.json if __name__ == "__main__": main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_delete.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_delete.py index 2f0dffac966a..6f0b95b89a86 100644 --- a/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_delete.py +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.devhub import DevHubMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = DevHubMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionId1", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.workflow.delete( @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Workflow_Delete.json +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/Workflow_Delete.json if __name__ == "__main__": main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_get.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_get.py index ac67f6cbb559..7ee352379721 100644 --- a/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_get.py +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.devhub import DevHubMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = DevHubMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionId1", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.workflow.get( @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Workflow_Get.json +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/Workflow_Get.json if __name__ == "__main__": main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_list.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_list.py index 99041916e132..620f718c88bc 100644 --- a/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_list.py +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.devhub import DevHubMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = DevHubMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionId1", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.workflow.list() @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Workflow_List.json +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/Workflow_List.json if __name__ == "__main__": main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_list_by_resource_group.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_list_by_resource_group.py index ecf422b357dc..252eac0277e9 100644 --- a/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_list_by_resource_group.py +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.devhub import DevHubMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = DevHubMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionId1", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.workflow.list_by_resource_group( @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Workflow_ListByResourceGroup.json +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/Workflow_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_update_tags.py b/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_update_tags.py index 97b27f559bce..0c49050ff340 100644 --- a/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_update_tags.py +++ b/sdk/devhub/azure-mgmt-devhub/generated_samples/workflow_update_tags.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.devhub import DevHubMgmtClient """ @@ -26,7 +27,7 @@ def main(): client = DevHubMgmtClient( credential=DefaultAzureCredential(), - subscription_id="subscriptionId1", + subscription_id="00000000-0000-0000-0000-000000000000", ) response = client.workflow.update_tags( @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2022-10-11-preview/examples/Workflow_UpdateTags.json +# x-ms-original-file: specification/developerhub/resource-manager/Microsoft.DevHub/preview/2024-05-01-preview/examples/Workflow_UpdateTags.json if __name__ == "__main__": main() diff --git a/sdk/devhub/azure-mgmt-devhub/generated_tests/conftest.py b/sdk/devhub/azure-mgmt-devhub/generated_tests/conftest.py new file mode 100644 index 000000000000..16e674323321 --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + devhubmgmt_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + devhubmgmt_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + devhubmgmt_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + devhubmgmt_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=devhubmgmt_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=devhubmgmt_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=devhubmgmt_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=devhubmgmt_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt.py b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt.py new file mode 100644 index 000000000000..6107778677ec --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt.py @@ -0,0 +1,80 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.devhub import DevHubMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDevHubMgmt(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DevHubMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_git_hub_o_auth(self, resource_group): + response = self.client.git_hub_o_auth( + location="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_git_hub_o_auth_callback(self, resource_group): + response = self.client.git_hub_o_auth_callback( + location="str", + code="str", + state="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_git_hub_o_auth(self, resource_group): + response = self.client.list_git_hub_o_auth( + location="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_generate_preview_artifacts(self, resource_group): + response = self.client.generate_preview_artifacts( + location="str", + parameters={ + "appName": "str", + "builderVersion": "str", + "dockerfileGenerationMode": "str", + "dockerfileOutputDirectory": "str", + "generationLanguage": "str", + "imageName": "str", + "imageTag": "str", + "languageVersion": "str", + "manifestGenerationMode": "str", + "manifestOutputDirectory": "str", + "manifestType": "str", + "namespace": "str", + "port": "str", + }, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_async.py b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_async.py new file mode 100644 index 000000000000..a8a7ad29935f --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_async.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.devhub.aio import DevHubMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDevHubMgmtAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DevHubMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_git_hub_o_auth(self, resource_group): + response = await self.client.git_hub_o_auth( + location="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_git_hub_o_auth_callback(self, resource_group): + response = await self.client.git_hub_o_auth_callback( + location="str", + code="str", + state="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_git_hub_o_auth(self, resource_group): + response = await self.client.list_git_hub_o_auth( + location="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_generate_preview_artifacts(self, resource_group): + response = await self.client.generate_preview_artifacts( + location="str", + parameters={ + "appName": "str", + "builderVersion": "str", + "dockerfileGenerationMode": "str", + "dockerfileOutputDirectory": "str", + "generationLanguage": "str", + "imageName": "str", + "imageTag": "str", + "languageVersion": "str", + "manifestGenerationMode": "str", + "manifestOutputDirectory": "str", + "manifestType": "str", + "namespace": "str", + "port": "str", + }, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_iac_profiles_operations.py b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_iac_profiles_operations.py new file mode 100644 index 000000000000..b1e9d7d2ec1d --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_iac_profiles_operations.py @@ -0,0 +1,174 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.devhub import DevHubMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDevHubMgmtIacProfilesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DevHubMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.iac_profiles.list( + api_version="2024-05-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.iac_profiles.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-05-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.iac_profiles.get( + resource_group_name=resource_group.name, + iac_profile_name="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.iac_profiles.create_or_update( + resource_group_name=resource_group.name, + iac_profile_name="str", + parameters={ + "location": "str", + "authStatus": "str", + "branchName": "str", + "etag": "str", + "id": "str", + "name": "str", + "prStatus": "str", + "pullNumber": 0, + "repositoryMainBranch": "str", + "repositoryName": "str", + "repositoryOwner": "str", + "stages": [{"dependencies": ["str"], "gitEnvironment": "str", "stageName": "str"}], + "storageAccountName": "str", + "storageAccountResourceGroup": "str", + "storageAccountSubscription": "str", + "storageContainerName": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "templates": [ + { + "instanceName": "str", + "instanceStage": "str", + "quickStartTemplateType": "str", + "sourceResourceId": "str", + "templateDetails": [{"count": 0, "namingConvention": "str", "productName": "str"}], + "templateName": "str", + } + ], + "type": "str", + }, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.iac_profiles.delete( + resource_group_name=resource_group.name, + iac_profile_name="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update_tags(self, resource_group): + response = self.client.iac_profiles.update_tags( + resource_group_name=resource_group.name, + iac_profile_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_export(self, resource_group): + response = self.client.iac_profiles.export( + resource_group_name=resource_group.name, + iac_profile_name="str", + parameters={ + "instanceName": "str", + "instanceStage": "str", + "resourceGroupIds": ["str"], + "siteId": "str", + "templateName": "str", + }, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scale(self, resource_group): + response = self.client.iac_profiles.scale( + resource_group_name=resource_group.name, + iac_profile_name="str", + parameters={ + "scaleProperties": [{"numberOfStores": 0, "region": "str", "stage": "str"}], + "templateName": "str", + }, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sync(self, resource_group): + response = self.client.iac_profiles.sync( + resource_group_name=resource_group.name, + iac_profile_name="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_iac_profiles_operations_async.py b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_iac_profiles_operations_async.py new file mode 100644 index 000000000000..accfeb7b175d --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_iac_profiles_operations_async.py @@ -0,0 +1,175 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.devhub.aio import DevHubMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDevHubMgmtIacProfilesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DevHubMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.iac_profiles.list( + api_version="2024-05-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.iac_profiles.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-05-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.iac_profiles.get( + resource_group_name=resource_group.name, + iac_profile_name="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.iac_profiles.create_or_update( + resource_group_name=resource_group.name, + iac_profile_name="str", + parameters={ + "location": "str", + "authStatus": "str", + "branchName": "str", + "etag": "str", + "id": "str", + "name": "str", + "prStatus": "str", + "pullNumber": 0, + "repositoryMainBranch": "str", + "repositoryName": "str", + "repositoryOwner": "str", + "stages": [{"dependencies": ["str"], "gitEnvironment": "str", "stageName": "str"}], + "storageAccountName": "str", + "storageAccountResourceGroup": "str", + "storageAccountSubscription": "str", + "storageContainerName": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "templates": [ + { + "instanceName": "str", + "instanceStage": "str", + "quickStartTemplateType": "str", + "sourceResourceId": "str", + "templateDetails": [{"count": 0, "namingConvention": "str", "productName": "str"}], + "templateName": "str", + } + ], + "type": "str", + }, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.iac_profiles.delete( + resource_group_name=resource_group.name, + iac_profile_name="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update_tags(self, resource_group): + response = await self.client.iac_profiles.update_tags( + resource_group_name=resource_group.name, + iac_profile_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_export(self, resource_group): + response = await self.client.iac_profiles.export( + resource_group_name=resource_group.name, + iac_profile_name="str", + parameters={ + "instanceName": "str", + "instanceStage": "str", + "resourceGroupIds": ["str"], + "siteId": "str", + "templateName": "str", + }, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scale(self, resource_group): + response = await self.client.iac_profiles.scale( + resource_group_name=resource_group.name, + iac_profile_name="str", + parameters={ + "scaleProperties": [{"numberOfStores": 0, "region": "str", "stage": "str"}], + "templateName": "str", + }, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sync(self, resource_group): + response = await self.client.iac_profiles.sync( + resource_group_name=resource_group.name, + iac_profile_name="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_operations.py b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_operations.py new file mode 100644 index 000000000000..f82683977865 --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.devhub import DevHubMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDevHubMgmtOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DevHubMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_operations_async.py b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_operations_async.py new file mode 100644 index 000000000000..d7ab65746b6d --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.devhub.aio import DevHubMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDevHubMgmtOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DevHubMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = await self.client.operations.list( + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_workflow_operations.py b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_workflow_operations.py new file mode 100644 index 000000000000..46e6f9c15ed4 --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_workflow_operations.py @@ -0,0 +1,147 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.devhub import DevHubMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDevHubMgmtWorkflowOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DevHubMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.workflow.list( + api_version="2024-05-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.workflow.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-05-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.workflow.get( + resource_group_name=resource_group.name, + workflow_name="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.workflow.create_or_update( + resource_group_name=resource_group.name, + workflow_name="str", + parameters={ + "location": "str", + "acr": { + "acrRegistryName": "str", + "acrRepositoryName": "str", + "acrResourceGroup": "str", + "acrSubscriptionId": "str", + }, + "aksResourceId": "str", + "appName": "str", + "authStatus": "str", + "branchName": "str", + "builderVersion": "str", + "deploymentProperties": { + "helmChartPath": "str", + "helmValues": "str", + "kubeManifestLocations": ["str"], + "manifestType": "str", + "overrides": {"str": "str"}, + }, + "dockerBuildContext": "str", + "dockerfile": "str", + "dockerfileGenerationMode": "str", + "dockerfileOutputDirectory": "str", + "generationLanguage": "str", + "id": "str", + "imageName": "str", + "imageTag": "str", + "languageVersion": "str", + "lastWorkflowRun": { + "lastRunAt": "2020-02-20 00:00:00", + "succeeded": bool, + "workflowRunStatus": "str", + "workflowRunURL": "str", + }, + "manifestGenerationMode": "str", + "manifestOutputDirectory": "str", + "manifestType": "str", + "name": "str", + "namespace": "str", + "oidcCredentials": {"azureClientId": "str", "azureTenantId": "str"}, + "port": "str", + "prStatus": "str", + "prURL": "str", + "pullNumber": 0, + "repositoryName": "str", + "repositoryOwner": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.workflow.delete( + resource_group_name=resource_group.name, + workflow_name="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update_tags(self, resource_group): + response = self.client.workflow.update_tags( + resource_group_name=resource_group.name, + workflow_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_workflow_operations_async.py b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_workflow_operations_async.py new file mode 100644 index 000000000000..709554fea0c3 --- /dev/null +++ b/sdk/devhub/azure-mgmt-devhub/generated_tests/test_dev_hub_mgmt_workflow_operations_async.py @@ -0,0 +1,148 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.devhub.aio import DevHubMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestDevHubMgmtWorkflowOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DevHubMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.workflow.list( + api_version="2024-05-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.workflow.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-05-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.workflow.get( + resource_group_name=resource_group.name, + workflow_name="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.workflow.create_or_update( + resource_group_name=resource_group.name, + workflow_name="str", + parameters={ + "location": "str", + "acr": { + "acrRegistryName": "str", + "acrRepositoryName": "str", + "acrResourceGroup": "str", + "acrSubscriptionId": "str", + }, + "aksResourceId": "str", + "appName": "str", + "authStatus": "str", + "branchName": "str", + "builderVersion": "str", + "deploymentProperties": { + "helmChartPath": "str", + "helmValues": "str", + "kubeManifestLocations": ["str"], + "manifestType": "str", + "overrides": {"str": "str"}, + }, + "dockerBuildContext": "str", + "dockerfile": "str", + "dockerfileGenerationMode": "str", + "dockerfileOutputDirectory": "str", + "generationLanguage": "str", + "id": "str", + "imageName": "str", + "imageTag": "str", + "languageVersion": "str", + "lastWorkflowRun": { + "lastRunAt": "2020-02-20 00:00:00", + "succeeded": bool, + "workflowRunStatus": "str", + "workflowRunURL": "str", + }, + "manifestGenerationMode": "str", + "manifestOutputDirectory": "str", + "manifestType": "str", + "name": "str", + "namespace": "str", + "oidcCredentials": {"azureClientId": "str", "azureTenantId": "str"}, + "port": "str", + "prStatus": "str", + "prURL": "str", + "pullNumber": 0, + "repositoryName": "str", + "repositoryOwner": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.workflow.delete( + resource_group_name=resource_group.name, + workflow_name="str", + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update_tags(self, resource_group): + response = await self.client.workflow.update_tags( + resource_group_name=resource_group.name, + workflow_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2024-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/devhub/azure-mgmt-devhub/setup.py b/sdk/devhub/azure-mgmt-devhub/setup.py index f6d8dcc8da9f..687718f1d77f 100644 --- a/sdk/devhub/azure-mgmt-devhub/setup.py +++ b/sdk/devhub/azure-mgmt-devhub/setup.py @@ -1,10 +1,10 @@ #!/usr/bin/env python -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -#-------------------------------------------------------------------------- +# -------------------------------------------------------------------------- import re import os.path @@ -16,64 +16,68 @@ PACKAGE_PPRINT_NAME = "Devhub Management" # a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace('-', '/') +package_folder_path = PACKAGE_NAME.replace("-", "/") # a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace('-', '.') +namespace_name = PACKAGE_NAME.replace("-", ".") # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py') - if os.path.exists(os.path.join(package_folder_path, 'version.py')) - else os.path.join(package_folder_path, '_version.py'), 'r') as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) +with open( + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py"), + "r", +) as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) if not version: - raise RuntimeError('Cannot find version information') + raise RuntimeError("Cannot find version information") -with open('README.md', encoding='utf-8') as f: +with open("README.md", encoding="utf-8") as f: readme = f.read() -with open('CHANGELOG.md', encoding='utf-8') as f: +with open("CHANGELOG.md", encoding="utf-8") as f: changelog = f.read() setup( name=PACKAGE_NAME, version=version, - description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), - long_description=readme + '\n\n' + changelog, - long_description_content_type='text/markdown', - license='MIT License', - author='Microsoft Corporation', - author_email='azpysdkhelp@microsoft.com', - url='https://github.com/Azure/azure-sdk-for-python', + description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=readme + "\n\n" + changelog, + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python", keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ - 'Development Status :: 4 - Beta', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'License :: OSI Approved :: MIT License', + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", ], zip_safe=False, - packages=find_packages(exclude=[ - 'tests', - # Exclude packages that will be covered by PEP420 or nspkg - 'azure', - 'azure.mgmt', - ]), + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.mgmt", + ] + ), include_package_data=True, package_data={ - 'pytyped': ['py.typed'], + "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7" + python_requires=">=3.8", )