diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 41489434029e..3e22b3c2229e 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -370,6 +370,12 @@ "nypg" ] }, + { + "filename": "sdk/containerregistry/azure-containerregistry/**", + "words": [ + "udpated" + ] + }, { "filename": "sdk/formrecognizer/azure-ai-formrecognizer/tests/*.py", "words": [ diff --git a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_models.py b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_models.py index 1786b5e343de..74dfc69bd7ca 100644 --- a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_models.py +++ b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_models.py @@ -4,6 +4,7 @@ # Licensed under the MIT License. # ------------------------------------ +import warnings from enum import Enum from typing import TYPE_CHECKING, Dict, Any, List @@ -200,6 +201,14 @@ def _to_generated(self): can_list=self.can_list, ) + def __getattr__(self, name): + if name == "last_udpated_on": + warnings.warn( + "The property name with a typo called 'last_udpated_on' has been deprecated and will be retired in future versions", # pylint: disable=line-too-long + DeprecationWarning) + return self.last_updated_on + return super().__getattr__(self, name) # pylint: disable=no-member + @property def created_on(self): # type: () -> datetime diff --git a/sdk/containerregistry/azure-containerregistry/tests/recordings/test_container_registry_client.test_get_misspell_property.yaml b/sdk/containerregistry/azure-containerregistry/tests/recordings/test_container_registry_client.test_get_misspell_property.yaml new file mode 100644 index 000000000000..26ebc0f1a545 --- /dev/null +++ b/sdk/containerregistry/azure-containerregistry/tests/recordings/test_container_registry_client.test_get_misspell_property.yaml @@ -0,0 +1,169 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-azure-containerregistry/1.0.1 Python/3.9.2 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://fake_url.azurecr.io/acr/v1/library%2Falpine?api-version=2021-07-01 + response: + body: + string: '{"errors": [{"code": "UNAUTHORIZED", "message": "authentication required, + visit https://aka.ms/acr/authorization for more information.", "detail": [{"Type": + "repository", "Name": "library/alpine", "Action": "metadata_read"}]}]}' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '217' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Mar 2022 13:08:48 GMT + docker-distribution-api-version: + - registry/2.0 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + www-authenticate: + - Bearer realm="https://fake_url.azurecr.io/oauth2/token",service="fake_url.azurecr.io",scope="fake_scope",error="invalid_token" + x-content-type-options: + - nosniff + status: + code: 401 + message: Unauthorized +- request: + body: grant_type=access_token&service=fake_url.azurecr.io&access_token=REDACTED + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '1379' + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - azsdk-python-azure-containerregistry/1.0.1 Python/3.9.2 (Windows-10-10.0.22000-SP0) + method: POST + uri: https://fake_url.azurecr.io/oauth2/exchange?api-version=2021-07-01 + response: + body: + string: '{"refresh_token": "REDACTED"}' + headers: + connection: + - keep-alive + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Mar 2022 13:08:48 GMT + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + x-ms-ratelimit-remaining-calls-per-second: + - '166.65' + status: + code: 200 + message: OK +- request: + body: service=fake_url.azurecr.io&scope=repository%3Alibrary%2Falpine%3Ametadata_read&refresh_token=REDACTED&grant_type=refresh_token + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '1156' + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - azsdk-python-azure-containerregistry/1.0.1 Python/3.9.2 (Windows-10-10.0.22000-SP0) + method: POST + uri: https://fake_url.azurecr.io/oauth2/token?api-version=2021-07-01 + response: + body: + string: '{"access_token": "REDACTED"}' + headers: + connection: + - keep-alive + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Mar 2022 13:08:49 GMT + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + x-ms-ratelimit-remaining-calls-per-second: + - '166.633333' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-azure-containerregistry/1.0.1 Python/3.9.2 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://fake_url.azurecr.io/acr/v1/library%2Falpine?api-version=2021-07-01 + response: + body: + string: '{"registry": "yallacrtests.azurecr.io", "imageName": "library/alpine", + "createdTime": "2022-03-17T12:20:47.2455348Z", "lastUpdateTime": "2022-03-17T12:20:45.8750709Z", + "manifestCount": 8, "tagCount": 1, "changeableAttributes": {"deleteEnabled": + true, "writeEnabled": true, "readEnabled": true, "listEnabled": true}}' + headers: + access-control-expose-headers: + - Docker-Content-Digest + - WWW-Authenticate + - Link + - X-Ms-Correlation-Request-Id + connection: + - keep-alive + content-length: + - '296' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 17 Mar 2022 13:08:49 GMT + docker-distribution-api-version: + - registry/2.0 + server: + - openresty + strict-transport-security: + - max-age=31536000; includeSubDomains + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/containerregistry/azure-containerregistry/tests/recordings/test_container_registry_client_async.test_get_misspell_property.yaml b/sdk/containerregistry/azure-containerregistry/tests/recordings/test_container_registry_client_async.test_get_misspell_property.yaml new file mode 100644 index 000000000000..b7114cd348f1 --- /dev/null +++ b/sdk/containerregistry/azure-containerregistry/tests/recordings/test_container_registry_client_async.test_get_misspell_property.yaml @@ -0,0 +1,120 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-azure-containerregistry/1.0.1 Python/3.9.2 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://fake_url.azurecr.io/acr/v1/library%2Falpine?api-version=2021-07-01 + response: + body: + string: '{"errors": [{"code": "UNAUTHORIZED", "message": "authentication required, + visit https://aka.ms/acr/authorization for more information.", "detail": [{"Type": + "repository", "Name": "library/alpine", "Action": "metadata_read"}]}]}' + headers: + access-control-expose-headers: X-Ms-Correlation-Request-Id + connection: keep-alive + content-length: '217' + content-type: application/json; charset=utf-8 + date: Thu, 17 Mar 2022 13:15:58 GMT + docker-distribution-api-version: registry/2.0 + server: openresty + strict-transport-security: max-age=31536000; includeSubDomains + www-authenticate: Bearer realm="https://fake_url.azurecr.io/oauth2/token",service="fake_url.azurecr.io",scope="fake_scope",error="invalid_token" + x-content-type-options: nosniff + status: + code: 401 + message: Unauthorized + url: https://yallacrtests.azurecr.io/acr/v1/library%2Falpine?api-version=2021-07-01 +- request: + body: + access_token: REDACTED + grant_type: !!python/object/apply:azure.containerregistry._generated.models._container_registry_enums.PostContentSchemaGrantType + - access_token + service: yallacrtests.azurecr.io + headers: + Accept: + - application/json + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - azsdk-python-azure-containerregistry/1.0.1 Python/3.9.2 (Windows-10-10.0.22000-SP0) + method: POST + uri: https://fake_url.azurecr.io/oauth2/exchange?api-version=2021-07-01 + response: + body: + string: '{"refresh_token": "REDACTED"}' + headers: + connection: keep-alive + content-type: application/json; charset=utf-8 + date: Thu, 17 Mar 2022 13:15:59 GMT + server: openresty + strict-transport-security: max-age=31536000; includeSubDomains + transfer-encoding: chunked + x-ms-ratelimit-remaining-calls-per-second: '166.616667' + status: + code: 200 + message: OK + url: https://yallacrtests.azurecr.io/oauth2/exchange?api-version=2021-07-01 +- request: + body: + grant_type: refresh_token + refresh_token: REDACTED + scope: repository:library/alpine:metadata_read + service: yallacrtests.azurecr.io + headers: + Accept: + - application/json + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - azsdk-python-azure-containerregistry/1.0.1 Python/3.9.2 (Windows-10-10.0.22000-SP0) + method: POST + uri: https://fake_url.azurecr.io/oauth2/token?api-version=2021-07-01 + response: + body: + string: '{"access_token": "REDACTED"}' + headers: + connection: keep-alive + content-type: application/json; charset=utf-8 + date: Thu, 17 Mar 2022 13:15:59 GMT + server: openresty + strict-transport-security: max-age=31536000; includeSubDomains + transfer-encoding: chunked + x-ms-ratelimit-remaining-calls-per-second: '166.6' + status: + code: 200 + message: OK + url: https://yallacrtests.azurecr.io/oauth2/token?api-version=2021-07-01 +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-azure-containerregistry/1.0.1 Python/3.9.2 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://fake_url.azurecr.io/acr/v1/library%2Falpine?api-version=2021-07-01 + response: + body: + string: '{"registry": "yallacrtests.azurecr.io", "imageName": "library/alpine", + "createdTime": "2022-03-17T12:20:47.2455348Z", "lastUpdateTime": "2022-03-17T12:20:45.8750709Z", + "manifestCount": 8, "tagCount": 1, "changeableAttributes": {"deleteEnabled": + true, "writeEnabled": true, "readEnabled": true, "listEnabled": true}}' + headers: + access-control-expose-headers: X-Ms-Correlation-Request-Id + connection: keep-alive + content-length: '296' + content-type: application/json; charset=utf-8 + date: Thu, 17 Mar 2022 13:15:59 GMT + docker-distribution-api-version: registry/2.0 + server: openresty + strict-transport-security: max-age=31536000; includeSubDomains + x-content-type-options: nosniff + status: + code: 200 + message: OK + url: https://yallacrtests.azurecr.io/acr/v1/library%2Falpine?api-version=2021-07-01 +version: 1 diff --git a/sdk/containerregistry/azure-containerregistry/tests/test_container_registry_client.py b/sdk/containerregistry/azure-containerregistry/tests/test_container_registry_client.py index 6d8fbb457a37..bfd7dd9c7ae8 100644 --- a/sdk/containerregistry/azure-containerregistry/tests/test_container_registry_client.py +++ b/sdk/containerregistry/azure-containerregistry/tests/test_container_registry_client.py @@ -591,3 +591,13 @@ def test_set_api_version(self, containerregistry_endpoint): with pytest.raises(ValueError): client = self.create_registry_client(containerregistry_endpoint, api_version = "2019-08-15") + + @acr_preparer() + def test_get_misspell_property(self, containerregistry_endpoint): + client = self.create_registry_client(containerregistry_endpoint) + properties = client.get_repository_properties(ALPINE) + + with self.assertWarns(DeprecationWarning): + last_udpated_on = properties.last_udpated_on + last_updated_on = properties.last_updated_on + assert last_udpated_on == last_updated_on diff --git a/sdk/containerregistry/azure-containerregistry/tests/test_container_registry_client_async.py b/sdk/containerregistry/azure-containerregistry/tests/test_container_registry_client_async.py index e00f4ef79528..4d6c702ffc33 100644 --- a/sdk/containerregistry/azure-containerregistry/tests/test_container_registry_client_async.py +++ b/sdk/containerregistry/azure-containerregistry/tests/test_container_registry_client_async.py @@ -584,3 +584,13 @@ def test_set_api_version(self, containerregistry_endpoint): with pytest.raises(ValueError): client = self.create_registry_client(containerregistry_endpoint, api_version = "2019-08-15") + + @acr_preparer() + async def test_get_misspell_property(self, containerregistry_endpoint): + client = self.create_registry_client(containerregistry_endpoint) + properties = await client.get_repository_properties(ALPINE) + + with self.assertWarns(DeprecationWarning): + last_udpated_on = properties.last_udpated_on + last_updated_on = properties.last_updated_on + assert last_udpated_on == last_updated_on