Skip to content

Commit 47ed56e

Browse files
author
SDKAuto
committed
CodeGen from PR 31996 in Azure/azure-rest-api-specs
Merge 00ec160e8fb58238a9cf966dd2f82f5b8e71eb99 into 4e8d16d3793228046ac6171eadda4b8d26ad2b4f
1 parent 832d03f commit 47ed56e

34 files changed

+7181
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Release History
2+
3+
## 1.0.0b1 (1970-01-01)
4+
5+
- Initial version
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) Microsoft Corporation.
2+
3+
MIT License
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include *.md
2+
include LICENSE
3+
include microsoft/app/dynamicsessions/py.typed
4+
recursive-include tests *.py
5+
recursive-include samples *.py *.md
6+
include microsoft/__init__.py
7+
include microsoft/app/__init__.py
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Microsoft App Dynamicsessions client library for Python
2+
<!-- write necessary description of service -->
3+
4+
## Getting started
5+
6+
### Install the package
7+
8+
```bash
9+
python -m pip install microsoft-app-dynamicsessions
10+
```
11+
12+
#### Prequisites
13+
14+
- Python 3.9 or later is required to use this package.
15+
- You need an [Azure subscription][azure_sub] to use this package.
16+
- An existing Microsoft App Dynamicsessions instance.
17+
18+
#### Create with an Azure Active Directory Credential
19+
To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
20+
provide an instance of the desired credential type obtained from the
21+
[azure-identity][azure_identity_credentials] library.
22+
23+
To authenticate with AAD, you must first [pip][pip] install [`azure-identity`][azure_identity_pip]
24+
25+
After setup, you can choose which type of [credential][azure_identity_credentials] from azure.identity to use.
26+
As an example, [DefaultAzureCredential][default_azure_credential] can be used to authenticate the client:
27+
28+
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
29+
`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`
30+
31+
Use the returned token credential to authenticate the client:
32+
33+
```python
34+
>>> from microsoft.app.dynamicsessions import DynamicSessionsClient
35+
>>> from azure.identity import DefaultAzureCredential
36+
>>> client = DynamicSessionsClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
37+
```
38+
39+
## Examples
40+
41+
```python
42+
>>> from microsoft.app.dynamicsessions import DynamicSessionsClient
43+
>>> from azure.identity import DefaultAzureCredential
44+
>>> from azure.core.exceptions import HttpResponseError
45+
46+
>>> client = DynamicSessionsClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
47+
>>> try:
48+
<!-- write test code here -->
49+
except HttpResponseError as e:
50+
print('service responds error: {}'.format(e.response.json()))
51+
52+
```
53+
54+
## Contributing
55+
56+
This project welcomes contributions and suggestions. Most contributions require
57+
you to agree to a Contributor License Agreement (CLA) declaring that you have
58+
the right to, and actually do, grant us the rights to use your contribution.
59+
For details, visit https://cla.microsoft.com.
60+
61+
When you submit a pull request, a CLA-bot will automatically determine whether
62+
you need to provide a CLA and decorate the PR appropriately (e.g., label,
63+
comment). Simply follow the instructions provided by the bot. You will only
64+
need to do this once across all repos using our CLA.
65+
66+
This project has adopted the
67+
[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,
68+
see the Code of Conduct FAQ or contact [email protected] with any
69+
additional questions or comments.
70+
71+
<!-- LINKS -->
72+
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
73+
[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token
74+
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials
75+
[azure_identity_pip]: https://pypi.org/project/azure-identity/
76+
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential
77+
[pip]: https://pypi.org/project/pip/
78+
[azure_sub]: https://azure.microsoft.com/free/
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"CrossLanguagePackageId": "Microsoft.App.DynamicSessions",
3+
"CrossLanguageDefinitionId": {
4+
"microsoft.app.dynamicsessions.models.JupyterKernel": "Microsoft.App.DynamicSessions.JupyterKernel",
5+
"microsoft.app.dynamicsessions.models.Package": "Microsoft.App.DynamicSessions.Package",
6+
"microsoft.app.dynamicsessions.models.Runtime": "Microsoft.App.DynamicSessions.Runtime",
7+
"microsoft.app.dynamicsessions.models.Session": "Microsoft.App.DynamicSessions.Session",
8+
"microsoft.app.dynamicsessions.models.SessionCodeExecutionRequest": "Microsoft.App.DynamicSessions.SessionCodeExecutionRequest",
9+
"microsoft.app.dynamicsessions.models.SessionCodeExecutionResource": "Microsoft.App.DynamicSessions.SessionCodeExecutionResource",
10+
"microsoft.app.dynamicsessions.models.SessionCodeExecutionResult": "Microsoft.App.DynamicSessions.SessionCodeExecutionResult",
11+
"microsoft.app.dynamicsessions.models.SessionPoolMetadataResponse": "Microsoft.App.DynamicSessions.SessionPoolMetadataResponse",
12+
"microsoft.app.dynamicsessions.models.SessionResourceFile": "Microsoft.App.DynamicSessions.SessionResourceFile",
13+
"microsoft.app.dynamicsessions.models.SessionsListResponse": "Microsoft.App.DynamicSessions.SessionsListResponse",
14+
"microsoft.app.dynamicsessions.models.UploadRequest": "Microsoft.App.DynamicSessions.upload.Request.anonymous",
15+
"microsoft.app.dynamicsessions.models.CodeInputType": "Microsoft.App.DynamicSessions.CodeInputType",
16+
"microsoft.app.dynamicsessions.models.ExecutionType": "Microsoft.App.DynamicSessions.ExecutionType",
17+
"microsoft.app.dynamicsessions.models.OperationState": "Azure.Core.Foundations.OperationState",
18+
"microsoft.app.dynamicsessions.operations.CodeExecutionOperations.begin_execute": "Microsoft.App.DynamicSessions.CodeExecution.execute",
19+
"microsoft.app.dynamicsessions.aio.operations.CodeExecutionOperations.begin_execute": "Microsoft.App.DynamicSessions.CodeExecution.execute",
20+
"microsoft.app.dynamicsessions.operations.CodeExecutionOperations.get": "Microsoft.App.DynamicSessions.CodeExecution.get",
21+
"microsoft.app.dynamicsessions.aio.operations.CodeExecutionOperations.get": "Microsoft.App.DynamicSessions.CodeExecution.get",
22+
"microsoft.app.dynamicsessions.operations.SessionResourceFilesOperations.list": "Microsoft.App.DynamicSessions.SessionResourceFiles.list",
23+
"microsoft.app.dynamicsessions.aio.operations.SessionResourceFilesOperations.list": "Microsoft.App.DynamicSessions.SessionResourceFiles.list",
24+
"microsoft.app.dynamicsessions.operations.SessionResourceFilesOperations.get": "Microsoft.App.DynamicSessions.SessionResourceFiles.get",
25+
"microsoft.app.dynamicsessions.aio.operations.SessionResourceFilesOperations.get": "Microsoft.App.DynamicSessions.SessionResourceFiles.get",
26+
"microsoft.app.dynamicsessions.operations.SessionResourceFilesOperations.delete": "Microsoft.App.DynamicSessions.SessionResourceFiles.delete",
27+
"microsoft.app.dynamicsessions.aio.operations.SessionResourceFilesOperations.delete": "Microsoft.App.DynamicSessions.SessionResourceFiles.delete",
28+
"microsoft.app.dynamicsessions.operations.SessionResourceFilesOperations.upload": "Microsoft.App.DynamicSessions.SessionResourceFiles.upload",
29+
"microsoft.app.dynamicsessions.aio.operations.SessionResourceFilesOperations.upload": "Microsoft.App.DynamicSessions.SessionResourceFiles.upload",
30+
"microsoft.app.dynamicsessions.operations.SessionResourceFilesOperations.get_content": "Microsoft.App.DynamicSessions.SessionResourceFiles.getContent",
31+
"microsoft.app.dynamicsessions.aio.operations.SessionResourceFilesOperations.get_content": "Microsoft.App.DynamicSessions.SessionResourceFiles.getContent",
32+
"microsoft.app.dynamicsessions.operations.SessionManagementOperations.get": "Microsoft.App.DynamicSessions.SessionManagement.get",
33+
"microsoft.app.dynamicsessions.aio.operations.SessionManagementOperations.get": "Microsoft.App.DynamicSessions.SessionManagement.get",
34+
"microsoft.app.dynamicsessions.operations.SessionManagementOperations.delete": "Microsoft.App.DynamicSessions.SessionManagement.delete",
35+
"microsoft.app.dynamicsessions.aio.operations.SessionManagementOperations.delete": "Microsoft.App.DynamicSessions.SessionManagement.delete",
36+
"microsoft.app.dynamicsessions.operations.ListSessionsOperations.get": "Microsoft.App.DynamicSessions.ListSessions.get",
37+
"microsoft.app.dynamicsessions.aio.operations.ListSessionsOperations.get": "Microsoft.App.DynamicSessions.ListSessions.get",
38+
"microsoft.app.dynamicsessions.operations.SessionPoolMetadataOperations.get": "Microsoft.App.DynamicSessions.SessionPoolMetadata.get",
39+
"microsoft.app.dynamicsessions.aio.operations.SessionPoolMetadataOperations.get": "Microsoft.App.DynamicSessions.SessionPoolMetadata.get"
40+
}
41+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-e ../../../tools/azure-sdk-tools
2+
../../core/azure-core
3+
../../identity/azure-identity
4+
aiohttp
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
9+
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._client import DynamicSessionsClient # type: ignore
16+
from ._version import VERSION
17+
18+
__version__ = VERSION
19+
20+
try:
21+
from ._patch import __all__ as _patch_all
22+
from ._patch import *
23+
except ImportError:
24+
_patch_all = []
25+
from ._patch import patch_sdk as _patch_sdk
26+
27+
__all__ = [
28+
"DynamicSessionsClient",
29+
]
30+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
31+
32+
_patch_sdk()
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from copy import deepcopy
10+
from typing import Any, TYPE_CHECKING
11+
from typing_extensions import Self
12+
13+
from azure.core import PipelineClient
14+
from azure.core.pipeline import policies
15+
from azure.core.rest import HttpRequest, HttpResponse
16+
17+
from ._configuration import DynamicSessionsClientConfiguration
18+
from ._utils.serialization import Deserializer, Serializer
19+
from .operations import (
20+
CodeExecutionOperations,
21+
ListSessionsOperations,
22+
SessionManagementOperations,
23+
SessionPoolMetadataOperations,
24+
SessionResourceFilesOperations,
25+
)
26+
27+
if TYPE_CHECKING:
28+
from azure.core.credentials import TokenCredential
29+
30+
31+
class DynamicSessionsClient:
32+
"""DynamicSessionsClient.
33+
34+
:ivar code_execution: CodeExecutionOperations operations
35+
:vartype code_execution: microsoft.app.dynamicsessions.operations.CodeExecutionOperations
36+
:ivar session_resource_files: SessionResourceFilesOperations operations
37+
:vartype session_resource_files:
38+
microsoft.app.dynamicsessions.operations.SessionResourceFilesOperations
39+
:ivar session_management: SessionManagementOperations operations
40+
:vartype session_management:
41+
microsoft.app.dynamicsessions.operations.SessionManagementOperations
42+
:ivar list_sessions: ListSessionsOperations operations
43+
:vartype list_sessions: microsoft.app.dynamicsessions.operations.ListSessionsOperations
44+
:ivar session_pool_metadata: SessionPoolMetadataOperations operations
45+
:vartype session_pool_metadata:
46+
microsoft.app.dynamicsessions.operations.SessionPoolMetadataOperations
47+
:param endpoint: The management endpoint of the session pool. Required.
48+
:type endpoint: str
49+
:param credential: Credential used to authenticate requests to the service. Required.
50+
:type credential: ~azure.core.credentials.TokenCredential
51+
:keyword api_version: The API version to use for this operation. Default value is
52+
"2024-10-02-preview". Note that overriding this default value may result in unsupported
53+
behavior.
54+
:paramtype api_version: str
55+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
56+
Retry-After header is present.
57+
"""
58+
59+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
60+
_endpoint = "{endpoint}"
61+
self._config = DynamicSessionsClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
62+
63+
_policies = kwargs.pop("policies", None)
64+
if _policies is None:
65+
_policies = [
66+
policies.RequestIdPolicy(**kwargs),
67+
self._config.headers_policy,
68+
self._config.user_agent_policy,
69+
self._config.proxy_policy,
70+
policies.ContentDecodePolicy(**kwargs),
71+
self._config.redirect_policy,
72+
self._config.retry_policy,
73+
self._config.authentication_policy,
74+
self._config.custom_hook_policy,
75+
self._config.logging_policy,
76+
policies.DistributedTracingPolicy(**kwargs),
77+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
78+
self._config.http_logging_policy,
79+
]
80+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
81+
82+
self._serialize = Serializer()
83+
self._deserialize = Deserializer()
84+
self._serialize.client_side_validation = False
85+
self.code_execution = CodeExecutionOperations(self._client, self._config, self._serialize, self._deserialize)
86+
self.session_resource_files = SessionResourceFilesOperations(
87+
self._client, self._config, self._serialize, self._deserialize
88+
)
89+
self.session_management = SessionManagementOperations(
90+
self._client, self._config, self._serialize, self._deserialize
91+
)
92+
self.list_sessions = ListSessionsOperations(self._client, self._config, self._serialize, self._deserialize)
93+
self.session_pool_metadata = SessionPoolMetadataOperations(
94+
self._client, self._config, self._serialize, self._deserialize
95+
)
96+
97+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
98+
"""Runs the network request through the client's chained policies.
99+
100+
>>> from azure.core.rest import HttpRequest
101+
>>> request = HttpRequest("GET", "https://www.example.org/")
102+
<HttpRequest [GET], url: 'https://www.example.org/'>
103+
>>> response = client.send_request(request)
104+
<HttpResponse: 200 OK>
105+
106+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
107+
108+
:param request: The network request you want to make. Required.
109+
:type request: ~azure.core.rest.HttpRequest
110+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
111+
:return: The response of your network call. Does not do error handling on your response.
112+
:rtype: ~azure.core.rest.HttpResponse
113+
"""
114+
115+
request_copy = deepcopy(request)
116+
path_format_arguments = {
117+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str"),
118+
}
119+
120+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
121+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
122+
123+
def close(self) -> None:
124+
self._client.close()
125+
126+
def __enter__(self) -> Self:
127+
self._client.__enter__()
128+
return self
129+
130+
def __exit__(self, *exc_details: Any) -> None:
131+
self._client.__exit__(*exc_details)

0 commit comments

Comments
 (0)