From 6f765463d16433ab1ac1b87eea523db6e2ccb430 Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Tue, 25 May 2021 18:48:01 -0700 Subject: [PATCH] credential operations (#18925) * credential operations * update * update * add tests * update * update * update * update * update * update * update * update * update * update * update * update --- .../azure-ai-metricsadvisor/CHANGELOG.md | 3 +- .../azure/ai/metricsadvisor/_helpers.py | 17 +- .../_metrics_advisor_administration_client.py | 184 +++++++ .../azure/ai/metricsadvisor/_version.py | 2 +- ...ics_advisor_administration_client_async.py | 186 ++++++- .../ai/metricsadvisor/models/__init__.py | 16 +- .../azure/ai/metricsadvisor/models/_models.py | 497 +++++++++++++++++- .../sample_credential_entities_async.py | 151 ++++++ .../samples/sample_credential_entities.py | 146 +++++ .../async_tests/base_testcase_aad_async.py | 18 - .../tests/async_tests/base_testcase_async.py | 18 - ...l_connection_string_credential_entity.yaml | 83 +++ ...ake_gen2_shared_key_credential_entity.yaml | 83 +++ ...s_async.test_list_credential_entities.yaml | 109 ++++ ...t_service_principal_credential_entity.yaml | 84 +++ ...ice_principal_in_kv_credential_entity.yaml | 86 +++ ...ake_gen2_shared_key_credential_entity.yaml | 114 ++++ ...e_service_principal_credential_entity.yaml | 116 ++++ ...ice_principal_in_kv_credential_entity.yaml | 119 +++++ ...l_connection_string_credential_entity.yaml | 114 ++++ .../test_credential_entities_async.py | 209 ++++++++ .../tests/base_testcase.py | 19 - .../tests/base_testcase_aad.py | 19 - ...l_connection_string_credential_entity.yaml | 117 +++++ ...ake_gen2_shared_key_credential_entity.yaml | 117 +++++ ...ntities.test_list_credential_entities.yaml | 154 ++++++ ...t_service_principal_credential_entity.yaml | 118 +++++ ...ice_principal_in_kv_credential_entity.yaml | 120 +++++ ...ake_gen2_shared_key_credential_entity.yaml | 159 ++++++ ...e_service_principal_credential_entity.yaml | 161 ++++++ ...ice_principal_in_kv_credential_entity.yaml | 164 ++++++ ...l_connection_string_credential_entity.yaml | 159 ++++++ ...l_connection_string_credential_entity.yaml | 41 ++ ...ake_gen2_shared_key_credential_entity.yaml | 38 ++ ...ies_aad.test_list_credential_entities.yaml | 38 ++ ...t_service_principal_credential_entity.yaml | 39 ++ ...ice_principal_in_kv_credential_entity.yaml | 41 ++ ...ake_gen2_shared_key_credential_entity.yaml | 38 ++ ...e_service_principal_credential_entity.yaml | 39 ++ ...ice_principal_in_kv_credential_entity.yaml | 41 ++ ...l_connection_string_credential_entity.yaml | 38 ++ .../tests/test_credential_entities.py | 187 +++++++ 42 files changed, 4109 insertions(+), 93 deletions(-) create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/samples/async_samples/sample_credential_entities_async.py create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/samples/sample_credential_entities.py create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_create_sql_connection_string_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_datalake_gen2_shared_key_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_list_credential_entities.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_service_principal_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_service_principal_in_kv_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_datalake_gen2_shared_key_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_service_principal_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_service_principal_in_kv_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_sql_connection_string_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/test_credential_entities_async.py create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_create_sql_connection_string_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_datalake_gen2_shared_key_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_list_credential_entities.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_service_principal_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_service_principal_in_kv_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_datalake_gen2_shared_key_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_service_principal_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_service_principal_in_kv_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_sql_connection_string_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_create_sql_connection_string_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_datalake_gen2_shared_key_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_list_credential_entities.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_service_principal_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_service_principal_in_kv_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_datalake_gen2_shared_key_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_service_principal_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_service_principal_in_kv_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_sql_connection_string_credential_entity.yaml create mode 100644 sdk/metricsadvisor/azure-ai-metricsadvisor/tests/test_credential_entities.py diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/CHANGELOG.md b/sdk/metricsadvisor/azure-ai-metricsadvisor/CHANGELOG.md index 2b64299dcbe2..0cf652ef6d3f 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/CHANGELOG.md +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/CHANGELOG.md @@ -1,10 +1,11 @@ # Release History -## 1.0.0b4 (Unreleased) +## 1.0.0 (2021-06-07) **New Features** - Added AzureLogAnalyticsDataFeedSource and AzureEventHubsDataFeedSource - Update method now returns the updated object +- Added CredentialEntities and CredentialEntity operations **Breaking Changes** diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_helpers.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_helpers.py index df5c4b56f8d1..71b2fd2d2c06 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_helpers.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_helpers.py @@ -24,7 +24,11 @@ ChangePointFeedback, CommentFeedback, PeriodFeedback, - DataFeedRollupType + DataFeedRollupType, + SQLConnectionStringCredentialEntity, + DataLakeGen2SharedKeyCredentialEntity, + ServicePrincipalCredentialEntity, + ServicePrincipalInKVCredentialEntity ) from ._metrics_advisor_key_credential import MetricsAdvisorKeyCredential from ._metrics_advisor_key_credential_policy import MetricsAdvisorKeyCredentialPolicy @@ -148,7 +152,7 @@ def convert_to_generated_data_feed_type( ) return generated_feed_type( - data_source_parameter=source.__dict__, + data_source_parameter=source._to_generated(), data_feed_name=name, granularity_name=granularity.granularity_type, granularity_amount=granularity.custom_granularity_value, @@ -217,3 +221,12 @@ def get_authentication_policy(credential): ) return authentication_policy + +def convert_to_credential_entity(credential_entity): + if credential_entity.data_source_credential_type == "AzureSQLConnectionString": + return SQLConnectionStringCredentialEntity._from_generated(credential_entity) + if credential_entity.data_source_credential_type == "DataLakeGen2SharedKey": + return DataLakeGen2SharedKeyCredentialEntity._from_generated(credential_entity) + if credential_entity.data_source_credential_type == "ServicePrincipal": + return ServicePrincipalCredentialEntity._from_generated(credential_entity) + return ServicePrincipalInKVCredentialEntity._from_generated(credential_entity) diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_administration_client.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_administration_client.py index 6a01e6dd8dd1..6d1ebd25e112 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_administration_client.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_metrics_advisor_administration_client.py @@ -60,6 +60,7 @@ construct_data_feed_dict, convert_datetime, get_authentication_policy, + convert_to_credential_entity, ) from .models._models import ( DataFeed, @@ -81,6 +82,10 @@ MongoDBDataFeedSource, AzureDataLakeStorageGen2DataFeedSource, AzureEventHubsDataFeedSource, + SQLConnectionStringCredentialEntity, + DataLakeGen2SharedKeyCredentialEntity, + ServicePrincipalCredentialEntity, + ServicePrincipalInKVCredentialEntity ) if TYPE_CHECKING: @@ -113,6 +118,13 @@ AzureEventHubsDataFeedSource, ] +CredentialEntityUnion = Union[ + SQLConnectionStringCredentialEntity, + DataLakeGen2SharedKeyCredentialEntity, + ServicePrincipalCredentialEntity, + ServicePrincipalInKVCredentialEntity, +] + DATA_FEED = { "SqlServer": _SQLServerDataFeed, "AzureApplicationInsights": _AzureApplicationInsightsDataFeed, @@ -1217,3 +1229,175 @@ def list_data_feed_ingestion_status( skip=skip, **kwargs ) + + @distributed_trace + def get_credential_entity( + self, + credential_entity_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> CredentialEntityUnion + """Get a data source credential entity + + :param credential_entity_id: Data source credential entity unique ID. + :type credential_entity_id: str + :return: The credential entity + :rtype: Union[~azure.ai.metricsadvisor.models.SQLConnectionStringCredentialEntity, + ~azure.ai.metricsadvisor.models.DataLakeGen2SharedKeyCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalInKVCredentialEntity] + :raises ~azure.core.exceptions.HttpResponseError: + + .. admonition:: Example: + + .. literalinclude:: ../samples/sample_credential_entities.py + :start-after: [START get_credential_entity] + :end-before: [END get_credential_entity] + :language: python + :dedent: 4 + :caption: Get a credential entity by its ID + """ + + credential_entity = self._client.get_credential(credential_entity_id, **kwargs) + return convert_to_credential_entity(credential_entity) + + @distributed_trace + def create_credential_entity( + self, credential_entity, # type: CredentialEntityUnion + **kwargs # type: Any + ): + # type: (...) -> CredentialEntityUnion + """Create a new data source credential entity. + + :param credential_entity: The data source credential entity to create + :type credential_entity: Union[~azure.ai.metricsadvisor.models.SQLConnectionStringCredentialEntity, + ~azure.ai.metricsadvisor.models.DataLakeGen2SharedKeyCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalInKVCredentialEntity] + :return: The created data source credential entity + :rtype: Union[~azure.ai.metricsadvisor.models.SQLConnectionStringCredentialEntity, + ~azure.ai.metricsadvisor.models.DataLakeGen2SharedKeyCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalInKVCredentialEntity] + :raises ~azure.core.exceptions.HttpResponseError: + + .. admonition:: Example: + + .. literalinclude:: ../samples/sample_credential_entities.py + :start-after: [START create_credential_entity] + :end-before: [END create_credential_entity] + :language: python + :dedent: 4 + :caption: Create a credential entity + """ + + credential_entity_request = None + if credential_entity.credential_entity_type in ["AzureSQLConnectionString", + "DataLakeGen2SharedKey", "ServicePrincipal", "ServicePrincipalInKV"]: + credential_entity_request = credential_entity._to_generated() + + response_headers = self._client.create_credential( # type: ignore + credential_entity_request, # type: ignore + cls=lambda pipeline_response, _, response_headers: response_headers, + **kwargs + ) + credential_entity_id = response_headers["Location"].split("credentials/")[1] + return self.get_credential_entity(credential_entity_id) + + @distributed_trace + def list_credential_entities( + self, + **kwargs # type: Any + ): + # type: (...) -> ItemPaged[CredentialEntityUnion] + """List all credential entities. + + :param skip: for paging, skipped number. + :type skip: int + :return: Pageable containing credential entities + :rtype: ~azure.core.paging.ItemPaged[Union[~azure.ai.metricsadvisor.models.SQLConnectionStringCredentialEntity, + ~azure.ai.metricsadvisor.models.DataLakeGen2SharedKeyCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalInKVCredentialEntity]] + :raises ~azure.core.exceptions.HttpResponseError: + + .. admonition:: Example: + + .. literalinclude:: ../samples/sample_credential_entities.py + :start-after: [START list_credential_entities] + :end-before: [END list_credential_entities] + :language: python + :dedent: 4 + :caption: List all of the credential entities under the account + """ + return self._client.list_credentials( # type: ignore + cls=kwargs.pop( + "cls", + lambda credentials: [convert_to_credential_entity(credential) for credential in credentials]), + **kwargs + ) + + @distributed_trace + def update_credential_entity( + self, + credential_entity, # type: CredentialEntityUnion + **kwargs # type: Any + ): + # type: (...) -> CredentialEntityUnion + """Update a credential entity. + + :param credential_entity: The new credential entity object + :type credential_entity: Union[~azure.ai.metricsadvisor.models.SQLConnectionStringCredentialEntity, + ~azure.ai.metricsadvisor.models.DataLakeGen2SharedKeyCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalInKVCredentialEntity] + :rtype: Union[~azure.ai.metricsadvisor.models.SQLConnectionStringCredentialEntity, + ~azure.ai.metricsadvisor.models.DataLakeGen2SharedKeyCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalInKVCredentialEntity] + :raises ~azure.core.exceptions.HttpResponseError: + + .. admonition:: Example: + + .. literalinclude:: ../samples/sample_credential_entities.py + :start-after: [START update_credential_entity] + :end-before: [END update_credential_entity] + :language: python + :dedent: 4 + :caption: Update an existing credential entity + """ + + if credential_entity.credential_entity_type in ["AzureSQLConnectionString", + "DataLakeGen2SharedKey", "ServicePrincipal", "ServicePrincipalInKV"]: + credential_entity_request = credential_entity._to_generated_patch() + + updated_credential_entity = self._client.update_credential( + credential_entity.id, + credential_entity_request, + **kwargs + ) + + return convert_to_credential_entity(updated_credential_entity) + + @distributed_trace + def delete_credential_entity(self, credential_entity_id, **kwargs): + # type: (str, Any) -> None + """Delete a credential entity by its ID. + + ::param credential_entity_id: Credential entity unique ID. + :type credential_entity_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + + .. admonition:: Example: + + .. literalinclude:: ../samples/sample_credential_entities.py + :start-after: [START delete_credential_entity] + :end-before: [END delete_credential_entity] + :language: python + :dedent: 4 + :caption: Delete a credential entity by its ID + """ + + self._client.delete_credential(credential_id=credential_entity_id, **kwargs) diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_version.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_version.py index ad77e314d16b..d5943ffb81a0 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_version.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/_version.py @@ -4,6 +4,6 @@ # Licensed under the MIT License. # ------------------------------------ -VERSION = "1.0.0b4" +VERSION = "1.0.0" SDK_MONIKER = "ai-metricsadvisor/{}".format(VERSION) # type: str diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/aio/_metrics_advisor_administration_client_async.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/aio/_metrics_advisor_administration_client_async.py index 76cf50b02fa1..fe9a7803e8d5 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/aio/_metrics_advisor_administration_client_async.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/aio/_metrics_advisor_administration_client_async.py @@ -36,6 +36,7 @@ construct_data_feed_dict, convert_datetime, get_authentication_policy, + convert_to_credential_entity, ) from ..models import ( DataFeed, @@ -50,17 +51,23 @@ DataFeedSchema, DataFeedIngestionSettings, NotificationHook, - MetricDetectionCondition + MetricDetectionCondition, ) from .._metrics_advisor_administration_client import ( DATA_FEED, DATA_FEED_PATCH, - DataFeedSourceUnion + DataFeedSourceUnion, + CredentialEntityUnion ) if TYPE_CHECKING: from .._metrics_advisor_key_credential import MetricsAdvisorKeyCredential from azure.core.credentials_async import AsyncTokenCredential - + from ..models import ( + SQLConnectionStringCredentialEntity, + DataLakeGen2SharedKeyCredentialEntity, + ServicePrincipalCredentialEntity, + ServicePrincipalInKVCredentialEntity + ) class MetricsAdvisorAdministrationClient(object): # pylint:disable=too-many-public-methods """MetricsAdvisorAdministrationClient is used to create and manage data feeds. @@ -1122,3 +1129,176 @@ def list_data_feed_ingestion_status( skip=skip, **kwargs ) + + @distributed_trace_async + async def get_credential_entity( + self, + credential_entity_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> CredentialEntityUnion + """Get a data source credential entity + + :param credential_entity_id: Data source credential entity unique ID. + :type credential_entity_id: str + :return: The credential entity + :rtype: Union[~azure.ai.metricsadvisor.models.SQLConnectionStringCredentialEntity, + ~azure.ai.metricsadvisor.models.DataLakeGen2SharedKeyCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalInKVCredentialEntity] + :raises ~azure.core.exceptions.HttpResponseError: + + .. admonition:: Example: + + .. literalinclude:: ../samples/async_samples/sample_credential_entities_async.py + :start-after: [START get_credential_entity_async] + :end-before: [END get_credential_entity_async] + :language: python + :dedent: 4 + :caption: Get a credential entity by its ID + """ + + credential_entity = await self._client.get_credential(credential_entity_id, **kwargs) + return convert_to_credential_entity(credential_entity) + + @distributed_trace_async + async def create_credential_entity( + self, credential_entity, # type: CredentialEntityUnion + **kwargs # type: Any + ): + # type: (...) -> CredentialEntityUnion + """Create a new data source credential entity. + + :param credential_entity: The data source credential entity to create + :type credential_entity: Union[~azure.ai.metricsadvisor.models.SQLConnectionStringCredentialEntity, + ~azure.ai.metricsadvisor.models.DataLakeGen2SharedKeyCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalInKVCredentialEntity] + :return: The created data source credential entity + :rtype: Union[~azure.ai.metricsadvisor.models.SQLConnectionStringCredentialEntity, + ~azure.ai.metricsadvisor.models.DataLakeGen2SharedKeyCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalInKVCredentialEntity] + :raises ~azure.core.exceptions.HttpResponseError: + + .. admonition:: Example: + + .. literalinclude:: ../samples/async_samples/sample_credential_entities_async.py + :start-after: [START create_credential_entity_async] + :end-before: [END create_credential_entity_async] + :language: python + :dedent: 4 + :caption: Create a credential entity + """ + + credential_entity_request = None + if credential_entity.credential_entity_type in ["AzureSQLConnectionString", + "DataLakeGen2SharedKey", "ServicePrincipal", "ServicePrincipalInKV"]: + credential_entity_request = credential_entity._to_generated() + + response_headers = await self._client.create_credential( # type: ignore + credential_entity_request, # type: ignore + cls=lambda pipeline_response, _, response_headers: response_headers, + **kwargs + ) + credential_entity_id = response_headers["Location"].split("credentials/")[1] # type: ignore + return await self.get_credential_entity(credential_entity_id) + + @distributed_trace + def list_credential_entities( + self, + **kwargs # type: Any + ): + # type: (...) -> AsyncItemPaged[CredentialEntityUnion] + """List all credential entities. + + :param skip: for paging, skipped number. + :type skip: int + :return: Pageable containing credential entities + :rtype: ~azure.core.paging.AsyncItemPaged[Union[ + ~azure.ai.metricsadvisor.models.SQLConnectionStringCredentialEntity, + ~azure.ai.metricsadvisor.models.DataLakeGen2SharedKeyCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalInKVCredentialEntity]] + :raises ~azure.core.exceptions.HttpResponseError: + + .. admonition:: Example: + + .. literalinclude:: ../samples/async_samples/sample_credential_entities_async.py + :start-after: [START list_credential_entities_async] + :end-before: [END list_credential_entities_async] + :language: python + :dedent: 4 + :caption: List all of the credential entities under the account + """ + return self._client.list_credentials( # type: ignore + cls=kwargs.pop( + "cls", + lambda credentials: [convert_to_credential_entity(credential) for credential in credentials]), + **kwargs + ) + + @distributed_trace_async + async def update_credential_entity( + self, + credential_entity, # type: CredentialEntityUnion + **kwargs # type: Any + ): + # type: (...) -> CredentialEntityUnion + """Update a credential entity. + + :param credential_entity: The new credential entity object + :type credential_entity: Union[~azure.ai.metricsadvisor.models.SQLConnectionStringCredentialEntity, + ~azure.ai.metricsadvisor.models.DataLakeGen2SharedKeyCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalInKVCredentialEntity] + :rtype: Union[~azure.ai.metricsadvisor.models.SQLConnectionStringCredentialEntity, + ~azure.ai.metricsadvisor.models.DataLakeGen2SharedKeyCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalCredentialEntity, + ~azure.ai.metricsadvisor.models.ServicePrincipalInKVCredentialEntity] + :raises ~azure.core.exceptions.HttpResponseError: + + .. admonition:: Example: + + .. literalinclude:: ../samples/async_samples/sample_credential_entities_async.py + :start-after: [START update_credential_entity_async] + :end-before: [END update_credential_entity_async] + :language: python + :dedent: 4 + :caption: Update an existing credential entity + """ + + if credential_entity.credential_entity_type in ["AzureSQLConnectionString", + "DataLakeGen2SharedKey", "ServicePrincipal", "ServicePrincipalInKV"]: + credential_entity_request = credential_entity._to_generated_patch() + + updated_credential_entity = await self._client.update_credential( + credential_entity.id, + credential_entity_request, + **kwargs + ) + + return convert_to_credential_entity(updated_credential_entity) + + @distributed_trace_async + async def delete_credential_entity(self, credential_entity_id, **kwargs): + # type: (str, Any) -> None + """Delete a credential entity by its ID. + + ::param credential_entity_id: Credential entity unique ID. + :type credential_entity_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + + .. admonition:: Example: + + .. literalinclude:: ../samples/async_samples/sample_credential_entities_async.py + :start-after: [START delete_credential_entity_async] + :end-before: [END delete_credential_entity_async] + :language: python + :dedent: 4 + :caption: Delete a credential entity by its ID + """ + + await self._client.delete_credential(credential_id=credential_entity_id, **kwargs) diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/__init__.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/__init__.py index 48095a05455c..a8d0f51f84db 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/__init__.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/__init__.py @@ -39,7 +39,8 @@ ChangePointValue, PeriodType, FeedbackType, - TimeMode as AlertQueryTimeMode + TimeMode as AlertQueryTimeMode, + DataSourceCredentialType ) from .._generated.models import ( @@ -111,7 +112,11 @@ MetricAnomalyAlertScopeType, DataFeedRollupType, IncidentRootCause, - MetricEnrichedSeriesData + MetricEnrichedSeriesData, + SQLConnectionStringCredentialEntity, + DataLakeGen2SharedKeyCredentialEntity, + ServicePrincipalCredentialEntity, + ServicePrincipalInKVCredentialEntity, ) @@ -196,5 +201,10 @@ "AlertQueryTimeMode", "IncidentRootCause", "SeverityFilterCondition", - "MetricEnrichedSeriesData" + "MetricEnrichedSeriesData", + "SQLConnectionStringCredentialEntity", + "DataLakeGen2SharedKeyCredentialEntity", + "ServicePrincipalCredentialEntity", + "ServicePrincipalInKVCredentialEntity", + "DataSourceCredentialType" ) diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/_models.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/_models.py index 6d0f28657bbf..454a38561cb2 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/_models.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/azure/ai/metricsadvisor/models/_models.py @@ -47,25 +47,48 @@ PeriodFeedbackValue, EmailHookParameterPatch as _EmailHookParameterPatch, WebhookHookParameterPatch as _WebhookHookParameterPatch, + AzureBlobParameter as _AzureBlobParameter, AzureBlobParameterPatch as _AzureBlobParameterPatch, - SQLSourceParameterPatch as _SqlSourceParameterPatch, - AzureDataExplorerDataFeedPatch as _AzureDataExplorerDataFeedPatch, - MySqlDataFeedPatch as _MySqlDataFeedPatch, - PostgreSqlDataFeedPatch as _PostgreSqlDataFeedPatch, + SqlSourceParameter as _SQLSourceParameter, + SQLSourceParameterPatch as _SQLSourceParameterPatch, + AzureApplicationInsightsParameter as _AzureApplicationInsightsParameter, AzureApplicationInsightsParameterPatch as _AzureApplicationInsightsParameterPatch, + AzureCosmosDBParameter as _AzureCosmosDBParameter, AzureCosmosDBParameterPatch as _AzureCosmosDBParameterPatch, + AzureTableParameter as _AzureTableParameter, AzureTableParameterPatch as _AzureTableParameterPatch, + AzureEventHubsParameter as _AzureEventHubsParameter, AzureEventHubsParameterPatch as _AzureEventHubsParameterPatch, + InfluxDBParameter as _InfluxDBParameter, InfluxDBParameterPatch as _InfluxDBParameterPatch, + MongoDBParameter as _MongoDBParameter, MongoDBParameterPatch as _MongoDBParameterPatch, + AzureDataLakeStorageGen2Parameter as _AzureDataLakeStorageGen2Parameter, AzureDataLakeStorageGen2ParameterPatch as _AzureDataLakeStorageGen2ParameterPatch, + AzureLogAnalyticsParameter as _AzureLogAnalyticsParameter, AzureLogAnalyticsParameterPatch as _AzureLogAnalyticsParameterPatch, DimensionGroupIdentity as _DimensionGroupIdentity, SeriesIdentity as _SeriesIdentity, AnomalyAlertingConfiguration as _AnomalyAlertingConfiguration, AnomalyDetectionConfiguration as _AnomalyDetectionConfiguration, AnomalyAlertingConfigurationPatch as _AnomalyAlertingConfigurationPatch, - AnomalyDetectionConfigurationPatch as _AnomalyDetectionConfigurationPatch + AnomalyDetectionConfigurationPatch as _AnomalyDetectionConfigurationPatch, + AzureSQLConnectionStringParam as _AzureSQLConnectionStringParam, + AzureSQLConnectionStringParamPatch as _AzureSQLConnectionStringParamPatch, + AzureSQLConnectionStringCredential as _AzureSQLConnectionStringCredential, + AzureSQLConnectionStringCredentialPatch as _AzureSQLConnectionStringCredentialPatch, + DataLakeGen2SharedKeyCredentialPatch as _DataLakeGen2SharedKeyCredentialPatch, + DataLakeGen2SharedKeyParamPatch as _DataLakeGen2SharedKeyParamPatch, + DataLakeGen2SharedKeyCredential as _DataLakeGen2SharedKeyCredential, + DataLakeGen2SharedKeyParam as _DataLakeGen2SharedKeyParam, + ServicePrincipalCredentialPatch as _ServicePrincipalCredentialPatch, + ServicePrincipalParamPatch as _ServicePrincipalParamPatch, + ServicePrincipalCredential as _ServicePrincipalCredential, + ServicePrincipalParam as _ServicePrincipalParam, + ServicePrincipalInKVCredentialPatch as _ServicePrincipalInKVCredentialPatch, + ServicePrincipalInKVParamPatch as _ServicePrincipalInKVParamPatch, + ServicePrincipalInKVCredential as _ServicePrincipalInKVCredential, + ServicePrincipalInKVParam as _ServicePrincipalInKVParam, ) if TYPE_CHECKING: @@ -964,6 +987,14 @@ def _from_generated(cls, source): query=source.query ) + def _to_generated(self): + return _AzureApplicationInsightsParameter( + azure_cloud=self.azure_cloud, + application_id=self.application_id, + api_key=self.api_key, + query=self.query + ) + def _to_generated_patch(self): return _AzureApplicationInsightsParameterPatch( azure_cloud=self.azure_cloud, @@ -1008,6 +1039,13 @@ def _from_generated(cls, source): blob_template=source.blob_template ) + def _to_generated(self): + return _AzureBlobParameter( + connection_string=self.connection_string, + container=self.container, + blob_template=self.blob_template + ) + def _to_generated_patch(self): return _AzureBlobParameterPatch( connection_string=self.connection_string, @@ -1062,6 +1100,14 @@ def _from_generated(cls, source): collection_id=source.collection_id ) + def _to_generated(self): + return _AzureCosmosDBParameter( + connection_string=self.connection_string, + sql_query=self.sql_query, + database=self.database, + collection_id=self.collection_id + ) + def _to_generated_patch(self): return _AzureCosmosDBParameterPatch( connection_string=self.connection_string, @@ -1100,8 +1146,14 @@ def _from_generated(cls, source): query=source.query, ) + def _to_generated(self): + return _SQLSourceParameter( + connection_string=self.connection_string, + query=self.query, + ) + def _to_generated_patch(self): - return _AzureDataExplorerDataFeedPatch( + return _SQLSourceParameterPatch( connection_string=self.connection_string, query=self.query, ) @@ -1141,6 +1193,13 @@ def _from_generated(cls, source): table=source.table ) + def _to_generated(self): + return _AzureTableParameter( + connection_string=self.connection_string, + query=self.query, + table=self.table + ) + def _to_generated_patch(self): return _AzureTableParameterPatch( connection_string=self.connection_string, @@ -1178,6 +1237,12 @@ def _from_generated(cls, source): consumer_group=source.consumer_group ) + def _to_generated(self): + return _AzureEventHubsParameter( + connection_string=self.connection_string, + consumer_group=self.consumer_group, + ) + def _to_generated_patch(self): return _AzureEventHubsParameterPatch( connection_string=self.connection_string, @@ -1237,6 +1302,15 @@ def _from_generated(cls, source): query=source.query ) + def _to_generated(self): + return _InfluxDBParameter( + connection_string=self.connection_string, + database=self.database, + user_name=self.user_name, + password=self.password, + query=self.query + ) + def _to_generated_patch(self): return _InfluxDBParameterPatch( connection_string=self.connection_string, @@ -1276,8 +1350,14 @@ def _from_generated(cls, source): query=source.query, ) + def _to_generated(self): + return _SQLSourceParameter( + connection_string=self.connection_string, + query=self.query + ) + def _to_generated_patch(self): - return _MySqlDataFeedPatch( + return _SQLSourceParameterPatch( connection_string=self.connection_string, query=self.query ) @@ -1312,8 +1392,14 @@ def _from_generated(cls, source): query=source.query, ) + def _to_generated(self): + return _SQLSourceParameter( + connection_string=self.connection_string, + query=self.query + ) + def _to_generated_patch(self): - return _PostgreSqlDataFeedPatch( + return _SQLSourceParameterPatch( connection_string=self.connection_string, query=self.query ) @@ -1348,8 +1434,14 @@ def _from_generated(cls, source): query=source.query, ) + def _to_generated(self): + return _SQLSourceParameter( + connection_string=self.connection_string, + query=self.query, + ) + def _to_generated_patch(self): - return _SqlSourceParameterPatch( + return _SQLSourceParameterPatch( connection_string=self.connection_string, query=self.query, ) @@ -1408,6 +1500,15 @@ def _from_generated(cls, source): file_template=source.file_template ) + def _to_generated(self): + return _AzureDataLakeStorageGen2Parameter( + account_name=self.account_name, + account_key=self.account_key, + file_system_name=self.file_system_name, + directory_template=self.directory_template, + file_template=self.file_template + ) + def _to_generated_patch(self): return _AzureDataLakeStorageGen2ParameterPatch( account_name=self.account_name, @@ -1468,6 +1569,15 @@ def _from_generated(cls, source): query=source.query ) + def _to_generated(self): + return _AzureLogAnalyticsParameter( + tenant_id=self.tenant_id, + client_id=self.client_id, + client_secret=self.client_secret, + workspace_id=self.workspace_id, + query=self.query + ) + def _to_generated_patch(self): return _AzureLogAnalyticsParameterPatch( tenant_id=self.tenant_id, @@ -1512,6 +1622,13 @@ def _from_generated(cls, source): command=source.command ) + def _to_generated(self): + return _MongoDBParameter( + connection_string=self.connection_string, + database=self.database, + command=self.command + ) + def _to_generated_patch(self): return _MongoDBParameterPatch( connection_string=self.connection_string, @@ -2993,3 +3110,365 @@ def _to_generated(self): dimension_filter=dimension_filter, value=value, ) + +class SQLConnectionStringCredentialEntity(object): + """SQLConnectionStringCredentialEntity. + + All required parameters must be populated in order to send to Azure. + + :ivar credential_entity_type: Required. Type of data source credential.Constant filled by + server. Possible values include: "AzureSQLConnectionString", "DataLakeGen2SharedKey", + "ServicePrincipal", "ServicePrincipalInKV". + :type credential_entity_type: str or + ~azure.ai.metricsadvisor.models.DataSourceCredentialType + :ivar id: Unique id of data source credential. + :vartype id: str + :param name: Required. Name of data source credential. + :type name: str + :keyword str description: Description of data source credential. + :param connection_string: Required. The connection string to access the Azure SQL. + :type connection_string: str + """ + + _attribute_map = { + 'credential_entity_type': {'key': 'credentialEntityType', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'connection_string': {'key': 'connectionString', 'type': 'str'}, + } + + def __init__(self, name, connection_string, **kwargs): + # type: (str, str, Any) -> None + self.credential_entity_type = 'AzureSQLConnectionString' + self.name = name + self.connection_string = connection_string + self.id = kwargs.get('id', None) + self.description = kwargs.get('description', None) + + def __repr__(self): + return "SQLConnectionStringCredentialEntity(id={}, credential_entity_type={}, name={}, " \ + "connection_string={}, description={})".format( + self.id, + self.credential_entity_type, + self.name, + self.connection_string, + self.description + )[:1024] + + @classmethod + def _from_generated(cls, source): + return cls( + name=source.data_source_credential_name, + connection_string=source.parameters.connection_string, + id=source.data_source_credential_id, + description=source.data_source_credential_description, + ) + + def _to_generated(self): + param = _AzureSQLConnectionStringParam(connection_string=self.connection_string) + return _AzureSQLConnectionStringCredential( + data_source_credential_type=self.credential_entity_type, + data_source_credential_name=self.name, + data_source_credential_description=self.description, + parameters=param, + ) + + def _to_generated_patch(self): + param_patch = _AzureSQLConnectionStringParamPatch(connection_string=self.connection_string) + return _AzureSQLConnectionStringCredentialPatch( + data_source_credential_type=self.credential_entity_type, + data_source_credential_name=self.name, + data_source_credential_description=self.description, + parameters=param_patch, + ) + +class DataLakeGen2SharedKeyCredentialEntity(object): + """DataLakeGen2SharedKeyCredentialEntity. + + All required parameters must be populated in order to send to Azure. + + :ivar credential_entity_type: Required. Type of data source credential.Constant filled by + server. Possible values include: "AzureSQLConnectionString", "DataLakeGen2SharedKey", + "ServicePrincipal", "ServicePrincipalInKV". + :type credential_entity_type: str or + ~azure.ai.metricsadvisor.models.DataSourceCredentialType + :ivar id: Unique id of data source credential. + :vartype id: str + :param name: Required. Name of data source credential. + :type name: str + :keyword str description: Description of data source credential. + :param account_key: Required. The account key to access the Azure Data Lake Storage Gen2. + :type account_key: str + """ + + _attribute_map = { + 'credential_entity_type': {'key': 'credentialEntityType', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'account_key': {'key': 'accountKey', 'type': 'str'}, + } + + def __init__(self, name, account_key, **kwargs): + # type: (str, str, Any) -> None + self.credential_entity_type = 'DataLakeGen2SharedKey' + self.name = name + self.account_key = account_key + self.id = kwargs.get('id', None) + self.description = kwargs.get('description', None) + + def __repr__(self): + return "DataLakeGen2SharedKeyCredentialEntity(id={}, credential_entity_type={}, name={}, " \ + "account_key={}, description={})".format( + self.id, + self.credential_entity_type, + self.name, + self.account_key, + self.description + )[:1024] + + @classmethod + def _from_generated(cls, source): + return cls( + name=source.data_source_credential_name, + account_key=source.parameters.account_key, + id=source.data_source_credential_id, + description=source.data_source_credential_description, + ) + + def _to_generated(self): + param = _DataLakeGen2SharedKeyParam(account_key=self.account_key) + return _DataLakeGen2SharedKeyCredential( + data_source_credential_type=self.credential_entity_type, + data_source_credential_name=self.name, + data_source_credential_description=self.description, + parameters=param, + ) + + def _to_generated_patch(self): + param_patch = _DataLakeGen2SharedKeyParamPatch(account_key=self.account_key) + return _DataLakeGen2SharedKeyCredentialPatch( + data_source_credential_type=self.credential_entity_type, + data_source_credential_name=self.name, + data_source_credential_description=self.description, + parameters=param_patch, + ) + +class ServicePrincipalCredentialEntity(object): + """ServicePrincipalCredentialEntity. + + All required parameters must be populated in order to send to Azure. + + :ivar credential_entity_type: Required. Type of data source credential.Constant filled by + server. Possible values include: "AzureSQLConnectionString", "DataLakeGen2SharedKey", + "ServicePrincipal", "ServicePrincipalInKV". + :type credential_entity_type: str or + ~azure.ai.metricsadvisor.models.DataSourceCredentialType + :ivar id: Unique id of data source credential. + :vartype id: str + :param name: Required. Name of data source credential. + :type name: str + :keyword str description: Description of data source credential. + :param client_id: Required. The client id of the service principal. + :type client_id: str + :param client_secret: Required. The client secret of the service principal. + :type client_secret: str + :param tenant_id: Required. The tenant id of the service principal. + :type tenant_id: str + """ + + _attribute_map = { + 'credential_entity_type': {'key': 'credentialEntityType', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__(self, name, client_id, client_secret, tenant_id, **kwargs): + # type: (str, str, str, str, Any) -> None + self.credential_entity_type = 'ServicePrincipal' + self.name = name + self.client_id = client_id + self.client_secret = client_secret + self.tenant_id = tenant_id + self.id = kwargs.get('id', None) + self.description = kwargs.get('description', None) + + def __repr__(self): + return "ServicePrincipalCredentialEntity(id={}, credential_entity_type={}, name={}, " \ + "client_id={}, client_secret={}, tenant_id={}, description={})".format( + self.id, + self.credential_entity_type, + self.name, + self.client_id, + self.client_secret, + self.tenant_id, + self.description + )[:1024] + + @classmethod + def _from_generated(cls, source): + return cls( + name=source.data_source_credential_name, + client_id=source.parameters.client_id, + client_secret=source.parameters.client_secret, + tenant_id=source.parameters.tenant_id, + id=source.data_source_credential_id, + description=source.data_source_credential_description, + ) + + def _to_generated(self): + param = _ServicePrincipalParam( + client_id=self.client_id, + client_secret=self.client_secret, + tenant_id=self.tenant_id + ) + return _ServicePrincipalCredential( + data_source_credential_type=self.credential_entity_type, + data_source_credential_name=self.name, + data_source_credential_description=self.description, + parameters=param, + ) + + def _to_generated_patch(self): + param_patch = _ServicePrincipalParamPatch( + client_id=self.client_id, + client_secret=self.client_secret, + tenant_id=self.tenant_id + ) + return _ServicePrincipalCredentialPatch( + data_source_credential_type=self.credential_entity_type, + data_source_credential_name=self.name, + data_source_credential_description=self.description, + parameters=param_patch, + ) + +class ServicePrincipalInKVCredentialEntity(object): + """ServicePrincipalCredentialEntity. + + All required parameters must be populated in order to send to Azure. + + :ivar credential_entity_type: Required. Type of data source credential.Constant filled by + server. Possible values include: "AzureSQLConnectionString", "DataLakeGen2SharedKey", + "ServicePrincipal", "ServicePrincipalInKV". + :type credential_entity_type: str or + ~azure.ai.metricsadvisor.models.DataSourceCredentialType + :ivar id: Unique id of data source credential. + :vartype id: str + :param name: Required. Name of data source credential. + :type name: str + :keyword str description: Description of data source credential. + :keyword str key_vault_endpoint: Required. The Key Vault endpoint that storing the service principal. + :keyword str key_vault_client_id: Required. The Client Id to access the Key Vault. + :keyword str key_vault_client_secret: Required. The Client Secret to access the Key Vault. + :keyword str service_principal_id_name_in_kv: Required. The secret name of the service principal's + client Id in the Key Vault. + :keyword str service_principal_secret_name_in_kv: Required. The secret name of the service + principal's client secret in the Key Vault. + :keyword str tenant_id: Required. The tenant id of your service principal. + """ + + _attribute_map = { + 'credential_entity_type': {'key': 'credentialEntityType', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'key_vault_endpoint': {'key': 'keyVaultEndpoint', 'type': 'str'}, + 'key_vault_client_id': {'key': 'keyVaultClientId', 'type': 'str'}, + 'key_vault_client_secret': {'key': 'keyVaultClientSecret', 'type': 'str'}, + 'service_principal_id_name_in_kv': {'key': 'servicePrincipalIdNameInKV', 'type': 'str'}, + 'service_principal_secret_name_in_kv': {'key': 'servicePrincipalSecretNameInKV', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__(self, name, **kwargs): + # type: (str, Any) -> None + if "key_vault_endpoint" not in kwargs: + raise ValueError("key_vault_endpoint is required.") + if "key_vault_client_id" not in kwargs: + raise ValueError("key_vault_client_id is required.") + if "key_vault_client_secret" not in kwargs: + raise ValueError("key_vault_client_secret is required.") + if "service_principal_id_name_in_kv" not in kwargs: + raise ValueError("service_principal_id_name_in_kv is required.") + if "service_principal_secret_name_in_kv" not in kwargs: + raise ValueError("service_principal_secret_name_in_kv is required.") + if "tenant_id" not in kwargs: + raise ValueError("tenant_id is required.") + self.credential_entity_type = 'ServicePrincipalInKV' + self.name = name + self.key_vault_endpoint = kwargs['key_vault_endpoint'] + self.key_vault_client_id = kwargs['key_vault_client_id'] + self.key_vault_client_secret = kwargs['key_vault_client_secret'] + self.service_principal_id_name_in_kv = kwargs['service_principal_id_name_in_kv'] + self.service_principal_secret_name_in_kv = kwargs['service_principal_secret_name_in_kv'] + self.tenant_id = kwargs['tenant_id'] + self.id = kwargs.get('id', None) + self.description = kwargs.get('description', None) + + def __repr__(self): + return "ServicePrincipalInKVCredentialEntity(id={}, credential_entity_type={}, name={}, " \ + "key_vault_endpoint={}, key_vault_client_id={}, key_vault_client_secret={}, " \ + "service_principal_id_name_in_kv={}, service_principal_secret_name_in_kv={}, tenant_id={}, " \ + "description={})".format( + self.id, + self.credential_entity_type, + self.name, + self.key_vault_endpoint, + self.key_vault_client_id, + self.key_vault_client_secret, + self.service_principal_id_name_in_kv, + self.service_principal_secret_name_in_kv, + self.tenant_id, + self.description + )[:1024] + + @classmethod + def _from_generated(cls, source): + return cls( + name=source.data_source_credential_name, + key_vault_endpoint=source.parameters.key_vault_endpoint, + key_vault_client_id=source.parameters.key_vault_client_id, + key_vault_client_secret=source.parameters.key_vault_client_secret, + service_principal_id_name_in_kv=source.parameters.service_principal_id_name_in_kv, + service_principal_secret_name_in_kv=source.parameters.service_principal_secret_name_in_kv, + tenant_id=source.parameters.tenant_id, + id=source.data_source_credential_id, + description=source.data_source_credential_description, + ) + + def _to_generated(self): + param = _ServicePrincipalInKVParam( + key_vault_endpoint=self.key_vault_endpoint, + key_vault_client_id=self.key_vault_client_id, + key_vault_client_secret=self.key_vault_client_secret, + service_principal_id_name_in_kv=self.service_principal_id_name_in_kv, + service_principal_secret_name_in_kv=self.service_principal_secret_name_in_kv, + tenant_id=self.tenant_id + ) + return _ServicePrincipalInKVCredential( + data_source_credential_type=self.credential_entity_type, + data_source_credential_name=self.name, + data_source_credential_description=self.description, + parameters=param, + ) + + def _to_generated_patch(self): + param_patch = _ServicePrincipalInKVParamPatch( + key_vault_endpoint=self.key_vault_endpoint, + key_vault_client_id=self.key_vault_client_id, + key_vault_client_secret=self.key_vault_client_secret, + service_principal_id_name_in_kv=self.service_principal_id_name_in_kv, + service_principal_secret_name_in_kv=self.service_principal_secret_name_in_kv, + tenant_id=self.tenant_id + ) + return _ServicePrincipalInKVCredentialPatch( + data_source_credential_type=self.credential_entity_type, + data_source_credential_name=self.name, + data_source_credential_description=self.description, + parameters=param_patch, + ) diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/samples/async_samples/sample_credential_entities_async.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/samples/async_samples/sample_credential_entities_async.py new file mode 100644 index 000000000000..7a81492ae894 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/samples/async_samples/sample_credential_entities_async.py @@ -0,0 +1,151 @@ +# 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. +# -------------------------------------------------------------------------- + +""" +FILE: sample_credential_entities_async.py + +DESCRIPTION: + This sample demonstrates how to create, get, list, update, and delete credential entities + under your Metrics Advisor account. SQLConnectionStringCredentialEntity is used as an example in this sample. + +USAGE: + python sample_credential_entities_async.py + + Set the environment variables with your own values before running the sample: + 1) METRICS_ADVISOR_ENDPOINT - the endpoint of your Azure Metrics Advisor service + 2) METRICS_ADVISOR_SUBSCRIPTION_KEY - Metrics Advisor service subscription key + 3) METRICS_ADVISOR_API_KEY - Metrics Advisor service API key + 4) SQL_SERVER_CONNECTION_STRING - SQL service connection string +""" + +import os +import asyncio + + +async def sample_create_credential_entity_async(): + # [START create_credential_entity_async] + from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential, MetricsAdvisorAdministrationClient + from azure.ai.metricsadvisor.models import SQLConnectionStringCredentialEntity + + service_endpoint = os.getenv("METRICS_ADVISOR_ENDPOINT") + subscription_key = os.getenv("METRICS_ADVISOR_SUBSCRIPTION_KEY") + api_key = os.getenv("METRICS_ADVISOR_API_KEY") + connection_string = os.getenv("SQL_SERVER_CONNECTION_STRING") + + client = MetricsAdvisorAdministrationClient(service_endpoint, + MetricsAdvisorKeyCredential(subscription_key, api_key)) + + credential_entity = await client.create_credential_entity( + credential_entity=SQLConnectionStringCredentialEntity( + name="sql credential entity", + connection_string=connection_string, + description="my credential entity", + ) + ) + + return credential_entity + # [END create_credential_entity_async] + + +async def sample_get_credential_entity_async(credential_entity_id): + # [START get_credential_entity_async] + from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential, MetricsAdvisorAdministrationClient + + service_endpoint = os.getenv("METRICS_ADVISOR_ENDPOINT") + subscription_key = os.getenv("METRICS_ADVISOR_SUBSCRIPTION_KEY") + api_key = os.getenv("METRICS_ADVISOR_API_KEY") + + client = MetricsAdvisorAdministrationClient(service_endpoint, + MetricsAdvisorKeyCredential(subscription_key, api_key)) + + credential_entity = await client.get_credential_entity(credential_entity_id) + + print("Credential entity type: {}".format(credential_entity.type)) + print("Credential entity name: {}".format(credential_entity.name)) + print("Description: {}".format(credential_entity.description)) + + # [END get_credential_entity_async] + + +async def sample_list_credential_entities_async(): + # [START list_credential_entities_async] + from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential, MetricsAdvisorAdministrationClient + + service_endpoint = os.getenv("METRICS_ADVISOR_ENDPOINT") + subscription_key = os.getenv("METRICS_ADVISOR_SUBSCRIPTION_KEY") + api_key = os.getenv("METRICS_ADVISOR_API_KEY") + + client = MetricsAdvisorAdministrationClient(service_endpoint, + MetricsAdvisorKeyCredential(subscription_key, api_key)) + + credential_entities = client.list_credential_entities() + async for credential_entity in credential_entities: + print("Credential entity type: {}".format(credential_entity.type)) + print("Credential entity name: {}".format(credential_entity.name)) + print("Description: {}\n".format(credential_entity.description)) + + # [END list_credential_entities_async] + + +async def sample_update_credential_entity_async(credential_entity): + # [START update_credential_entity_async] + from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential, MetricsAdvisorAdministrationClient + + service_endpoint = os.getenv("METRICS_ADVISOR_ENDPOINT") + subscription_key = os.getenv("METRICS_ADVISOR_SUBSCRIPTION_KEY") + api_key = os.getenv("METRICS_ADVISOR_API_KEY") + + client = MetricsAdvisorAdministrationClient(service_endpoint, + MetricsAdvisorKeyCredential(subscription_key, api_key)) + + credential_entity.description = "updated description" + + updated = await client.update_credential_entity(credential_entity) + print("Credential entity type: {}".format(updated.type)) + print("Credential entity name: {}".format(updated.name)) + print("Description: {}\n".format(updated.description)) + # [END update_credential_entity_async] + + +async def sample_delete_credential_entity_async(credential_entity_id): + # [START delete_credential_entity_async] + from azure.core.exceptions import ResourceNotFoundError + from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential, MetricsAdvisorAdministrationClient + + service_endpoint = os.getenv("METRICS_ADVISOR_ENDPOINT") + subscription_key = os.getenv("METRICS_ADVISOR_SUBSCRIPTION_KEY") + api_key = os.getenv("METRICS_ADVISOR_API_KEY") + + client = MetricsAdvisorAdministrationClient(service_endpoint, + MetricsAdvisorKeyCredential(subscription_key, api_key)) + + await client.delete_credential_entity(credential_entity_id) + + try: + await client.get_credential_entity(credential_entity_id) + except ResourceNotFoundError: + print("Credential entity successfully deleted.") + # [END delete_credential_entity_async] + + +async def main(): + print("---Creating credential entity...") + credential_entity = await sample_create_credential_entity_async() + print("Credential_entity successfully created...") + print("\n---Get a credential entity...") + await sample_get_credential_entity_async(credential_entity.id) + print("\n---List credential entities...") + await sample_list_credential_entities_async() + print("\n---Update a credential entity...") + await sample_update_credential_entity_async(credential_entity) + print("\n---Delete a credential entity...") + await sample_delete_credential_entity_async(credential_entity.id) + +if __name__ == '__main__': + loop = asyncio.get_event_loop() + loop.run_until_complete(main()) \ No newline at end of file diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/samples/sample_credential_entities.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/samples/sample_credential_entities.py new file mode 100644 index 000000000000..586e99eaab5e --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/samples/sample_credential_entities.py @@ -0,0 +1,146 @@ +# 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. +# -------------------------------------------------------------------------- + +""" +FILE: sample_credential_entities.py + +DESCRIPTION: + This sample demonstrates how to create, get, list, update, and delete credential entities + under your Metrics Advisor account. SQLConnectionStringCredentialEntity is used as an example in this sample. + +USAGE: + python sample_credential_entities.py + + Set the environment variables with your own values before running the sample: + 1) METRICS_ADVISOR_ENDPOINT - the endpoint of your Azure Metrics Advisor service + 2) METRICS_ADVISOR_SUBSCRIPTION_KEY - Metrics Advisor service subscription key + 3) METRICS_ADVISOR_API_KEY - Metrics Advisor service API key + 4) SQL_SERVER_CONNECTION_STRING - SQL service connection string +""" + +import os + + +def sample_create_credential_entity(): + # [START create_credential_entity] + from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential, MetricsAdvisorAdministrationClient + from azure.ai.metricsadvisor.models import SQLConnectionStringCredentialEntity + + service_endpoint = os.getenv("METRICS_ADVISOR_ENDPOINT") + subscription_key = os.getenv("METRICS_ADVISOR_SUBSCRIPTION_KEY") + api_key = os.getenv("METRICS_ADVISOR_API_KEY") + connection_string = os.getenv("SQL_SERVER_CONNECTION_STRING") + + client = MetricsAdvisorAdministrationClient(service_endpoint, + MetricsAdvisorKeyCredential(subscription_key, api_key)) + + credential_entity = client.create_credential_entity( + credential_entity=SQLConnectionStringCredentialEntity( + name="sql credential entity", + connection_string=connection_string, + description="my credential entity", + ) + ) + + return credential_entity + # [END create_credential_entity] + + +def sample_get_credential_entity(credential_entity_id): + # [START get_credential_entity] + from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential, MetricsAdvisorAdministrationClient + + service_endpoint = os.getenv("METRICS_ADVISOR_ENDPOINT") + subscription_key = os.getenv("METRICS_ADVISOR_SUBSCRIPTION_KEY") + api_key = os.getenv("METRICS_ADVISOR_API_KEY") + + client = MetricsAdvisorAdministrationClient(service_endpoint, + MetricsAdvisorKeyCredential(subscription_key, api_key)) + + credential_entity = client.get_credential_entity(credential_entity_id) + + print("Type: {}".format(credential_entity.type)) + print("Name: {}".format(credential_entity.name)) + print("Description: {}".format(credential_entity.description)) + + # [END get_credential_entity] + + +def sample_list_credential_entities(): + # [START list_credential_entities] + from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential, MetricsAdvisorAdministrationClient + + service_endpoint = os.getenv("METRICS_ADVISOR_ENDPOINT") + subscription_key = os.getenv("METRICS_ADVISOR_SUBSCRIPTION_KEY") + api_key = os.getenv("METRICS_ADVISOR_API_KEY") + + client = MetricsAdvisorAdministrationClient(service_endpoint, + MetricsAdvisorKeyCredential(subscription_key, api_key)) + + credential_entities = client.list_credential_entities() + for credential_entity in credential_entities: + print("Type: {}".format(credential_entity.type)) + print("Name: {}".format(credential_entity.name)) + print("Description: {}\n".format(credential_entity.description)) + + # [END list_credential_entities] + + +def sample_update_credential_entity(credential_entity): + # [START update_credential_entity] + from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential, MetricsAdvisorAdministrationClient + + service_endpoint = os.getenv("METRICS_ADVISOR_ENDPOINT") + subscription_key = os.getenv("METRICS_ADVISOR_SUBSCRIPTION_KEY") + api_key = os.getenv("METRICS_ADVISOR_API_KEY") + + client = MetricsAdvisorAdministrationClient(service_endpoint, + MetricsAdvisorKeyCredential(subscription_key, api_key)) + + credential_entity.description = "updated description" + + updated = client.update_credential_entity(credential_entity) + print("Type: {}".format(updated.type)) + print("Name: {}".format(updated.name)) + print("Description: {}\n".format(updated.description)) + # [END update_credential_entity] + + +def sample_delete_credential_entity(credential_entity_id): + # [START delete_credential_entity] + from azure.core.exceptions import ResourceNotFoundError + from azure.ai.metricsadvisor import MetricsAdvisorKeyCredential, MetricsAdvisorAdministrationClient + + service_endpoint = os.getenv("METRICS_ADVISOR_ENDPOINT") + subscription_key = os.getenv("METRICS_ADVISOR_SUBSCRIPTION_KEY") + api_key = os.getenv("METRICS_ADVISOR_API_KEY") + + client = MetricsAdvisorAdministrationClient(service_endpoint, + MetricsAdvisorKeyCredential(subscription_key, api_key)) + + client.delete_credential_entity(credential_entity_id) + + try: + client.get_credential_entity(credential_entity_id) + except ResourceNotFoundError: + print("Credential entity successfully deleted.") + # [END delete_credential_entity] + + +if __name__ == '__main__': + print("---Creating credential entity...") + credential_entity = sample_create_credential_entity() + print("Credential_entity successfully created...") + print("\n---Get a credential entity...") + sample_get_credential_entity(credential_entity.id) + print("\n---List credential entities...") + sample_list_credential_entities() + print("\n---Update a credential entity...") + sample_update_credential_entity(credential_entity) + print("\n---Delete a credential entity...") + sample_delete_credential_entity(credential_entity.id) \ No newline at end of file diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/base_testcase_aad_async.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/base_testcase_aad_async.py index 437c645953d6..35426718858d 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/base_testcase_aad_async.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/base_testcase_aad_async.py @@ -67,8 +67,6 @@ def __init__(self, method_name): self.azure_table_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_TABLE_CONNECTION_STRING") self.azure_blob_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_BLOB_CONNECTION_STRING") self.azure_cosmosdb_connection_string = self.get_settings_value("METRICS_ADVISOR_COSMOS_DB_CONNECTION_STRING") - self.http_request_get_url = self.get_settings_value("METRICS_ADVISOR_HTTP_GET_URL") - self.http_request_post_url = self.get_settings_value("METRICS_ADVISOR_HTTP_POST_URL") self.application_insights_api_key = self.get_settings_value("METRICS_ADVISOR_APPLICATION_INSIGHTS_API_KEY") self.azure_data_explorer_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_DATA_EXPLORER_CONNECTION_STRING") self.influxdb_connection_string = self.get_settings_value("METRICS_ADVISOR_INFLUX_DB_CONNECTION_STRING") @@ -77,7 +75,6 @@ def __init__(self, method_name): self.mongodb_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_MONGO_DB_CONNECTION_STRING") self.mysql_connection_string = self.get_settings_value("METRICS_ADVISOR_MYSQL_CONNECTION_STRING") self.postgresql_connection_string = self.get_settings_value("METRICS_ADVISOR_POSTGRESQL_CONNECTION_STRING") - self.elasticsearch_auth_header = self.get_settings_value("METRICS_ADVISOR_ELASTICSEARCH_AUTH_HEADER") self.anomaly_detection_configuration_id = self.get_settings_value("METRICS_ADVISOR_ANOMALY_DETECTION_CONFIGURATION_ID") self.data_feed_id = self.get_settings_value("METRICS_ADVISOR_DATA_FEED_ID") self.metric_id = self.get_settings_value("METRICS_ADVISOR_METRIC_ID") @@ -98,14 +95,6 @@ def __init__(self, method_name): self.azure_cosmosdb_connection_string, "connectionstring" ) - self.scrubber.register_name_pair( - self.http_request_get_url, - "connectionstring" - ) - self.scrubber.register_name_pair( - self.http_request_post_url, - "connectionstring" - ) self.scrubber.register_name_pair( self.application_insights_api_key, "connectionstring" @@ -138,10 +127,6 @@ def __init__(self, method_name): self.postgresql_connection_string, "connectionstring" ) - self.scrubber.register_name_pair( - self.elasticsearch_auth_header, - "connectionstring" - ) self.scrubber.register_name_pair( self.metric_id, "metric_id" @@ -160,8 +145,6 @@ def __init__(self, method_name): self.azure_table_connection_string = "AZURE_TABLE_CONNECTION_STRING" self.azure_blob_connection_string = "AZURE_BLOB_CONNECTION_STRING" self.azure_cosmosdb_connection_string = "COSMOS_DB_CONNECTION_STRING" - self.http_request_get_url = "METRICS_ADVISOR_HTTP_GET_URL" - self.http_request_post_url = "METRICS_ADVISOR_HTTP_POST_URL" self.application_insights_api_key = "METRICS_ADVISOR_APPLICATION_INSIGHTS_API_KEY" self.azure_data_explorer_connection_string = "METRICS_ADVISOR_AZURE_DATA_EXPLORER_CONNECTION_STRING" self.influxdb_connection_string = "METRICS_ADVISOR_INFLUXDB_CONNECTION_STRING" @@ -170,7 +153,6 @@ def __init__(self, method_name): self.mongodb_connection_string = "METRICS_ADVISOR_AZURE_MONGODB_CONNECTION_STRING" self.mysql_connection_string = "METRICS_ADVISOR_MYSQL_CONNECTION_STRING" self.postgresql_connection_string = "METRICS_ADVISOR_POSTGRESQL_CONNECTION_STRING" - self.elasticsearch_auth_header = "METRICS_ADVISOR_ELASTICSEARCH_AUTH" self.anomaly_detection_configuration_id = "anomaly_detection_configuration_id" self.data_feed_id = "data_feed_id" self.metric_id = "metric_id" diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/base_testcase_async.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/base_testcase_async.py index bab9561c316b..d0efd132c495 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/base_testcase_async.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/base_testcase_async.py @@ -64,8 +64,6 @@ def __init__(self, method_name): self.azure_table_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_TABLE_CONNECTION_STRING") self.azure_blob_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_BLOB_CONNECTION_STRING") self.azure_cosmosdb_connection_string = self.get_settings_value("METRICS_ADVISOR_COSMOS_DB_CONNECTION_STRING") - self.http_request_get_url = self.get_settings_value("METRICS_ADVISOR_HTTP_GET_URL") - self.http_request_post_url = self.get_settings_value("METRICS_ADVISOR_HTTP_POST_URL") self.application_insights_api_key = self.get_settings_value("METRICS_ADVISOR_APPLICATION_INSIGHTS_API_KEY") self.azure_data_explorer_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_DATA_EXPLORER_CONNECTION_STRING") self.influxdb_connection_string = self.get_settings_value("METRICS_ADVISOR_INFLUX_DB_CONNECTION_STRING") @@ -74,7 +72,6 @@ def __init__(self, method_name): self.mongodb_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_MONGO_DB_CONNECTION_STRING") self.mysql_connection_string = self.get_settings_value("METRICS_ADVISOR_MYSQL_CONNECTION_STRING") self.postgresql_connection_string = self.get_settings_value("METRICS_ADVISOR_POSTGRESQL_CONNECTION_STRING") - self.elasticsearch_auth_header = self.get_settings_value("METRICS_ADVISOR_ELASTICSEARCH_AUTH_HEADER") self.anomaly_detection_configuration_id = self.get_settings_value("METRICS_ADVISOR_ANOMALY_DETECTION_CONFIGURATION_ID") self.data_feed_id = self.get_settings_value("METRICS_ADVISOR_DATA_FEED_ID") self.metric_id = self.get_settings_value("METRICS_ADVISOR_METRIC_ID") @@ -94,14 +91,6 @@ def __init__(self, method_name): self.azure_cosmosdb_connection_string, "connectionstring" ) - self.scrubber.register_name_pair( - self.http_request_get_url, - "connectionstring" - ) - self.scrubber.register_name_pair( - self.http_request_post_url, - "connectionstring" - ) self.scrubber.register_name_pair( self.application_insights_api_key, "connectionstring" @@ -134,10 +123,6 @@ def __init__(self, method_name): self.postgresql_connection_string, "connectionstring" ) - self.scrubber.register_name_pair( - self.elasticsearch_auth_header, - "connectionstring" - ) self.scrubber.register_name_pair( self.metric_id, "metric_id" @@ -158,8 +143,6 @@ def __init__(self, method_name): self.azure_table_connection_string = "AZURE_TABLE_CONNECTION_STRING" self.azure_blob_connection_string = "AZURE_BLOB_CONNECTION_STRING" self.azure_cosmosdb_connection_string = "COSMOS_DB_CONNECTION_STRING" - self.http_request_get_url = "METRICS_ADVISOR_HTTP_GET_URL" - self.http_request_post_url = "METRICS_ADVISOR_HTTP_POST_URL" self.application_insights_api_key = "METRICS_ADVISOR_APPLICATION_INSIGHTS_API_KEY" self.azure_data_explorer_connection_string = "METRICS_ADVISOR_AZURE_DATA_EXPLORER_CONNECTION_STRING" self.influxdb_connection_string = "METRICS_ADVISOR_INFLUXDB_CONNECTION_STRING" @@ -168,7 +151,6 @@ def __init__(self, method_name): self.mongodb_connection_string = "METRICS_ADVISOR_AZURE_MONGODB_CONNECTION_STRING" self.mysql_connection_string = "METRICS_ADVISOR_MYSQL_CONNECTION_STRING" self.postgresql_connection_string = "METRICS_ADVISOR_POSTGRESQL_CONNECTION_STRING" - self.elasticsearch_auth_header = "METRICS_ADVISOR_ELASTICSEARCH_AUTH" self.anomaly_detection_configuration_id = "anomaly_detection_configuration_id" self.data_feed_id = "data_feed_id" self.metric_id = "metric_id" diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_create_sql_connection_string_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_create_sql_connection_string_credential_entity.yaml new file mode 100644 index 000000000000..232558d16345 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_create_sql_connection_string_credential_entity.yaml @@ -0,0 +1,83 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "AzureSQLConnectionString", "dataSourceCredentialName": + "testsqlcredential7b3721e7", "dataSourceCredentialDescription": "my credential + entity", "parameters": {"connectionString": "connectionstring"}}' + headers: + Accept: + - application/json + Content-Length: + - '444' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: 39cf0c22-bed0-464f-a3d8-d9b1c98bae20 + content-length: '0' + date: Tue, 25 May 2021 19:02:14 GMT + location: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/407e55f4-8be1-45de-8f8d-15d1608e4b25 + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '5641' + x-request-id: 39cf0c22-bed0-464f-a3d8-d9b1c98bae20 + status: + code: 201 + message: Created + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/407e55f4-8be1-45de-8f8d-15d1608e4b25 + response: + body: + string: '{"dataSourceCredentialId":"407e55f4-8be1-45de-8f8d-15d1608e4b25","dataSourceCredentialName":"testsqlcredential7b3721e7","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"AzureSQLConnectionString","parameters":{}}' + headers: + apim-request-id: e6589f5f-4d9e-4818-aee2-0486daaacd70 + content-length: '247' + content-type: application/json; charset=utf-8 + date: Tue, 25 May 2021 19:02:14 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '115' + x-request-id: e6589f5f-4d9e-4818-aee2-0486daaacd70 + status: + code: 200 + message: OK + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/407e55f4-8be1-45de-8f8d-15d1608e4b25 +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/407e55f4-8be1-45de-8f8d-15d1608e4b25 + response: + body: + string: '' + headers: + apim-request-id: d0a77f9a-31b0-4e54-bd81-60959199ae6a + content-length: '0' + date: Tue, 25 May 2021 19:02:20 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '5242' + x-request-id: d0a77f9a-31b0-4e54-bd81-60959199ae6a + status: + code: 204 + message: No Content + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/407e55f4-8be1-45de-8f8d-15d1608e4b25 +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_datalake_gen2_shared_key_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_datalake_gen2_shared_key_credential_entity.yaml new file mode 100644 index 000000000000..9b43e3d0219e --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_datalake_gen2_shared_key_credential_entity.yaml @@ -0,0 +1,83 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "DataLakeGen2SharedKey", "dataSourceCredentialName": + "testdatalakecredentiale78f1fbf", "dataSourceCredentialDescription": "my credential + entity", "parameters": {"accountKey": "connectionstring"}}' + headers: + Accept: + - application/json + Content-Length: + - '296' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: bc02e34b-88bf-48ff-8a53-d47f4003654c + content-length: '0' + date: Tue, 25 May 2021 19:02:20 GMT + location: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/958e046c-30fc-45da-b6e4-a86752ffbed6 + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '549' + x-request-id: bc02e34b-88bf-48ff-8a53-d47f4003654c + status: + code: 201 + message: Created + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/958e046c-30fc-45da-b6e4-a86752ffbed6 + response: + body: + string: '{"dataSourceCredentialId":"958e046c-30fc-45da-b6e4-a86752ffbed6","dataSourceCredentialName":"testdatalakecredentiale78f1fbf","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"DataLakeGen2SharedKey","parameters":{}}' + headers: + apim-request-id: b6192fcb-f6e4-421c-8c71-4c39a990980a + content-length: '249' + content-type: application/json; charset=utf-8 + date: Tue, 25 May 2021 19:02:20 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '111' + x-request-id: b6192fcb-f6e4-421c-8c71-4c39a990980a + status: + code: 200 + message: OK + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/958e046c-30fc-45da-b6e4-a86752ffbed6 +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/958e046c-30fc-45da-b6e4-a86752ffbed6 + response: + body: + string: '' + headers: + apim-request-id: b9f3ab26-3d51-4527-acf3-130a0de74abe + content-length: '0' + date: Tue, 25 May 2021 19:02:21 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '197' + x-request-id: b9f3ab26-3d51-4527-acf3-130a0de74abe + status: + code: 204 + message: No Content + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/958e046c-30fc-45da-b6e4-a86752ffbed6 +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_list_credential_entities.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_list_credential_entities.yaml new file mode 100644 index 000000000000..ff04efd97e2f --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_list_credential_entities.yaml @@ -0,0 +1,109 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "AzureSQLConnectionString", "dataSourceCredentialName": + "testsqlcredentialf33b18c3", "dataSourceCredentialDescription": "my credential + entity", "parameters": {"connectionString": "connectionstring"}}' + headers: + Accept: + - application/json + Content-Length: + - '444' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: 093a346b-b9ab-46d8-a868-c926d4fdbe0e + content-length: '0' + date: Tue, 25 May 2021 19:02:22 GMT + location: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/2b873791-2387-44c4-8b54-f267fb2cd4d0 + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '535' + x-request-id: 093a346b-b9ab-46d8-a868-c926d4fdbe0e + status: + code: 201 + message: Created + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/2b873791-2387-44c4-8b54-f267fb2cd4d0 + response: + body: + string: '{"dataSourceCredentialId":"2b873791-2387-44c4-8b54-f267fb2cd4d0","dataSourceCredentialName":"testsqlcredentialf33b18c3","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"AzureSQLConnectionString","parameters":{}}' + headers: + apim-request-id: fa4cbb40-6607-49f2-8b30-e316163406cf + content-length: '247' + content-type: application/json; charset=utf-8 + date: Tue, 25 May 2021 19:02:22 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '86' + x-request-id: fa4cbb40-6607-49f2-8b30-e316163406cf + status: + code: 200 + message: OK + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/2b873791-2387-44c4-8b54-f267fb2cd4d0 +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '{"value":[{"dataSourceCredentialId":"2b873791-2387-44c4-8b54-f267fb2cd4d0","dataSourceCredentialName":"testsqlcredentialf33b18c3","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"AzureSQLConnectionString","parameters":{}}],"@nextLink":null}' + headers: + apim-request-id: 040ff84f-69a0-4e91-9887-1ca4b24bf4ff + content-length: '276' + content-type: application/json; charset=utf-8 + date: Tue, 25 May 2021 19:02:22 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '114' + x-request-id: 040ff84f-69a0-4e91-9887-1ca4b24bf4ff + status: + code: 200 + message: OK + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/2b873791-2387-44c4-8b54-f267fb2cd4d0 + response: + body: + string: '' + headers: + apim-request-id: d6134df1-e7b8-4c2e-b095-940188996239 + content-length: '0' + date: Tue, 25 May 2021 19:02:23 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '185' + x-request-id: d6134df1-e7b8-4c2e-b095-940188996239 + status: + code: 204 + message: No Content + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/2b873791-2387-44c4-8b54-f267fb2cd4d0 +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_service_principal_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_service_principal_credential_entity.yaml new file mode 100644 index 000000000000..fd1900ea2c02 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_service_principal_credential_entity.yaml @@ -0,0 +1,84 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "ServicePrincipal", "dataSourceCredentialName": + "testserviceprincipalcredential1e711d51", "dataSourceCredentialDescription": + "my credential entity", "parameters": {"clientId": "client_id", "clientSecret": + "client_secret", "tenantId": "tenant_id"}}' + headers: + Accept: + - application/json + Content-Length: + - '276' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: 9ce9de11-5969-490b-af01-8f6a6912f249 + content-length: '0' + date: Tue, 25 May 2021 19:02:23 GMT + location: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/07762811-3687-49e1-afe5-242fc70278d7 + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '471' + x-request-id: 9ce9de11-5969-490b-af01-8f6a6912f249 + status: + code: 201 + message: Created + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/07762811-3687-49e1-afe5-242fc70278d7 + response: + body: + string: '{"dataSourceCredentialId":"07762811-3687-49e1-afe5-242fc70278d7","dataSourceCredentialName":"testserviceprincipalcredential1e711d51","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"ServicePrincipal","parameters":{"clientId":"client_id","tenantId":"tenant_id"}}' + headers: + apim-request-id: dca70831-5949-4e75-9104-a95788dce9bd + content-length: '297' + content-type: application/json; charset=utf-8 + date: Tue, 25 May 2021 19:02:23 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '88' + x-request-id: dca70831-5949-4e75-9104-a95788dce9bd + status: + code: 200 + message: OK + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/07762811-3687-49e1-afe5-242fc70278d7 +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/07762811-3687-49e1-afe5-242fc70278d7 + response: + body: + string: '' + headers: + apim-request-id: 2f944010-7994-487f-9462-0177cd25055f + content-length: '0' + date: Tue, 25 May 2021 19:02:23 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '194' + x-request-id: 2f944010-7994-487f-9462-0177cd25055f + status: + code: 204 + message: No Content + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/07762811-3687-49e1-afe5-242fc70278d7 +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_service_principal_in_kv_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_service_principal_in_kv_credential_entity.yaml new file mode 100644 index 000000000000..4996b7e58c3d --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_service_principal_in_kv_credential_entity.yaml @@ -0,0 +1,86 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "ServicePrincipalInKV", "dataSourceCredentialName": + "testserviceprincipalcredentiald6471fc7", "dataSourceCredentialDescription": + "my credential entity", "parameters": {"keyVaultEndpoint": "key_vault_endpoint", + "keyVaultClientId": "key_vault_client_id", "keyVaultClientSecret": "key_vault_client_secret", + "servicePrincipalIdNameInKV": "service_principal_id_name_in_kv", "servicePrincipalSecretNameInKV": + "service_principal_secret_name_in_kv", "tenantId": "tenant_id"}}' + headers: + Accept: + - application/json + Content-Length: + - '496' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: 517b9b69-b8e2-494f-9ad8-7ff7e448fadb + content-length: '0' + date: Tue, 25 May 2021 19:02:24 GMT + location: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/40eaf24e-0cad-469c-9122-418a35bdfcea + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '430' + x-request-id: 517b9b69-b8e2-494f-9ad8-7ff7e448fadb + status: + code: 201 + message: Created + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/40eaf24e-0cad-469c-9122-418a35bdfcea + response: + body: + string: '{"dataSourceCredentialId":"40eaf24e-0cad-469c-9122-418a35bdfcea","dataSourceCredentialName":"testserviceprincipalcredentiald6471fc7","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"ServicePrincipalInKV","parameters":{"servicePrincipalSecretNameInKV":"service_principal_secret_name_in_kv","servicePrincipalIdNameInKV":"service_principal_id_name_in_kv","tenantId":"tenant_id","keyVaultClientId":"key_vault_client_id","keyVaultEndpoint":"key_vault_endpoint"}}' + headers: + apim-request-id: 1f643aec-d1e8-4edd-bdce-14e0d9f4418f + content-length: '493' + content-type: application/json; charset=utf-8 + date: Tue, 25 May 2021 19:02:24 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '97' + x-request-id: 1f643aec-d1e8-4edd-bdce-14e0d9f4418f + status: + code: 200 + message: OK + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/40eaf24e-0cad-469c-9122-418a35bdfcea +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/40eaf24e-0cad-469c-9122-418a35bdfcea + response: + body: + string: '' + headers: + apim-request-id: 4e9959aa-351c-46af-b094-e36dcd26d1e6 + content-length: '0' + date: Tue, 25 May 2021 19:02:24 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '216' + x-request-id: 4e9959aa-351c-46af-b094-e36dcd26d1e6 + status: + code: 204 + message: No Content + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/40eaf24e-0cad-469c-9122-418a35bdfcea +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_datalake_gen2_shared_key_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_datalake_gen2_shared_key_credential_entity.yaml new file mode 100644 index 000000000000..31da1ec867b7 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_datalake_gen2_shared_key_credential_entity.yaml @@ -0,0 +1,114 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "DataLakeGen2SharedKey", "dataSourceCredentialName": + "testdatalakecredentiald40122a1", "dataSourceCredentialDescription": "my credential + entity", "parameters": {"accountKey": "connectionstring"}}' + headers: + Accept: + - application/json + Content-Length: + - '296' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: b3ff2009-9083-4e80-a68b-0b83338ce346 + content-length: '0' + date: Tue, 25 May 2021 19:02:26 GMT + location: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/8853d749-ae66-48ef-b4ae-90c8d19809fe + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '696' + x-request-id: b3ff2009-9083-4e80-a68b-0b83338ce346 + status: + code: 201 + message: Created + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/8853d749-ae66-48ef-b4ae-90c8d19809fe + response: + body: + string: '{"dataSourceCredentialId":"8853d749-ae66-48ef-b4ae-90c8d19809fe","dataSourceCredentialName":"testdatalakecredentiald40122a1","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"DataLakeGen2SharedKey","parameters":{}}' + headers: + apim-request-id: 54f1067d-e39b-4eaf-b9e6-168df85cf6aa + content-length: '249' + content-type: application/json; charset=utf-8 + date: Tue, 25 May 2021 19:02:26 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '69' + x-request-id: 54f1067d-e39b-4eaf-b9e6-168df85cf6aa + status: + code: 200 + message: OK + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/8853d749-ae66-48ef-b4ae-90c8d19809fe +- request: + body: '{"dataSourceCredentialType": "DataLakeGen2SharedKey", "dataSourceCredentialName": + "testdatalakecredentiald40122a1", "dataSourceCredentialDescription": "update", + "parameters": {"accountKey": "update"}}' + headers: + Accept: + - application/json + Content-Length: + - '200' + Content-Type: + - application/merge-patch+json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: PATCH + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/8853d749-ae66-48ef-b4ae-90c8d19809fe + response: + body: + string: '{"dataSourceCredentialId":"8853d749-ae66-48ef-b4ae-90c8d19809fe","dataSourceCredentialName":"testdatalakecredentiald40122a1","dataSourceCredentialDescription":"update","dataSourceCredentialType":"DataLakeGen2SharedKey","parameters":{}}' + headers: + apim-request-id: a7253b01-ff6a-46d2-a344-a5e9e0ccb9a4 + content-length: '235' + content-type: application/json; charset=utf-8 + date: Tue, 25 May 2021 19:02:26 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '577' + x-request-id: a7253b01-ff6a-46d2-a344-a5e9e0ccb9a4 + status: + code: 200 + message: OK + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/8853d749-ae66-48ef-b4ae-90c8d19809fe +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/8853d749-ae66-48ef-b4ae-90c8d19809fe + response: + body: + string: '' + headers: + apim-request-id: d02eba9c-8575-4f80-a0bd-d239f30ee47f + content-length: '0' + date: Tue, 25 May 2021 19:02:27 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '202' + x-request-id: d02eba9c-8575-4f80-a0bd-d239f30ee47f + status: + code: 204 + message: No Content + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/8853d749-ae66-48ef-b4ae-90c8d19809fe +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_service_principal_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_service_principal_credential_entity.yaml new file mode 100644 index 000000000000..b704379db519 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_service_principal_credential_entity.yaml @@ -0,0 +1,116 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "ServicePrincipal", "dataSourceCredentialName": + "testserviceprincipalcredentialf6a62033", "dataSourceCredentialDescription": + "my credential entity", "parameters": {"clientId": "client_id", "clientSecret": + "client_secret", "tenantId": "tenant_id"}}' + headers: + Accept: + - application/json + Content-Length: + - '276' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: bfb0c28e-761b-43fd-8c1a-15511c7e6ba0 + content-length: '0' + date: Tue, 25 May 2021 19:02:28 GMT + location: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/bd197eb4-eea4-484b-bb40-00a68f8d2393 + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '587' + x-request-id: bfb0c28e-761b-43fd-8c1a-15511c7e6ba0 + status: + code: 201 + message: Created + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/bd197eb4-eea4-484b-bb40-00a68f8d2393 + response: + body: + string: '{"dataSourceCredentialId":"bd197eb4-eea4-484b-bb40-00a68f8d2393","dataSourceCredentialName":"testserviceprincipalcredentialf6a62033","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"ServicePrincipal","parameters":{"clientId":"client_id","tenantId":"tenant_id"}}' + headers: + apim-request-id: ccff7ad5-604a-4210-b189-14977a4333e6 + content-length: '297' + content-type: application/json; charset=utf-8 + date: Tue, 25 May 2021 19:02:28 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '90' + x-request-id: ccff7ad5-604a-4210-b189-14977a4333e6 + status: + code: 200 + message: OK + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/bd197eb4-eea4-484b-bb40-00a68f8d2393 +- request: + body: '{"dataSourceCredentialType": "ServicePrincipal", "dataSourceCredentialName": + "testserviceprincipalcredentialf6a62033", "dataSourceCredentialDescription": + "update", "parameters": {"clientId": "update", "clientSecret": "update", "tenantId": + "update"}}' + headers: + Accept: + - application/json + Content-Length: + - '249' + Content-Type: + - application/merge-patch+json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: PATCH + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/bd197eb4-eea4-484b-bb40-00a68f8d2393 + response: + body: + string: '{"dataSourceCredentialId":"bd197eb4-eea4-484b-bb40-00a68f8d2393","dataSourceCredentialName":"testserviceprincipalcredentialf6a62033","dataSourceCredentialDescription":"update","dataSourceCredentialType":"ServicePrincipal","parameters":{"clientId":"update","tenantId":"update"}}' + headers: + apim-request-id: 67527b14-e549-4913-8326-7591a4e1598e + content-length: '277' + content-type: application/json; charset=utf-8 + date: Tue, 25 May 2021 19:02:28 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '533' + x-request-id: 67527b14-e549-4913-8326-7591a4e1598e + status: + code: 200 + message: OK + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/bd197eb4-eea4-484b-bb40-00a68f8d2393 +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/bd197eb4-eea4-484b-bb40-00a68f8d2393 + response: + body: + string: '' + headers: + apim-request-id: 33e0652c-878c-4304-b9c2-f33c291ba7ff + content-length: '0' + date: Tue, 25 May 2021 19:02:29 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '187' + x-request-id: 33e0652c-878c-4304-b9c2-f33c291ba7ff + status: + code: 204 + message: No Content + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/bd197eb4-eea4-484b-bb40-00a68f8d2393 +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_service_principal_in_kv_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_service_principal_in_kv_credential_entity.yaml new file mode 100644 index 000000000000..4b481e17bcd0 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_service_principal_in_kv_credential_entity.yaml @@ -0,0 +1,119 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "ServicePrincipalInKV", "dataSourceCredentialName": + "testserviceprincipalcredentialbfd722a9", "dataSourceCredentialDescription": + "my credential entity", "parameters": {"keyVaultEndpoint": "key_vault_endpoint", + "keyVaultClientId": "key_vault_client_id", "keyVaultClientSecret": "key_vault_client_secret", + "servicePrincipalIdNameInKV": "service_principal_id_name_in_kv", "servicePrincipalSecretNameInKV": + "service_principal_secret_name_in_kv", "tenantId": "tenant_id"}}' + headers: + Accept: + - application/json + Content-Length: + - '496' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: 4a594299-c5d9-471d-9313-7eeb4dcc9ac5 + content-length: '0' + date: Tue, 25 May 2021 19:02:29 GMT + location: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/e47083cf-2610-4fc1-ad0d-f7fca7ca443d + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '480' + x-request-id: 4a594299-c5d9-471d-9313-7eeb4dcc9ac5 + status: + code: 201 + message: Created + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/e47083cf-2610-4fc1-ad0d-f7fca7ca443d + response: + body: + string: '{"dataSourceCredentialId":"e47083cf-2610-4fc1-ad0d-f7fca7ca443d","dataSourceCredentialName":"testserviceprincipalcredentialbfd722a9","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"ServicePrincipalInKV","parameters":{"servicePrincipalSecretNameInKV":"service_principal_secret_name_in_kv","servicePrincipalIdNameInKV":"service_principal_id_name_in_kv","tenantId":"tenant_id","keyVaultClientId":"key_vault_client_id","keyVaultEndpoint":"key_vault_endpoint"}}' + headers: + apim-request-id: 027756e4-42d5-4498-b85e-d9af7b7a6f42 + content-length: '493' + content-type: application/json; charset=utf-8 + date: Tue, 25 May 2021 19:02:29 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '93' + x-request-id: 027756e4-42d5-4498-b85e-d9af7b7a6f42 + status: + code: 200 + message: OK + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/e47083cf-2610-4fc1-ad0d-f7fca7ca443d +- request: + body: '{"dataSourceCredentialType": "ServicePrincipalInKV", "dataSourceCredentialName": + "testserviceprincipalcredentialbfd722a9", "dataSourceCredentialDescription": + "update", "parameters": {"keyVaultEndpoint": "update", "keyVaultClientId": "update", + "keyVaultClientSecret": "update", "servicePrincipalIdNameInKV": "update", "servicePrincipalSecretNameInKV": + "update", "tenantId": "update"}}' + headers: + Accept: + - application/json + Content-Length: + - '383' + Content-Type: + - application/merge-patch+json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: PATCH + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/e47083cf-2610-4fc1-ad0d-f7fca7ca443d + response: + body: + string: '{"dataSourceCredentialId":"e47083cf-2610-4fc1-ad0d-f7fca7ca443d","dataSourceCredentialName":"testserviceprincipalcredentialbfd722a9","dataSourceCredentialDescription":"update","dataSourceCredentialType":"ServicePrincipalInKV","parameters":{"servicePrincipalSecretNameInKV":"update","servicePrincipalIdNameInKV":"update","tenantId":"update","keyVaultClientId":"update","keyVaultEndpoint":"update"}}' + headers: + apim-request-id: a3a957a4-7f28-44aa-930f-7c391e802c22 + content-length: '397' + content-type: application/json; charset=utf-8 + date: Tue, 25 May 2021 19:02:29 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '595' + x-request-id: a3a957a4-7f28-44aa-930f-7c391e802c22 + status: + code: 200 + message: OK + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/e47083cf-2610-4fc1-ad0d-f7fca7ca443d +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/e47083cf-2610-4fc1-ad0d-f7fca7ca443d + response: + body: + string: '' + headers: + apim-request-id: 3ce1a5bb-231a-408b-b49c-2e1a09ebaf79 + content-length: '0' + date: Tue, 25 May 2021 19:02:30 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '176' + x-request-id: 3ce1a5bb-231a-408b-b49c-2e1a09ebaf79 + status: + code: 204 + message: No Content + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/e47083cf-2610-4fc1-ad0d-f7fca7ca443d +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_sql_connection_string_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_sql_connection_string_credential_entity.yaml new file mode 100644 index 000000000000..31a1ab4627cf --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/recordings/test_credential_entities_async.test_update_sql_connection_string_credential_entity.yaml @@ -0,0 +1,114 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "AzureSQLConnectionString", "dataSourceCredentialName": + "testsqlcredential7ded21f6", "dataSourceCredentialDescription": "my credential + entity", "parameters": {"connectionString": "connectionstring"}}' + headers: + Accept: + - application/json + Content-Length: + - '444' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: 03f1ae86-6cef-4afe-948b-6ab4b64976e3 + content-length: '0' + date: Tue, 25 May 2021 19:02:31 GMT + location: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/2f06a2ec-1f2b-499e-98e8-1d87b075f781 + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '471' + x-request-id: 03f1ae86-6cef-4afe-948b-6ab4b64976e3 + status: + code: 201 + message: Created + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/2f06a2ec-1f2b-499e-98e8-1d87b075f781 + response: + body: + string: '{"dataSourceCredentialId":"2f06a2ec-1f2b-499e-98e8-1d87b075f781","dataSourceCredentialName":"testsqlcredential7ded21f6","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"AzureSQLConnectionString","parameters":{}}' + headers: + apim-request-id: 58d9a567-55a3-466c-84a6-4ad9c8f81fee + content-length: '247' + content-type: application/json; charset=utf-8 + date: Tue, 25 May 2021 19:02:31 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '82' + x-request-id: 58d9a567-55a3-466c-84a6-4ad9c8f81fee + status: + code: 200 + message: OK + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/2f06a2ec-1f2b-499e-98e8-1d87b075f781 +- request: + body: '{"dataSourceCredentialType": "AzureSQLConnectionString", "dataSourceCredentialName": + "testsqlcredential7ded21f6", "dataSourceCredentialDescription": "update", "parameters": + {"connectionString": "update"}}' + headers: + Accept: + - application/json + Content-Length: + - '204' + Content-Type: + - application/merge-patch+json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: PATCH + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/2f06a2ec-1f2b-499e-98e8-1d87b075f781 + response: + body: + string: '{"dataSourceCredentialId":"2f06a2ec-1f2b-499e-98e8-1d87b075f781","dataSourceCredentialName":"testsqlcredential7ded21f6","dataSourceCredentialDescription":"update","dataSourceCredentialType":"AzureSQLConnectionString","parameters":{}}' + headers: + apim-request-id: c0d4487f-bc1e-46d3-a1bd-90799068a920 + content-length: '233' + content-type: application/json; charset=utf-8 + date: Tue, 25 May 2021 19:02:32 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '533' + x-request-id: c0d4487f-bc1e-46d3-a1bd-90799068a920 + status: + code: 200 + message: OK + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/2f06a2ec-1f2b-499e-98e8-1d87b075f781 +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/2f06a2ec-1f2b-499e-98e8-1d87b075f781 + response: + body: + string: '' + headers: + apim-request-id: 5886fefe-c0cc-4d64-a878-69e2bd7d08b8 + content-length: '0' + date: Tue, 25 May 2021 19:02:32 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '178' + x-request-id: 5886fefe-c0cc-4d64-a878-69e2bd7d08b8 + status: + code: 204 + message: No Content + url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/credentials/2f06a2ec-1f2b-499e-98e8-1d87b075f781 +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/test_credential_entities_async.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/test_credential_entities_async.py new file mode 100644 index 000000000000..8969cfb70453 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/async_tests/test_credential_entities_async.py @@ -0,0 +1,209 @@ +# 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. +# -------------------------------------------------------------------------- + +import pytest +from devtools_testutils import AzureTestCase + +from azure.ai.metricsadvisor.models import ( + SQLConnectionStringCredentialEntity, + DataLakeGen2SharedKeyCredentialEntity, + ServicePrincipalCredentialEntity, + ServicePrincipalInKVCredentialEntity +) +from base_testcase_async import TestMetricsAdvisorAdministrationClientBaseAsync + + +class TestMetricsAdvisorAdministrationClient(TestMetricsAdvisorAdministrationClientBaseAsync): + + @AzureTestCase.await_prepared_test + async def test_create_sql_connection_string_credential_entity(self): + credential_entity_name = self.create_random_name("testsqlcredential") + async with self.admin_client: + try: + credential_entity = await self.admin_client.create_credential_entity( + credential_entity=SQLConnectionStringCredentialEntity( + name=credential_entity_name, + connection_string=self.sql_server_connection_string, + description="my credential entity", + ) + ) + self.assertIsNotNone(credential_entity.id) + self.assertEqual(credential_entity.name, credential_entity_name) + self.assertEqual(credential_entity.credential_entity_type, 'AzureSQLConnectionString') + finally: + await self.admin_client.delete_credential_entity(credential_entity.id) + + @AzureTestCase.await_prepared_test + async def test_datalake_gen2_shared_key_credential_entity(self): + credential_entity_name = self.create_random_name("testdatalakecredential") + async with self.admin_client: + try: + credential_entity = await self.admin_client.create_credential_entity( + credential_entity=DataLakeGen2SharedKeyCredentialEntity( + name=credential_entity_name, + account_key=self.azure_datalake_account_key, + description="my credential entity", + ) + ) + self.assertIsNotNone(credential_entity.id) + self.assertEqual(credential_entity.name, credential_entity_name) + self.assertEqual(credential_entity.credential_entity_type, 'DataLakeGen2SharedKey') + finally: + await self.admin_client.delete_credential_entity(credential_entity.id) + + @AzureTestCase.await_prepared_test + async def test_service_principal_credential_entity(self): + credential_entity_name = self.create_random_name("testserviceprincipalcredential") + async with self.admin_client: + try: + credential_entity = await self.admin_client.create_credential_entity( + credential_entity=ServicePrincipalCredentialEntity( + name=credential_entity_name, + client_id="client_id", + client_secret="client_secret", + tenant_id="tenant_id", + description="my credential entity", + ) + ) + self.assertIsNotNone(credential_entity.id) + self.assertEqual(credential_entity.name, credential_entity_name) + self.assertEqual(credential_entity.credential_entity_type, 'ServicePrincipal') + finally: + await self.admin_client.delete_credential_entity(credential_entity.id) + + @AzureTestCase.await_prepared_test + async def test_service_principal_in_kv_credential_entity(self): + credential_entity_name = self.create_random_name("testserviceprincipalcredential") + async with self.admin_client: + try: + credential_entity = await self.admin_client.create_credential_entity( + credential_entity=ServicePrincipalInKVCredentialEntity( + name=credential_entity_name, + key_vault_endpoint="key_vault_endpoint", + key_vault_client_id="key_vault_client_id", + key_vault_client_secret="key_vault_client_secret", + service_principal_id_name_in_kv="service_principal_id_name_in_kv", + service_principal_secret_name_in_kv="service_principal_secret_name_in_kv", + tenant_id="tenant_id", + description="my credential entity", + ) + ) + self.assertIsNotNone(credential_entity.id) + self.assertEqual(credential_entity.name, credential_entity_name) + self.assertEqual(credential_entity.credential_entity_type, 'ServicePrincipalInKV') + finally: + await self.admin_client.delete_credential_entity(credential_entity.id) + + @AzureTestCase.await_prepared_test + async def test_list_credential_entities(self): + credential_entity_name = self.create_random_name("testsqlcredential") + async with self.admin_client: + try: + credential_entity = await self.admin_client.create_credential_entity( + credential_entity=SQLConnectionStringCredentialEntity( + name=credential_entity_name, + connection_string=self.sql_server_connection_string, + description="my credential entity", + ) + ) + credential_entities = self.admin_client.list_credential_entities() + credential_entities_list = [] + async for credential_entity in credential_entities: + credential_entities_list.append(credential_entity) + assert len(credential_entities_list) > 0 + finally: + await self.admin_client.delete_credential_entity(credential_entity.id) + + @AzureTestCase.await_prepared_test + async def test_update_sql_connection_string_credential_entity(self): + credential_entity_name = self.create_random_name("testsqlcredential") + async with self.admin_client: + try: + credential_entity = await self.admin_client.create_credential_entity( + credential_entity=SQLConnectionStringCredentialEntity( + name=credential_entity_name, + connection_string=self.sql_server_connection_string, + description="my credential entity", + ) + ) + credential_entity.connection_string = "update" + credential_entity.description = "update" + credential_entity_updated = await self.admin_client.update_credential_entity(credential_entity) + self.assertEqual(credential_entity_updated.description, "update") + finally: + await self.admin_client.delete_credential_entity(credential_entity.id) + + @AzureTestCase.await_prepared_test + async def test_update_datalake_gen2_shared_key_credential_entity(self): + credential_entity_name = self.create_random_name("testdatalakecredential") + async with self.admin_client: + try: + credential_entity = await self.admin_client.create_credential_entity( + credential_entity=DataLakeGen2SharedKeyCredentialEntity( + name=credential_entity_name, + account_key=self.azure_datalake_account_key, + description="my credential entity", + ) + ) + credential_entity.account_key = "update" + credential_entity.description = "update" + credential_entity_updated = await self.admin_client.update_credential_entity(credential_entity) + self.assertEqual(credential_entity_updated.description, "update") + finally: + await self.admin_client.delete_credential_entity(credential_entity.id) + + @AzureTestCase.await_prepared_test + async def test_update_service_principal_credential_entity(self): + credential_entity_name = self.create_random_name("testserviceprincipalcredential") + async with self.admin_client: + try: + credential_entity = await self.admin_client.create_credential_entity( + credential_entity=ServicePrincipalCredentialEntity( + name=credential_entity_name, + client_id="client_id", + client_secret="client_secret", + tenant_id="tenant_id", + description="my credential entity", + ) + ) + credential_entity.client_id = "update" + credential_entity.client_secret = "update" + credential_entity.tenant_id = "update" + credential_entity.description = "update" + credential_entity_updated = await self.admin_client.update_credential_entity(credential_entity) + self.assertEqual(credential_entity_updated.description, "update") + finally: + await self.admin_client.delete_credential_entity(credential_entity.id) + + @AzureTestCase.await_prepared_test + async def test_update_service_principal_in_kv_credential_entity(self): + credential_entity_name = self.create_random_name("testserviceprincipalcredential") + async with self.admin_client: + try: + credential_entity = await self.admin_client.create_credential_entity( + credential_entity=ServicePrincipalInKVCredentialEntity( + name=credential_entity_name, + key_vault_endpoint="key_vault_endpoint", + key_vault_client_id="key_vault_client_id", + key_vault_client_secret="key_vault_client_secret", + service_principal_id_name_in_kv="service_principal_id_name_in_kv", + service_principal_secret_name_in_kv="service_principal_secret_name_in_kv", + tenant_id="tenant_id", + description="my credential entity", + ) + ) + credential_entity.key_vault_endpoint = "update" + credential_entity.key_vault_client_id = "update" + credential_entity.key_vault_client_secret = "update" + credential_entity.service_principal_id_name_in_kv = "update" + credential_entity.service_principal_secret_name_in_kv = "update" + credential_entity.tenant_id = "update" + credential_entity.description = "update" + credential_entity_updated = await self.admin_client.update_credential_entity(credential_entity) + self.assertEqual(credential_entity_updated.description, "update") + finally: + await self.admin_client.delete_credential_entity(credential_entity.id) diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/base_testcase.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/base_testcase.py index a0dadbf74128..f67f85581511 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/base_testcase.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/base_testcase.py @@ -59,8 +59,6 @@ def __init__(self, method_name): self.azure_table_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_TABLE_CONNECTION_STRING") self.azure_blob_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_BLOB_CONNECTION_STRING") self.azure_cosmosdb_connection_string = self.get_settings_value("METRICS_ADVISOR_COSMOS_DB_CONNECTION_STRING") - self.http_request_get_url = self.get_settings_value("METRICS_ADVISOR_HTTP_GET_URL") - self.http_request_post_url = self.get_settings_value("METRICS_ADVISOR_HTTP_POST_URL") self.application_insights_api_key = self.get_settings_value("METRICS_ADVISOR_APPLICATION_INSIGHTS_API_KEY") self.azure_data_explorer_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_DATA_EXPLORER_CONNECTION_STRING") self.influxdb_connection_string = self.get_settings_value("METRICS_ADVISOR_INFLUX_DB_CONNECTION_STRING") @@ -69,7 +67,6 @@ def __init__(self, method_name): self.mongodb_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_MONGO_DB_CONNECTION_STRING") self.mysql_connection_string = self.get_settings_value("METRICS_ADVISOR_MYSQL_CONNECTION_STRING") self.postgresql_connection_string = self.get_settings_value("METRICS_ADVISOR_POSTGRESQL_CONNECTION_STRING") - self.elasticsearch_auth_header = self.get_settings_value("METRICS_ADVISOR_ELASTICSEARCH_AUTH_HEADER") self.anomaly_detection_configuration_id = self.get_settings_value("METRICS_ADVISOR_ANOMALY_DETECTION_CONFIGURATION_ID") self.data_feed_id = self.get_settings_value("METRICS_ADVISOR_DATA_FEED_ID") self.metric_id = self.get_settings_value("METRICS_ADVISOR_METRIC_ID") @@ -89,14 +86,6 @@ def __init__(self, method_name): self.azure_cosmosdb_connection_string, "connectionstring" ) - self.scrubber.register_name_pair( - self.http_request_get_url, - "connectionstring" - ) - self.scrubber.register_name_pair( - self.http_request_post_url, - "connectionstring" - ) self.scrubber.register_name_pair( self.application_insights_api_key, "connectionstring" @@ -129,11 +118,6 @@ def __init__(self, method_name): self.postgresql_connection_string, "connectionstring" ) - self.scrubber.register_name_pair( - self.elasticsearch_auth_header, - "connectionstring" - ) - self.scrubber.register_name_pair( self.metric_id, "metric_id" @@ -154,8 +138,6 @@ def __init__(self, method_name): self.azure_table_connection_string = "AZURE_TABLE_CONNECTION_STRING" self.azure_blob_connection_string = "AZURE_BLOB_CONNECTION_STRING" self.azure_cosmosdb_connection_string = "COSMOS_DB_CONNECTION_STRING" - self.http_request_get_url = "METRICS_ADVISOR_HTTP_GET_URL" - self.http_request_post_url = "METRICS_ADVISOR_HTTP_POST_URL" self.application_insights_api_key = "METRICS_ADVISOR_APPLICATION_INSIGHTS_API_KEY" self.azure_data_explorer_connection_string = "METRICS_ADVISOR_AZURE_DATA_EXPLORER_CONNECTION_STRING" self.influxdb_connection_string = "METRICS_ADVISOR_INFLUXDB_CONNECTION_STRING" @@ -164,7 +146,6 @@ def __init__(self, method_name): self.mongodb_connection_string = "METRICS_ADVISOR_AZURE_MONGODB_CONNECTION_STRING" self.mysql_connection_string = "METRICS_ADVISOR_MYSQL_CONNECTION_STRING" self.postgresql_connection_string = "METRICS_ADVISOR_POSTGRESQL_CONNECTION_STRING" - self.elasticsearch_auth_header = "METRICS_ADVISOR_ELASTICSEARCH_AUTH" self.anomaly_detection_configuration_id = "anomaly_detection_configuration_id" self.metric_id = "metric_id" self.data_feed_id = "data_feed_id" diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/base_testcase_aad.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/base_testcase_aad.py index 87907cd0df29..5c63e69e5bd4 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/base_testcase_aad.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/base_testcase_aad.py @@ -62,8 +62,6 @@ def __init__(self, method_name): self.azure_table_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_TABLE_CONNECTION_STRING") self.azure_blob_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_BLOB_CONNECTION_STRING") self.azure_cosmosdb_connection_string = self.get_settings_value("METRICS_ADVISOR_COSMOS_DB_CONNECTION_STRING") - self.http_request_get_url = self.get_settings_value("METRICS_ADVISOR_HTTP_GET_URL") - self.http_request_post_url = self.get_settings_value("METRICS_ADVISOR_HTTP_POST_URL") self.application_insights_api_key = self.get_settings_value("METRICS_ADVISOR_APPLICATION_INSIGHTS_API_KEY") self.azure_data_explorer_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_DATA_EXPLORER_CONNECTION_STRING") self.influxdb_connection_string = self.get_settings_value("METRICS_ADVISOR_INFLUX_DB_CONNECTION_STRING") @@ -72,7 +70,6 @@ def __init__(self, method_name): self.mongodb_connection_string = self.get_settings_value("METRICS_ADVISOR_AZURE_MONGO_DB_CONNECTION_STRING") self.mysql_connection_string = self.get_settings_value("METRICS_ADVISOR_MYSQL_CONNECTION_STRING") self.postgresql_connection_string = self.get_settings_value("METRICS_ADVISOR_POSTGRESQL_CONNECTION_STRING") - self.elasticsearch_auth_header = self.get_settings_value("METRICS_ADVISOR_ELASTICSEARCH_AUTH_HEADER") self.anomaly_detection_configuration_id = self.get_settings_value("METRICS_ADVISOR_ANOMALY_DETECTION_CONFIGURATION_ID") self.data_feed_id = self.get_settings_value("METRICS_ADVISOR_DATA_FEED_ID") self.metric_id = self.get_settings_value("METRICS_ADVISOR_METRIC_ID") @@ -93,14 +90,6 @@ def __init__(self, method_name): self.azure_cosmosdb_connection_string, "connectionstring" ) - self.scrubber.register_name_pair( - self.http_request_get_url, - "connectionstring" - ) - self.scrubber.register_name_pair( - self.http_request_post_url, - "connectionstring" - ) self.scrubber.register_name_pair( self.application_insights_api_key, "connectionstring" @@ -133,11 +122,6 @@ def __init__(self, method_name): self.postgresql_connection_string, "connectionstring" ) - self.scrubber.register_name_pair( - self.elasticsearch_auth_header, - "connectionstring" - ) - self.scrubber.register_name_pair( self.metric_id, "metric_id" @@ -156,8 +140,6 @@ def __init__(self, method_name): self.azure_table_connection_string = "AZURE_TABLE_CONNECTION_STRING" self.azure_blob_connection_string = "AZURE_BLOB_CONNECTION_STRING" self.azure_cosmosdb_connection_string = "COSMOS_DB_CONNECTION_STRING" - self.http_request_get_url = "METRICS_ADVISOR_HTTP_GET_URL" - self.http_request_post_url = "METRICS_ADVISOR_HTTP_POST_URL" self.application_insights_api_key = "METRICS_ADVISOR_APPLICATION_INSIGHTS_API_KEY" self.azure_data_explorer_connection_string = "METRICS_ADVISOR_AZURE_DATA_EXPLORER_CONNECTION_STRING" self.influxdb_connection_string = "METRICS_ADVISOR_INFLUXDB_CONNECTION_STRING" @@ -166,7 +148,6 @@ def __init__(self, method_name): self.mongodb_connection_string = "METRICS_ADVISOR_AZURE_MONGODB_CONNECTION_STRING" self.mysql_connection_string = "METRICS_ADVISOR_MYSQL_CONNECTION_STRING" self.postgresql_connection_string = "METRICS_ADVISOR_POSTGRESQL_CONNECTION_STRING" - self.elasticsearch_auth_header = "METRICS_ADVISOR_ELASTICSEARCH_AUTH" self.anomaly_detection_configuration_id = "anomaly_detection_configuration_id" self.metric_id = "metric_id" self.data_feed_id = "data_feed_id" diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_create_sql_connection_string_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_create_sql_connection_string_credential_entity.yaml new file mode 100644 index 000000000000..586bfdeb3d58 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_create_sql_connection_string_credential_entity.yaml @@ -0,0 +1,117 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "AzureSQLConnectionString", "dataSourceCredentialName": + "testsqlcredentialb5351f6a", "dataSourceCredentialDescription": "my credential + entity", "parameters": {"connectionString": "connectionstring"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '444' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - 0aa0b14e-1406-4d29-acf6-982b062aef26 + content-length: + - '0' + date: + - Tue, 25 May 2021 18:08:29 GMT + location: + - https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/d255d3a3-24c3-48db-87ad-bcb838fbe94f + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '833' + x-request-id: + - 0aa0b14e-1406-4d29-acf6-982b062aef26 + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/d255d3a3-24c3-48db-87ad-bcb838fbe94f + response: + body: + string: '{"dataSourceCredentialId":"d255d3a3-24c3-48db-87ad-bcb838fbe94f","dataSourceCredentialName":"testsqlcredentialb5351f6a","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"AzureSQLConnectionString","parameters":{}}' + headers: + apim-request-id: + - ba05948a-eb2a-4e7a-a971-128589dbfa88 + content-length: + - '247' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 25 May 2021 18:08:29 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '122' + x-request-id: + - ba05948a-eb2a-4e7a-a971-128589dbfa88 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/d255d3a3-24c3-48db-87ad-bcb838fbe94f + response: + body: + string: '' + headers: + apim-request-id: + - cb4dd7d0-2790-4473-9a8a-81f2472d65d9 + content-length: + - '0' + date: + - Tue, 25 May 2021 18:08:29 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '256' + x-request-id: + - cb4dd7d0-2790-4473-9a8a-81f2472d65d9 + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_datalake_gen2_shared_key_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_datalake_gen2_shared_key_credential_entity.yaml new file mode 100644 index 000000000000..a5570ed9756e --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_datalake_gen2_shared_key_credential_entity.yaml @@ -0,0 +1,117 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "DataLakeGen2SharedKey", "dataSourceCredentialName": + "testdatalakecredential2b901d42", "dataSourceCredentialDescription": "my credential + entity", "parameters": {"accountKey": "connectionstring"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '296' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - cf63f5df-4f21-4ecc-87a8-a61a2f696a89 + content-length: + - '0' + date: + - Tue, 25 May 2021 19:25:45 GMT + location: + - https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/9a893101-884c-47de-a828-790d69682995 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '350' + x-request-id: + - cf63f5df-4f21-4ecc-87a8-a61a2f696a89 + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/9a893101-884c-47de-a828-790d69682995 + response: + body: + string: '{"dataSourceCredentialId":"9a893101-884c-47de-a828-790d69682995","dataSourceCredentialName":"testdatalakecredential2b901d42","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"DataLakeGen2SharedKey","parameters":{}}' + headers: + apim-request-id: + - dad809dd-669e-4056-9f5e-10f647f431de + content-length: + - '249' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 25 May 2021 19:25:51 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '5134' + x-request-id: + - dad809dd-669e-4056-9f5e-10f647f431de + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/9a893101-884c-47de-a828-790d69682995 + response: + body: + string: '' + headers: + apim-request-id: + - e60db2c5-4716-43d7-82e4-9feb15044e8c + content-length: + - '0' + date: + - Tue, 25 May 2021 19:25:56 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '5340' + x-request-id: + - e60db2c5-4716-43d7-82e4-9feb15044e8c + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_list_credential_entities.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_list_credential_entities.yaml new file mode 100644 index 000000000000..090f63424be1 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_list_credential_entities.yaml @@ -0,0 +1,154 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "AzureSQLConnectionString", "dataSourceCredentialName": + "testsqlcredential64061646", "dataSourceCredentialDescription": "my credential + entity", "parameters": {"connectionString": "connectionstring"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '444' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - df49b8ca-a640-4feb-add0-b4c1fd941fb0 + content-length: + - '0' + date: + - Tue, 25 May 2021 18:21:07 GMT + location: + - https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/21d11799-9b18-4cdc-8d48-1a39a7d50d52 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '651' + x-request-id: + - df49b8ca-a640-4feb-add0-b4c1fd941fb0 + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/21d11799-9b18-4cdc-8d48-1a39a7d50d52 + response: + body: + string: '{"dataSourceCredentialId":"21d11799-9b18-4cdc-8d48-1a39a7d50d52","dataSourceCredentialName":"testsqlcredential64061646","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"AzureSQLConnectionString","parameters":{}}' + headers: + apim-request-id: + - 97116af5-e2a2-48c5-9f5d-44da28765d01 + content-length: + - '247' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 25 May 2021 18:21:07 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '86' + x-request-id: + - 97116af5-e2a2-48c5-9f5d-44da28765d01 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '{"value":[{"dataSourceCredentialId":"21d11799-9b18-4cdc-8d48-1a39a7d50d52","dataSourceCredentialName":"testsqlcredential64061646","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"AzureSQLConnectionString","parameters":{}}],"@nextLink":null}' + headers: + apim-request-id: + - 7177def8-cde5-4267-8746-9ba123f3e3e1 + content-length: + - '276' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 25 May 2021 18:21:08 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '99' + x-request-id: + - 7177def8-cde5-4267-8746-9ba123f3e3e1 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/21d11799-9b18-4cdc-8d48-1a39a7d50d52 + response: + body: + string: '' + headers: + apim-request-id: + - 13ed7d19-ea36-41b0-af73-b5ec0ddca71c + content-length: + - '0' + date: + - Tue, 25 May 2021 18:21:08 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '180' + x-request-id: + - 13ed7d19-ea36-41b0-af73-b5ec0ddca71c + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_service_principal_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_service_principal_credential_entity.yaml new file mode 100644 index 000000000000..33041ffe476d --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_service_principal_credential_entity.yaml @@ -0,0 +1,118 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "ServicePrincipal", "dataSourceCredentialName": + "testserviceprincipalcredential73ce1ad4", "dataSourceCredentialDescription": + "my credential entity", "parameters": {"clientId": "client_id", "clientSecret": + "client_secret", "tenantId": "tenant_id"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '276' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - 199edd85-62ef-4ee4-a3b6-5ee869643981 + content-length: + - '0' + date: + - Tue, 25 May 2021 18:12:41 GMT + location: + - https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/9b187da5-52df-4ebf-8970-ebe90989cca2 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '597' + x-request-id: + - 199edd85-62ef-4ee4-a3b6-5ee869643981 + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/9b187da5-52df-4ebf-8970-ebe90989cca2 + response: + body: + string: '{"dataSourceCredentialId":"9b187da5-52df-4ebf-8970-ebe90989cca2","dataSourceCredentialName":"testserviceprincipalcredential73ce1ad4","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"ServicePrincipal","parameters":{"clientId":"client_id","tenantId":"tenant_id"}}' + headers: + apim-request-id: + - a46ebc74-ff17-475f-968e-6470f10b7d39 + content-length: + - '297' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 25 May 2021 18:12:41 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '157' + x-request-id: + - a46ebc74-ff17-475f-968e-6470f10b7d39 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/9b187da5-52df-4ebf-8970-ebe90989cca2 + response: + body: + string: '' + headers: + apim-request-id: + - 836aa6df-26b0-4bc4-9afd-f244850b5dbc + content-length: + - '0' + date: + - Tue, 25 May 2021 18:12:42 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '239' + x-request-id: + - 836aa6df-26b0-4bc4-9afd-f244850b5dbc + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_service_principal_in_kv_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_service_principal_in_kv_credential_entity.yaml new file mode 100644 index 000000000000..c61bab2d1411 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_service_principal_in_kv_credential_entity.yaml @@ -0,0 +1,120 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "ServicePrincipalInKV", "dataSourceCredentialName": + "testserviceprincipalcredential1cc51d4a", "dataSourceCredentialDescription": + "my credential entity", "parameters": {"keyVaultEndpoint": "key_vault_endpoint", + "keyVaultClientId": "key_vault_client_id", "keyVaultClientSecret": "key_vault_client_secret", + "servicePrincipalIdNameInKV": "service_principal_id_name_in_kv", "servicePrincipalSecretNameInKV": + "service_principal_secret_name_in_kv", "tenantId": "tenant_id"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '496' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - ee023242-6bd3-4907-8ae5-de5e0b38c11e + content-length: + - '0' + date: + - Tue, 25 May 2021 18:15:31 GMT + location: + - https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/a35a1ee8-8116-41f6-a46c-0a1904ae89c9 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '590' + x-request-id: + - ee023242-6bd3-4907-8ae5-de5e0b38c11e + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/a35a1ee8-8116-41f6-a46c-0a1904ae89c9 + response: + body: + string: '{"dataSourceCredentialId":"a35a1ee8-8116-41f6-a46c-0a1904ae89c9","dataSourceCredentialName":"testserviceprincipalcredential1cc51d4a","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"ServicePrincipalInKV","parameters":{"servicePrincipalSecretNameInKV":"service_principal_secret_name_in_kv","servicePrincipalIdNameInKV":"service_principal_id_name_in_kv","tenantId":"tenant_id","keyVaultClientId":"key_vault_client_id","keyVaultEndpoint":"key_vault_endpoint"}}' + headers: + apim-request-id: + - 1fb2d8b5-202b-42e4-8e2d-c4ee85456e47 + content-length: + - '493' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 25 May 2021 18:15:31 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '71' + x-request-id: + - 1fb2d8b5-202b-42e4-8e2d-c4ee85456e47 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/a35a1ee8-8116-41f6-a46c-0a1904ae89c9 + response: + body: + string: '' + headers: + apim-request-id: + - 511d2943-2014-412f-aea2-eb8ab72c374e + content-length: + - '0' + date: + - Tue, 25 May 2021 18:15:31 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '195' + x-request-id: + - 511d2943-2014-412f-aea2-eb8ab72c374e + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_datalake_gen2_shared_key_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_datalake_gen2_shared_key_credential_entity.yaml new file mode 100644 index 000000000000..95e992ebbd66 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_datalake_gen2_shared_key_credential_entity.yaml @@ -0,0 +1,159 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "DataLakeGen2SharedKey", "dataSourceCredentialName": + "testdatalakecredential6972024", "dataSourceCredentialDescription": "my credential + entity", "parameters": {"accountKey": "connectionstring"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '295' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - 46b94533-723d-45cb-b1b9-033e67acfe43 + content-length: + - '0' + date: + - Tue, 25 May 2021 18:43:05 GMT + location: + - https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/78baa623-70fc-444e-9b18-831b819d2763 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '2436' + x-request-id: + - 46b94533-723d-45cb-b1b9-033e67acfe43 + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/78baa623-70fc-444e-9b18-831b819d2763 + response: + body: + string: '{"dataSourceCredentialId":"78baa623-70fc-444e-9b18-831b819d2763","dataSourceCredentialName":"testdatalakecredential6972024","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"DataLakeGen2SharedKey","parameters":{}}' + headers: + apim-request-id: + - ee866c3c-302f-4972-b431-ce540c1fa7f6 + content-length: + - '248' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 25 May 2021 18:43:05 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '97' + x-request-id: + - ee866c3c-302f-4972-b431-ce540c1fa7f6 + status: + code: 200 + message: OK +- request: + body: '{"dataSourceCredentialType": "DataLakeGen2SharedKey", "dataSourceCredentialName": + "testdatalakecredential6972024", "dataSourceCredentialDescription": "update", + "parameters": {"accountKey": "update"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '199' + Content-Type: + - application/merge-patch+json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: PATCH + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/78baa623-70fc-444e-9b18-831b819d2763 + response: + body: + string: '{"dataSourceCredentialId":"78baa623-70fc-444e-9b18-831b819d2763","dataSourceCredentialName":"testdatalakecredential6972024","dataSourceCredentialDescription":"update","dataSourceCredentialType":"DataLakeGen2SharedKey","parameters":{}}' + headers: + apim-request-id: + - df5e30fb-94ab-4304-b6d5-7692b7cf2c5d + content-length: + - '234' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 25 May 2021 18:43:08 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '2077' + x-request-id: + - df5e30fb-94ab-4304-b6d5-7692b7cf2c5d + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/78baa623-70fc-444e-9b18-831b819d2763 + response: + body: + string: '' + headers: + apim-request-id: + - feb51a54-438d-4cd9-a3cb-1401a13d7149 + content-length: + - '0' + date: + - Tue, 25 May 2021 18:43:09 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '209' + x-request-id: + - feb51a54-438d-4cd9-a3cb-1401a13d7149 + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_service_principal_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_service_principal_credential_entity.yaml new file mode 100644 index 000000000000..f7d24b38894b --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_service_principal_credential_entity.yaml @@ -0,0 +1,161 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "ServicePrincipal", "dataSourceCredentialName": + "testserviceprincipalcredential3aa71db6", "dataSourceCredentialDescription": + "my credential entity", "parameters": {"clientId": "client_id", "clientSecret": + "client_secret", "tenantId": "tenant_id"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '276' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - 9dc3af57-c07d-43fa-b877-265aa5d78422 + content-length: + - '0' + date: + - Tue, 25 May 2021 18:44:03 GMT + location: + - https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/a088de08-7397-4483-9dad-c29268721f1c + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '389' + x-request-id: + - 9dc3af57-c07d-43fa-b877-265aa5d78422 + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/a088de08-7397-4483-9dad-c29268721f1c + response: + body: + string: '{"dataSourceCredentialId":"a088de08-7397-4483-9dad-c29268721f1c","dataSourceCredentialName":"testserviceprincipalcredential3aa71db6","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"ServicePrincipal","parameters":{"clientId":"client_id","tenantId":"tenant_id"}}' + headers: + apim-request-id: + - 8065bb1f-43b6-4675-9edc-49f7c51f6d44 + content-length: + - '297' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 25 May 2021 18:44:04 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '79' + x-request-id: + - 8065bb1f-43b6-4675-9edc-49f7c51f6d44 + status: + code: 200 + message: OK +- request: + body: '{"dataSourceCredentialType": "ServicePrincipal", "dataSourceCredentialName": + "testserviceprincipalcredential3aa71db6", "dataSourceCredentialDescription": + "update", "parameters": {"clientId": "update", "clientSecret": "update", "tenantId": + "update"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '249' + Content-Type: + - application/merge-patch+json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: PATCH + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/a088de08-7397-4483-9dad-c29268721f1c + response: + body: + string: '{"dataSourceCredentialId":"a088de08-7397-4483-9dad-c29268721f1c","dataSourceCredentialName":"testserviceprincipalcredential3aa71db6","dataSourceCredentialDescription":"update","dataSourceCredentialType":"ServicePrincipal","parameters":{"clientId":"update","tenantId":"update"}}' + headers: + apim-request-id: + - be6b658e-f978-4568-9535-353b19b5a3dd + content-length: + - '277' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 25 May 2021 18:44:04 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '416' + x-request-id: + - be6b658e-f978-4568-9535-353b19b5a3dd + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/a088de08-7397-4483-9dad-c29268721f1c + response: + body: + string: '' + headers: + apim-request-id: + - 25d5ef87-8669-4b51-a4d8-204ddb72b965 + content-length: + - '0' + date: + - Tue, 25 May 2021 18:44:04 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '166' + x-request-id: + - 25d5ef87-8669-4b51-a4d8-204ddb72b965 + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_service_principal_in_kv_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_service_principal_in_kv_credential_entity.yaml new file mode 100644 index 000000000000..7bd15d3d86a4 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_service_principal_in_kv_credential_entity.yaml @@ -0,0 +1,164 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "ServicePrincipalInKV", "dataSourceCredentialName": + "testserviceprincipalcredentialf4db202c", "dataSourceCredentialDescription": + "my credential entity", "parameters": {"keyVaultEndpoint": "key_vault_endpoint", + "keyVaultClientId": "key_vault_client_id", "keyVaultClientSecret": "key_vault_client_secret", + "servicePrincipalIdNameInKV": "service_principal_id_name_in_kv", "servicePrincipalSecretNameInKV": + "service_principal_secret_name_in_kv", "tenantId": "tenant_id"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '496' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - 19d01405-0eba-4de3-a22a-252c10aeec1b + content-length: + - '0' + date: + - Tue, 25 May 2021 18:45:39 GMT + location: + - https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/46019494-bad1-4e70-a414-4354897f8c64 + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '5482' + x-request-id: + - 19d01405-0eba-4de3-a22a-252c10aeec1b + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/46019494-bad1-4e70-a414-4354897f8c64 + response: + body: + string: '{"dataSourceCredentialId":"46019494-bad1-4e70-a414-4354897f8c64","dataSourceCredentialName":"testserviceprincipalcredentialf4db202c","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"ServicePrincipalInKV","parameters":{"servicePrincipalSecretNameInKV":"service_principal_secret_name_in_kv","servicePrincipalIdNameInKV":"service_principal_id_name_in_kv","tenantId":"tenant_id","keyVaultClientId":"key_vault_client_id","keyVaultEndpoint":"key_vault_endpoint"}}' + headers: + apim-request-id: + - c7119bb4-e887-4e5e-ae86-f0fc46d7449b + content-length: + - '493' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 25 May 2021 18:45:39 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '122' + x-request-id: + - c7119bb4-e887-4e5e-ae86-f0fc46d7449b + status: + code: 200 + message: OK +- request: + body: '{"dataSourceCredentialType": "ServicePrincipalInKV", "dataSourceCredentialName": + "testserviceprincipalcredentialf4db202c", "dataSourceCredentialDescription": + "update", "parameters": {"keyVaultEndpoint": "update", "keyVaultClientId": "update", + "keyVaultClientSecret": "update", "servicePrincipalIdNameInKV": "update", "servicePrincipalSecretNameInKV": + "update", "tenantId": "update"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '383' + Content-Type: + - application/merge-patch+json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: PATCH + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/46019494-bad1-4e70-a414-4354897f8c64 + response: + body: + string: '{"dataSourceCredentialId":"46019494-bad1-4e70-a414-4354897f8c64","dataSourceCredentialName":"testserviceprincipalcredentialf4db202c","dataSourceCredentialDescription":"update","dataSourceCredentialType":"ServicePrincipalInKV","parameters":{"servicePrincipalSecretNameInKV":"update","servicePrincipalIdNameInKV":"update","tenantId":"update","keyVaultClientId":"update","keyVaultEndpoint":"update"}}' + headers: + apim-request-id: + - 882132ee-e4fa-4ed6-9e30-f2487aacc94c + content-length: + - '397' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 25 May 2021 18:45:40 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '537' + x-request-id: + - 882132ee-e4fa-4ed6-9e30-f2487aacc94c + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/46019494-bad1-4e70-a414-4354897f8c64 + response: + body: + string: '' + headers: + apim-request-id: + - b7ca6ff3-5363-4b61-a0fa-b821b4e16216 + content-length: + - '0' + date: + - Tue, 25 May 2021 18:45:40 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '216' + x-request-id: + - b7ca6ff3-5363-4b61-a0fa-b821b4e16216 + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_sql_connection_string_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_sql_connection_string_credential_entity.yaml new file mode 100644 index 000000000000..e2a1bc86821d --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities.test_update_sql_connection_string_credential_entity.yaml @@ -0,0 +1,159 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "AzureSQLConnectionString", "dataSourceCredentialName": + "testsqlcredentialb7eb1f79", "dataSourceCredentialDescription": "my credential + entity", "parameters": {"connectionString": "connectionstring"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '444' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - f6f3d1d3-0908-41ff-a6dd-032af1bd32ed + content-length: + - '0' + date: + - Tue, 25 May 2021 18:25:30 GMT + location: + - https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/9eb66b80-f1ab-462c-bc5f-4b8bcf3501bc + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '651' + x-request-id: + - f6f3d1d3-0908-41ff-a6dd-032af1bd32ed + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/9eb66b80-f1ab-462c-bc5f-4b8bcf3501bc + response: + body: + string: '{"dataSourceCredentialId":"9eb66b80-f1ab-462c-bc5f-4b8bcf3501bc","dataSourceCredentialName":"testsqlcredentialb7eb1f79","dataSourceCredentialDescription":"my + credential entity","dataSourceCredentialType":"AzureSQLConnectionString","parameters":{}}' + headers: + apim-request-id: + - 6b337ecd-0187-43aa-b77e-6704e2886e42 + content-length: + - '247' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 25 May 2021 18:25:30 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '82' + x-request-id: + - 6b337ecd-0187-43aa-b77e-6704e2886e42 + status: + code: 200 + message: OK +- request: + body: '{"dataSourceCredentialType": "AzureSQLConnectionString", "dataSourceCredentialName": + "testsqlcredentialb7eb1f79", "dataSourceCredentialDescription": "update", "parameters": + {"connectionString": "update"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '204' + Content-Type: + - application/merge-patch+json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: PATCH + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/9eb66b80-f1ab-462c-bc5f-4b8bcf3501bc + response: + body: + string: '{"dataSourceCredentialId":"9eb66b80-f1ab-462c-bc5f-4b8bcf3501bc","dataSourceCredentialName":"testsqlcredentialb7eb1f79","dataSourceCredentialDescription":"update","dataSourceCredentialType":"AzureSQLConnectionString","parameters":{}}' + headers: + apim-request-id: + - bf13c5fc-0721-4fda-b338-9cd4bf1a093a + content-length: + - '233' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 25 May 2021 18:25:31 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '712' + x-request-id: + - bf13c5fc-0721-4fda-b338-9cd4bf1a093a + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials/9eb66b80-f1ab-462c-bc5f-4b8bcf3501bc + response: + body: + string: '' + headers: + apim-request-id: + - 7ca925af-b5ce-47fe-afda-db38a9a9264c + content-length: + - '0' + date: + - Tue, 25 May 2021 18:25:31 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '180' + x-request-id: + - 7ca925af-b5ce-47fe-afda-db38a9a9264c + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_create_sql_connection_string_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_create_sql_connection_string_credential_entity.yaml new file mode 100644 index 000000000000..c8c932ef128d --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_create_sql_connection_string_credential_entity.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "AzureSQLConnectionString", "dataSourceCredentialName": + "testsqlcredential300920ef", "dataSourceCredentialDescription": "my credential + entity", "parameters": {"connectionString": "connectionstring"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '444' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '{"error":{"code":"API operation not supported for token authentication","message":"ApiId + MetricsAdvisor OperationId createCredential not supported for CheckAccess."}}' + headers: + apim-request-id: + - 68ea7324-26bb-4f9c-ac05-3f25206255e9 + content-length: + - '166' + content-type: + - application/json + date: + - Tue, 25 May 2021 18:49:26 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + status: + code: 400 + message: BadRequest +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_datalake_gen2_shared_key_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_datalake_gen2_shared_key_credential_entity.yaml new file mode 100644 index 000000000000..ba25f37b0015 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_datalake_gen2_shared_key_credential_entity.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "DataLakeGen2SharedKey", "dataSourceCredentialName": + "testdatalakecredentiala0411ec7", "dataSourceCredentialDescription": "my credential + entity", "parameters": {"accountKey": "connectionstring"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '296' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - d0624cf3-b596-49c6-bd20-616f4e1e391f + content-length: + - '0' + date: + - Tue, 25 May 2021 18:49:28 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + status: + code: 400 + message: BadRequest +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_list_credential_entities.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_list_credential_entities.yaml new file mode 100644 index 000000000000..51f3ba293c2f --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_list_credential_entities.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "AzureSQLConnectionString", "dataSourceCredentialName": + "testsqlcredentialbd5d17cb", "dataSourceCredentialDescription": "my credential + entity", "parameters": {"connectionString": "connectionstring"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '444' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - c8adc86a-2f2f-42d6-b2b1-b3e5a2edfe17 + content-length: + - '0' + date: + - Tue, 25 May 2021 18:49:29 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + status: + code: 400 + message: BadRequest +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_service_principal_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_service_principal_credential_entity.yaml new file mode 100644 index 000000000000..d3e66eddd551 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_service_principal_credential_entity.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "ServicePrincipal", "dataSourceCredentialName": + "testserviceprincipalcredentialdddc1c59", "dataSourceCredentialDescription": + "my credential entity", "parameters": {"clientId": "client_id", "clientSecret": + "client_secret", "tenantId": "tenant_id"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '276' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - 21f927a7-9144-4068-99b9-07116c038af2 + content-length: + - '0' + date: + - Tue, 25 May 2021 18:49:30 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + status: + code: 400 + message: BadRequest +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_service_principal_in_kv_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_service_principal_in_kv_credential_entity.yaml new file mode 100644 index 000000000000..f3bfd451ab54 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_service_principal_in_kv_credential_entity.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "ServicePrincipalInKV", "dataSourceCredentialName": + "testserviceprincipalcredential8ff11ecf", "dataSourceCredentialDescription": + "my credential entity", "parameters": {"keyVaultEndpoint": "key_vault_endpoint", + "keyVaultClientId": "key_vault_client_id", "keyVaultClientSecret": "key_vault_client_secret", + "servicePrincipalIdNameInKV": "service_principal_id_name_in_kv", "servicePrincipalSecretNameInKV": + "service_principal_secret_name_in_kv", "tenantId": "tenant_id"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '496' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - 56a3cb9d-8b50-4ae4-8c75-f10ede18d415 + content-length: + - '0' + date: + - Tue, 25 May 2021 18:49:32 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + status: + code: 400 + message: BadRequest +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_datalake_gen2_shared_key_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_datalake_gen2_shared_key_credential_entity.yaml new file mode 100644 index 000000000000..3effacac7920 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_datalake_gen2_shared_key_credential_entity.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "DataLakeGen2SharedKey", "dataSourceCredentialName": + "testdatalakecredential85eb21a9", "dataSourceCredentialDescription": "my credential + entity", "parameters": {"accountKey": "connectionstring"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '296' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - ab92cb36-08ea-4ef6-87a0-a8963137c0d9 + content-length: + - '0' + date: + - Tue, 25 May 2021 18:49:34 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + status: + code: 400 + message: BadRequest +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_service_principal_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_service_principal_credential_entity.yaml new file mode 100644 index 000000000000..c89427f0b3cd --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_service_principal_credential_entity.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "ServicePrincipal", "dataSourceCredentialName": + "testserviceprincipalcredentialaf581f3b", "dataSourceCredentialDescription": + "my credential entity", "parameters": {"clientId": "client_id", "clientSecret": + "client_secret", "tenantId": "tenant_id"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '276' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - 409ffe74-dab0-4b46-a39e-fcfda42eeafb + content-length: + - '0' + date: + - Tue, 25 May 2021 18:49:35 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + status: + code: 400 + message: BadRequest +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_service_principal_in_kv_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_service_principal_in_kv_credential_entity.yaml new file mode 100644 index 000000000000..ec735fa3ed3b --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_service_principal_in_kv_credential_entity.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "ServicePrincipalInKV", "dataSourceCredentialName": + "testserviceprincipalcredential72b921b1", "dataSourceCredentialDescription": + "my credential entity", "parameters": {"keyVaultEndpoint": "key_vault_endpoint", + "keyVaultClientId": "key_vault_client_id", "keyVaultClientSecret": "key_vault_client_secret", + "servicePrincipalIdNameInKV": "service_principal_id_name_in_kv", "servicePrincipalSecretNameInKV": + "service_principal_secret_name_in_kv", "tenantId": "tenant_id"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '496' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - 01019bf1-a9c9-4902-a293-75febea8114e + content-length: + - '0' + date: + - Tue, 25 May 2021 18:49:36 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + status: + code: 400 + message: BadRequest +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_sql_connection_string_credential_entity.yaml b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_sql_connection_string_credential_entity.yaml new file mode 100644 index 000000000000..a7d45fb72ae4 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/recordings/test_credential_entities_aad.test_update_sql_connection_string_credential_entity.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: '{"dataSourceCredentialType": "AzureSQLConnectionString", "dataSourceCredentialName": + "testsqlcredential32bf20fe", "dataSourceCredentialDescription": "my credential + entity", "parameters": {"connectionString": "connectionstring"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '444' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-metricsadvisor/1.0.0b4 Python/3.8.6 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/credentials + response: + body: + string: '' + headers: + apim-request-id: + - 7d4e51a8-33da-4ae7-ae92-44f4da0e87e6 + content-length: + - '0' + date: + - Tue, 25 May 2021 18:49:37 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + status: + code: 400 + message: BadRequest +version: 1 diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/test_credential_entities.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/test_credential_entities.py new file mode 100644 index 000000000000..41150468ae46 --- /dev/null +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/tests/test_credential_entities.py @@ -0,0 +1,187 @@ +# 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. +# -------------------------------------------------------------------------- + +import pytest + +from azure.ai.metricsadvisor.models import ( + SQLConnectionStringCredentialEntity, + DataLakeGen2SharedKeyCredentialEntity, + ServicePrincipalCredentialEntity, + ServicePrincipalInKVCredentialEntity +) +from base_testcase import TestMetricsAdvisorAdministrationClientBase + + +class TestMetricsAdvisorAdministrationClient(TestMetricsAdvisorAdministrationClientBase): + + def test_create_sql_connection_string_credential_entity(self): + credential_entity_name = self.create_random_name("testsqlcredential") + try: + credential_entity = self.admin_client.create_credential_entity( + credential_entity=SQLConnectionStringCredentialEntity( + name=credential_entity_name, + connection_string=self.sql_server_connection_string, + description="my credential entity", + ) + ) + self.assertIsNotNone(credential_entity.id) + self.assertEqual(credential_entity.name, credential_entity_name) + self.assertEqual(credential_entity.credential_entity_type, 'AzureSQLConnectionString') + finally: + self.admin_client.delete_credential_entity(credential_entity.id) + + def test_datalake_gen2_shared_key_credential_entity(self): + credential_entity_name = self.create_random_name("testdatalakecredential") + try: + credential_entity = self.admin_client.create_credential_entity( + credential_entity=DataLakeGen2SharedKeyCredentialEntity( + name=credential_entity_name, + account_key=self.azure_datalake_account_key, + description="my credential entity", + ) + ) + self.assertIsNotNone(credential_entity.id) + self.assertEqual(credential_entity.name, credential_entity_name) + self.assertEqual(credential_entity.credential_entity_type, 'DataLakeGen2SharedKey') + finally: + self.admin_client.delete_credential_entity(credential_entity.id) + + def test_service_principal_credential_entity(self): + credential_entity_name = self.create_random_name("testserviceprincipalcredential") + try: + credential_entity = self.admin_client.create_credential_entity( + credential_entity=ServicePrincipalCredentialEntity( + name=credential_entity_name, + client_id="client_id", + client_secret="client_secret", + tenant_id="tenant_id", + description="my credential entity", + ) + ) + self.assertIsNotNone(credential_entity.id) + self.assertEqual(credential_entity.name, credential_entity_name) + self.assertEqual(credential_entity.credential_entity_type, 'ServicePrincipal') + finally: + self.admin_client.delete_credential_entity(credential_entity.id) + + def test_service_principal_in_kv_credential_entity(self): + credential_entity_name = self.create_random_name("testserviceprincipalcredential") + try: + credential_entity = self.admin_client.create_credential_entity( + credential_entity=ServicePrincipalInKVCredentialEntity( + name=credential_entity_name, + key_vault_endpoint="key_vault_endpoint", + key_vault_client_id="key_vault_client_id", + key_vault_client_secret="key_vault_client_secret", + service_principal_id_name_in_kv="service_principal_id_name_in_kv", + service_principal_secret_name_in_kv="service_principal_secret_name_in_kv", + tenant_id="tenant_id", + description="my credential entity", + ) + ) + self.assertIsNotNone(credential_entity.id) + self.assertEqual(credential_entity.name, credential_entity_name) + self.assertEqual(credential_entity.credential_entity_type, 'ServicePrincipalInKV') + finally: + self.admin_client.delete_credential_entity(credential_entity.id) + + def test_list_credential_entities(self): + credential_entity_name = self.create_random_name("testsqlcredential") + try: + credential_entity = self.admin_client.create_credential_entity( + credential_entity=SQLConnectionStringCredentialEntity( + name=credential_entity_name, + connection_string=self.sql_server_connection_string, + description="my credential entity", + ) + ) + credential_entities = self.admin_client.list_credential_entities() + assert len(list(credential_entities)) > 0 + finally: + self.admin_client.delete_credential_entity(credential_entity.id) + + def test_update_sql_connection_string_credential_entity(self): + credential_entity_name = self.create_random_name("testsqlcredential") + try: + credential_entity = self.admin_client.create_credential_entity( + credential_entity=SQLConnectionStringCredentialEntity( + name=credential_entity_name, + connection_string=self.sql_server_connection_string, + description="my credential entity", + ) + ) + credential_entity.connection_string = "update" + credential_entity.description = "update" + credential_entity_updated = self.admin_client.update_credential_entity(credential_entity) + self.assertEqual(credential_entity_updated.description, "update") + finally: + self.admin_client.delete_credential_entity(credential_entity.id) + + def test_update_datalake_gen2_shared_key_credential_entity(self): + credential_entity_name = self.create_random_name("testdatalakecredential") + try: + credential_entity = self.admin_client.create_credential_entity( + credential_entity=DataLakeGen2SharedKeyCredentialEntity( + name=credential_entity_name, + account_key=self.azure_datalake_account_key, + description="my credential entity", + ) + ) + credential_entity.account_key = "update" + credential_entity.description = "update" + credential_entity_updated = self.admin_client.update_credential_entity(credential_entity) + self.assertEqual(credential_entity_updated.description, "update") + finally: + self.admin_client.delete_credential_entity(credential_entity.id) + + def test_update_service_principal_credential_entity(self): + credential_entity_name = self.create_random_name("testserviceprincipalcredential") + try: + credential_entity = self.admin_client.create_credential_entity( + credential_entity=ServicePrincipalCredentialEntity( + name=credential_entity_name, + client_id="client_id", + client_secret="client_secret", + tenant_id="tenant_id", + description="my credential entity", + ) + ) + credential_entity.client_id = "update" + credential_entity.client_secret = "update" + credential_entity.tenant_id = "update" + credential_entity.description = "update" + credential_entity_updated = self.admin_client.update_credential_entity(credential_entity) + self.assertEqual(credential_entity_updated.description, "update") + finally: + self.admin_client.delete_credential_entity(credential_entity.id) + + def test_update_service_principal_in_kv_credential_entity(self): + credential_entity_name = self.create_random_name("testserviceprincipalcredential") + try: + credential_entity = self.admin_client.create_credential_entity( + credential_entity=ServicePrincipalInKVCredentialEntity( + name=credential_entity_name, + key_vault_endpoint="key_vault_endpoint", + key_vault_client_id="key_vault_client_id", + key_vault_client_secret="key_vault_client_secret", + service_principal_id_name_in_kv="service_principal_id_name_in_kv", + service_principal_secret_name_in_kv="service_principal_secret_name_in_kv", + tenant_id="tenant_id", + description="my credential entity", + ) + ) + credential_entity.key_vault_endpoint = "update" + credential_entity.key_vault_client_id = "update" + credential_entity.key_vault_client_secret = "update" + credential_entity.service_principal_id_name_in_kv = "update" + credential_entity.service_principal_secret_name_in_kv = "update" + credential_entity.tenant_id = "update" + credential_entity.description = "update" + credential_entity_updated = self.admin_client.update_credential_entity(credential_entity) + self.assertEqual(credential_entity_updated.description, "update") + finally: + self.admin_client.delete_credential_entity(credential_entity.id)