Skip to content

Commit 96b25c1

Browse files
author
SDKAuto
committed
CodeGen from PR 34246 in Azure/azure-rest-api-specs
Merge ab3be28614e1ccf01dfa474b6d780629990a1a53 into 67aef4a58261c9485a320c0d5abb52c377aee72d
1 parent 2c9172e commit 96b25c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+7588
-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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include *.md
2+
include LICENSE
3+
include azure/programmableconnectivity/py.typed
4+
recursive-include tests *.py
5+
recursive-include samples *.py *.md
6+
include azure/__init__.py
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Azure Programmableconnectivity 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 azure-programmableconnectivity
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 Azure Programmableconnectivity 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 azure.programmableconnectivity import ProgrammableConnectivityClient
35+
>>> from azure.identity import DefaultAzureCredential
36+
>>> client = ProgrammableConnectivityClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
37+
```
38+
39+
## Examples
40+
41+
```python
42+
>>> from azure.programmableconnectivity import ProgrammableConnectivityClient
43+
>>> from azure.identity import DefaultAzureCredential
44+
>>> from azure.core.exceptions import HttpResponseError
45+
46+
>>> client = ProgrammableConnectivityClient(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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "5ed8bfec09b6881b6d18f1589fcacf14a93014ff",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/programmableconnectivity/Azure.ProgrammableConnectivity",
5+
"@azure-tools/typespec-python": "0.44.1"
6+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"CrossLanguagePackageId": "Azure.ProgrammableConnectivity",
3+
"CrossLanguageDefinitionId": {
4+
"azure.programmableconnectivity.models.DeviceLocationVerificationContent": "Azure.ProgrammableConnectivity.DeviceLocationVerificationContent",
5+
"azure.programmableconnectivity.models.DeviceLocationVerificationResult": "Azure.ProgrammableConnectivity.DeviceLocationVerificationResult",
6+
"azure.programmableconnectivity.models.Ipv4Address": "Azure.ProgrammableConnectivity.Ipv4Address",
7+
"azure.programmableconnectivity.models.Ipv6Address": "Azure.ProgrammableConnectivity.Ipv6Address",
8+
"azure.programmableconnectivity.models.LocationDevice": "Azure.ProgrammableConnectivity.LocationDevice",
9+
"azure.programmableconnectivity.models.NetworkIdentifier": "Azure.ProgrammableConnectivity.NetworkIdentifier",
10+
"azure.programmableconnectivity.models.NetworkRetrievalResult": "Azure.ProgrammableConnectivity.NetworkRetrievalResult",
11+
"azure.programmableconnectivity.models.NumberVerificationResult": "Azure.ProgrammableConnectivity.NumberVerificationResult",
12+
"azure.programmableconnectivity.models.NumberVerificationWithCodeContent": "Azure.ProgrammableConnectivity.NumberVerificationWithCodeContent",
13+
"azure.programmableconnectivity.models.NumberVerificationWithoutCodeContent": "Azure.ProgrammableConnectivity.NumberVerificationWithoutCodeContent",
14+
"azure.programmableconnectivity.models.SimSwapRetrievalContent": "Azure.ProgrammableConnectivity.SimSwapRetrievalContent",
15+
"azure.programmableconnectivity.models.SimSwapRetrievalResult": "Azure.ProgrammableConnectivity.SimSwapRetrievalResult",
16+
"azure.programmableconnectivity.models.SimSwapVerificationContent": "Azure.ProgrammableConnectivity.SimSwapVerificationContent",
17+
"azure.programmableconnectivity.models.SimSwapVerificationResult": "Azure.ProgrammableConnectivity.SimSwapVerificationResult",
18+
"azure.programmableconnectivity.operations.DeviceLocationOperations.verify": "Azure.ProgrammableConnectivity.DeviceLocation.verify",
19+
"azure.programmableconnectivity.aio.operations.DeviceLocationOperations.verify": "Azure.ProgrammableConnectivity.DeviceLocation.verify",
20+
"azure.programmableconnectivity.operations.DeviceNetworkOperations.retrieve": "Azure.ProgrammableConnectivity.DeviceNetwork.retrieve",
21+
"azure.programmableconnectivity.aio.operations.DeviceNetworkOperations.retrieve": "Azure.ProgrammableConnectivity.DeviceNetwork.retrieve",
22+
"azure.programmableconnectivity.operations.NumberVerificationOperations.verify_without_code": "Azure.ProgrammableConnectivity.NumberVerification.verifyWithoutCode",
23+
"azure.programmableconnectivity.aio.operations.NumberVerificationOperations.verify_without_code": "Azure.ProgrammableConnectivity.NumberVerification.verifyWithoutCode",
24+
"azure.programmableconnectivity.operations.NumberVerificationOperations.verify_with_code": "Azure.ProgrammableConnectivity.NumberVerification.verifyWithCode",
25+
"azure.programmableconnectivity.aio.operations.NumberVerificationOperations.verify_with_code": "Azure.ProgrammableConnectivity.NumberVerification.verifyWithCode",
26+
"azure.programmableconnectivity.operations.SimSwapOperations.retrieve": "Azure.ProgrammableConnectivity.SimSwap.retrieve",
27+
"azure.programmableconnectivity.aio.operations.SimSwapOperations.retrieve": "Azure.ProgrammableConnectivity.SimSwap.retrieve",
28+
"azure.programmableconnectivity.operations.SimSwapOperations.verify": "Azure.ProgrammableConnectivity.SimSwap.verify",
29+
"azure.programmableconnectivity.aio.operations.SimSwapOperations.verify": "Azure.ProgrammableConnectivity.SimSwap.verify"
30+
}
31+
}
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 ProgrammableConnectivityClient # 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+
"ProgrammableConnectivityClient",
29+
]
30+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
31+
32+
_patch_sdk()
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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 ProgrammableConnectivityClientConfiguration
18+
from ._utils.serialization import Deserializer, Serializer
19+
from .operations import (
20+
DeviceLocationOperations,
21+
DeviceNetworkOperations,
22+
NumberVerificationOperations,
23+
SimSwapOperations,
24+
)
25+
26+
if TYPE_CHECKING:
27+
from azure.core.credentials import TokenCredential
28+
29+
30+
class ProgrammableConnectivityClient:
31+
"""Azure Programmable Connectivity (APC) provides a unified interface to the Network APIs of
32+
multiple Telecom Operators. Note that Operators may deprecate a Network API with less advance
33+
notice than the Azure standard, in which case APC will also deprecate that Network API.
34+
35+
:ivar device_location: DeviceLocationOperations operations
36+
:vartype device_location: azure.programmableconnectivity.operations.DeviceLocationOperations
37+
:ivar device_network: DeviceNetworkOperations operations
38+
:vartype device_network: azure.programmableconnectivity.operations.DeviceNetworkOperations
39+
:ivar number_verification: NumberVerificationOperations operations
40+
:vartype number_verification:
41+
azure.programmableconnectivity.operations.NumberVerificationOperations
42+
:ivar sim_swap: SimSwapOperations operations
43+
:vartype sim_swap: azure.programmableconnectivity.operations.SimSwapOperations
44+
:param endpoint: An Azure Programmable Connectivity Endpoint providing access to Network APIs,
45+
for example https://{region}.apcgatewayapi.azure.com. Required.
46+
:type endpoint: str
47+
:param credential: Credential used to authenticate requests to the service. Required.
48+
:type credential: ~azure.core.credentials.TokenCredential
49+
:keyword api_version: The API version to use for this operation. Default value is
50+
"2024-02-09-preview". Note that overriding this default value may result in unsupported
51+
behavior.
52+
:paramtype api_version: str
53+
"""
54+
55+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
56+
_endpoint = "{endpoint}"
57+
self._config = ProgrammableConnectivityClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
58+
59+
_policies = kwargs.pop("policies", None)
60+
if _policies is None:
61+
_policies = [
62+
policies.RequestIdPolicy(**kwargs),
63+
self._config.headers_policy,
64+
self._config.user_agent_policy,
65+
self._config.proxy_policy,
66+
policies.ContentDecodePolicy(**kwargs),
67+
self._config.redirect_policy,
68+
self._config.retry_policy,
69+
self._config.authentication_policy,
70+
self._config.custom_hook_policy,
71+
self._config.logging_policy,
72+
policies.DistributedTracingPolicy(**kwargs),
73+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
74+
self._config.http_logging_policy,
75+
]
76+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
77+
78+
self._serialize = Serializer()
79+
self._deserialize = Deserializer()
80+
self._serialize.client_side_validation = False
81+
self.device_location = DeviceLocationOperations(self._client, self._config, self._serialize, self._deserialize)
82+
self.device_network = DeviceNetworkOperations(self._client, self._config, self._serialize, self._deserialize)
83+
self.number_verification = NumberVerificationOperations(
84+
self._client, self._config, self._serialize, self._deserialize
85+
)
86+
self.sim_swap = SimSwapOperations(self._client, self._config, self._serialize, self._deserialize)
87+
88+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
89+
"""Runs the network request through the client's chained policies.
90+
91+
>>> from azure.core.rest import HttpRequest
92+
>>> request = HttpRequest("GET", "https://www.example.org/")
93+
<HttpRequest [GET], url: 'https://www.example.org/'>
94+
>>> response = client.send_request(request)
95+
<HttpResponse: 200 OK>
96+
97+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
98+
99+
:param request: The network request you want to make. Required.
100+
:type request: ~azure.core.rest.HttpRequest
101+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
102+
:return: The response of your network call. Does not do error handling on your response.
103+
:rtype: ~azure.core.rest.HttpResponse
104+
"""
105+
106+
request_copy = deepcopy(request)
107+
path_format_arguments = {
108+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str"),
109+
}
110+
111+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
112+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
113+
114+
def close(self) -> None:
115+
self._client.close()
116+
117+
def __enter__(self) -> Self:
118+
self._client.__enter__()
119+
return self
120+
121+
def __exit__(self, *exc_details: Any) -> None:
122+
self._client.__exit__(*exc_details)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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 typing import Any, TYPE_CHECKING
10+
11+
from azure.core.pipeline import policies
12+
13+
from ._version import VERSION
14+
15+
if TYPE_CHECKING:
16+
from azure.core.credentials import TokenCredential
17+
18+
19+
class ProgrammableConnectivityClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
20+
"""Configuration for ProgrammableConnectivityClient.
21+
22+
Note that all parameters used to create this instance are saved as instance
23+
attributes.
24+
25+
:param endpoint: An Azure Programmable Connectivity Endpoint providing access to Network APIs,
26+
for example https://{region}.apcgatewayapi.azure.com. Required.
27+
:type endpoint: str
28+
:param credential: Credential used to authenticate requests to the service. Required.
29+
:type credential: ~azure.core.credentials.TokenCredential
30+
:keyword api_version: The API version to use for this operation. Default value is
31+
"2024-02-09-preview". Note that overriding this default value may result in unsupported
32+
behavior.
33+
:paramtype api_version: str
34+
"""
35+
36+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
37+
api_version: str = kwargs.pop("api_version", "2024-02-09-preview")
38+
39+
if endpoint is None:
40+
raise ValueError("Parameter 'endpoint' must not be None.")
41+
if credential is None:
42+
raise ValueError("Parameter 'credential' must not be None.")
43+
44+
self.endpoint = endpoint
45+
self.credential = credential
46+
self.api_version = api_version
47+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com//.default"])
48+
kwargs.setdefault("sdk_moniker", "programmableconnectivity/{}".format(VERSION))
49+
self.polling_interval = kwargs.get("polling_interval", 30)
50+
self._configure(**kwargs)
51+
52+
def _configure(self, **kwargs: Any) -> None:
53+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
54+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
55+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
56+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
57+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
58+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
59+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
60+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
61+
self.authentication_policy = kwargs.get("authentication_policy")
62+
if self.credential and not self.authentication_policy:
63+
self.authentication_policy = policies.BearerTokenCredentialPolicy(
64+
self.credential, *self.credential_scopes, **kwargs
65+
)

0 commit comments

Comments
 (0)