diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/MANIFEST.in b/sdk/webpubsub/azure-messaging-webpubsubservice/MANIFEST.in index a3b68055b727..0f4b34f64729 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/MANIFEST.in +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/MANIFEST.in @@ -1,6 +1,5 @@ +recursive-include tests *.py *.yaml include *.md include azure/__init__.py include azure/messaging/__init__.py -include LICENSE.txt -recursive-include tests *.py -recursive-include examples *.py *.md \ No newline at end of file + diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/README.md b/sdk/webpubsub/azure-messaging-webpubsubservice/README.md index 203f3f0aeddf..04f78efb5acd 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/README.md @@ -1,148 +1,27 @@ -# Azure WebPubSubService client library for Python +# Microsoft Azure SDK for Python -[Azure Web PubSub Service](https://aka.ms/awps/doc) is a service that enables you to build real-time messaging web applications using WebSockets and the publish-subscribe pattern. Any platform supporting WebSocket APIs can connect to the service easily, e.g. web pages, mobile applications, edge devices, etc. The service manages the WebSocket connections for you and allows up to 100K \*concurrent connections. It provides powerful APIs for you to manage these clients and deliver real-time messages. +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). -Any scenario that requires real-time publish-subscribe messaging between server and clients or among clients, can use Azure Web PubSub service. Traditional real-time features that often require polling from server or submitting HTTP requests, can also use Azure Web PubSub service. -We list some examples that are good to use Azure Web PubSub service: +# Usage -- **High frequency data updates:** gaming, voting, polling, auction. -- **Live dashboards and monitoring:** company dashboard, financial market data, instant sales update, multi-player game leader board, and IoT monitoring. -- **Cross-platform live chat:** live chat room, chat bot, on-line customer support, real-time shopping assistant, messenger, in-game chat, and so on. -- **Real-time location on map:** logistic tracking, delivery status tracking, transportation status updates, GPS apps. -- **Real-time targeted ads:** personalized real-time push ads and offers, interactive ads. -- **Collaborative apps:** coauthoring, whiteboard apps and team meeting software. -- **Push instant notifications:** social network, email, game, travel alert. -- **Real-time broadcasting:** live audio/video broadcasting, live captioning, translating, events/news broadcasting. -- **IoT and connected devices:** real-time IoT metrics, remote control, real-time status, and location tracking. -- **Automation:** real-time trigger from upstream events. -Use the client library to: +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) -- Send messages to hubs and groups. -- Send messages to particular users and connections. -- Organize users and connections into groups. -- Close connections -- Grant/revoke/check permissions for an existing connection -[Source code](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/webpubsub/azure-messaging-webpubsubservice) | [Package (Pypi)][package] | [API reference documentation](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/webpubsub/azure-messaging-webpubsubservice) | [Product documentation][webpubsubservice_docs] + +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) -## Getting started -### Installating the package +# Provide Feedback -```bash -python -m pip install azure-messaging-webpubsubservice -``` +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. -#### Prequisites -- Python 2.7, or 3.6 or later is required to use this package. -- You need an [Azure subscription][azure_sub], and a [Azure WebPubSub service instance][webpubsubservice_docs] to use this package. -- An existing Azure Web PubSub service instance. - -### Authenticating the client - -In order to interact with the Azure WebPubSub service, you'll need to create an instance of the [WebPubSubServiceClient][webpubsubservice_client_class] class. In order to authenticate against the service, you need to pass in an AzureKeyCredential instance with endpoint and api key. The endpoint and api key can be found on the azure portal. - -```python ->>> from azure.messaging.webpubsubservice import WebPubSubServiceClient ->>> from azure.core.credentials import AzureKeyCredential ->>> client = WebPubSubServiceClient(endpoint='', credential=AzureKeyCredential('somesecret')) ->>> client -'> -``` - -## Examples - -### Sending a request - -```python ->>> from azure.messaging.webpubsubservice import WebPubSubServiceClient ->>> from azure.core.credentials import AzureKeyCredential ->>> from azure.messaging.webpubsubservice.rest import build_send_to_all_request ->>> client = WebPubSubServiceClient(endpoint='', credential=AzureKeyCredential('somesecret')) ->>> request = build_send_to_all_request('default', json={ 'Hello': 'webpubsub!' }) ->>> request - ->>> response = client.send_request(request) ->>> response - ->>> response.status_code -202 ->>> with open('file.json', 'r') as f: ->>> request = build_send_to_all_request('ahub', content=f, content_type='application/json') ->>> response = client.send_request(request) ->>> print(response) - -``` - -## Key concepts - -### Hub - -Hub is a logical set of connections. All connections to Web PubSub connect to a specific hub. Messages that are broadcast to the hub are dispatched to all connections to that hub. For example, hub can be used for different applications, different applications can share one Azure Web PubSub service by using different hub names. - -### Group - -Group allow broadcast messages to a subset of connections to the hub. You can add and remove users and connections as needed. A client can join multiple groups, and a group can contain multiple clients. - -### User - -Connections to Web PubSub can belong to one user. A user might have multiple connections, for example when a single user is connected across multiple devices or multiple browser tabs. - -### Connection - -Connections, represented by a connection id, represent an individual websocket connection to the Web PubSub service. Connection id is always unique. - -### Message - -A message is either a UTF-8 encoded string, json or raw binary data. - -## Troubleshooting - -### Logging - -This SDK uses Python standard logging library. -You can configure logging print out debugging information to the stdout or anywhere you want. - -```python -import logging - -logging.basicConfig(level=logging.DEBUG) -```` - -Http request and response details are printed to stdout with this logging config. - -## Next steps - -More examples are coming soon... - -## Contributing - -This project welcomes contributions and suggestions. Most contributions require -you to agree to a Contributor License Agreement (CLA) declaring that you have -the right to, and actually do, grant us the rights to use your contribution. -For details, visit https://cla.microsoft.com. - -When you submit a pull request, a CLA-bot will automatically determine whether -you need to provide a CLA and decorate the PR appropriately (e.g., label, -comment). Simply follow the instructions provided by the bot. You will only -need to do this once across all repos using our CLA. - -This project has adopted the -[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information, -see the Code of Conduct FAQ or contact opencode@microsoft.com with any -additional questions or comments. - - -[webpubsubservice_docs]: https://aka.ms/awps/doc -[azure_cli]: https://docs.microsoft.com/cli/azure -[azure_sub]: https://azure.microsoft.com/free/ -[webpubsubservice_client_class]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/__init__.py -[package]: https://pypi.org/project/azure-messaging-webpubsubservice/ -[default_cred_ref]: https://aka.ms/azsdk-python-identity-default-cred-ref -[cla]: https://cla.microsoft.com -[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ -[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ -[coc_contact]: mailto:opencode@microsoft.com +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-messaging-webpubsubservice%2FREADME.png) diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/__init__.py b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/__init__.py index 8db66d3d0f0f..0260537a02bb 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/__init__.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/__init__.py b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/__init__.py index 8db66d3d0f0f..0260537a02bb 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/__init__.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/sdk_packaging.toml b/sdk/webpubsub/azure-messaging-webpubsubservice/sdk_packaging.toml new file mode 100644 index 000000000000..c81f38775bd5 --- /dev/null +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-messaging-webpubsubservice" +package_nspkg = "azure-messaging-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/webpubsub/azure-messaging-webpubsubservice/setup.py b/sdk/webpubsub/azure-messaging-webpubsubservice/setup.py index 7b4cee515a8a..874e582407f7 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/setup.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/setup.py @@ -1,74 +1,91 @@ #!/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 os import re - -from setuptools import setup, find_packages - +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-messaging-webpubsubservice" -PACKAGE_PPRINT_NAME = "Azure WebPubSub Service" +PACKAGE_PPRINT_NAME = "MyService Management" # a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: - version = re.search( - r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE - ).group(1) +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) if not version: - raise RuntimeError("Cannot find version information") + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() setup( name=PACKAGE_NAME, version=version, - description="Microsoft {} Client Library for Python".format(PACKAGE_PPRINT_NAME), - long_description=open("README.md", "r").read(), - 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/tree/master/sdk/signalr/azure-messaging-webpubsubservice", + 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', classifiers=[ - "Development Status :: 5 - Production/Stable", - "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "License :: OSI Approved :: MIT License", + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', ], zip_safe=False, - packages=find_packages( - exclude=[ - # Exclude packages that will be covered by PEP420 or nspkg - "azure", - "azure.messaging", - ] - ), + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.messaging', + ]), install_requires=[ - "azure-core<2.0.0,>=1.10.0", - "msrest>=0.6.18", - "cryptography>=2.1.4", - "pyjwt>=1.7.1", - "six>=1.12.0", + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.2.0,<2.0.0', ], extras_require={ - ":python_version<'3.0'": ["futures", "azure-messaging-nspkg"], - ":python_version<'3.5'": ["typing"], - }, + ":python_version<'3.0'": ['azure-messaging-nspkg'], + } )