From 49e90ffb55b6a09cfc4de456a8301da0a95aa7a8 Mon Sep 17 00:00:00 2001 From: SDKAuto <sdkautomation@microsoft.com> Date: Tue, 24 May 2022 02:03:20 +0000 Subject: [PATCH] CodeGen from PR 18846 in Azure/azure-rest-api-specs change operationIds (#18846) --- .../azure-mgmt-education/CHANGELOG.md | 5 + sdk/education/azure-mgmt-education/LICENSE | 21 + .../azure-mgmt-education/MANIFEST.in | 7 + sdk/education/azure-mgmt-education/README.md | 30 + sdk/education/azure-mgmt-education/_meta.json | 11 + .../azure-mgmt-education/azure/__init__.py | 1 + .../azure/mgmt/__init__.py | 1 + .../azure/mgmt/education/__init__.py | 18 + .../azure/mgmt/education/_configuration.py | 67 ++ .../education/_education_management_client.py | 107 ++ .../azure/mgmt/education/_metadata.json | 113 ++ .../azure/mgmt/education/_patch.py | 31 + .../azure/mgmt/education/_vendor.py | 27 + .../azure/mgmt/education/_version.py | 9 + .../azure/mgmt/education/aio/__init__.py | 15 + .../mgmt/education/aio/_configuration.py | 66 ++ .../aio/_education_management_client.py | 104 ++ .../azure/mgmt/education/aio/_patch.py | 31 + .../mgmt/education/aio/operations/__init__.py | 25 + ..._education_management_client_operations.py | 77 ++ .../aio/operations/_grants_operations.py | 271 +++++ .../operations/_join_requests_operations.py | 326 ++++++ .../aio/operations/_labs_operations.py | 501 ++++++++ .../education/aio/operations/_operations.py | 94 ++ .../operations/_student_labs_operations.py | 172 +++ .../aio/operations/_students_operations.py | 343 ++++++ .../azure/mgmt/education/models/__init__.py | 73 ++ .../_education_management_client_enums.py | 81 ++ .../mgmt/education/models/_models_py3.py | 1043 +++++++++++++++++ .../mgmt/education/operations/__init__.py | 25 + ..._education_management_client_operations.py | 115 ++ .../operations/_grants_operations.py | 379 ++++++ .../operations/_join_requests_operations.py | 482 ++++++++ .../education/operations/_labs_operations.py | 752 ++++++++++++ .../mgmt/education/operations/_operations.py | 123 ++ .../operations/_student_labs_operations.py | 231 ++++ .../operations/_students_operations.py | 508 ++++++++ .../azure/mgmt/education/py.typed | 1 + .../azure-mgmt-education/sdk_packaging.toml | 9 + sdk/education/azure-mgmt-education/setup.py | 78 ++ sdk/education/ci.yml | 33 + 41 files changed, 6406 insertions(+) create mode 100644 sdk/education/azure-mgmt-education/CHANGELOG.md create mode 100644 sdk/education/azure-mgmt-education/LICENSE create mode 100644 sdk/education/azure-mgmt-education/MANIFEST.in create mode 100644 sdk/education/azure-mgmt-education/README.md create mode 100644 sdk/education/azure-mgmt-education/_meta.json create mode 100644 sdk/education/azure-mgmt-education/azure/__init__.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/__init__.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/__init__.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/_configuration.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/_education_management_client.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/_metadata.json create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/_patch.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/_vendor.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/_version.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/aio/__init__.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/aio/_configuration.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/aio/_education_management_client.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/aio/_patch.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/__init__.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_education_management_client_operations.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_grants_operations.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_join_requests_operations.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_labs_operations.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_operations.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_student_labs_operations.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_students_operations.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/models/__init__.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/models/_education_management_client_enums.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/models/_models_py3.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/operations/__init__.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_education_management_client_operations.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_grants_operations.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_join_requests_operations.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_labs_operations.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_operations.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_student_labs_operations.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_students_operations.py create mode 100644 sdk/education/azure-mgmt-education/azure/mgmt/education/py.typed create mode 100644 sdk/education/azure-mgmt-education/sdk_packaging.toml create mode 100644 sdk/education/azure-mgmt-education/setup.py create mode 100644 sdk/education/ci.yml diff --git a/sdk/education/azure-mgmt-education/CHANGELOG.md b/sdk/education/azure-mgmt-education/CHANGELOG.md new file mode 100644 index 0000000000000..578ed6acf4796 --- /dev/null +++ b/sdk/education/azure-mgmt-education/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/education/azure-mgmt-education/LICENSE b/sdk/education/azure-mgmt-education/LICENSE new file mode 100644 index 0000000000000..b2f52a2bad4e2 --- /dev/null +++ b/sdk/education/azure-mgmt-education/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/education/azure-mgmt-education/MANIFEST.in b/sdk/education/azure-mgmt-education/MANIFEST.in new file mode 100644 index 0000000000000..a2190201d23f4 --- /dev/null +++ b/sdk/education/azure-mgmt-education/MANIFEST.in @@ -0,0 +1,7 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py +include LICENSE +include azure/mgmt/education/py.typed diff --git a/sdk/education/azure-mgmt-education/README.md b/sdk/education/azure-mgmt-education/README.md new file mode 100644 index 0000000000000..406b90043c1fc --- /dev/null +++ b/sdk/education/azure-mgmt-education/README.md @@ -0,0 +1,30 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 3.6+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +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-education%2FREADME.png) diff --git a/sdk/education/azure-mgmt-education/_meta.json b/sdk/education/azure-mgmt-education/_meta.json new file mode 100644 index 0000000000000..793e0d208e395 --- /dev/null +++ b/sdk/education/azure-mgmt-education/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.13.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "fbc7948ff6ec796e273c9f0aeac718ddde6e84fd", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/education/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/education/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/education/azure-mgmt-education/azure/__init__.py b/sdk/education/azure-mgmt-education/azure/__init__.py new file mode 100644 index 0000000000000..8db66d3d0f0f2 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/__init__.py b/sdk/education/azure-mgmt-education/azure/mgmt/__init__.py new file mode 100644 index 0000000000000..8db66d3d0f0f2 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/__init__.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/__init__.py new file mode 100644 index 0000000000000..b071c838f6c0e --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/__init__.py @@ -0,0 +1,18 @@ +# 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 ._education_management_client import EducationManagementClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['EducationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/_configuration.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/_configuration.py new file mode 100644 index 0000000000000..2cbdb44c9e0e5 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/_configuration.py @@ -0,0 +1,67 @@ +# 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 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 + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class EducationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for EducationManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + **kwargs: Any + ) -> None: + super(EducationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-education/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + 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.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/_education_management_client.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/_education_management_client.py new file mode 100644 index 0000000000000..66f612caec0e7 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/_education_management_client.py @@ -0,0 +1,107 @@ +# 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 copy import deepcopy +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from ._configuration import EducationManagementClientConfiguration +from .operations import EducationManagementClientOperationsMixin, GrantsOperations, JoinRequestsOperations, LabsOperations, Operations, StudentLabsOperations, StudentsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class EducationManagementClient(EducationManagementClientOperationsMixin): # pylint: disable=too-many-instance-attributes + """Education client provides access to education resources for Azure subscriptions. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.education.operations.Operations + :ivar grants: GrantsOperations operations + :vartype grants: azure.mgmt.education.operations.GrantsOperations + :ivar labs: LabsOperations operations + :vartype labs: azure.mgmt.education.operations.LabsOperations + :ivar join_requests: JoinRequestsOperations operations + :vartype join_requests: azure.mgmt.education.operations.JoinRequestsOperations + :ivar students: StudentsOperations operations + :vartype students: azure.mgmt.education.operations.StudentsOperations + :ivar student_labs: StudentLabsOperations operations + :vartype student_labs: azure.mgmt.education.operations.StudentLabsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = EducationManagementClientConfiguration(credential=credential, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.grants = GrantsOperations(self._client, self._config, self._serialize, self._deserialize) + self.labs = LabsOperations(self._client, self._config, self._serialize, self._deserialize) + self.join_requests = JoinRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.students = StudentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.student_labs = StudentLabsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + <HttpRequest [GET], url: 'https://www.example.org/'> + >>> response = client._send_request(request) + <HttpResponse: 200 OK> + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> EducationManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/_metadata.json b/sdk/education/azure-mgmt-education/azure/mgmt/education/_metadata.json new file mode 100644 index 0000000000000..adc774d4132fb --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/_metadata.json @@ -0,0 +1,113 @@ +{ + "chosen_version": "2021-12-01-preview", + "total_api_version_list": ["2021-12-01-preview"], + "client": { + "name": "EducationManagementClient", + "filename": "_education_management_client", + "description": "Education client provides access to education resources for Azure subscriptions.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"EducationManagementClientConfiguration\"], \"._operations_mixin\": [\"EducationManagementClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"EducationManagementClientConfiguration\"], \"._operations_mixin\": [\"EducationManagementClientOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "operations": "Operations", + "grants": "GrantsOperations", + "labs": "LabsOperations", + "join_requests": "JoinRequestsOperations", + "students": "StudentsOperations", + "student_labs": "StudentLabsOperations" + }, + "operation_mixins": { + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "operations": { + "redeem_invitation_code" : { + "sync": { + "signature": "def redeem_invitation_code( # pylint: disable=inconsistent-return-statements\n self,\n parameters, # type: \"_models.RedeemRequest\"\n **kwargs # type: Any\n):\n # type: (...) -\u003e None\n", + "doc": "\"\"\"Redeem invite code to join a redeemable lab.\n\n:param parameters: Request parameters to provide redeem code.\n:type parameters: ~azure.mgmt.education.models.RedeemRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def redeem_invitation_code( # pylint: disable=inconsistent-return-statements\n self,\n parameters: \"_models.RedeemRequest\",\n **kwargs: Any\n) -\u003e None:\n", + "doc": "\"\"\"Redeem invite code to join a redeemable lab.\n\n:param parameters: Request parameters to provide redeem code.\n:type parameters: ~azure.mgmt.education.models.RedeemRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "parameters" + } + } + } +} \ No newline at end of file diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/_patch.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/_vendor.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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.core.pipeline.transport import HttpRequest + +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: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/_version.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/_version.py new file mode 100644 index 0000000000000..e5754a47ce68f --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/_version.py @@ -0,0 +1,9 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/__init__.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/__init__.py new file mode 100644 index 0000000000000..040ad819b864f --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/__init__.py @@ -0,0 +1,15 @@ +# 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 ._education_management_client import EducationManagementClient +__all__ = ['EducationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/_configuration.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/_configuration.py new file mode 100644 index 0000000000000..e57ef3b3af875 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/_configuration.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 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 + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class EducationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for EducationManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + **kwargs: Any + ) -> None: + super(EducationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-education/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + 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.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/_education_management_client.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/_education_management_client.py new file mode 100644 index 0000000000000..61df980950de8 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/_education_management_client.py @@ -0,0 +1,104 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ._configuration import EducationManagementClientConfiguration +from .operations import EducationManagementClientOperationsMixin, GrantsOperations, JoinRequestsOperations, LabsOperations, Operations, StudentLabsOperations, StudentsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class EducationManagementClient(EducationManagementClientOperationsMixin): # pylint: disable=too-many-instance-attributes + """Education client provides access to education resources for Azure subscriptions. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.education.aio.operations.Operations + :ivar grants: GrantsOperations operations + :vartype grants: azure.mgmt.education.aio.operations.GrantsOperations + :ivar labs: LabsOperations operations + :vartype labs: azure.mgmt.education.aio.operations.LabsOperations + :ivar join_requests: JoinRequestsOperations operations + :vartype join_requests: azure.mgmt.education.aio.operations.JoinRequestsOperations + :ivar students: StudentsOperations operations + :vartype students: azure.mgmt.education.aio.operations.StudentsOperations + :ivar student_labs: StudentLabsOperations operations + :vartype student_labs: azure.mgmt.education.aio.operations.StudentLabsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = EducationManagementClientConfiguration(credential=credential, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.grants = GrantsOperations(self._client, self._config, self._serialize, self._deserialize) + self.labs = LabsOperations(self._client, self._config, self._serialize, self._deserialize) + self.join_requests = JoinRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.students = StudentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.student_labs = StudentLabsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + <HttpRequest [GET], url: 'https://www.example.org/'> + >>> response = await client._send_request(request) + <AsyncHttpResponse: 200 OK> + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "EducationManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/_patch.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/__init__.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/__init__.py new file mode 100644 index 0000000000000..28ef5e3989459 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/__init__.py @@ -0,0 +1,25 @@ +# 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 ._operations import Operations +from ._grants_operations import GrantsOperations +from ._labs_operations import LabsOperations +from ._join_requests_operations import JoinRequestsOperations +from ._education_management_client_operations import EducationManagementClientOperationsMixin +from ._students_operations import StudentsOperations +from ._student_labs_operations import StudentLabsOperations + +__all__ = [ + 'Operations', + 'GrantsOperations', + 'LabsOperations', + 'JoinRequestsOperations', + 'EducationManagementClientOperationsMixin', + 'StudentsOperations', + 'StudentLabsOperations', +] diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_education_management_client_operations.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_education_management_client_operations.py new file mode 100644 index 0000000000000..3b3969fcfca6e --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_education_management_client_operations.py @@ -0,0 +1,77 @@ +# pylint: disable=too-many-lines +# 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 typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._education_management_client_operations import build_redeem_invitation_code_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class EducationManagementClientOperationsMixin: + + @distributed_trace_async + async def redeem_invitation_code( # pylint: disable=inconsistent-return-statements + self, + parameters: "_models.RedeemRequest", + **kwargs: Any + ) -> None: + """Redeem invite code to join a redeemable lab. + + :param parameters: Request parameters to provide redeem code. + :type parameters: ~azure.mgmt.education.models.RedeemRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RedeemRequest') + + request = build_redeem_invitation_code_request( + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.redeem_invitation_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + redeem_invitation_code.metadata = {'url': "/providers/Microsoft.Education/redeemInvitationCode"} # type: ignore + diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_grants_operations.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_grants_operations.py new file mode 100644 index 0000000000000..6b6ff5bb914d2 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_grants_operations.py @@ -0,0 +1,271 @@ +# pylint: disable=too-many-lines +# 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._grants_operations import build_get_request, build_list_all_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class GrantsOperations: + """GrantsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.education.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_all( + self, + include_allocated_budget: Optional[bool] = None, + **kwargs: Any + ) -> AsyncIterable["_models.GrantListResponse"]: + """Get a list of grants that Microsoft has provided. + + :param include_allocated_budget: May be used to include information about budget that has been + allocated. Default value is None. + :type include_allocated_budget: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GrantListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.education.models.GrantListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrantListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_all_request( + api_version=api_version, + include_allocated_budget=include_allocated_budget, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_all_request( + api_version=api_version, + include_allocated_budget=include_allocated_budget, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GrantListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': "/providers/Microsoft.Education/grants"} # type: ignore + + @distributed_trace + def list( + self, + billing_account_name: str, + billing_profile_name: str, + include_allocated_budget: Optional[bool] = None, + **kwargs: Any + ) -> AsyncIterable["_models.GrantListResponse"]: + """Get details for a specific grant linked to the provided billing account and billing profile. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param include_allocated_budget: May be used to include information about budget that has been + allocated. Default value is None. + :type include_allocated_budget: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GrantListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.education.models.GrantListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrantListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + api_version=api_version, + include_allocated_budget=include_allocated_budget, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + api_version=api_version, + include_allocated_budget=include_allocated_budget, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GrantListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Education/grants"} # type: ignore + + @distributed_trace_async + async def get( + self, + billing_account_name: str, + billing_profile_name: str, + include_allocated_budget: Optional[bool] = None, + **kwargs: Any + ) -> "_models.GrantDetails": + """Get details for a specific grant linked to the provided billing account and billing profile. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param include_allocated_budget: May be used to include information about budget that has been + allocated. Default value is None. + :type include_allocated_budget: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GrantDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.GrantDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrantDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + api_version=api_version, + include_allocated_budget=include_allocated_budget, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GrantDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Education/grants/default"} # type: ignore + diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_join_requests_operations.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_join_requests_operations.py new file mode 100644 index 0000000000000..fabf5eea13cf4 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_join_requests_operations.py @@ -0,0 +1,326 @@ +# pylint: disable=too-many-lines +# 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._join_requests_operations import build_approve_request, build_deny_request, build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class JoinRequestsOperations: + """JoinRequestsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.education.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + include_denied: Optional[bool] = None, + **kwargs: Any + ) -> AsyncIterable["_models.JoinRequestList"]: + """get student join requests. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param include_denied: Include denied. Default value is None. + :type include_denied: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either JoinRequestList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.education.models.JoinRequestList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.JoinRequestList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + include_denied=include_denied, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + include_denied=include_denied, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("JoinRequestList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/joinRequests"} # type: ignore + + @distributed_trace_async + async def get( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + join_request_name: str, + **kwargs: Any + ) -> "_models.JoinRequestDetails": + """get student join requests. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param join_request_name: Join name. + :type join_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JoinRequestDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.JoinRequestDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.JoinRequestDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + join_request_name=join_request_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JoinRequestDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/joinRequests/{joinRequestName}"} # type: ignore + + + @distributed_trace_async + async def approve( # pylint: disable=inconsistent-return-statements + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + join_request_name: str, + **kwargs: Any + ) -> None: + """Approve student joining the redeemable lab. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param join_request_name: Join name. + :type join_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_approve_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + join_request_name=join_request_name, + api_version=api_version, + template_url=self.approve.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + approve.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/joinRequests/{joinRequestName}/approve"} # type: ignore + + + @distributed_trace_async + async def deny( # pylint: disable=inconsistent-return-statements + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + join_request_name: str, + **kwargs: Any + ) -> None: + """Deny student joining the redeemable lab. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param join_request_name: Join name. + :type join_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_deny_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + join_request_name=join_request_name, + api_version=api_version, + template_url=self.deny.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + deny.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/joinRequests/{joinRequestName}/deny"} # type: ignore + diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_labs_operations.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_labs_operations.py new file mode 100644 index 0000000000000..4b4b969ce8461 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_labs_operations.py @@ -0,0 +1,501 @@ +# pylint: disable=too-many-lines +# 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._labs_operations import build_create_or_update_request, build_delete_request, build_generate_invite_code_request, build_get_request, build_list_all_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class LabsOperations: + """LabsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.education.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_all( + self, + billing_account_name: str, + billing_profile_name: str, + include_budget: Optional[bool] = None, + include_deleted: Optional[bool] = None, + **kwargs: Any + ) -> AsyncIterable["_models.LabListResult"]: + """Get a list of labs associated with the provided billing account name and billing profile name. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param include_budget: May be used to include budget information. Default value is None. + :type include_budget: bool + :param include_deleted: May be used to show deleted items. Default value is None. + :type include_deleted: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LabListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.education.models.LabListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_all_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + api_version=api_version, + include_budget=include_budget, + include_deleted=include_deleted, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_all_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + api_version=api_version, + include_budget=include_budget, + include_deleted=include_deleted, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("LabListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Education/labs"} # type: ignore + + @distributed_trace + def list( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + include_budget: Optional[bool] = None, + **kwargs: Any + ) -> AsyncIterable["_models.LabListResult"]: + """Get the details for a specific lab associated with the provided billing account name, billing + profile name, and invoice section name. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param include_budget: May be used to include budget information. Default value is None. + :type include_budget: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LabListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.education.models.LabListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + include_budget=include_budget, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + include_budget=include_budget, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("LabListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs"} # type: ignore + + @distributed_trace_async + async def get( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + include_budget: Optional[bool] = None, + **kwargs: Any + ) -> "_models.LabDetails": + """Get the details for a specific lab associated with the provided billing account name, billing + profile name, and invoice section name. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param include_budget: May be used to include budget information. Default value is None. + :type include_budget: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LabDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.LabDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + include_budget=include_budget, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LabDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs: Any + ) -> None: + """Delete a specific lab associated with the provided billing account name, billing profile name, + and invoice section name. Note all students must be removed from the lab in order to delete the + lab. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_delete_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + parameters: "_models.LabDetails", + **kwargs: Any + ) -> "_models.LabDetails": + """Create a new lab or update a previously created lab. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param parameters: Request parameters that are provided to create lab resource. + :type parameters: ~azure.mgmt.education.models.LabDetails + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LabDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.LabDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'LabDetails') + + request = build_create_or_update_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LabDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LabDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"} # type: ignore + + + @distributed_trace_async + async def generate_invite_code( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + parameters: "_models.InviteCodeGenerateRequest", + only_update_student_count_parameter: Optional[bool] = None, + **kwargs: Any + ) -> "_models.LabDetails": + """Generate invite code for a lab. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param parameters: Request parameters that are provided to generate invite code. + :type parameters: ~azure.mgmt.education.models.InviteCodeGenerateRequest + :param only_update_student_count_parameter: set this flag to true if you want to update student + count without generating a new invite code. Default value is None. + :type only_update_student_count_parameter: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LabDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.LabDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'InviteCodeGenerateRequest') + + request = build_generate_invite_code_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + content_type=content_type, + json=_json, + only_update_student_count_parameter=only_update_student_count_parameter, + template_url=self.generate_invite_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LabDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + generate_invite_code.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/generateInviteCode"} # type: ignore + diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_operations.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_operations.py new file mode 100644 index 0000000000000..365387f2bb0f2 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_operations.py @@ -0,0 +1,94 @@ +# pylint: disable=too-many-lines +# 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 typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.education.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def list( + self, + **kwargs: Any + ) -> "_models.OperationListResult": + """Lists all of the available Microsoft.Education API 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.education.models.OperationListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OperationListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {'url': "/providers/Microsoft.Education/operations"} # type: ignore + diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_student_labs_operations.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_student_labs_operations.py new file mode 100644 index 0000000000000..cffa9643d5d53 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_student_labs_operations.py @@ -0,0 +1,172 @@ +# pylint: disable=too-many-lines +# 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._student_labs_operations import build_get_request, build_list_all_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class StudentLabsOperations: + """StudentLabsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.education.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_all( + self, + **kwargs: Any + ) -> AsyncIterable["_models.StudentLabListResult"]: + """Get a list of all labs associated with the caller of the API. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StudentLabListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.education.models.StudentLabListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.StudentLabListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_all_request( + api_version=api_version, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_all_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StudentLabListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': "/providers/Microsoft.Education/studentLabs"} # type: ignore + + @distributed_trace_async + async def get( + self, + student_lab_name: str, + **kwargs: Any + ) -> "_models.StudentLabDetails": + """Get the details for a specified lab associated with the student lab. + + :param student_lab_name: Student lab name. + :type student_lab_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StudentLabDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.StudentLabDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.StudentLabDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_get_request( + student_lab_name=student_lab_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StudentLabDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Education/studentLabs/{studentLabName}"} # type: ignore + diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_students_operations.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_students_operations.py new file mode 100644 index 0000000000000..046ca64a747a6 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/aio/operations/_students_operations.py @@ -0,0 +1,343 @@ +# pylint: disable=too-many-lines +# 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._students_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class StudentsOperations: + """StudentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.education.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + include_deleted: Optional[bool] = None, + **kwargs: Any + ) -> AsyncIterable["_models.StudentListResult"]: + """Get a list of details about students that are associated with the specified lab. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param include_deleted: May be used to show deleted items. Default value is None. + :type include_deleted: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StudentListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.education.models.StudentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.StudentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + include_deleted=include_deleted, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + include_deleted=include_deleted, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StudentListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/students"} # type: ignore + + @distributed_trace_async + async def get( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + student_alias: str, + **kwargs: Any + ) -> "_models.StudentDetails": + """Get the details for a specific student in the specified lab by student alias. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param student_alias: Student alias. + :type student_alias: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StudentDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.StudentDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.StudentDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + student_alias=student_alias, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StudentDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/students/{studentAlias}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + student_alias: str, + **kwargs: Any + ) -> None: + """Delete the specified student based on the student alias. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param student_alias: Student alias. + :type student_alias: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_delete_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + student_alias=student_alias, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/students/{studentAlias}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + student_alias: str, + parameters: "_models.StudentDetails", + **kwargs: Any + ) -> "_models.StudentDetails": + """Create and add a new student to the specified lab or update the details of an existing student + in a lab. Note the student must have a valid tenant to accept the lab after they have been + added to lab. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param student_alias: Student alias. + :type student_alias: str + :param parameters: Request parameters that are provided to update student properties. + :type parameters: ~azure.mgmt.education.models.StudentDetails + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StudentDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.StudentDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.StudentDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'StudentDetails') + + request = build_create_or_update_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + student_alias=student_alias, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('StudentDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('StudentDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/students/{studentAlias}"} # type: ignore + diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/models/__init__.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/models/__init__.py new file mode 100644 index 0000000000000..d394d6ae2a759 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/models/__init__.py @@ -0,0 +1,73 @@ +# 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 ._models_py3 import Amount +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseBody +from ._models_py3 import GrantDetails +from ._models_py3 import GrantListResponse +from ._models_py3 import InviteCodeGenerateRequest +from ._models_py3 import JoinRequestDetails +from ._models_py3 import JoinRequestList +from ._models_py3 import LabDetails +from ._models_py3 import LabListResult +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import RedeemRequest +from ._models_py3 import Resource +from ._models_py3 import StudentDetails +from ._models_py3 import StudentLabDetails +from ._models_py3 import StudentLabListResult +from ._models_py3 import StudentListResult +from ._models_py3 import SystemData + + +from ._education_management_client_enums import ( + ActionType, + CreatedByType, + GrantStatus, + GrantType, + JoinRequestStatus, + LabStatus, + Origin, + StudentLabStatus, + StudentRole, +) + +__all__ = [ + 'Amount', + 'ErrorResponse', + 'ErrorResponseBody', + 'GrantDetails', + 'GrantListResponse', + 'InviteCodeGenerateRequest', + 'JoinRequestDetails', + 'JoinRequestList', + 'LabDetails', + 'LabListResult', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'RedeemRequest', + 'Resource', + 'StudentDetails', + 'StudentLabDetails', + 'StudentLabListResult', + 'StudentListResult', + 'SystemData', + 'ActionType', + 'CreatedByType', + 'GrantStatus', + 'GrantType', + 'JoinRequestStatus', + 'LabStatus', + 'Origin', + 'StudentLabStatus', + 'StudentRole', +] diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/models/_education_management_client_enums.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/models/_education_management_client_enums.py new file mode 100644 index 0000000000000..ab78cc7ea2321 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/models/_education_management_client_enums.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. +# -------------------------------------------------------------------------- + +from enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class GrantStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Grant status + """ + + ACTIVE = "Active" + INACTIVE = "Inactive" + +class GrantType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Grant Offer Type + """ + + STUDENT = "Student" + ACADEMIC = "Academic" + +class JoinRequestStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Join request status + """ + + PENDING = "Pending" + DENIED = "Denied" + +class LabStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The status of this lab + """ + + ACTIVE = "Active" + DELETED = "Deleted" + +class Origin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class StudentLabStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Student Lab Status + """ + + ACTIVE = "Active" + DISABLED = "Disabled" + EXPIRED = "Expired" + PENDING = "Pending" + DELETED = "Deleted" + +class StudentRole(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Student Role + """ + + STUDENT = "Student" + ADMIN = "Admin" diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/models/_models_py3.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/models/_models_py3.py new file mode 100644 index 0000000000000..4eb9637acafa8 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/models/_models_py3.py @@ -0,0 +1,1043 @@ +# 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 datetime +from typing import Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._education_management_client_enums import * + + +class Amount(msrest.serialization.Model): + """The amount. + + :ivar currency: The type of currency being used for the value. + :vartype currency: str + :ivar value: Amount value. + :vartype value: float + """ + + _attribute_map = { + 'currency': {'key': 'currency', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'float'}, + } + + def __init__( + self, + *, + currency: Optional[str] = None, + value: Optional[float] = None, + **kwargs + ): + """ + :keyword currency: The type of currency being used for the value. + :paramtype currency: str + :keyword value: Amount value. + :paramtype value: float + """ + super(Amount, self).__init__(**kwargs) + self.currency = currency + self.value = value + + +class ErrorResponse(msrest.serialization.Model): + """Describes the format of Error response. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ + super(ErrorResponse, self).__init__(**kwargs) + self.code = code + self.message = message + + +class ErrorResponseBody(msrest.serialization.Model): + """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. + + :ivar error: The details of the error. + :vartype error: ~azure.mgmt.education.models.ErrorResponse + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } + + def __init__( + self, + *, + error: Optional["ErrorResponse"] = None, + **kwargs + ): + """ + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.education.models.ErrorResponse + """ + super(ErrorResponseBody, self).__init__(**kwargs) + self.error = error + + +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + 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}. + :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.education.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 + ): + """ + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class GrantDetails(Resource): + """Grant details. + + 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}. + :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.education.models.SystemData + :ivar offer_cap: Offer Cap. + :vartype offer_cap: ~azure.mgmt.education.models.Amount + :ivar effective_date: Grant Effective Date. + :vartype effective_date: ~datetime.datetime + :ivar offer_type: Grant Offer Type. Possible values include: "Student", "Academic". + :vartype offer_type: str or ~azure.mgmt.education.models.GrantType + :ivar expiration_date: Expiration Date. + :vartype expiration_date: ~datetime.datetime + :ivar status: Grant status. Possible values include: "Active", "Inactive". + :vartype status: str or ~azure.mgmt.education.models.GrantStatus + :ivar allocated_budget: allocated budget. + :vartype allocated_budget: ~azure.mgmt.education.models.Amount + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'offer_cap': {'readonly': True}, + 'effective_date': {'readonly': True}, + 'offer_type': {'readonly': True}, + 'expiration_date': {'readonly': True}, + 'status': {'readonly': True}, + 'allocated_budget': {'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'}, + 'offer_cap': {'key': 'properties.offerCap', 'type': 'Amount'}, + 'effective_date': {'key': 'properties.effectiveDate', 'type': 'iso-8601'}, + 'offer_type': {'key': 'properties.offerType', 'type': 'str'}, + 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'allocated_budget': {'key': 'properties.allocatedBudget', 'type': 'Amount'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(GrantDetails, self).__init__(**kwargs) + self.offer_cap = None + self.effective_date = None + self.offer_type = None + self.expiration_date = None + self.status = None + self.allocated_budget = None + + +class GrantListResponse(msrest.serialization.Model): + """List of Grants info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of labs. + :vartype value: list[~azure.mgmt.education.models.GrantDetails] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GrantDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(GrantListResponse, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class InviteCodeGenerateRequest(msrest.serialization.Model): + """invite code generate request. + + :ivar max_student_count: the total number of students that can be accepted to the lab. + :vartype max_student_count: float + """ + + _attribute_map = { + 'max_student_count': {'key': 'maxStudentCount', 'type': 'float'}, + } + + def __init__( + self, + *, + max_student_count: Optional[float] = None, + **kwargs + ): + """ + :keyword max_student_count: the total number of students that can be accepted to the lab. + :paramtype max_student_count: float + """ + super(InviteCodeGenerateRequest, self).__init__(**kwargs) + self.max_student_count = max_student_count + + +class JoinRequestDetails(Resource): + """join requests. + + 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}. + :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.education.models.SystemData + :ivar first_name: First Name. + :vartype first_name: str + :ivar last_name: Last Name. + :vartype last_name: str + :ivar email: join request email. + :vartype email: str + :ivar status: Join request status. Possible values include: "Pending", "Denied". + :vartype status: str or ~azure.mgmt.education.models.JoinRequestStatus + """ + + _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'}, + 'first_name': {'key': 'properties.firstName', 'type': 'str'}, + 'last_name': {'key': 'properties.lastName', 'type': 'str'}, + 'email': {'key': 'properties.email', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + } + + def __init__( + self, + *, + first_name: Optional[str] = None, + last_name: Optional[str] = None, + email: Optional[str] = None, + status: Optional[Union[str, "JoinRequestStatus"]] = None, + **kwargs + ): + """ + :keyword first_name: First Name. + :paramtype first_name: str + :keyword last_name: Last Name. + :paramtype last_name: str + :keyword email: join request email. + :paramtype email: str + :keyword status: Join request status. Possible values include: "Pending", "Denied". + :paramtype status: str or ~azure.mgmt.education.models.JoinRequestStatus + """ + super(JoinRequestDetails, self).__init__(**kwargs) + self.first_name = first_name + self.last_name = last_name + self.email = email + self.status = status + + +class JoinRequestList(msrest.serialization.Model): + """list of join requests. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of requests. + :vartype value: list[~azure.mgmt.education.models.JoinRequestDetails] + :ivar next_link: the link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[JoinRequestDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(JoinRequestList, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class LabDetails(Resource): + """Lab details. + + 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}. + :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.education.models.SystemData + :ivar display_name: Lab Display Name. + :vartype display_name: str + :ivar budget_per_student: Default monetary cap for each student in this lab. + :vartype budget_per_student: ~azure.mgmt.education.models.Amount + :ivar description: Detail description of this lab. + :vartype description: str + :ivar expiration_date: Default expiration date for each student in this lab. + :vartype expiration_date: ~datetime.datetime + :ivar effective_date: Lab creation date. + :vartype effective_date: ~datetime.datetime + :ivar status: The status of this lab. Possible values include: "Active", "Deleted". + :vartype status: str or ~azure.mgmt.education.models.LabStatus + :ivar max_student_count: the total number of students that can be accepted to the lab. + :vartype max_student_count: float + :ivar invitation_code: invitation code for redeemable lab. + :vartype invitation_code: str + :ivar currency_properties_total_allocated_budget_currency: The type of currency being used for + the value. + :vartype currency_properties_total_allocated_budget_currency: str + :ivar value_properties_total_allocated_budget_value: Amount value. + :vartype value_properties_total_allocated_budget_value: float + :ivar currency_properties_total_budget_currency: The type of currency being used for the value. + :vartype currency_properties_total_budget_currency: str + :ivar value_properties_total_budget_value: Amount value. + :vartype value_properties_total_budget_value: float + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'effective_date': {'readonly': True}, + 'status': {'readonly': True}, + 'max_student_count': {'readonly': True}, + 'invitation_code': {'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'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'budget_per_student': {'key': 'properties.budgetPerStudent', 'type': 'Amount'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, + 'effective_date': {'key': 'properties.effectiveDate', 'type': 'iso-8601'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'max_student_count': {'key': 'properties.maxStudentCount', 'type': 'float'}, + 'invitation_code': {'key': 'properties.invitationCode', 'type': 'str'}, + 'currency_properties_total_allocated_budget_currency': {'key': 'properties.totalAllocatedBudget.currency', 'type': 'str'}, + 'value_properties_total_allocated_budget_value': {'key': 'properties.totalAllocatedBudget.value', 'type': 'float'}, + 'currency_properties_total_budget_currency': {'key': 'properties.totalBudget.currency', 'type': 'str'}, + 'value_properties_total_budget_value': {'key': 'properties.totalBudget.value', 'type': 'float'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + budget_per_student: Optional["Amount"] = None, + description: Optional[str] = None, + expiration_date: Optional[datetime.datetime] = None, + currency_properties_total_allocated_budget_currency: Optional[str] = None, + value_properties_total_allocated_budget_value: Optional[float] = None, + currency_properties_total_budget_currency: Optional[str] = None, + value_properties_total_budget_value: Optional[float] = None, + **kwargs + ): + """ + :keyword display_name: Lab Display Name. + :paramtype display_name: str + :keyword budget_per_student: Default monetary cap for each student in this lab. + :paramtype budget_per_student: ~azure.mgmt.education.models.Amount + :keyword description: Detail description of this lab. + :paramtype description: str + :keyword expiration_date: Default expiration date for each student in this lab. + :paramtype expiration_date: ~datetime.datetime + :keyword currency_properties_total_allocated_budget_currency: The type of currency being used + for the value. + :paramtype currency_properties_total_allocated_budget_currency: str + :keyword value_properties_total_allocated_budget_value: Amount value. + :paramtype value_properties_total_allocated_budget_value: float + :keyword currency_properties_total_budget_currency: The type of currency being used for the + value. + :paramtype currency_properties_total_budget_currency: str + :keyword value_properties_total_budget_value: Amount value. + :paramtype value_properties_total_budget_value: float + """ + super(LabDetails, self).__init__(**kwargs) + self.display_name = display_name + self.budget_per_student = budget_per_student + self.description = description + self.expiration_date = expiration_date + self.effective_date = None + self.status = None + self.max_student_count = None + self.invitation_code = None + self.currency_properties_total_allocated_budget_currency = currency_properties_total_allocated_budget_currency + self.value_properties_total_allocated_budget_value = value_properties_total_allocated_budget_value + self.currency_properties_total_budget_currency = currency_properties_total_budget_currency + self.value_properties_total_budget_value = value_properties_total_budget_value + + +class LabListResult(msrest.serialization.Model): + """List of labs. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of labs. + :vartype value: list[~azure.mgmt.education.models.LabDetails] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[LabDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(LabListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.education.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", + "system", "user,system". + :vartype origin: str or ~azure.mgmt.education.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Possible values include: "Internal". + :vartype action_type: str or ~azure.mgmt.education.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["OperationDisplay"] = None, + **kwargs + ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.education.models.OperationDisplay + """ + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.education.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class RedeemRequest(msrest.serialization.Model): + """redeem request. + + All required parameters must be populated in order to send to Azure. + + :ivar redeem_code: Required. redeem code. + :vartype redeem_code: str + :ivar first_name: Required. first name of requester. + :vartype first_name: str + :ivar last_name: Required. last name of requester. + :vartype last_name: str + """ + + _validation = { + 'redeem_code': {'required': True}, + 'first_name': {'required': True}, + 'last_name': {'required': True}, + } + + _attribute_map = { + 'redeem_code': {'key': 'redeemCode', 'type': 'str'}, + 'first_name': {'key': 'firstName', 'type': 'str'}, + 'last_name': {'key': 'lastName', 'type': 'str'}, + } + + def __init__( + self, + *, + redeem_code: str, + first_name: str, + last_name: str, + **kwargs + ): + """ + :keyword redeem_code: Required. redeem code. + :paramtype redeem_code: str + :keyword first_name: Required. first name of requester. + :paramtype first_name: str + :keyword last_name: Required. last name of requester. + :paramtype last_name: str + """ + super(RedeemRequest, self).__init__(**kwargs) + self.redeem_code = redeem_code + self.first_name = first_name + self.last_name = last_name + + +class StudentDetails(Resource): + """Student details. + + 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}. + :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.education.models.SystemData + :ivar first_name: First Name. + :vartype first_name: str + :ivar last_name: Last Name. + :vartype last_name: str + :ivar email: Student Email. + :vartype email: str + :ivar role: Student Role. Possible values include: "Student", "Admin". + :vartype role: str or ~azure.mgmt.education.models.StudentRole + :ivar budget: Student Budget. + :vartype budget: ~azure.mgmt.education.models.Amount + :ivar subscription_id: Subscription Id. + :vartype subscription_id: str + :ivar expiration_date: Date this student is set to expire from the lab. + :vartype expiration_date: ~datetime.datetime + :ivar status: Student Lab Status. Possible values include: "Active", "Disabled", "Expired", + "Pending", "Deleted". + :vartype status: str or ~azure.mgmt.education.models.StudentLabStatus + :ivar effective_date: Date student was added to the lab. + :vartype effective_date: ~datetime.datetime + :ivar subscription_alias: Subscription alias. + :vartype subscription_alias: str + :ivar subscription_invite_last_sent_date: subscription invite last sent date. + :vartype subscription_invite_last_sent_date: ~datetime.datetime + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'status': {'readonly': True}, + 'effective_date': {'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'}, + 'first_name': {'key': 'properties.firstName', 'type': 'str'}, + 'last_name': {'key': 'properties.lastName', 'type': 'str'}, + 'email': {'key': 'properties.email', 'type': 'str'}, + 'role': {'key': 'properties.role', 'type': 'str'}, + 'budget': {'key': 'properties.budget', 'type': 'Amount'}, + 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, + 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'effective_date': {'key': 'properties.effectiveDate', 'type': 'iso-8601'}, + 'subscription_alias': {'key': 'properties.subscriptionAlias', 'type': 'str'}, + 'subscription_invite_last_sent_date': {'key': 'properties.subscriptionInviteLastSentDate', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + first_name: Optional[str] = None, + last_name: Optional[str] = None, + email: Optional[str] = None, + role: Optional[Union[str, "StudentRole"]] = None, + budget: Optional["Amount"] = None, + expiration_date: Optional[datetime.datetime] = None, + subscription_alias: Optional[str] = None, + subscription_invite_last_sent_date: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword first_name: First Name. + :paramtype first_name: str + :keyword last_name: Last Name. + :paramtype last_name: str + :keyword email: Student Email. + :paramtype email: str + :keyword role: Student Role. Possible values include: "Student", "Admin". + :paramtype role: str or ~azure.mgmt.education.models.StudentRole + :keyword budget: Student Budget. + :paramtype budget: ~azure.mgmt.education.models.Amount + :keyword expiration_date: Date this student is set to expire from the lab. + :paramtype expiration_date: ~datetime.datetime + :keyword subscription_alias: Subscription alias. + :paramtype subscription_alias: str + :keyword subscription_invite_last_sent_date: subscription invite last sent date. + :paramtype subscription_invite_last_sent_date: ~datetime.datetime + """ + super(StudentDetails, self).__init__(**kwargs) + self.first_name = first_name + self.last_name = last_name + self.email = email + self.role = role + self.budget = budget + self.subscription_id = None + self.expiration_date = expiration_date + self.status = None + self.effective_date = None + self.subscription_alias = subscription_alias + self.subscription_invite_last_sent_date = subscription_invite_last_sent_date + + +class StudentLabDetails(Resource): + """Student lab details. + + 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}. + :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.education.models.SystemData + :ivar display_name: Student lab Display Name. + :vartype display_name: str + :ivar description: Detail description of this lab. + :vartype description: str + :ivar expiration_date: Date the lab will expire and by default will be the expiration date for + each student in this lab. + :vartype expiration_date: ~datetime.datetime + :ivar role: Student Role. Possible values include: "Student", "Admin". + :vartype role: str or ~azure.mgmt.education.models.StudentRole + :ivar budget: Student Budget. + :vartype budget: ~azure.mgmt.education.models.Amount + :ivar subscription_id: Subscription Id. + :vartype subscription_id: str + :ivar status: Student Lab Status. Possible values include: "Active", "Disabled", "Expired", + "Pending", "Deleted". + :vartype status: str or ~azure.mgmt.education.models.StudentLabStatus + :ivar effective_date: User Added Date. + :vartype effective_date: ~datetime.datetime + :ivar lab_scope: Lab Scope. + /providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default. + :vartype lab_scope: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'display_name': {'readonly': True}, + 'description': {'readonly': True}, + 'expiration_date': {'readonly': True}, + 'role': {'readonly': True}, + 'budget': {'readonly': True}, + 'subscription_id': {'readonly': True}, + 'status': {'readonly': True}, + 'effective_date': {'readonly': True}, + 'lab_scope': {'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'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, + 'role': {'key': 'properties.role', 'type': 'str'}, + 'budget': {'key': 'properties.budget', 'type': 'Amount'}, + 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'effective_date': {'key': 'properties.effectiveDate', 'type': 'iso-8601'}, + 'lab_scope': {'key': 'properties.labScope', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(StudentLabDetails, self).__init__(**kwargs) + self.display_name = None + self.description = None + self.expiration_date = None + self.role = None + self.budget = None + self.subscription_id = None + self.status = None + self.effective_date = None + self.lab_scope = None + + +class StudentLabListResult(msrest.serialization.Model): + """List of labs. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of labs. + :vartype value: list[~azure.mgmt.education.models.StudentLabDetails] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[StudentLabDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(StudentLabListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class StudentListResult(msrest.serialization.Model): + """List of students. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of students. + :vartype value: list[~azure.mgmt.education.models.StudentDetails] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[StudentDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(StudentListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.education.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.education.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.education.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.education.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/__init__.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/__init__.py new file mode 100644 index 0000000000000..28ef5e3989459 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/__init__.py @@ -0,0 +1,25 @@ +# 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 ._operations import Operations +from ._grants_operations import GrantsOperations +from ._labs_operations import LabsOperations +from ._join_requests_operations import JoinRequestsOperations +from ._education_management_client_operations import EducationManagementClientOperationsMixin +from ._students_operations import StudentsOperations +from ._student_labs_operations import StudentLabsOperations + +__all__ = [ + 'Operations', + 'GrantsOperations', + 'LabsOperations', + 'JoinRequestsOperations', + 'EducationManagementClientOperationsMixin', + 'StudentsOperations', + 'StudentLabsOperations', +] diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_education_management_client_operations.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_education_management_client_operations.py new file mode 100644 index 0000000000000..69b4a296ffa09 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_education_management_client_operations.py @@ -0,0 +1,115 @@ +# pylint: disable=too-many-lines +# 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 typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_redeem_invitation_code_request( + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Education/redeemInvitationCode") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + +class EducationManagementClientOperationsMixin(object): + + @distributed_trace + def redeem_invitation_code( # pylint: disable=inconsistent-return-statements + self, + parameters: "_models.RedeemRequest", + **kwargs: Any + ) -> None: + """Redeem invite code to join a redeemable lab. + + :param parameters: Request parameters to provide redeem code. + :type parameters: ~azure.mgmt.education.models.RedeemRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RedeemRequest') + + request = build_redeem_invitation_code_request( + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.redeem_invitation_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + redeem_invitation_code.metadata = {'url': "/providers/Microsoft.Education/redeemInvitationCode"} # type: ignore + diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_grants_operations.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_grants_operations.py new file mode 100644 index 0000000000000..1e83c47ed4f6c --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_grants_operations.py @@ -0,0 +1,379 @@ +# pylint: disable=too-many-lines +# 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_all_request( + *, + include_allocated_budget: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Education/grants") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if include_allocated_budget is not None: + _query_parameters['includeAllocatedBudget'] = _SERIALIZER.query("include_allocated_budget", include_allocated_budget, 'bool') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_request( + billing_account_name: str, + billing_profile_name: str, + *, + include_allocated_budget: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Education/grants") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if include_allocated_budget is not None: + _query_parameters['includeAllocatedBudget'] = _SERIALIZER.query("include_allocated_budget", include_allocated_budget, 'bool') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + billing_account_name: str, + billing_profile_name: str, + *, + include_allocated_budget: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Education/grants/default") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if include_allocated_budget is not None: + _query_parameters['includeAllocatedBudget'] = _SERIALIZER.query("include_allocated_budget", include_allocated_budget, 'bool') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class GrantsOperations(object): + """GrantsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.education.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_all( + self, + include_allocated_budget: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.GrantListResponse"]: + """Get a list of grants that Microsoft has provided. + + :param include_allocated_budget: May be used to include information about budget that has been + allocated. Default value is None. + :type include_allocated_budget: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GrantListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.education.models.GrantListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrantListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_all_request( + api_version=api_version, + include_allocated_budget=include_allocated_budget, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_all_request( + api_version=api_version, + include_allocated_budget=include_allocated_budget, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GrantListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': "/providers/Microsoft.Education/grants"} # type: ignore + + @distributed_trace + def list( + self, + billing_account_name: str, + billing_profile_name: str, + include_allocated_budget: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.GrantListResponse"]: + """Get details for a specific grant linked to the provided billing account and billing profile. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param include_allocated_budget: May be used to include information about budget that has been + allocated. Default value is None. + :type include_allocated_budget: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GrantListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.education.models.GrantListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrantListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + api_version=api_version, + include_allocated_budget=include_allocated_budget, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + api_version=api_version, + include_allocated_budget=include_allocated_budget, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GrantListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Education/grants"} # type: ignore + + @distributed_trace + def get( + self, + billing_account_name: str, + billing_profile_name: str, + include_allocated_budget: Optional[bool] = None, + **kwargs: Any + ) -> "_models.GrantDetails": + """Get details for a specific grant linked to the provided billing account and billing profile. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param include_allocated_budget: May be used to include information about budget that has been + allocated. Default value is None. + :type include_allocated_budget: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GrantDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.GrantDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrantDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + api_version=api_version, + include_allocated_budget=include_allocated_budget, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GrantDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Education/grants/default"} # type: ignore + diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_join_requests_operations.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_join_requests_operations.py new file mode 100644 index 0000000000000..6b40690b288b0 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_join_requests_operations.py @@ -0,0 +1,482 @@ +# pylint: disable=too-many-lines +# 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +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( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + *, + include_denied: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/joinRequests") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if include_denied is not None: + _query_parameters['includeDenied'] = _SERIALIZER.query("include_denied", include_denied, 'bool') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + join_request_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/joinRequests/{joinRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + "joinRequestName": _SERIALIZER.url("join_request_name", join_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_approve_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + join_request_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/joinRequests/{joinRequestName}/approve") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + "joinRequestName": _SERIALIZER.url("join_request_name", join_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_deny_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + join_request_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/joinRequests/{joinRequestName}/deny") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + "joinRequestName": _SERIALIZER.url("join_request_name", join_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class JoinRequestsOperations(object): + """JoinRequestsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.education.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + include_denied: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.JoinRequestList"]: + """get student join requests. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param include_denied: Include denied. Default value is None. + :type include_denied: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either JoinRequestList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.education.models.JoinRequestList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.JoinRequestList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + include_denied=include_denied, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + include_denied=include_denied, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("JoinRequestList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/joinRequests"} # type: ignore + + @distributed_trace + def get( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + join_request_name: str, + **kwargs: Any + ) -> "_models.JoinRequestDetails": + """get student join requests. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param join_request_name: Join name. + :type join_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JoinRequestDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.JoinRequestDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.JoinRequestDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + join_request_name=join_request_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('JoinRequestDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/joinRequests/{joinRequestName}"} # type: ignore + + + @distributed_trace + def approve( # pylint: disable=inconsistent-return-statements + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + join_request_name: str, + **kwargs: Any + ) -> None: + """Approve student joining the redeemable lab. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param join_request_name: Join name. + :type join_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_approve_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + join_request_name=join_request_name, + api_version=api_version, + template_url=self.approve.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + approve.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/joinRequests/{joinRequestName}/approve"} # type: ignore + + + @distributed_trace + def deny( # pylint: disable=inconsistent-return-statements + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + join_request_name: str, + **kwargs: Any + ) -> None: + """Deny student joining the redeemable lab. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param join_request_name: Join name. + :type join_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_deny_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + join_request_name=join_request_name, + api_version=api_version, + template_url=self.deny.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + deny.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/joinRequests/{joinRequestName}/deny"} # type: ignore + diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_labs_operations.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_labs_operations.py new file mode 100644 index 0000000000000..aeec5310fdab6 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_labs_operations.py @@ -0,0 +1,752 @@ +# pylint: disable=too-many-lines +# 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_all_request( + billing_account_name: str, + billing_profile_name: str, + *, + include_budget: Optional[bool] = None, + include_deleted: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Education/labs") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if include_budget is not None: + _query_parameters['includeBudget'] = _SERIALIZER.query("include_budget", include_budget, 'bool') + if include_deleted is not None: + _query_parameters['includeDeleted'] = _SERIALIZER.query("include_deleted", include_deleted, 'bool') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + *, + include_budget: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if include_budget is not None: + _query_parameters['includeBudget'] = _SERIALIZER.query("include_budget", include_budget, 'bool') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + *, + include_budget: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if include_budget is not None: + _query_parameters['includeBudget'] = _SERIALIZER.query("include_budget", include_budget, 'bool') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_generate_invite_code_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + *, + json: JSONType = None, + content: Any = None, + only_update_student_count_parameter: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/generateInviteCode") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if only_update_student_count_parameter is not None: + _query_parameters['onlyUpdateStudentCountParameter'] = _SERIALIZER.query("only_update_student_count_parameter", only_update_student_count_parameter, 'bool') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + +class LabsOperations(object): + """LabsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.education.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_all( + self, + billing_account_name: str, + billing_profile_name: str, + include_budget: Optional[bool] = None, + include_deleted: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.LabListResult"]: + """Get a list of labs associated with the provided billing account name and billing profile name. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param include_budget: May be used to include budget information. Default value is None. + :type include_budget: bool + :param include_deleted: May be used to show deleted items. Default value is None. + :type include_deleted: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LabListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.education.models.LabListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_all_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + api_version=api_version, + include_budget=include_budget, + include_deleted=include_deleted, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_all_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + api_version=api_version, + include_budget=include_budget, + include_deleted=include_deleted, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("LabListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Education/labs"} # type: ignore + + @distributed_trace + def list( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + include_budget: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.LabListResult"]: + """Get the details for a specific lab associated with the provided billing account name, billing + profile name, and invoice section name. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param include_budget: May be used to include budget information. Default value is None. + :type include_budget: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LabListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.education.models.LabListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + include_budget=include_budget, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + include_budget=include_budget, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("LabListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs"} # type: ignore + + @distributed_trace + def get( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + include_budget: Optional[bool] = None, + **kwargs: Any + ) -> "_models.LabDetails": + """Get the details for a specific lab associated with the provided billing account name, billing + profile name, and invoice section name. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param include_budget: May be used to include budget information. Default value is None. + :type include_budget: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LabDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.LabDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + include_budget=include_budget, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LabDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs: Any + ) -> None: + """Delete a specific lab associated with the provided billing account name, billing profile name, + and invoice section name. Note all students must be removed from the lab in order to delete the + lab. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_delete_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + parameters: "_models.LabDetails", + **kwargs: Any + ) -> "_models.LabDetails": + """Create a new lab or update a previously created lab. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param parameters: Request parameters that are provided to create lab resource. + :type parameters: ~azure.mgmt.education.models.LabDetails + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LabDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.LabDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'LabDetails') + + request = build_create_or_update_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('LabDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('LabDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"} # type: ignore + + + @distributed_trace + def generate_invite_code( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + parameters: "_models.InviteCodeGenerateRequest", + only_update_student_count_parameter: Optional[bool] = None, + **kwargs: Any + ) -> "_models.LabDetails": + """Generate invite code for a lab. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param parameters: Request parameters that are provided to generate invite code. + :type parameters: ~azure.mgmt.education.models.InviteCodeGenerateRequest + :param only_update_student_count_parameter: set this flag to true if you want to update student + count without generating a new invite code. Default value is None. + :type only_update_student_count_parameter: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LabDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.LabDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LabDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'InviteCodeGenerateRequest') + + request = build_generate_invite_code_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + content_type=content_type, + json=_json, + only_update_student_count_parameter=only_update_student_count_parameter, + template_url=self.generate_invite_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LabDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + generate_invite_code.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/generateInviteCode"} # type: ignore + diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_operations.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_operations.py new file mode 100644 index 0000000000000..38c08b769663e --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_operations.py @@ -0,0 +1,123 @@ +# pylint: disable=too-many-lines +# 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 typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request +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( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Education/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.education.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> "_models.OperationListResult": + """Lists all of the available Microsoft.Education API 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.education.models.OperationListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OperationListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {'url': "/providers/Microsoft.Education/operations"} # type: ignore + diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_student_labs_operations.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_student_labs_operations.py new file mode 100644 index 0000000000000..dbbe319c25e37 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_student_labs_operations.py @@ -0,0 +1,231 @@ +# pylint: disable=too-many-lines +# 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_all_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Education/studentLabs") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + student_lab_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Education/studentLabs/{studentLabName}") + path_format_arguments = { + "studentLabName": _SERIALIZER.url("student_lab_name", student_lab_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class StudentLabsOperations(object): + """StudentLabsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.education.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_all( + self, + **kwargs: Any + ) -> Iterable["_models.StudentLabListResult"]: + """Get a list of all labs associated with the caller of the API. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StudentLabListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.education.models.StudentLabListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.StudentLabListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_all_request( + api_version=api_version, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_all_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StudentLabListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': "/providers/Microsoft.Education/studentLabs"} # type: ignore + + @distributed_trace + def get( + self, + student_lab_name: str, + **kwargs: Any + ) -> "_models.StudentLabDetails": + """Get the details for a specified lab associated with the student lab. + + :param student_lab_name: Student lab name. + :type student_lab_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StudentLabDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.StudentLabDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.StudentLabDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_get_request( + student_lab_name=student_lab_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StudentLabDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Education/studentLabs/{studentLabName}"} # type: ignore + diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_students_operations.py b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_students_operations.py new file mode 100644 index 0000000000000..cbcaa19ed246d --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/operations/_students_operations.py @@ -0,0 +1,508 @@ +# pylint: disable=too-many-lines +# 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + *, + include_deleted: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/students") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if include_deleted is not None: + _query_parameters['includeDeleted'] = _SERIALIZER.query("include_deleted", include_deleted, 'bool') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + student_alias: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/students/{studentAlias}") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + "studentAlias": _SERIALIZER.url("student_alias", student_alias, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + student_alias: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/students/{studentAlias}") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + "studentAlias": _SERIALIZER.url("student_alias", student_alias, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + student_alias: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/students/{studentAlias}") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + "studentAlias": _SERIALIZER.url("student_alias", student_alias, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + +class StudentsOperations(object): + """StudentsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.education.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + include_deleted: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.StudentListResult"]: + """Get a list of details about students that are associated with the specified lab. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param include_deleted: May be used to show deleted items. Default value is None. + :type include_deleted: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StudentListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.education.models.StudentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.StudentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + include_deleted=include_deleted, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + api_version=api_version, + include_deleted=include_deleted, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StudentListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/students"} # type: ignore + + @distributed_trace + def get( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + student_alias: str, + **kwargs: Any + ) -> "_models.StudentDetails": + """Get the details for a specific student in the specified lab by student alias. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param student_alias: Student alias. + :type student_alias: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StudentDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.StudentDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.StudentDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + student_alias=student_alias, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StudentDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/students/{studentAlias}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + student_alias: str, + **kwargs: Any + ) -> None: + """Delete the specified student based on the student alias. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param student_alias: Student alias. + :type student_alias: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + + + request = build_delete_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + student_alias=student_alias, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/students/{studentAlias}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + student_alias: str, + parameters: "_models.StudentDetails", + **kwargs: Any + ) -> "_models.StudentDetails": + """Create and add a new student to the specified lab or update the details of an existing student + in a lab. Note the student must have a valid tenant to accept the lab after they have been + added to lab. + + :param billing_account_name: Billing account name. + :type billing_account_name: str + :param billing_profile_name: Billing profile name. + :type billing_profile_name: str + :param invoice_section_name: Invoice section name. + :type invoice_section_name: str + :param student_alias: Student alias. + :type student_alias: str + :param parameters: Request parameters that are provided to update student properties. + :type parameters: ~azure.mgmt.education.models.StudentDetails + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StudentDetails, or the result of cls(response) + :rtype: ~azure.mgmt.education.models.StudentDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.StudentDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-12-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'StudentDetails') + + request = build_create_or_update_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + student_alias=student_alias, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **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.ErrorResponseBody, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('StudentDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('StudentDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/students/{studentAlias}"} # type: ignore + diff --git a/sdk/education/azure-mgmt-education/azure/mgmt/education/py.typed b/sdk/education/azure-mgmt-education/azure/mgmt/education/py.typed new file mode 100644 index 0000000000000..e5aff4f83af86 --- /dev/null +++ b/sdk/education/azure-mgmt-education/azure/mgmt/education/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/education/azure-mgmt-education/sdk_packaging.toml b/sdk/education/azure-mgmt-education/sdk_packaging.toml new file mode 100644 index 0000000000000..60a8e2b77b0d1 --- /dev/null +++ b/sdk/education/azure-mgmt-education/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-education" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/education/azure-mgmt-education/setup.py b/sdk/education/azure-mgmt-education/setup.py new file mode 100644 index 0000000000000..536d2bb6588c8 --- /dev/null +++ b/sdk/education/azure-mgmt-education/setup.py @@ -0,0 +1,78 @@ +#!/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 +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-education" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +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) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +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', + 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.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + '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', + ]), + include_package_data=True, + package_data={ + 'pytyped': ['py.typed'], + }, + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.3.0,<2.0.0', + ], + python_requires=">=3.6" +) diff --git a/sdk/education/ci.yml b/sdk/education/ci.yml new file mode 100644 index 0000000000000..325e1f3014f9a --- /dev/null +++ b/sdk/education/ci.yml @@ -0,0 +1,33 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/education/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/education/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: education + Artifacts: + - name: azure-mgmt-education + safeName: azuremgmteducation