diff --git a/sdk/maps/azure-mgmt-maps/MANIFEST.in b/sdk/maps/azure-mgmt-maps/MANIFEST.in index 5b365d1fb18e..a3cb07df8765 100644 --- a/sdk/maps/azure-mgmt-maps/MANIFEST.in +++ b/sdk/maps/azure-mgmt-maps/MANIFEST.in @@ -1 +1,5 @@ -include *.rst *.md +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py + diff --git a/sdk/maps/azure-mgmt-maps/README.md b/sdk/maps/azure-mgmt-maps/README.md index 4f21f0c6ddaf..53f2deb187b7 100644 --- a/sdk/maps/azure-mgmt-maps/README.md +++ b/sdk/maps/azure-mgmt-maps/README.md @@ -1,47 +1,21 @@ -## Microsoft Azure SDK for Python +# Microsoft Azure SDK for Python This is the Microsoft Azure Maps 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 [Github repo](https://github.com/Azure/azure-sdk-for-python/) -Azure Resource Manager (ARM) is the next generation of management APIs -that replace the old Azure Service Management (ASM). -This package has been tested with Python 2.7, 3.4, 3.5, 3.6 and 3.7. +# Usage -For the older Azure Service Management (ASM) libraries, see -[azure-servicemanagement-legacy](https://pypi.python.org/pypi/azure-servicemanagement-legacy) -library. +For code examples, see [Maps](https://docs.microsoft.com/python/api/overview/azure/) +on docs.microsoft.com. -For a more complete set of Azure libraries, see the -[azure](https://pypi.python.org/pypi/azure) bundle package. -## Compatibility +# Provide Feedback -**IMPORTANT**: If you have an earlier version of the azure package -(version < 1.0), you should uninstall it before installing this -package. - -You can check the version using pip: - -``` shell -pip freeze -``` - -If you see azure==0.11.0 (or any version below 1.0), uninstall it first: - -``` shell -pip uninstall azure -``` - -## Usage - -For code examples, see -[Maps](https://docs.microsoft.com/python/api/overview/azure/) on -docs.microsoft.com. - -## 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) +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. -![image](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-maps%2FREADME.png) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-maps%2FREADME.png) diff --git a/sdk/maps/azure-mgmt-maps/setup.py b/sdk/maps/azure-mgmt-maps/setup.py index 230863918a61..d828a745206f 100644 --- a/sdk/maps/azure-mgmt-maps/setup.py +++ b/sdk/maps/azure-mgmt-maps/setup.py @@ -36,7 +36,9 @@ pass # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: +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) @@ -64,10 +66,10 @@ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'License :: OSI Approved :: MIT License', ], zip_safe=False, diff --git a/sdk/maps/azure-mgmt-maps/tests/recordings/test_cli_mgmt_maps.test_maps.yaml b/sdk/maps/azure-mgmt-maps/tests/recordings/test_cli_mgmt_maps.test_maps.yaml new file mode 100644 index 000000000000..be4dc70875b6 --- /dev/null +++ b/sdk/maps/azure-mgmt-maps/tests/recordings/test_cli_mgmt_maps.test_maps.yaml @@ -0,0 +1,317 @@ +interactions: +- request: + body: '{"location": "global", "tags": {"test": "true"}, "sku": {"name": "S0"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '71' + Content-Type: + - application/json; charset=utf-8 + User-Agent: + - python/3.6.9 (Linux-4.9.184-linuxkit-x86_64-with-Ubuntu-18.04-bionic) msrest/0.6.10 + msrest_azure/0.6.2 azure-mgmt-maps/0.1.0 Azure-SDK-For-Python + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_maps_test_mapsa6f40b7a/providers/Microsoft.Maps/accounts/accountname?api-version=2018-05-01 + response: + body: + string: "{\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_maps_test_mapsa6f40b7a/providers/Microsoft.Maps/accounts/accountname\"\ + ,\r\n \"name\": \"accountname\",\r\n \"type\": \"Microsoft.Maps/accounts\"\ + ,\r\n \"location\": \"global\",\r\n \"tags\": {\r\n \"test\": \"true\"\ + \r\n },\r\n \"sku\": {\r\n \"name\": \"S0\",\r\n \"tier\": \"Standard\"\ + \r\n },\r\n \"properties\": {\r\n \"x-ms-client-id\": \"144cabaf-076d-4e9f-8d96-b5da49bcce07\"\ + \r\n }\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '441' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 18 Feb 2020 04:17:32 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Type: + - application/json; charset=utf-8 + User-Agent: + - python/3.6.9 (Linux-4.9.184-linuxkit-x86_64-with-Ubuntu-18.04-bionic) msrest/0.6.10 + msrest_azure/0.6.2 azure-mgmt-maps/0.1.0 Azure-SDK-For-Python + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_maps_test_mapsa6f40b7a/providers/Microsoft.Maps/accounts/accountname?api-version=2018-05-01 + response: + body: + string: "{\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_maps_test_mapsa6f40b7a/providers/Microsoft.Maps/accounts/accountname\"\ + ,\r\n \"name\": \"accountname\",\r\n \"type\": \"Microsoft.Maps/accounts\"\ + ,\r\n \"location\": \"global\",\r\n \"tags\": {\r\n \"test\": \"true\"\ + \r\n },\r\n \"sku\": {\r\n \"name\": \"S0\",\r\n \"tier\": \"Standard\"\ + \r\n },\r\n \"properties\": {\r\n \"x-ms-client-id\": \"144cabaf-076d-4e9f-8d96-b5da49bcce07\"\ + \r\n }\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '441' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 18 Feb 2020 04:17:33 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"keyType": "primary"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json; charset=utf-8 + User-Agent: + - python/3.6.9 (Linux-4.9.184-linuxkit-x86_64-with-Ubuntu-18.04-bionic) msrest/0.6.10 + msrest_azure/0.6.2 azure-mgmt-maps/0.1.0 Azure-SDK-For-Python + accept-language: + - en-US + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_maps_test_mapsa6f40b7a/providers/Microsoft.Maps/accounts/accountname/regenerateKey?api-version=2018-05-01 + response: + body: + string: "{\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_maps_test_mapsa6f40b7a/providers/Microsoft.Maps/accounts/accountname\"\ + ,\r\n \"primaryKey\": \"MYNPUe9z30krVAYcD4lUQo2wZrds6mfNxJMFK8Qabtc\",\r\n\ + \ \"secondaryKey\": \"ICubKt1Cjhyj69U4cvdggWkb5feV85I577UxSDRB65M\",\r\n\ + \ \"primaryKeyLastUpdated\": \"2020-02-18T04:17:35.298607Z\",\r\n \"secondaryKeyLastUpdated\"\ + : \"2020-02-18T04:17:31.9655787Z\"\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '416' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 18 Feb 2020 04:17:34 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/json; charset=utf-8 + User-Agent: + - python/3.6.9 (Linux-4.9.184-linuxkit-x86_64-with-Ubuntu-18.04-bionic) msrest/0.6.10 + msrest_azure/0.6.2 azure-mgmt-maps/0.1.0 Azure-SDK-For-Python + accept-language: + - en-US + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_maps_test_mapsa6f40b7a/providers/Microsoft.Maps/accounts/accountname/listKeys?api-version=2018-05-01 + response: + body: + string: "{\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_maps_test_mapsa6f40b7a/providers/Microsoft.Maps/accounts/accountname\"\ + ,\r\n \"primaryKey\": \"MYNPUe9z30krVAYcD4lUQo2wZrds6mfNxJMFK8Qabtc\",\r\n\ + \ \"secondaryKey\": \"ICubKt1Cjhyj69U4cvdggWkb5feV85I577UxSDRB65M\",\r\n\ + \ \"primaryKeyLastUpdated\": \"2020-02-18T04:17:35.298607Z\",\r\n \"secondaryKeyLastUpdated\"\ + : \"2020-02-18T04:17:31.9655787Z\"\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '416' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 18 Feb 2020 04:17:36 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: '{"tags": {"tags": "{''special_tag'': ''true''}"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '45' + Content-Type: + - application/json; charset=utf-8 + User-Agent: + - python/3.6.9 (Linux-4.9.184-linuxkit-x86_64-with-Ubuntu-18.04-bionic) msrest/0.6.10 + msrest_azure/0.6.2 azure-mgmt-maps/0.1.0 Azure-SDK-For-Python + accept-language: + - en-US + method: PATCH + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_maps_test_mapsa6f40b7a/providers/Microsoft.Maps/accounts/accountname?api-version=2018-05-01 + response: + body: + string: "{\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_maps_test_mapsa6f40b7a/providers/Microsoft.Maps/accounts/accountname\"\ + ,\r\n \"name\": \"accountname\",\r\n \"type\": \"Microsoft.Maps/accounts\"\ + ,\r\n \"location\": \"global\",\r\n \"tags\": {\r\n \"tags\": \"{'special_tag':\ + \ 'true'}\"\r\n },\r\n \"sku\": {\r\n \"name\": \"S0\",\r\n \"tier\"\ + : \"Standard\"\r\n },\r\n \"properties\": {\r\n \"x-ms-client-id\": \"\ + 144cabaf-076d-4e9f-8d96-b5da49bcce07\"\r\n }\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '460' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 18 Feb 2020 04:17:43 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/json; charset=utf-8 + User-Agent: + - python/3.6.9 (Linux-4.9.184-linuxkit-x86_64-with-Ubuntu-18.04-bionic) msrest/0.6.10 + msrest_azure/0.6.2 azure-mgmt-maps/0.1.0 Azure-SDK-For-Python + accept-language: + - en-US + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_cli_mgmt_maps_test_mapsa6f40b7a/providers/Microsoft.Maps/accounts/accountname?api-version=2018-05-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Tue, 18 Feb 2020 04:17:48 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14998' + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/maps/azure-mgmt-maps/tests/test_cli_mgmt_maps.py b/sdk/maps/azure-mgmt-maps/tests/test_cli_mgmt_maps.py new file mode 100644 index 000000000000..85c99b48a67e --- /dev/null +++ b/sdk/maps/azure-mgmt-maps/tests/test_cli_mgmt_maps.py @@ -0,0 +1,97 @@ +# 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. +#-------------------------------------------------------------------------- + + +# TEST SCENARIO COVERAGE +# ---------------------- +# Methods Total : 10 +# Methods Covered : 10 +# Examples Total : 10 +# Examples Tested : 9 +# Coverage % : 90 +# ---------------------- + +import unittest + +import azure.mgmt.maps +from devtools_testutils import AzureMgmtTestCase, ResourceGroupPreparer + +AZURE_LOCATION = 'eastus' + +class MgmtMapsManagementClientTest(AzureMgmtTestCase): + + def setUp(self): + super(MgmtMapsManagementClientTest, self).setUp() + self.mgmt_client = self.create_mgmt_client( + azure.mgmt.maps.MapsManagementClient + ) + + @ResourceGroupPreparer(location=AZURE_LOCATION) + def test_maps(self, resource_group): + + ACCOUNT_NAME = "accountname" + # CreateAccount[put] + BODY = { + "location": "global", + "sku": { + "name": "S0" + }, + "tags": { + "test": "true" + } + } + result = self.mgmt_client.accounts.create_or_update(resource_group.name, ACCOUNT_NAME, BODY) + + # GetAccount[get] + result = self.mgmt_client.accounts.get(resource_group.name, ACCOUNT_NAME) + + # ListAccountsByResourceGroup[get] + result = self.mgmt_client.accounts.list_by_resource_group(resource_group.name) + + # ListAccountsBySubscription[get] + result = self.mgmt_client.accounts.list_by_subscription() + + # GetOperations[get] + result = self.mgmt_client.accounts.list_operations() + + # RegenerateKey[post] + # BODY = { + # "key_type": "primary" + # } + key_type = "primary" + result = self.mgmt_client.accounts.regenerate_keys(resource_group.name, ACCOUNT_NAME, key_type) + + # ListKeys[post] + result = self.mgmt_client.accounts.list_keys(resource_group.name, ACCOUNT_NAME) + + # UpdateAccount[patch] + BODY = { + "tags": { + "special_tag": "true" + } + } + result = self.mgmt_client.accounts.update(resource_group.name, ACCOUNT_NAME, BODY) + + # TODO: Multiple resources involved + # # MoveAccounts[post] + # BODY = { + # "target_resource_group": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "", + # "resource_ids": [ + # "/subscriptions/21a9967a-e8a9-4656-a70b-96ff1c4d05a0/resourceGroups/myResourceGroup/providers/Microsoft.Maps/accounts/myMapsAccount", + # "/subscriptions/21a9967a-e8a9-4656-a70b-96ff1c4d05a0/resourceGroups/myResourceGroup/providers/Microsoft.Maps/accounts/myMapsAccount2" + # ] + # } + # result = self.mgmt_client.accounts.move(resource_group.name, BODY) + + # DeleteAccount[delete] + result = self.mgmt_client.accounts.delete(resource_group.name, ACCOUNT_NAME) + + +#------------------------------------------------------------------------------ +if __name__ == '__main__': + unittest.main()