From 60d8822257d71a313b5ef44d84717ee32c18a619 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 28 Apr 2020 22:04:14 -0700 Subject: [PATCH 01/17] sync --- .../azure/search/documents/__init__.py | 2 + .../documents/_service/_datasources_client.py | 47 ++-- .../documents/_service/_indexes_client.py | 49 ++-- .../documents/_service/_skillsets_client.py | 44 ++-- .../_service/_synonym_maps_client.py | 59 +++-- .../azure/search/documents/_service/_utils.py | 9 + ...ate_or_update_datasource_if_unchanged.yaml | 170 ++++++++++++++ ...create_or_update_indexes_if_unchanged.yaml | 173 ++++++++++++++ ...reate_or_update_skillset_if_unchanged.yaml | 221 ++++++++++++++++++ ...te_or_update_synonym_map_if_unchanged.yaml | 169 ++++++++++++++ ...e.test_delete_datasource_if_unchanged.yaml | 164 +++++++++++++ ...live.test_delete_indexes_if_unchanged.yaml | 166 +++++++++++++ ...ive.test_delete_skillset_if_unchanged.yaml | 165 +++++++++++++ ....test_delete_synonym_map_if_unchanged.yaml | 164 +++++++++++++ .../tests/test_service_live.py | 195 +++++++++++++++- 15 files changed, 1728 insertions(+), 69 deletions(-) create mode 100644 sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_datasource_if_unchanged.yaml create mode 100644 sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_indexes_if_unchanged.yaml create mode 100644 sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_skillset_if_unchanged.yaml create mode 100644 sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_synonym_map_if_unchanged.yaml create mode 100644 sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_datasource_if_unchanged.yaml create mode 100644 sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_indexes_if_unchanged.yaml create mode 100644 sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_skillset_if_unchanged.yaml create mode 100644 sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_synonym_map_if_unchanged.yaml diff --git a/sdk/search/azure-search-documents/azure/search/documents/__init__.py b/sdk/search/azure-search-documents/azure/search/documents/__init__.py index 2437d1bcf989..5b77c15a9009 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/__init__.py +++ b/sdk/search/azure-search-documents/azure/search/documents/__init__.py @@ -104,6 +104,7 @@ StopAnalyzer, StopwordsTokenFilter, Suggester, + SynonymMap, SynonymTokenFilter, TagScoringFunction, TagScoringParameters, @@ -203,6 +204,7 @@ "StopwordsTokenFilter", "SuggestQuery", "Suggester", + "SynonymMap", "SynonymTokenFilter", "TagScoringFunction", "TagScoringParameters", diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py index 7ffe5b0fce3b..eeda2448b611 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py @@ -8,6 +8,7 @@ from azure.core.tracing.decorator import distributed_trace from ._generated import SearchServiceClient as _SearchServiceClient +from ._utils import get_access_conditions from .._headers_mixin import HeadersMixin from .._version import SDK_MONIKER @@ -78,22 +79,28 @@ def create_datasource(self, data_source, **kwargs): @distributed_trace def create_or_update_datasource(self, data_source, name=None, **kwargs): - # type: (DataSource, Optional[str], **Any) -> Dict[str, Any] + # type: (str, DataSource, Optional[str], **Any) -> Dict[str, Any] """Creates a new datasource or updates a datasource if it already exists. - :param name: The name of the datasource to create or update. :type name: str :param data_source: The definition of the datasource to create or update. :type data_source: ~search.models.DataSource + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed data_source. + :type only_if_unchanged: bool :return: The created DataSource :rtype: dict """ - # TODO: access_condition kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - + access_condition = get_access_conditions(data_source, kwargs.pop('only_if_unchanged', False)) if not name: name = data_source.name - result = self._client.data_sources.create_or_update(name, data_source, **kwargs) + result = self._client.data_sources.create_or_update( + data_source_name=name, + data_source=data_source, + access_condition=access_condition, + **kwargs + ) return result @distributed_trace @@ -141,13 +148,17 @@ def get_datasources(self, **kwargs): return result.data_sources @distributed_trace - def delete_datasource(self, name, **kwargs): - # type: (str, **Any) -> None - """Deletes a datasource. - - :param name: The name of the datasource to delete. - :type name: str - + def delete_datasource(self, data_source, **kwargs): + # type: (Union[str, DataSource], **Any) -> None + """Deletes a datasource. To use only_if_unchanged, the Datasource model must be + provided instead of the name. It is enough to provide the name of the datasource + to delete unconditionally + + :param data_source: The datasource to delete. + :type data_source: str or ~search.models.DataSource + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed data_source. + :type only_if_unchanged: bool :return: None :rtype: None @@ -161,4 +172,14 @@ def delete_datasource(self, name, **kwargs): :caption: Delete a DataSource """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - self._client.data_sources.delete(name, **kwargs) + access_condition = None + try: + name = data_source.name + access_condition = get_access_conditions(data_source, kwargs.pop('only_if_unchanged', False)) + except AttributeError: + name = data_source + self._client.data_sources.delete( + data_source_name=name, + access_condition=access_condition, + **kwargs + ) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py index 35af04afb31c..ca7a255a03bf 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py @@ -22,6 +22,7 @@ listize_flags_for_index, prep_if_match, prep_if_none_match, + get_access_conditions ) from .._headers_mixin import HeadersMixin from .._version import SDK_MONIKER @@ -130,12 +131,16 @@ def get_index_statistics(self, index_name, **kwargs): return result.as_dict() @distributed_trace - def delete_index(self, index_name, **kwargs): - # type: (str, **Any) -> None - """Deletes a search index and all the documents it contains. - - :param index_name: The name of the index to retrieve. - :type index_name: str + def delete_index(self, index, **kwargs): + # type: (Union[str, Index], **Any) -> None + """Deletes a search index and all the documents it contains. The model must be + provided instead of the name to use the access condition only_if_unchanged + + :param index: The index to retrieve. + :type index: str or ~search.models.Index + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed index. + :type only_if_unchanged: bool :raises: ~azure.core.exceptions.HttpResponseError .. admonition:: Example: @@ -148,7 +153,13 @@ def delete_index(self, index_name, **kwargs): :caption: Delete an index. """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - self._client.indexes.delete(index_name, **kwargs) + access_condition = None + try: + index_name = index.name + access_condition = get_access_conditions(index, kwargs.pop('only_if_unchanged', False)) + except AttributeError: + index_name = index + self._client.indexes.delete(index_name=index_name, access_condition=access_condition, **kwargs) @distributed_trace def create_index(self, index, **kwargs): @@ -181,10 +192,9 @@ def create_or_update_index( index_name, index, allow_index_downtime=None, - match_condition=MatchConditions.Unconditionally, **kwargs ): - # type: (str, Index, bool, MatchConditions, **Any) -> Index + # type: (str, Index, bool, **Any) -> Index """Creates a new search index or updates an index if it already exists. :param index_name: The name of the index. @@ -197,8 +207,9 @@ def create_or_update_index( the index can be impaired for several minutes after the index is updated, or longer for very large indexes. :type allow_index_downtime: bool - :param match_condition: The match condition to use upon the etag - :type match_condition: ~azure.core.MatchConditions + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed index. + :type only_if_unchanged: bool :return: The index created or updated :rtype: :class:`~azure.search.documents.Index` :raises: :class:`~azure.core.exceptions.ResourceNotFoundError`, \ @@ -217,21 +228,7 @@ def create_or_update_index( :caption: Update an index. """ error_map = {404: ResourceNotFoundError} # type: Dict[int, Any] - access_condition = None - if index.e_tag: - access_condition = AccessCondition() - access_condition.if_match = prep_if_match(index.e_tag, match_condition) - access_condition.if_none_match = prep_if_none_match( - index.e_tag, match_condition - ) - if match_condition == MatchConditions.IfNotModified: - error_map[412] = ResourceModifiedError - if match_condition == MatchConditions.IfModified: - error_map[304] = ResourceNotModifiedError - if match_condition == MatchConditions.IfPresent: - error_map[412] = ResourceNotFoundError - if match_condition == MatchConditions.IfMissing: - error_map[412] = ResourceExistsError + access_condition = get_access_conditions(index, kwargs.pop('only_if_unchanged', False)) kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) patched_index = delistize_flags_for_index(index) result = self._client.indexes.create_or_update( diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py index c68019091506..30cee39a67b4 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py @@ -9,6 +9,7 @@ from ._generated import SearchServiceClient as _SearchServiceClient from ._generated.models import Skillset +from ._utils import get_access_conditions from .._headers_mixin import HeadersMixin from .._version import SDK_MONIKER @@ -102,12 +103,17 @@ def get_skillset(self, name, **kwargs): return self._client.skillsets.get(name, **kwargs) @distributed_trace - def delete_skillset(self, name, **kwargs): - # type: (str, **Any) -> None - """Delete a named Skillset in an Azure Search service - - :param name: The name of the Skillset to delete - :type name: str + def delete_skillset(self, skillset, **kwargs): + # type: (Union[str, Skillset], **Any) -> None + """Delete a named Skillset in an Azure Search service. To use only_if_unchanged, + the Skillset model must be provided instead of the name. It is enough to provide + the name of the skillset to delete unconditionally + + :param name: The Skillset to delete + :type name: str or ~search.models.Skillset + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed skillset. + :type only_if_unchanged: bool .. admonition:: Example: @@ -120,7 +126,13 @@ def delete_skillset(self, name, **kwargs): """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - self._client.skillsets.delete(name, **kwargs) + access_condition = None + try: + name = skillset.name + access_condition = get_access_conditions(skillset, kwargs.pop('only_if_unchanged', False)) + except AttributeError: + name = skillset + self._client.skillsets.delete(name, access_condition=access_condition, **kwargs) @distributed_trace def create_skillset(self, name, skills, description, **kwargs): @@ -156,18 +168,20 @@ def create_skillset(self, name, skills, description, **kwargs): def create_or_update_skillset(self, name, **kwargs): # type: (str, **Any) -> Skillset """Create a new Skillset in an Azure Search service, or update an - existing one. - - A `Skillset` object mat + existing one. The skillset param must be provided to perform the + operation with access conditions. :param name: The name of the Skillset to create or update :type name: str - :param skills: A list of Skill objects to include in the Skillset + :keyword skills: A list of Skill objects to include in the Skillset :type skills: List[Skill] - :param description: A description for the Skillset + :keyword description: A description for the Skillset :type description: Optional[str] - :param skillset: A Skillset to create or update. + :keyword skillset: A Skillset to create or update. :type skillset: :class:`~azure.search.documents.Skillset` + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed skillset. + :type only_if_unchanged: bool :return: The created or updated Skillset :rtype: dict @@ -176,9 +190,11 @@ def create_or_update_skillset(self, name, **kwargs): """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) + access_condition = None if "skillset" in kwargs: skillset = kwargs.pop("skillset") + access_condition = get_access_conditions(skillset, kwargs.pop('only_if_unchanged', False)) skillset = Skillset.deserialize(skillset.serialize()) skillset.name = name for param in ("description", "skills"): @@ -192,4 +208,4 @@ def create_or_update_skillset(self, name, **kwargs): skills=kwargs.pop("skills", None), ) - return self._client.skillsets.create_or_update(name, skillset, **kwargs) + return self._client.skillsets.create_or_update(name, skillset, access_condition=access_condition, **kwargs) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py index eed4074f99d6..b6a8ea9c83d0 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py @@ -9,7 +9,7 @@ from ._generated import SearchServiceClient as _SearchServiceClient from ._generated.models import SynonymMap -from ._utils import listize_synonyms +from ._utils import listize_synonyms, get_access_conditions from .._headers_mixin import HeadersMixin from .._version import SDK_MONIKER @@ -104,12 +104,19 @@ def get_synonym_map(self, name, **kwargs): return listize_synonyms(result.as_dict()) @distributed_trace - def delete_synonym_map(self, name, **kwargs): - # type: (str, **Any) -> None - """Delete a named Synonym Map in an Azure Search service - - :param name: The name of the Synonym Map to delete - :type name: str + def delete_synonym_map(self, synonym_map, **kwargs): + # type: (Union[str, SynonymMap], **Any) -> None + """Delete a named Synonym Map in an Azure Search service. To use only_if_unchanged, + the SynonymMap model must be provided instead of the name. It is enough to provide + the name of the synonym map to delete unconditionally. + + :param name: The Synonym Map to delete + :type name: str or ~search.models.SynonymMap + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed synonym_map. + :type only_if_unchanged: bool + :return: None + :rtype: None .. admonition:: Example: @@ -122,7 +129,13 @@ def delete_synonym_map(self, name, **kwargs): """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - self._client.synonym_maps.delete(name, **kwargs) + access_condition = None + try: + name = synonym_map.name + access_condition = get_access_conditions(synonym_map, kwargs.pop('only_if_unchanged', False)) + except AttributeError: + name = synonym_map + self._client.synonym_maps.delete(synonym_map_name=name, access_condition=access_condition, **kwargs) @distributed_trace def create_synonym_map(self, name, synonyms, **kwargs): @@ -153,21 +166,37 @@ def create_synonym_map(self, name, synonyms, **kwargs): return listize_synonyms(result.as_dict()) @distributed_trace - def create_or_update_synonym_map(self, name, synonyms, **kwargs): - # type: (str, Sequence[str], **Any) -> dict + def create_or_update_synonym_map(self, synonym_map, synonyms=None, **kwargs): + # type: (Union[str, SynonymMap], Optional[Sequence[str]], **Any) -> dict """Create a new Synonym Map in an Azure Search service, or update an existing one. - :param name: The name of the Synonym Map to create or update - :type name: str + :param synonym_map: The name of the Synonym Map to create or update + :type synonym_map: str or ~azure.search.documents.SynonymMap :param synonyms: A list of synonyms in SOLR format :type synonyms: List[str] + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed synonym_map. + :type only_if_unchanged: bool :return: The created or updated Synonym Map :rtype: dict """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - solr_format_synonyms = "\n".join(synonyms) - synonym_map = SynonymMap(name=name, synonyms=solr_format_synonyms) - result = self._client.synonym_maps.create_or_update(name, synonym_map, **kwargs) + access_condition = None + try: + name = synonym_map.name + access_condition = get_access_conditions(synonym_map, kwargs.pop('only_if_unchanged', False)) + if synonyms: + synonym_map.synonyms = "\n".join(synonyms) + except AttributeError: + name = synonym_map + solr_format_synonyms = "\n".join(synonyms) + synonym_map = SynonymMap(name=name, synonyms=solr_format_synonyms) + result = self._client.synonym_maps.create_or_update( + synonym_map_name=name, + synonym_map=synonym_map, + access_condition=access_condition, + **kwargs + ) return listize_synonyms(result.as_dict()) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py index b615500ee7a4..690e4a358759 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py @@ -10,6 +10,7 @@ Index, PatternAnalyzer as _PatternAnalyzer, PatternTokenizer as _PatternTokenizer, + AccessCondition ) from ._models import PatternAnalyzer, PatternTokenizer @@ -151,3 +152,11 @@ def listize_synonyms(synonym_map): # type: (dict) -> dict synonym_map["synonyms"] = synonym_map["synonyms"].split("\n") return synonym_map + +def get_access_conditions(model, only_if_unchanged=False): + if not only_if_unchanged: + return + try: + return AccessCondition(if_match=model.e_tag) + except AttributeError: + raise ValueError("Unable to get e_tag from the model") diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_datasource_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_datasource_if_unchanged.yaml new file mode 100644 index 000000000000..12c1fe3b93f1 --- /dev/null +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_datasource_if_unchanged.yaml @@ -0,0 +1,170 @@ +interactions: +- request: + body: '{"name": "sample-datasource", "type": "azureblob", "credentials": {"connectionString": + "DefaultEndpointsProtocol=https;AccountName=storagename;AccountKey=NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg==;EndpointSuffix=core.windows.net"}, + "container": {"name": "searchcontainer"}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '319' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - B6E6C1BF71B889B3CD59FCE617987E2C + method: POST + uri: https://search3c8b19c7.search.windows.net/datasources?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search3c8b19c7.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBDEA25ADD51\"","name":"sample-datasource","description":null,"type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + headers: + cache-control: + - no-cache + content-length: + - '370' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 01:42:52 GMT + elapsed-time: + - '70' + etag: + - W/"0x8D7EBDEA25ADD51" + expires: + - '-1' + location: + - https://search3c8b19c7.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - bdb36bb4-89ba-11ea-a706-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 201 + message: Created +- request: + body: '{"name": "sample-datasource", "description": "updated", "type": "azureblob", + "credentials": {"connectionString": "DefaultEndpointsProtocol=https;AccountName=storagename;AccountKey=NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg==;EndpointSuffix=core.windows.net"}, + "container": {"name": "searchcontainer"}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '345' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - B6E6C1BF71B889B3CD59FCE617987E2C + method: PUT + uri: https://search3c8b19c7.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search3c8b19c7.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBDEA26EDE1F\"","name":"sample-datasource","description":"updated","type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + headers: + cache-control: + - no-cache + content-length: + - '375' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 01:42:53 GMT + elapsed-time: + - '50' + etag: + - W/"0x8D7EBDEA26EDE1F" + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - bdfd1386-89ba-11ea-a6a3-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + vary: + - Accept-Encoding + status: + code: 200 + message: OK +- request: + body: '{"name": "sample-datasource", "description": "changed", "type": "azureblob", + "credentials": {"connectionString": "DefaultEndpointsProtocol=https;AccountName=storagename;AccountKey=NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg==;EndpointSuffix=core.windows.net"}, + "container": {"name": "searchcontainer"}, "@odata.etag": "\"0x8D7EBDEA25ADD51\""}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '385' + Content-Type: + - application/json + If-Match: + - '"0x8D7EBDEA25ADD51"' + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - B6E6C1BF71B889B3CD59FCE617987E2C + method: PUT + uri: https://search3c8b19c7.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: + - no-cache + content-language: + - en + content-length: + - '160' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 01:42:53 GMT + elapsed-time: + - '19' + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - be11c5d8-89ba-11ea-919b-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed +version: 1 diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_indexes_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_indexes_if_unchanged.yaml new file mode 100644 index 000000000000..ed0ac61910d1 --- /dev/null +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_indexes_if_unchanged.yaml @@ -0,0 +1,173 @@ +interactions: +- request: + body: '{"name": "hotels", "fields": [{"name": "hotelId", "type": "Edm.String", + "key": true, "searchable": false}, {"name": "baseRate", "type": "Edm.Double"}], + "scoringProfiles": [{"name": "MyProfile"}], "corsOptions": {"allowedOrigins": + ["*"], "maxAgeInSeconds": 60}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '260' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - FA0774CEFCEDF7C1DF7FC6F29A8CEB94 + method: POST + uri: https://searchf02d188c.search.windows.net/indexes?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searchf02d188c.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBE409D8C054\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[{"name":"MyProfile","functionAggregation":null,"text":null,"functions":[]}],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + headers: + cache-control: + - no-cache + content-length: + - '890' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 02:21:34 GMT + elapsed-time: + - '666' + etag: + - W/"0x8D7EBE409D8C054" + expires: + - '-1' + location: + - https://searchf02d188c.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - 24d28880-89c0-11ea-ad8d-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 201 + message: Created +- request: + body: '{"name": "hotels", "fields": [{"name": "hotelId", "type": "Edm.String", + "key": true, "searchable": false}, {"name": "baseRate", "type": "Edm.Double"}], + "scoringProfiles": [], "corsOptions": {"allowedOrigins": ["*"], "maxAgeInSeconds": + 60}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '239' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - FA0774CEFCEDF7C1DF7FC6F29A8CEB94 + method: PUT + uri: https://searchf02d188c.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searchf02d188c.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBE409FFB049\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + headers: + cache-control: + - no-cache + content-length: + - '816' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 02:21:34 GMT + elapsed-time: + - '123' + etag: + - W/"0x8D7EBE409FFB049" + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - 2582c1e8-89c0-11ea-a867-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + vary: + - Accept-Encoding + status: + code: 200 + message: OK +- request: + body: '{"name": "hotels", "fields": [{"name": "hotelId", "type": "Edm.String", + "key": true, "searchable": false}, {"name": "baseRate", "type": "Edm.Double"}], + "scoringProfiles": [], "corsOptions": {"allowedOrigins": ["*"], "maxAgeInSeconds": + 60}, "@odata.etag": "\"0x8D7EBE409D8C054\""}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '279' + Content-Type: + - application/json + If-Match: + - '"0x8D7EBE409D8C054"' + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - FA0774CEFCEDF7C1DF7FC6F29A8CEB94 + method: PUT + uri: https://searchf02d188c.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: + - no-cache + content-language: + - en + content-length: + - '160' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 02:21:34 GMT + elapsed-time: + - '45' + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - 25a96818-89c0-11ea-8721-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed +version: 1 diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_skillset_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_skillset_if_unchanged.yaml new file mode 100644 index 000000000000..8adca9a67ebd --- /dev/null +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_skillset_if_unchanged.yaml @@ -0,0 +1,221 @@ +interactions: +- request: + body: '{"name": "test-ss", "description": "desc1", "skills": [{"@odata.type": + "#Microsoft.Skills.Text.EntityRecognitionSkill", "inputs": [{"name": "text", + "source": "/document/content"}], "outputs": [{"name": "organizations", "targetName": + "organizations"}]}]}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '253' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 0C98EDCFB7EF2403F053EADAEAAE16E3 + method: PUT + uri: https://searcha9b1907.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searcha9b1907.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBF2E425F4FD\"","name":"test-ss","description":"desc1","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + headers: + cache-control: + - no-cache + content-length: + - '587' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 04:07:53 GMT + elapsed-time: + - '39' + etag: + - W/"0x8D7EBF2E425F4FD" + expires: + - '-1' + location: + - https://searcha9b1907.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - ff82be46-89ce-11ea-b113-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 201 + message: Created +- request: + body: '{"name": "test-ss", "description": "desc2", "skills": [{"@odata.type": + "#Microsoft.Skills.Text.EntityRecognitionSkill", "inputs": [{"name": "text", + "source": "/document/content"}], "outputs": [{"name": "organizations", "targetName": + "organizations"}]}], "@odata.etag": "\"0x8D7EBF2E425F4FD\""}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '293' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 0C98EDCFB7EF2403F053EADAEAAE16E3 + method: PUT + uri: https://searcha9b1907.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searcha9b1907.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBF2E44409AD\"","name":"test-ss","description":"desc2","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + headers: + cache-control: + - no-cache + content-length: + - '587' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 04:07:53 GMT + elapsed-time: + - '66' + etag: + - W/"0x8D7EBF2E44409AD" + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - ffd4ecf6-89ce-11ea-bb24-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + vary: + - Accept-Encoding + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 0C98EDCFB7EF2403F053EADAEAAE16E3 + method: GET + uri: https://searcha9b1907.search.windows.net/skillsets?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searcha9b1907.search.windows.net/$metadata#skillsets","value":[{"@odata.etag":"\"0x8D7EBF2E44409AD\"","name":"test-ss","description":"desc2","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":"#1","description":null,"context":"/document","categories":["Person","Quantity","Organization","URL","Email","Location","DateTime"],"defaultLanguageCode":"en","minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}]}' + headers: + cache-control: + - no-cache + content-length: + - '668' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 04:07:53 GMT + elapsed-time: + - '33' + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - fff5f330-89ce-11ea-96ec-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + vary: + - Accept-Encoding + status: + code: 200 + message: OK +- request: + body: '{"name": "test-ss", "description": "desc1", "skills": [{"@odata.type": + "#Microsoft.Skills.Text.EntityRecognitionSkill", "inputs": [{"name": "text", + "source": "/document/content"}], "outputs": [{"name": "organizations", "targetName": + "organizations"}]}], "@odata.etag": "\"0x8D7EBF2E425F4FD\""}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '293' + Content-Type: + - application/json + If-Match: + - '"0x8D7EBF2E425F4FD"' + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 0C98EDCFB7EF2403F053EADAEAAE16E3 + method: PUT + uri: https://searcha9b1907.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: + - no-cache + content-language: + - en + content-length: + - '160' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 04:07:53 GMT + elapsed-time: + - '15' + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - 0011f33e-89cf-11ea-9102-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed +version: 1 diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_synonym_map_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_synonym_map_if_unchanged.yaml new file mode 100644 index 000000000000..52a815d85252 --- /dev/null +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_synonym_map_if_unchanged.yaml @@ -0,0 +1,169 @@ +interactions: +- request: + body: '{"name": "test-syn-map", "format": "solr", "synonyms": "USA, United States, + United States of America"}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '102' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 725A70C9E63294C7FDB7947876C60C59 + method: POST + uri: https://search5a551a56.search.windows.net/synonymmaps?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search5a551a56.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7EBFABA313996\"","name":"test-syn-map","format":"solr","synonyms":"USA, + United States, United States of America","encryptionKey":null}' + headers: + cache-control: + - no-cache + content-length: + - '247' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 05:03:59 GMT + elapsed-time: + - '46' + etag: + - W/"0x8D7EBFABA313996" + expires: + - '-1' + location: + - https://search5a551a56.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - d5a560d2-89d6-11ea-8831-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 201 + message: Created +- request: + body: '{"name": "test-syn-map", "format": "solr", "synonyms": "Washington, Wash. + => WA"}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '81' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 725A70C9E63294C7FDB7947876C60C59 + method: PUT + uri: https://search5a551a56.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search5a551a56.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7EBFABA4784C3\"","name":"test-syn-map","format":"solr","synonyms":"Washington, + Wash. => WA","encryptionKey":null}' + headers: + cache-control: + - no-cache + content-length: + - '226' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 05:03:59 GMT + elapsed-time: + - '19' + etag: + - W/"0x8D7EBFABA4784C3" + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - d5e26958-89d6-11ea-a330-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + vary: + - Accept-Encoding + status: + code: 200 + message: OK +- request: + body: '{"name": "test-syn-map", "format": "solr", "synonyms": "[''USA, United + States, United States of America'']", "@odata.etag": "\"0x8D7EBFABA313996\""}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '146' + Content-Type: + - application/json + If-Match: + - '"0x8D7EBFABA313996"' + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 725A70C9E63294C7FDB7947876C60C59 + method: PUT + uri: https://search5a551a56.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: + - no-cache + content-language: + - en + content-length: + - '160' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 05:03:59 GMT + elapsed-time: + - '10' + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - d5f82be6-89d6-11ea-9c97-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed +version: 1 diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_datasource_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_datasource_if_unchanged.yaml new file mode 100644 index 000000000000..29cad1be1597 --- /dev/null +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_datasource_if_unchanged.yaml @@ -0,0 +1,164 @@ +interactions: +- request: + body: '{"name": "sample-datasource", "type": "azureblob", "credentials": {"connectionString": + "DefaultEndpointsProtocol=https;AccountName=storagename;AccountKey=NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg==;EndpointSuffix=core.windows.net"}, + "container": {"name": "searchcontainer"}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '319' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 590713A0C8B9510FFE57929645E27732 + method: POST + uri: https://search4ba315a4.search.windows.net/datasources?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search4ba315a4.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBDE85E01289\"","name":"sample-datasource","description":null,"type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + headers: + cache-control: + - no-cache + content-length: + - '370' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 01:42:05 GMT + elapsed-time: + - '58' + etag: + - W/"0x8D7EBDE85E01289" + expires: + - '-1' + location: + - https://search4ba315a4.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - a13a84b4-89ba-11ea-8175-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 201 + message: Created +- request: + body: '{"name": "sample-datasource", "description": "updated", "type": "azureblob", + "credentials": {"connectionString": "DefaultEndpointsProtocol=https;AccountName=storagename;AccountKey=NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg==;EndpointSuffix=core.windows.net"}, + "container": {"name": "searchcontainer"}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '345' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 590713A0C8B9510FFE57929645E27732 + method: PUT + uri: https://search4ba315a4.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search4ba315a4.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBDE85F684D1\"","name":"sample-datasource","description":"updated","type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + headers: + cache-control: + - no-cache + content-length: + - '375' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 01:42:05 GMT + elapsed-time: + - '34' + etag: + - W/"0x8D7EBDE85F684D1" + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - a1825870-89ba-11ea-b725-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + vary: + - Accept-Encoding + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + If-Match: + - '"0x8D7EBDE85E01289"' + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 590713A0C8B9510FFE57929645E27732 + method: DELETE + uri: https://search4ba315a4.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: + - no-cache + content-language: + - en + content-length: + - '160' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 01:42:05 GMT + elapsed-time: + - '9' + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - a198de08-89ba-11ea-ae8e-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed +version: 1 diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_indexes_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_indexes_if_unchanged.yaml new file mode 100644 index 000000000000..a927a72c47a4 --- /dev/null +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_indexes_if_unchanged.yaml @@ -0,0 +1,166 @@ +interactions: +- request: + body: '{"name": "hotels", "fields": [{"name": "hotelId", "type": "Edm.String", + "key": true, "searchable": false}, {"name": "baseRate", "type": "Edm.Double"}], + "scoringProfiles": [{"name": "MyProfile"}], "corsOptions": {"allowedOrigins": + ["*"], "maxAgeInSeconds": 60}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '260' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - AF52C3C90CE766533CDA6EAA964604AB + method: POST + uri: https://searchbbd1469.search.windows.net/indexes?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searchbbd1469.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBE3D36EA891\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[{"name":"MyProfile","functionAggregation":null,"text":null,"functions":[]}],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + headers: + cache-control: + - no-cache + content-length: + - '889' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 02:20:03 GMT + elapsed-time: + - '643' + etag: + - W/"0x8D7EBE3D36EA891" + expires: + - '-1' + location: + - https://searchbbd1469.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - ee76b2c2-89bf-11ea-8c6b-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 201 + message: Created +- request: + body: '{"name": "hotels", "fields": [{"name": "hotelId", "type": "Edm.String", + "key": true, "searchable": false}, {"name": "baseRate", "type": "Edm.Double"}], + "scoringProfiles": [], "corsOptions": {"allowedOrigins": ["*"], "maxAgeInSeconds": + 60}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '239' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - AF52C3C90CE766533CDA6EAA964604AB + method: PUT + uri: https://searchbbd1469.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searchbbd1469.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBE3D393C372\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + headers: + cache-control: + - no-cache + content-length: + - '815' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 02:20:03 GMT + elapsed-time: + - '105' + etag: + - W/"0x8D7EBE3D393C372" + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - ef18eda8-89bf-11ea-a573-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + vary: + - Accept-Encoding + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + If-Match: + - '"0x8D7EBE3D36EA891"' + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - AF52C3C90CE766533CDA6EAA964604AB + method: DELETE + uri: https://searchbbd1469.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: + - no-cache + content-language: + - en + content-length: + - '160' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 02:20:03 GMT + elapsed-time: + - '50' + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - ef3d7258-89bf-11ea-834b-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed +version: 1 diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_skillset_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_skillset_if_unchanged.yaml new file mode 100644 index 000000000000..2c3f9a785492 --- /dev/null +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_skillset_if_unchanged.yaml @@ -0,0 +1,165 @@ +interactions: +- request: + body: '{"name": "test-ss", "description": "desc", "skills": [{"@odata.type": "#Microsoft.Skills.Text.EntityRecognitionSkill", + "inputs": [{"name": "text", "source": "/document/content"}], "outputs": [{"name": + "organizations", "targetName": "organizations"}]}]}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '252' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - DABF6CB43B698738C7939253D7A72E9F + method: POST + uri: https://search21f914e4.search.windows.net/skillsets?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search21f914e4.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBF284749492\"","name":"test-ss","description":"desc","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + headers: + cache-control: + - no-cache + content-length: + - '587' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 04:05:13 GMT + elapsed-time: + - '55' + etag: + - W/"0x8D7EBF284749492" + expires: + - '-1' + location: + - https://search21f914e4.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - 9fde43d2-89ce-11ea-b519-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 201 + message: Created +- request: + body: '{"name": "test-ss", "description": "updated", "skills": [{"@odata.type": + "#Microsoft.Skills.Text.EntityRecognitionSkill", "inputs": [{"name": "text", + "source": "/document/content"}], "outputs": [{"name": "organizations", "targetName": + "organizations"}]}]}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '255' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - DABF6CB43B698738C7939253D7A72E9F + method: PUT + uri: https://search21f914e4.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search21f914e4.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBF2848EB0EC\"","name":"test-ss","description":"updated","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + headers: + cache-control: + - no-cache + content-length: + - '590' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 04:05:13 GMT + elapsed-time: + - '45' + etag: + - W/"0x8D7EBF2848EB0EC" + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - a0230ef8-89ce-11ea-a53b-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + vary: + - Accept-Encoding + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + If-Match: + - '"0x8D7EBF284749492"' + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - DABF6CB43B698738C7939253D7A72E9F + method: DELETE + uri: https://search21f914e4.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: + - no-cache + content-language: + - en + content-length: + - '160' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 04:05:13 GMT + elapsed-time: + - '14' + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - a03d629a-89ce-11ea-8f8d-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed +version: 1 diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_synonym_map_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_synonym_map_if_unchanged.yaml new file mode 100644 index 000000000000..1353baba00e7 --- /dev/null +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_synonym_map_if_unchanged.yaml @@ -0,0 +1,164 @@ +interactions: +- request: + body: '{"name": "test-syn-map", "format": "solr", "synonyms": "USA, United States, + United States of America\nWashington, Wash. => WA"}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '127' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 13C25F60415C700FD39787BC02ACDFC0 + method: POST + uri: https://search654a1633.search.windows.net/synonymmaps?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search654a1633.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7EBFA7A96EF2E\"","name":"test-syn-map","format":"solr","synonyms":"USA, + United States, United States of America\nWashington, Wash. => WA","encryptionKey":null}' + headers: + cache-control: + - no-cache + content-length: + - '272' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 05:02:12 GMT + elapsed-time: + - '52' + etag: + - W/"0x8D7EBFA7A96EF2E" + expires: + - '-1' + location: + - https://search654a1633.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - 95f84e62-89d6-11ea-b612-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 201 + message: Created +- request: + body: '{"name": "test-syn-map", "format": "solr", "synonyms": "Washington, Wash. + => WA"}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '81' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 13C25F60415C700FD39787BC02ACDFC0 + method: PUT + uri: https://search654a1633.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search654a1633.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7EBFA7AAEC138\"","name":"test-syn-map","format":"solr","synonyms":"Washington, + Wash. => WA","encryptionKey":null}' + headers: + cache-control: + - no-cache + content-length: + - '226' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 05:02:12 GMT + elapsed-time: + - '27' + etag: + - W/"0x8D7EBFA7AAEC138" + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - 9648590c-89d6-11ea-af8c-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + vary: + - Accept-Encoding + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + If-Match: + - '"0x8D7EBFA7A96EF2E"' + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 13C25F60415C700FD39787BC02ACDFC0 + method: DELETE + uri: https://search654a1633.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: + - no-cache + content-language: + - en + content-length: + - '160' + content-type: + - application/json; odata.metadata=minimal + date: + - Wed, 29 Apr 2020 05:02:12 GMT + elapsed-time: + - '14' + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - 965ff0ba-89d6-11ea-b83f-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed +version: 1 diff --git a/sdk/search/azure-search-documents/tests/test_service_live.py b/sdk/search/azure-search-documents/tests/test_service_live.py index 44e213cfe5b1..113760a047e8 100644 --- a/sdk/search/azure-search-documents/tests/test_service_live.py +++ b/sdk/search/azure-search-documents/tests/test_service_live.py @@ -29,7 +29,8 @@ Skillset, DataSourceCredentials, DataSource, - DataContainer + DataContainer, + SynonymMap ) CWD = dirname(realpath(__file__)) @@ -98,6 +99,45 @@ def test_delete_indexes(self, api_key, endpoint, index_name, **kwargs): @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + def test_delete_indexes_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_indexes_client() + + # First create an index + name = "hotels" + fields = [ + { + "name": "hotelId", + "type": "Edm.String", + "key": True, + "searchable": False + }, + { + "name": "baseRate", + "type": "Edm.Double" + }] + scoring_profile = ScoringProfile( + name="MyProfile" + ) + scoring_profiles = [] + scoring_profiles.append(scoring_profile) + cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60) + index = Index( + name=name, + fields=fields, + scoring_profiles=scoring_profiles, + cors_options=cors_options) + result = client.create_index(index) + etag = result.e_tag + # get e tag nd update + index.scoring_profiles = [] + client.create_or_update_index(index.name, index) + + index.e_tag = etag + with pytest.raises(HttpResponseError): + client.delete_index(index, only_if_unchanged=True) + + @ResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) def test_create_index(self, api_key, endpoint, index_name, **kwargs): name = "hotels" fields = [ @@ -173,6 +213,45 @@ def test_create_or_update_index(self, api_key, endpoint, index_name, **kwargs): @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + def test_create_or_update_indexes_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_indexes_client() + + # First create an index + name = "hotels" + fields = [ + { + "name": "hotelId", + "type": "Edm.String", + "key": True, + "searchable": False + }, + { + "name": "baseRate", + "type": "Edm.Double" + }] + scoring_profile = ScoringProfile( + name="MyProfile" + ) + scoring_profiles = [] + scoring_profiles.append(scoring_profile) + cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60) + index = Index( + name=name, + fields=fields, + scoring_profiles=scoring_profiles, + cors_options=cors_options) + result = client.create_index(index) + etag = result.e_tag + # get e tag nd update + index.scoring_profiles = [] + client.create_or_update_index(index.name, index) + + index.e_tag = etag + with pytest.raises(HttpResponseError): + client.create_or_update_index(index.name, index, only_if_unchanged=True) + + @ResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) def test_analyze_text(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_indexes_client() analyze_request = AnalyzeRequest(text="One's ", analyzer="standard.lucene") @@ -180,6 +259,12 @@ def test_analyze_text(self, api_key, endpoint, index_name, **kwargs): assert len(result.tokens) == 2 class SearchSynonymMapsClientTest(AzureMgmtTestCase): + def _build_synonym_map_from_dict(self, synonym_map): + sm = SynonymMap(name=synonym_map["name"], synonyms=synonym_map["synonyms"]) + for k, v in synonym_map.items(): + setattr(sm, k, v) + + return sm @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) @@ -211,6 +296,26 @@ def test_delete_synonym_map(self, api_key, endpoint, index_name, **kwargs): @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + def test_delete_synonym_map_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_synonym_maps_client() + result = client.create_synonym_map("test-syn-map", [ + "USA, United States, United States of America", + "Washington, Wash. => WA", + ]) + sm_result = self._build_synonym_map_from_dict(result) + etag = sm_result.e_tag + + client.create_or_update_synonym_map("test-syn-map", [ + "Washington, Wash. => WA", + ]) + + sm_result.e_tag = etag + with pytest.raises(HttpResponseError): + client.delete_synonym_map(sm_result, only_if_unchanged=True) + assert len(client.get_synonym_maps()) == 1 + + @ResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) def test_get_synonym_map(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_synonym_maps_client() client.create_synonym_map("test-syn-map", [ @@ -260,6 +365,24 @@ def test_create_or_update_synonym_map(self, api_key, endpoint, index_name, **kwa "Washington, Wash. => WA", ] + @ResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + def test_create_or_update_synonym_map_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_synonym_maps_client() + result = self._build_synonym_map_from_dict(client.create_synonym_map("test-syn-map", [ + "USA, United States, United States of America", + ])) + etag = result.e_tag + + client.create_or_update_synonym_map("test-syn-map", [ + "Washington, Wash. => WA", + ]) + + result.e_tag = etag + with pytest.raises(HttpResponseError): + client.create_or_update_synonym_map(result, only_if_unchanged=True) + + class SearchSkillsetClientTest(AzureMgmtTestCase): @SearchResourceGroupPreparer(random_name_enabled=True) @@ -295,6 +418,22 @@ def test_delete_skillset(self, api_key, endpoint, index_name, **kwargs): @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + def test_delete_skillset_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_skillsets_client() + s = EntityRecognitionSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], + outputs=[OutputFieldMappingEntry(name="organizations", target_name="organizations")]) + + result = client.create_skillset(name='test-ss', skills=[s], description="desc") + etag = result.e_tag + + updated = client.create_or_update_skillset(name='test-ss', skills=[s], description="updated") + updated.e_tag = etag + + with pytest.raises(HttpResponseError): + client.delete_skillset(updated, only_if_unchanged=True) + + @ResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) def test_get_skillset(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_skillsets_client() s = EntityRecognitionSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], @@ -357,6 +496,23 @@ def test_create_or_update_skillset_inplace(self, api_key, endpoint, index_name, assert result.name == "test-ss" assert result.description == "desc2" + @ResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + def test_create_or_update_skillset_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_skillsets_client() + s = EntityRecognitionSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], + outputs=[OutputFieldMappingEntry(name="organizations", target_name="organizations")]) + + ss = client.create_or_update_skillset(name='test-ss', skills=[s], description="desc1") + etag = ss.e_tag + + client.create_or_update_skillset(name='test-ss', skills=[s], description="desc2", skillset=ss) + assert len(client.get_skillsets()) == 1 + + ss.e_tag = etag + with pytest.raises(HttpResponseError): + client.create_or_update_skillset(name='test-ss', skills=[s], skillset=ss, only_if_unchanged=True) + class SearchDataSourcesClientTest(AzureMgmtTestCase): def _create_datasource(self, name="sample-datasource"): @@ -423,3 +579,40 @@ def test_create_or_update_datasource(self, api_key, endpoint, index_name, **kwar result = client.get_datasource("sample-datasource") assert result.name == "sample-datasource" assert result.description == "updated" + + @ResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + def test_create_or_update_datasource_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_datasources_client() + data_source = self._create_datasource() + created = client.create_datasource(data_source) + etag = created.e_tag + + # Now update the data source + data_source.description = "updated" + client.create_or_update_datasource(data_source) + + # prepare data source + data_source.e_tag = etag # reset to the original datasource + data_source.description = "changed" + with pytest.raises(HttpResponseError): + client.create_or_update_datasource(data_source, only_if_unchanged=True) + assert len(client.get_datasources()) == 1 + + @ResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + def test_delete_datasource_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_datasources_client() + data_source = self._create_datasource() + created = client.create_datasource(data_source) + etag = created.e_tag + + # Now update the data source + data_source.description = "updated" + client.create_or_update_datasource(data_source) + + # prepare data source + data_source.e_tag = etag # reset to the original datasource + with pytest.raises(HttpResponseError): + client.delete_datasource(data_source, only_if_unchanged=True) + assert len(client.get_datasources()) == 1 From 722fd373cd727cc99fcf7a25ac5a050d2ae418e5 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 28 Apr 2020 22:34:21 -0700 Subject: [PATCH 02/17] async --- .../documents/_service/_indexes_client.py | 1 - .../documents/_service/_skillsets_client.py | 7 +- .../_service/aio/_datasources_client.py | 43 ++-- .../documents/_service/aio/_indexes_client.py | 48 ++--- .../_service/aio/_skillsets_client.py | 47 +++-- .../_service/aio/_synonym_maps_client.py | 56 ++++-- ...ate_or_update_datasource_if_unchanged.yaml | 145 ++++++++++++++ ...create_or_update_indexes_if_unchanged.yaml | 148 ++++++++++++++ ...reate_or_update_skillset_if_unchanged.yaml | 189 ++++++++++++++++++ ...te_or_update_synonym_map_if_unchanged.yaml | 144 +++++++++++++ ...c.test_delete_datasource_if_unchanged.yaml | 137 +++++++++++++ ...sync.test_delete_indexes_if_unchanged.yaml | 139 +++++++++++++ ...ync.test_delete_skillset_if_unchanged.yaml | 138 +++++++++++++ ....test_delete_synonym_map_if_unchanged.yaml | 137 +++++++++++++ .../async_tests/test_service_live_async.py | 180 ++++++++++++++++- 15 files changed, 1491 insertions(+), 68 deletions(-) create mode 100644 sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_datasource_if_unchanged.yaml create mode 100644 sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_indexes_if_unchanged.yaml create mode 100644 sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_skillset_if_unchanged.yaml create mode 100644 sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_synonym_map_if_unchanged.yaml create mode 100644 sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_datasource_if_unchanged.yaml create mode 100644 sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_indexes_if_unchanged.yaml create mode 100644 sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_skillset_if_unchanged.yaml create mode 100644 sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_synonym_map_if_unchanged.yaml diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py index ca7a255a03bf..0e5f530e6c13 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py @@ -227,7 +227,6 @@ def create_or_update_index( :dedent: 4 :caption: Update an index. """ - error_map = {404: ResourceNotFoundError} # type: Dict[int, Any] access_condition = get_access_conditions(index, kwargs.pop('only_if_unchanged', False)) kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) patched_index = delistize_flags_for_index(index) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py index 30cee39a67b4..af410a8c23f9 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py @@ -208,4 +208,9 @@ def create_or_update_skillset(self, name, **kwargs): skills=kwargs.pop("skills", None), ) - return self._client.skillsets.create_or_update(name, skillset, access_condition=access_condition, **kwargs) + return self._client.skillsets.create_or_update( + skillset_name=name, + skillset=skillset, + access_condition=access_condition, + **kwargs + ) \ No newline at end of file diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py index ef2ce6887d5b..72d529a6d685 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py @@ -8,6 +8,7 @@ from azure.core.tracing.decorator_async import distributed_trace_async from .._generated.aio import SearchServiceClient as _SearchServiceClient +from .._utils import get_access_conditions from ..._headers_mixin import HeadersMixin from ..._version import SDK_MONIKER @@ -79,31 +80,40 @@ async def create_datasource(self, data_source, **kwargs): async def create_or_update_datasource(self, data_source, name=None, **kwargs): # type: (DataSource, Optional[str], **Any) -> Dict[str, Any] """Creates a new datasource or updates a datasource if it already exists. - :param name: The name of the datasource to create or update. :type name: str :param data_source: The definition of the datasource to create or update. :type data_source: ~search.models.DataSource + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed data_source. + :type only_if_unchanged: bool :return: The created DataSource :rtype: dict """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - + access_condition = get_access_conditions(data_source, kwargs.pop('only_if_unchanged', False)) if not name: name = data_source.name result = await self._client.data_sources.create_or_update( - name, data_source, **kwargs + data_source_name=name, + data_source=data_source, + access_condition=access_condition, + **kwargs ) return result @distributed_trace_async - async def delete_datasource(self, name, **kwargs): - # type: (str, **Any) -> None - """Deletes a datasource. - - :param name: The name of the datasource to delete. - :type name: str - + async def delete_datasource(self, data_source, **kwargs): + # type: (Union[str, DataSource], **Any) -> None + """Deletes a datasource. To use only_if_unchanged, the Datasource model must be + provided instead of the name. It is enough to provide the name of the datasource + to delete unconditionally + + :param data_source: The datasource to delete. + :type data_source: str or ~search.models.DataSource + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed data_source. + :type only_if_unchanged: bool :return: None :rtype: None @@ -117,8 +127,17 @@ async def delete_datasource(self, name, **kwargs): :caption: Delete a DataSource """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - result = await self._client.data_sources.delete(name, **kwargs) - return result + access_condition = None + try: + name = data_source.name + access_condition = get_access_conditions(data_source, kwargs.pop('only_if_unchanged', False)) + except AttributeError: + name = data_source + await self._client.data_sources.delete( + data_source_name=name, + access_condition=access_condition, + **kwargs + ) @distributed_trace_async async def get_datasource(self, name, **kwargs): diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py index 072809eac216..936d449b857e 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py @@ -22,6 +22,7 @@ listize_flags_for_index, prep_if_match, prep_if_none_match, + get_access_conditions ) from ..._headers_mixin import HeadersMixin from ..._version import SDK_MONIKER @@ -130,12 +131,16 @@ async def get_index_statistics(self, index_name, **kwargs): return result.as_dict() @distributed_trace_async - async def delete_index(self, index_name, **kwargs): - # type: (str, **Any) -> None - """Deletes a search index and all the documents it contains. - - :param index_name: The name of the index to retrieve. - :type index_name: str + async def delete_index(self, index, **kwargs): + # type: (Union[str, Index], **Any) -> None + """Deletes a search index and all the documents it contains. The model must be + provided instead of the name to use the access condition only_if_unchanged + + :param index: The index to retrieve. + :type index: str or ~search.models.Index + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed index. + :type only_if_unchanged: bool :raises: ~azure.core.exceptions.HttpResponseError .. admonition:: Example: @@ -148,7 +153,13 @@ async def delete_index(self, index_name, **kwargs): :caption: Delete an index. """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - await self._client.indexes.delete(index_name, **kwargs) + access_condition = None + try: + index_name = index.name + access_condition = get_access_conditions(index, kwargs.pop('only_if_unchanged', False)) + except AttributeError: + index_name = index + await self._client.indexes.delete(index_name=index_name, access_condition=access_condition, **kwargs) @distributed_trace_async async def create_index(self, index, **kwargs): @@ -181,7 +192,6 @@ async def create_or_update_index( index_name, index, allow_index_downtime=None, - match_condition=MatchConditions.Unconditionally, **kwargs ): # type: (str, Index, bool, MatchConditions, **Any) -> Index @@ -197,8 +207,9 @@ async def create_or_update_index( the index can be impaired for several minutes after the index is updated, or longer for very large indexes. :type allow_index_downtime: bool - :param match_condition: The match condition to use upon the etag - :type match_condition: `~azure.core.MatchConditions` + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed index. + :type only_if_unchanged: bool :return: The index created or updated :rtype: :class:`~azure.search.documents.Index` :raises: :class:`~azure.core.exceptions.ResourceNotFoundError`, \ @@ -216,22 +227,7 @@ async def create_or_update_index( :dedent: 4 :caption: Update an index. """ - error_map = {404: ResourceNotFoundError} # type: Dict[int, Any] - access_condition = None - if index.e_tag: - access_condition = AccessCondition() - access_condition.if_match = prep_if_match(index.e_tag, match_condition) - access_condition.if_none_match = prep_if_none_match( - index.e_tag, match_condition - ) - if match_condition == MatchConditions.IfNotModified: - error_map[412] = ResourceModifiedError - if match_condition == MatchConditions.IfModified: - error_map[304] = ResourceNotModifiedError - if match_condition == MatchConditions.IfPresent: - error_map[412] = ResourceNotFoundError - if match_condition == MatchConditions.IfMissing: - error_map[412] = ResourceExistsError + access_condition = get_access_conditions(index, kwargs.pop('only_if_unchanged', False)) kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) patched_index = delistize_flags_for_index(index) result = await self._client.indexes.create_or_update( diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py index 28b6cf8f398b..109bbafb147c 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py @@ -9,6 +9,7 @@ from .._generated.aio import SearchServiceClient as _SearchServiceClient from .._generated.models import Skillset +from .._utils import get_access_conditions from ..._headers_mixin import HeadersMixin from ..._version import SDK_MONIKER @@ -102,12 +103,17 @@ async def get_skillset(self, name, **kwargs): return await self._client.skillsets.get(name, **kwargs) @distributed_trace_async - async def delete_skillset(self, name, **kwargs): - # type: (str, **Any) -> None - """Delete a named Skillset in an Azure Search service - - :param name: The name of the Skillset to delete - :type name: str + async def delete_skillset(self, skillset, **kwargs): + # type: (Union[str, Skillset], **Any) -> None + """Delete a named Skillset in an Azure Search service. To use only_if_unchanged, + the Skillset model must be provided instead of the name. It is enough to provide + the name of the skillset to delete unconditionally + + :param name: The Skillset to delete + :type name: str or ~search.models.Skillset + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed skillset. + :type only_if_unchanged: bool .. admonition:: Example: @@ -120,7 +126,13 @@ async def delete_skillset(self, name, **kwargs): """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - await self._client.skillsets.delete(name, **kwargs) + access_condition = None + try: + name = skillset.name + access_condition = get_access_conditions(skillset, kwargs.pop('only_if_unchanged', False)) + except AttributeError: + name = skillset + await self._client.skillsets.delete(name, access_condition=access_condition, **kwargs) @distributed_trace_async async def create_skillset(self, name, skills, description, **kwargs): @@ -156,16 +168,20 @@ async def create_skillset(self, name, skills, description, **kwargs): async def create_or_update_skillset(self, name, **kwargs): # type: (str, **Any) -> Skillset """Create a new Skillset in an Azure Search service, or update an - existing one. + existing one. The skillset param must be provided to perform the + operation with access conditions. :param name: The name of the Skillset to create or update :type name: str - :param skills: A list of Skill objects to include in the Skillset + :keyword skills: A list of Skill objects to include in the Skillset :type skills: List[Skill] - :param description: A description for the Skillset + :keyword description: A description for the Skillset :type description: Optional[str] - :param skillset: A Skillset to create or update. + :keyword skillset: A Skillset to create or update. :type skillset: :class:`~azure.search.documents.Skillset` + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed skillset. + :type only_if_unchanged: bool :return: The created or updated Skillset :rtype: dict @@ -175,9 +191,11 @@ async def create_or_update_skillset(self, name, **kwargs): """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) + access_condition = None if "skillset" in kwargs: skillset = kwargs.pop("skillset") + access_condition = get_access_conditions(skillset, kwargs.pop('only_if_unchanged', False)) skillset = Skillset.deserialize(skillset.serialize()) skillset.name = name for param in ("description", "skills"): @@ -191,4 +209,9 @@ async def create_or_update_skillset(self, name, **kwargs): skills=kwargs.pop("skills", None), ) - return await self._client.skillsets.create_or_update(name, skillset, **kwargs) + return await self._client.skillsets.create_or_update( + skillset_name=name, + skillset=skillset, + access_condition=access_condition, + **kwargs + ) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py index 42b88de49cc5..dfe17d843671 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py @@ -9,7 +9,7 @@ from .._generated.aio import SearchServiceClient as _SearchServiceClient from .._generated.models import SynonymMap -from .._utils import listize_synonyms +from .._utils import listize_synonyms, get_access_conditions from ..._headers_mixin import HeadersMixin from ..._version import SDK_MONIKER @@ -104,12 +104,20 @@ async def get_synonym_map(self, name, **kwargs): return listize_synonyms(result.as_dict()) @distributed_trace_async - async def delete_synonym_map(self, name, **kwargs): - # type: (str, **Any) -> None - """Delete a named Synonym Map in an Azure Search service + async def delete_synonym_map(self, synonym_map, **kwargs): + # type: (Union[str, SynonymMap], **Any) -> None + """Delete a named Synonym Map in an Azure Search service. To use only_if_unchanged, + the SynonymMap model must be provided instead of the name. It is enough to provide + the name of the synonym map to delete unconditionally. + + :param name: The Synonym Map to delete + :type name: str or ~search.models.SynonymMap + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed synonym_map. + :type only_if_unchanged: bool + :return: None + :rtype: None - :param name: The name of the Synonym Map to delete - :type name: str .. admonition:: Example: @@ -122,7 +130,13 @@ async def delete_synonym_map(self, name, **kwargs): """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - await self._client.synonym_maps.delete(name, **kwargs) + access_condition = None + try: + name = synonym_map.name + access_condition = get_access_conditions(synonym_map, kwargs.pop('only_if_unchanged', False)) + except AttributeError: + name = synonym_map + await self._client.synonym_maps.delete(synonym_map_name=name, access_condition=access_condition, **kwargs) @distributed_trace_async async def create_synonym_map(self, name, synonyms, **kwargs): @@ -153,23 +167,37 @@ async def create_synonym_map(self, name, synonyms, **kwargs): return listize_synonyms(result.as_dict()) @distributed_trace_async - async def create_or_update_synonym_map(self, name, synonyms, **kwargs): - # type: (str, Sequence[str], **Any) -> dict + async def create_or_update_synonym_map(self, synonym_map, synonyms=None, **kwargs): + # type: (Union[str, SynonymMap], Optional[Sequence[str]], **Any) -> dict """Create a new Synonym Map in an Azure Search service, or update an existing one. - :param name: The name of the Synonym Map to create or update - :type name: str + :param synonym_map: The name of the Synonym Map to create or update + :type synonym_map: str or ~azure.search.documents.SynonymMap :param synonyms: A list of synonyms in SOLR format :type synonyms: List[str] + :keyword only_if_unchanged: If set to true, the operation is performed only if the + e_tag on the server matches the e_tag value of the passed synonym_map. + :type only_if_unchanged: bool :return: The created or updated Synonym Map :rtype: dict """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - solr_format_synonyms = "\n".join(synonyms) - synonym_map = SynonymMap(name=name, synonyms=solr_format_synonyms) + access_condition = None + try: + name = synonym_map.name + access_condition = get_access_conditions(synonym_map, kwargs.pop('only_if_unchanged', False)) + if synonyms: + synonym_map.synonyms = "\n".join(synonyms) + except AttributeError: + name = synonym_map + solr_format_synonyms = "\n".join(synonyms) + synonym_map = SynonymMap(name=name, synonyms=solr_format_synonyms) result = await self._client.synonym_maps.create_or_update( - name, synonym_map, **kwargs + synonym_map_name=name, + synonym_map=synonym_map, + access_condition=access_condition, + **kwargs ) return listize_synonyms(result.as_dict()) diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_datasource_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_datasource_if_unchanged.yaml new file mode 100644 index 000000000000..383d9fd8fd9a --- /dev/null +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_datasource_if_unchanged.yaml @@ -0,0 +1,145 @@ +interactions: +- request: + body: '{"name": "sample-datasource", "type": "azureblob", "credentials": {"connectionString": + "DefaultEndpointsProtocol=https;AccountName=storagename;AccountKey=NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg==;EndpointSuffix=core.windows.net"}, + "container": {"name": "searchcontainer"}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '319' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 9934F9F394547FDB82394143EC2A49E5 + method: POST + uri: https://searche2561c44.search.windows.net/datasources?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searche2561c44.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBFED6E968C7\"","name":"sample-datasource","description":null,"type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + headers: + cache-control: no-cache + content-length: '370' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:33:25 GMT + elapsed-time: '57' + etag: W/"0x8D7EBFED6E968C7" + expires: '-1' + location: https://searche2561c44.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: f2604cd0-89da-11ea-a3f0-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 201 + message: Created + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searche2561c44.search.windows.net + - /datasources + - api-version=2019-05-06-Preview + - '' +- request: + body: '{"name": "sample-datasource", "description": "updated", "type": "azureblob", + "credentials": {"connectionString": "DefaultEndpointsProtocol=https;AccountName=storagename;AccountKey=NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg==;EndpointSuffix=core.windows.net"}, + "container": {"name": "searchcontainer"}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '345' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 9934F9F394547FDB82394143EC2A49E5 + method: PUT + uri: https://searche2561c44.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searche2561c44.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBFED6F92313\"","name":"sample-datasource","description":"updated","type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + headers: + cache-control: no-cache + content-encoding: gzip + content-length: '365' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:33:25 GMT + elapsed-time: '46' + etag: W/"0x8D7EBFED6F92313" + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: f29e1606-89da-11ea-8535-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + vary: Accept-Encoding + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searche2561c44.search.windows.net + - /datasources('sample-datasource') + - api-version=2019-05-06-Preview + - '' +- request: + body: '{"name": "sample-datasource", "description": "changed", "type": "azureblob", + "credentials": {"connectionString": "DefaultEndpointsProtocol=https;AccountName=storagename;AccountKey=NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg==;EndpointSuffix=core.windows.net"}, + "container": {"name": "searchcontainer"}, "@odata.etag": "\"0x8D7EBFED6E968C7\""}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '385' + Content-Type: + - application/json + If-Match: + - '"0x8D7EBFED6E968C7"' + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 9934F9F394547FDB82394143EC2A49E5 + method: PUT + uri: https://searche2561c44.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: no-cache + content-language: en + content-length: '160' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:33:25 GMT + elapsed-time: '6' + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: f2ad9d64-89da-11ea-8625-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searche2561c44.search.windows.net + - /datasources('sample-datasource') + - api-version=2019-05-06-Preview + - '' +version: 1 diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_indexes_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_indexes_if_unchanged.yaml new file mode 100644 index 000000000000..2825b66979f2 --- /dev/null +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_indexes_if_unchanged.yaml @@ -0,0 +1,148 @@ +interactions: +- request: + body: '{"name": "hotels", "fields": [{"name": "hotelId", "type": "Edm.String", + "key": true, "searchable": false}, {"name": "baseRate", "type": "Edm.Double"}], + "scoringProfiles": [{"name": "MyProfile"}], "corsOptions": {"allowedOrigins": + ["*"], "maxAgeInSeconds": 60}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '260' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 3D334C55C9D5A2A42878933ACEDBF6E9 + method: POST + uri: https://search8e901b09.search.windows.net/indexes?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search8e901b09.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBFDD175C98C\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[{"name":"MyProfile","functionAggregation":null,"text":null,"functions":[]}],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + headers: + cache-control: no-cache + content-length: '890' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:26:07 GMT + elapsed-time: '894' + etag: W/"0x8D7EBFDD175C98C" + expires: '-1' + location: https://search8e901b09.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: ec8338d8-89d9-11ea-bf89-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 201 + message: Created + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - search8e901b09.search.windows.net + - /indexes + - api-version=2019-05-06-Preview + - '' +- request: + body: '{"name": "hotels", "fields": [{"name": "hotelId", "type": "Edm.String", + "key": true, "searchable": false}, {"name": "baseRate", "type": "Edm.Double"}], + "scoringProfiles": [], "corsOptions": {"allowedOrigins": ["*"], "maxAgeInSeconds": + 60}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '239' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 3D334C55C9D5A2A42878933ACEDBF6E9 + method: PUT + uri: https://search8e901b09.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search8e901b09.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBFDD1947AAB\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + headers: + cache-control: no-cache + content-encoding: gzip + content-length: '506' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:26:07 GMT + elapsed-time: '131' + etag: W/"0x8D7EBFDD1947AAB" + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: ed2ff258-89d9-11ea-831e-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + vary: Accept-Encoding + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - search8e901b09.search.windows.net + - /indexes('hotels') + - api-version=2019-05-06-Preview + - '' +- request: + body: '{"name": "hotels", "fields": [{"name": "hotelId", "type": "Edm.String", + "key": true, "searchable": false}, {"name": "baseRate", "type": "Edm.Double"}], + "scoringProfiles": [], "corsOptions": {"allowedOrigins": ["*"], "maxAgeInSeconds": + 60}, "@odata.etag": "\"0x8D7EBFDD175C98C\""}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '279' + Content-Type: + - application/json + If-Match: + - '"0x8D7EBFDD175C98C"' + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 3D334C55C9D5A2A42878933ACEDBF6E9 + method: PUT + uri: https://search8e901b09.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: no-cache + content-language: en + content-length: '160' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:26:07 GMT + elapsed-time: '27' + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: ed4c19da-89d9-11ea-8928-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - search8e901b09.search.windows.net + - /indexes('hotels') + - api-version=2019-05-06-Preview + - '' +version: 1 diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_skillset_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_skillset_if_unchanged.yaml new file mode 100644 index 000000000000..3d5b2b1c8755 --- /dev/null +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_skillset_if_unchanged.yaml @@ -0,0 +1,189 @@ +interactions: +- request: + body: '{"name": "test-ss", "description": "desc1", "skills": [{"@odata.type": + "#Microsoft.Skills.Text.EntityRecognitionSkill", "inputs": [{"name": "text", + "source": "/document/content"}], "outputs": [{"name": "organizations", "targetName": + "organizations"}]}]}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '253' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 2793D4FA267F0520CBA834F3F73ADB14 + method: PUT + uri: https://searchab6c1b84.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searchab6c1b84.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBFEAB2F1999\"","name":"test-ss","description":"desc1","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + headers: + cache-control: no-cache + content-length: '588' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:32:11 GMT + elapsed-time: '147' + etag: W/"0x8D7EBFEAB2F1999" + expires: '-1' + location: https://searchab6c1b84.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: c69e43fa-89da-11ea-9542-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 201 + message: Created + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searchab6c1b84.search.windows.net + - /skillsets('test-ss') + - api-version=2019-05-06-Preview + - '' +- request: + body: '{"name": "test-ss", "description": "desc2", "skills": [{"@odata.type": + "#Microsoft.Skills.Text.EntityRecognitionSkill", "inputs": [{"name": "text", + "source": "/document/content"}], "outputs": [{"name": "organizations", "targetName": + "organizations"}]}], "@odata.etag": "\"0x8D7EBFEAB2F1999\""}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '293' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 2793D4FA267F0520CBA834F3F73ADB14 + method: PUT + uri: https://searchab6c1b84.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searchab6c1b84.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBFEAB42F34B\"","name":"test-ss","description":"desc2","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + headers: + cache-control: no-cache + content-encoding: gzip + content-length: '464' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:32:12 GMT + elapsed-time: '154' + etag: W/"0x8D7EBFEAB42F34B" + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: c6e553e2-89da-11ea-8220-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + vary: Accept-Encoding + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searchab6c1b84.search.windows.net + - /skillsets('test-ss') + - api-version=2019-05-06-Preview + - '' +- request: + body: null + headers: + Accept: + - application/json;odata.metadata=minimal + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 2793D4FA267F0520CBA834F3F73ADB14 + method: GET + uri: https://searchab6c1b84.search.windows.net/skillsets?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searchab6c1b84.search.windows.net/$metadata#skillsets","value":[{"@odata.etag":"\"0x8D7EBFEAB42F34B\"","name":"test-ss","description":"desc2","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":"#1","description":null,"context":"/document","categories":["Person","Quantity","Organization","URL","Email","Location","DateTime"],"defaultLanguageCode":"en","minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}]}' + headers: + cache-control: no-cache + content-encoding: gzip + content-length: '521' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:32:12 GMT + elapsed-time: '45' + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: c706aeee-89da-11ea-a068-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + vary: Accept-Encoding + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searchab6c1b84.search.windows.net + - /skillsets + - api-version=2019-05-06-Preview + - '' +- request: + body: '{"name": "test-ss", "description": "desc1", "skills": [{"@odata.type": + "#Microsoft.Skills.Text.EntityRecognitionSkill", "inputs": [{"name": "text", + "source": "/document/content"}], "outputs": [{"name": "organizations", "targetName": + "organizations"}]}], "@odata.etag": "\"0x8D7EBFEAB2F1999\""}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '293' + Content-Type: + - application/json + If-Match: + - '"0x8D7EBFEAB2F1999"' + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 2793D4FA267F0520CBA834F3F73ADB14 + method: PUT + uri: https://searchab6c1b84.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: no-cache + content-language: en + content-length: '160' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:32:12 GMT + elapsed-time: '13' + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: c716caf6-89da-11ea-950e-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searchab6c1b84.search.windows.net + - /skillsets('test-ss') + - api-version=2019-05-06-Preview + - '' +version: 1 diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_synonym_map_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_synonym_map_if_unchanged.yaml new file mode 100644 index 000000000000..4b47c2404166 --- /dev/null +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_synonym_map_if_unchanged.yaml @@ -0,0 +1,144 @@ +interactions: +- request: + body: '{"name": "test-syn-map", "format": "solr", "synonyms": "USA, United States, + United States of America"}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '102' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 1F470418E60BD2366ACB8D27D1F361CA + method: POST + uri: https://search2ac1cd3.search.windows.net/synonymmaps?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search2ac1cd3.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7EBFE52E29170\"","name":"test-syn-map","format":"solr","synonyms":"USA, + United States, United States of America","encryptionKey":null}' + headers: + cache-control: no-cache + content-length: '246' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:29:43 GMT + elapsed-time: '22' + etag: W/"0x8D7EBFE52E29170" + expires: '-1' + location: https://search2ac1cd3.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: 6e62904c-89da-11ea-8ed2-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 201 + message: Created + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - search2ac1cd3.search.windows.net + - /synonymmaps + - api-version=2019-05-06-Preview + - '' +- request: + body: '{"name": "test-syn-map", "format": "solr", "synonyms": "Washington, Wash. + => WA"}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '81' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 1F470418E60BD2366ACB8D27D1F361CA + method: PUT + uri: https://search2ac1cd3.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search2ac1cd3.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7EBFE52ED8FE6\"","name":"test-syn-map","format":"solr","synonyms":"Washington, + Wash. => WA","encryptionKey":null}' + headers: + cache-control: no-cache + content-encoding: gzip + content-length: '301' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:29:43 GMT + elapsed-time: '17' + etag: W/"0x8D7EBFE52ED8FE6" + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: 6e9516d8-89da-11ea-af0b-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + vary: Accept-Encoding + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - search2ac1cd3.search.windows.net + - /synonymmaps('test-syn-map') + - api-version=2019-05-06-Preview + - '' +- request: + body: '{"name": "test-syn-map", "format": "solr", "synonyms": "[''USA, United + States, United States of America'']", "@odata.etag": "\"0x8D7EBFE52E29170\""}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '146' + Content-Type: + - application/json + If-Match: + - '"0x8D7EBFE52E29170"' + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 1F470418E60BD2366ACB8D27D1F361CA + method: PUT + uri: https://search2ac1cd3.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: no-cache + content-language: en + content-length: '160' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:29:43 GMT + elapsed-time: '8' + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: 6ea00d7e-89da-11ea-8cd0-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - search2ac1cd3.search.windows.net + - /synonymmaps('test-syn-map') + - api-version=2019-05-06-Preview + - '' +version: 1 diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_datasource_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_datasource_if_unchanged.yaml new file mode 100644 index 000000000000..dfb52f2e8da4 --- /dev/null +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_datasource_if_unchanged.yaml @@ -0,0 +1,137 @@ +interactions: +- request: + body: '{"name": "sample-datasource", "type": "azureblob", "credentials": {"connectionString": + "DefaultEndpointsProtocol=https;AccountName=storagename;AccountKey=NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg==;EndpointSuffix=core.windows.net"}, + "container": {"name": "searchcontainer"}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '319' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 8FB8762DCBC41254CE64DD3DB80AF75C + method: POST + uri: https://searchd88c1821.search.windows.net/datasources?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searchd88c1821.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBFEE09DC6D9\"","name":"sample-datasource","description":null,"type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + headers: + cache-control: no-cache + content-length: '370' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:33:41 GMT + elapsed-time: '70' + etag: W/"0x8D7EBFEE09DC6D9" + expires: '-1' + location: https://searchd88c1821.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: fc27f286-89da-11ea-ae0d-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 201 + message: Created + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searchd88c1821.search.windows.net + - /datasources + - api-version=2019-05-06-Preview + - '' +- request: + body: '{"name": "sample-datasource", "description": "updated", "type": "azureblob", + "credentials": {"connectionString": "DefaultEndpointsProtocol=https;AccountName=storagename;AccountKey=NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg==;EndpointSuffix=core.windows.net"}, + "container": {"name": "searchcontainer"}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '345' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 8FB8762DCBC41254CE64DD3DB80AF75C + method: PUT + uri: https://searchd88c1821.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searchd88c1821.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBFEE0AA4C3B\"","name":"sample-datasource","description":"updated","type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + headers: + cache-control: no-cache + content-encoding: gzip + content-length: '364' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:33:41 GMT + elapsed-time: '41' + etag: W/"0x8D7EBFEE0AA4C3B" + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: fc51a506-89da-11ea-96e0-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + vary: Accept-Encoding + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searchd88c1821.search.windows.net + - /datasources('sample-datasource') + - api-version=2019-05-06-Preview + - '' +- request: + body: null + headers: + Accept: + - application/json;odata.metadata=minimal + If-Match: + - '"0x8D7EBFEE09DC6D9"' + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 8FB8762DCBC41254CE64DD3DB80AF75C + method: DELETE + uri: https://searchd88c1821.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: no-cache + content-language: en + content-length: '160' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:33:41 GMT + elapsed-time: '6' + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: fc5f2ec0-89da-11ea-b074-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searchd88c1821.search.windows.net + - /datasources('sample-datasource') + - api-version=2019-05-06-Preview + - '' +version: 1 diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_indexes_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_indexes_if_unchanged.yaml new file mode 100644 index 000000000000..2fd57765380f --- /dev/null +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_indexes_if_unchanged.yaml @@ -0,0 +1,139 @@ +interactions: +- request: + body: '{"name": "hotels", "fields": [{"name": "hotelId", "type": "Edm.String", + "key": true, "searchable": false}, {"name": "baseRate", "type": "Edm.Double"}], + "scoringProfiles": [{"name": "MyProfile"}], "corsOptions": {"allowedOrigins": + ["*"], "maxAgeInSeconds": 60}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '260' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 9AB5844141C2630ED3729D56C13F5B77 + method: POST + uri: https://search912f16e6.search.windows.net/indexes?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search912f16e6.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBFDEAE97C83\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[{"name":"MyProfile","functionAggregation":null,"text":null,"functions":[]}],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + headers: + cache-control: no-cache + content-length: '890' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:26:48 GMT + elapsed-time: '945' + etag: W/"0x8D7EBFDEAE97C83" + expires: '-1' + location: https://search912f16e6.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: 05e79154-89da-11ea-8299-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 201 + message: Created + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - search912f16e6.search.windows.net + - /indexes + - api-version=2019-05-06-Preview + - '' +- request: + body: '{"name": "hotels", "fields": [{"name": "hotelId", "type": "Edm.String", + "key": true, "searchable": false}, {"name": "baseRate", "type": "Edm.Double"}], + "scoringProfiles": [], "corsOptions": {"allowedOrigins": ["*"], "maxAgeInSeconds": + 60}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '239' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 9AB5844141C2630ED3729D56C13F5B77 + method: PUT + uri: https://search912f16e6.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://search912f16e6.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBFDEB08CA07\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + headers: + cache-control: no-cache + content-encoding: gzip + content-length: '506' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:26:49 GMT + elapsed-time: '156' + etag: W/"0x8D7EBFDEB08CA07" + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: 06a298fa-89da-11ea-9a6c-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + vary: Accept-Encoding + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - search912f16e6.search.windows.net + - /indexes('hotels') + - api-version=2019-05-06-Preview + - '' +- request: + body: null + headers: + Accept: + - application/json;odata.metadata=minimal + If-Match: + - '"0x8D7EBFDEAE97C83"' + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 9AB5844141C2630ED3729D56C13F5B77 + method: DELETE + uri: https://search912f16e6.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: no-cache + content-language: en + content-length: '160' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:26:49 GMT + elapsed-time: '18' + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: 06c5e56e-89da-11ea-af40-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - search912f16e6.search.windows.net + - /indexes('hotels') + - api-version=2019-05-06-Preview + - '' +version: 1 diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_skillset_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_skillset_if_unchanged.yaml new file mode 100644 index 000000000000..808f2af956c7 --- /dev/null +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_skillset_if_unchanged.yaml @@ -0,0 +1,138 @@ +interactions: +- request: + body: '{"name": "test-ss", "description": "desc", "skills": [{"@odata.type": "#Microsoft.Skills.Text.EntityRecognitionSkill", + "inputs": [{"name": "text", "source": "/document/content"}], "outputs": [{"name": + "organizations", "targetName": "organizations"}]}]}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '252' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 36DD0265BF1F3517C97B8BDED46C4F81 + method: POST + uri: https://searcha9e81761.search.windows.net/skillsets?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searcha9e81761.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBFE8EB6C23F\"","name":"test-ss","description":"desc","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + headers: + cache-control: no-cache + content-length: '587' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:31:24 GMT + elapsed-time: '144' + etag: W/"0x8D7EBFE8EB6C23F" + expires: '-1' + location: https://searcha9e81761.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: aa38cb98-89da-11ea-a6f3-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 201 + message: Created + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searcha9e81761.search.windows.net + - /skillsets + - api-version=2019-05-06-Preview + - '' +- request: + body: '{"name": "test-ss", "description": "updated", "skills": [{"@odata.type": + "#Microsoft.Skills.Text.EntityRecognitionSkill", "inputs": [{"name": "text", + "source": "/document/content"}], "outputs": [{"name": "organizations", "targetName": + "organizations"}]}]}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '255' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 36DD0265BF1F3517C97B8BDED46C4F81 + method: PUT + uri: https://searcha9e81761.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searcha9e81761.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBFE8EC6A3A2\"","name":"test-ss","description":"updated","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + headers: + cache-control: no-cache + content-encoding: gzip + content-length: '466' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:31:24 GMT + elapsed-time: '48' + etag: W/"0x8D7EBFE8EC6A3A2" + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: aa6b50c0-89da-11ea-802d-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + vary: Accept-Encoding + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searcha9e81761.search.windows.net + - /skillsets('test-ss') + - api-version=2019-05-06-Preview + - '' +- request: + body: null + headers: + Accept: + - application/json;odata.metadata=minimal + If-Match: + - '"0x8D7EBFE8EB6C23F"' + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 36DD0265BF1F3517C97B8BDED46C4F81 + method: DELETE + uri: https://searcha9e81761.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: no-cache + content-language: en + content-length: '160' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:31:24 GMT + elapsed-time: '13' + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: aa7a8a06-89da-11ea-9d6c-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searcha9e81761.search.windows.net + - /skillsets('test-ss') + - api-version=2019-05-06-Preview + - '' +version: 1 diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_synonym_map_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_synonym_map_if_unchanged.yaml new file mode 100644 index 000000000000..24c6b878affc --- /dev/null +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_synonym_map_if_unchanged.yaml @@ -0,0 +1,137 @@ +interactions: +- request: + body: '{"name": "test-syn-map", "format": "solr", "synonyms": "USA, United States, + United States of America\nWashington, Wash. => WA"}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '127' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - E39678EFF623BB3835D835591F71923A + method: POST + uri: https://searchf4b018b0.search.windows.net/synonymmaps?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searchf4b018b0.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7EBFE66105C68\"","name":"test-syn-map","format":"solr","synonyms":"USA, + United States, United States of America\nWashington, Wash. => WA","encryptionKey":null}' + headers: + cache-control: no-cache + content-length: '272' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:30:16 GMT + elapsed-time: '21' + etag: W/"0x8D7EBFE66105C68" + expires: '-1' + location: https://searchf4b018b0.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: 81a052b4-89da-11ea-9760-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 201 + message: Created + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searchf4b018b0.search.windows.net + - /synonymmaps + - api-version=2019-05-06-Preview + - '' +- request: + body: '{"name": "test-syn-map", "format": "solr", "synonyms": "Washington, Wash. + => WA"}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '81' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - E39678EFF623BB3835D835591F71923A + method: PUT + uri: https://searchf4b018b0.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searchf4b018b0.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7EBFE661B5AE7\"","name":"test-syn-map","format":"solr","synonyms":"Washington, + Wash. => WA","encryptionKey":null}' + headers: + cache-control: no-cache + content-encoding: gzip + content-length: '302' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:30:16 GMT + elapsed-time: '17' + etag: W/"0x8D7EBFE661B5AE7" + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: 81c35314-89da-11ea-b434-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + vary: Accept-Encoding + status: + code: 200 + message: OK + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searchf4b018b0.search.windows.net + - /synonymmaps('test-syn-map') + - api-version=2019-05-06-Preview + - '' +- request: + body: null + headers: + Accept: + - application/json;odata.metadata=minimal + If-Match: + - '"0x8D7EBFE66105C68"' + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - E39678EFF623BB3835D835591F71923A + method: DELETE + uri: https://searchf4b018b0.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview + response: + body: + string: '{"error":{"code":"","message":"The precondition given in one of the + request headers evaluated to false. No change was made to the resource from + this request."}}' + headers: + cache-control: no-cache + content-language: en + content-length: '160' + content-type: application/json; odata.metadata=minimal + date: Wed, 29 Apr 2020 05:30:16 GMT + elapsed-time: '10' + expires: '-1' + odata-version: '4.0' + pragma: no-cache + preference-applied: odata.include-annotations="*" + request-id: 81cdae24-89da-11ea-bc5b-2816a845e8c6 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 412 + message: Precondition Failed + url: !!python/object/new:yarl.URL + state: !!python/tuple + - !!python/object/new:urllib.parse.SplitResult + - https + - searchf4b018b0.search.windows.net + - /synonymmaps('test-syn-map') + - api-version=2019-05-06-Preview + - '' +version: 1 diff --git a/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py b/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py index c09085af7789..1faa4468d040 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py +++ b/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py @@ -32,7 +32,8 @@ Skillset, DataSourceCredentials, DataSource, - DataContainer + DataContainer, + SynonymMap ) from azure.search.documents.aio import SearchServiceClient @@ -115,6 +116,45 @@ async def test_delete_indexes(self, api_key, endpoint, index_name, **kwargs): @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + async def test_delete_indexes_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_indexes_client() + + # First create an index + name = "hotels" + fields = [ + { + "name": "hotelId", + "type": "Edm.String", + "key": True, + "searchable": False + }, + { + "name": "baseRate", + "type": "Edm.Double" + }] + scoring_profile = ScoringProfile( + name="MyProfile" + ) + scoring_profiles = [] + scoring_profiles.append(scoring_profile) + cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60) + index = Index( + name=name, + fields=fields, + scoring_profiles=scoring_profiles, + cors_options=cors_options) + result = await client.create_index(index) + etag = result.e_tag + # get e tag nd update + index.scoring_profiles = [] + await client.create_or_update_index(index.name, index) + + index.e_tag = etag + with pytest.raises(HttpResponseError): + await client.delete_index(index, only_if_unchanged=True) + + @ResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) async def test_create_index(self, api_key, endpoint, index_name, **kwargs): name = "hotels" fields = [ @@ -190,6 +230,45 @@ async def test_create_or_update_index(self, api_key, endpoint, index_name, **kwa @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + async def test_create_or_update_indexes_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_indexes_client() + + # First create an index + name = "hotels" + fields = [ + { + "name": "hotelId", + "type": "Edm.String", + "key": True, + "searchable": False + }, + { + "name": "baseRate", + "type": "Edm.Double" + }] + scoring_profile = ScoringProfile( + name="MyProfile" + ) + scoring_profiles = [] + scoring_profiles.append(scoring_profile) + cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60) + index = Index( + name=name, + fields=fields, + scoring_profiles=scoring_profiles, + cors_options=cors_options) + result = await client.create_index(index) + etag = result.e_tag + # get e tag nd update + index.scoring_profiles = [] + await client.create_or_update_index(index.name, index) + + index.e_tag = etag + with pytest.raises(HttpResponseError): + await client.create_or_update_index(index.name, index, only_if_unchanged=True) + + @ResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) async def test_analyze_text(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_indexes_client() analyze_request = AnalyzeRequest(text="One's ", analyzer="standard.lucene") @@ -197,6 +276,12 @@ async def test_analyze_text(self, api_key, endpoint, index_name, **kwargs): assert len(result.tokens) == 2 class SearchSynonymMapsClientTest(AzureMgmtTestCase): + def _build_synonym_map_from_dict(self, synonym_map): + sm = SynonymMap(name=synonym_map["name"], synonyms=synonym_map["synonyms"]) + for k, v in synonym_map.items(): + setattr(sm, k, v) + + return sm @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) @@ -228,6 +313,26 @@ async def test_delete_synonym_map(self, api_key, endpoint, index_name, **kwargs) @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + async def test_delete_synonym_map_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_synonym_maps_client() + result = await client.create_synonym_map("test-syn-map", [ + "USA, United States, United States of America", + "Washington, Wash. => WA", + ]) + sm_result = self._build_synonym_map_from_dict(result) + etag = sm_result.e_tag + + await client.create_or_update_synonym_map("test-syn-map", [ + "Washington, Wash. => WA", + ]) + + sm_result.e_tag = etag + with pytest.raises(HttpResponseError): + await client.delete_synonym_map(sm_result, only_if_unchanged=True) + assert len(client.get_synonym_maps()) == 1 + + @ResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) async def test_get_synonym_map(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_synonym_maps_client() await client.create_synonym_map("test-syn-map", [ @@ -277,7 +382,7 @@ async def test_create_or_update_synonym_map(self, api_key, endpoint, index_name, "Washington, Wash. => WA", ] -class SearchDataSourcesClientTest(AzureMgmtTestCase): +class SearchSkillsetClientTest(AzureMgmtTestCase): @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) @@ -314,6 +419,22 @@ async def test_delete_skillset(self, api_key, endpoint, index_name, **kwargs): @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + async def test_delete_skillset_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_skillsets_client() + s = EntityRecognitionSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], + outputs=[OutputFieldMappingEntry(name="organizations", target_name="organizations")]) + + result = await client.create_skillset(name='test-ss', skills=[s], description="desc") + etag = result.e_tag + + updated = await client.create_or_update_skillset(name='test-ss', skills=[s], description="updated") + updated.e_tag = etag + + with pytest.raises(HttpResponseError): + await client.delete_skillset(updated, only_if_unchanged=True) + + @ResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) async def test_get_skillset(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_skillsets_client() s = EntityRecognitionSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], @@ -376,6 +497,24 @@ async def test_create_or_update_skillset_inplace(self, api_key, endpoint, index_ assert result.name == "test-ss" assert result.description == "desc2" + @ResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + async def test_create_or_update_skillset_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_skillsets_client() + s = EntityRecognitionSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], + outputs=[OutputFieldMappingEntry(name="organizations", target_name="organizations")]) + + ss = await client.create_or_update_skillset(name='test-ss', skills=[s], description="desc1") + etag = ss.e_tag + + await client.create_or_update_skillset(name='test-ss', skills=[s], description="desc2", skillset=ss) + assert len(await client.get_skillsets()) == 1 + + ss.e_tag = etag + with pytest.raises(HttpResponseError): + await client.create_or_update_skillset(name='test-ss', skills=[s], skillset=ss, only_if_unchanged=True) + + class SearchDataSourcesClientTest(AzureMgmtTestCase): def _create_datasource(self, name="sample-datasource"): @@ -442,3 +581,40 @@ async def test_create_or_update_datasource_async(self, api_key, endpoint, index_ result = await client.get_datasource("sample-datasource") assert result.name == "sample-datasource" assert result.description == "updated" + + @ResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + async def test_create_or_update_datasource_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_datasources_client() + data_source = self._create_datasource() + created = await client.create_datasource(data_source) + etag = created.e_tag + + # Now update the data source + data_source.description = "updated" + await client.create_or_update_datasource(data_source) + + # prepare data source + data_source.e_tag = etag # reset to the original datasource + data_source.description = "changed" + with pytest.raises(HttpResponseError): + await client.create_or_update_datasource(data_source, only_if_unchanged=True) + assert len(await client.get_datasources()) == 1 + + @ResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + async def test_delete_datasource_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_datasources_client() + data_source = self._create_datasource() + created = await client.create_datasource(data_source) + etag = created.e_tag + + # Now update the data source + data_source.description = "updated" + await client.create_or_update_datasource(data_source) + + # prepare data source + data_source.e_tag = etag # reset to the original datasource + with pytest.raises(HttpResponseError): + await client.delete_datasource(data_source, only_if_unchanged=True) + assert len(await client.get_datasources()) == 1 From 92207f704dfc397697528ecb328d29c0d57f1f7c Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 28 Apr 2020 22:54:29 -0700 Subject: [PATCH 03/17] lint --- .../documents/_service/_datasources_client.py | 2 +- .../search/documents/_service/_indexes_client.py | 12 +----------- .../search/documents/_service/_skillsets_client.py | 4 ++-- .../documents/_service/_synonym_maps_client.py | 2 +- .../azure/search/documents/_service/_utils.py | 2 +- .../documents/_service/aio/_datasources_client.py | 2 +- .../documents/_service/aio/_indexes_client.py | 13 +------------ .../documents/_service/aio/_skillsets_client.py | 2 +- .../documents/_service/aio/_synonym_maps_client.py | 2 +- 9 files changed, 10 insertions(+), 31 deletions(-) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py index eeda2448b611..bac95dbf26d0 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py @@ -15,7 +15,7 @@ if TYPE_CHECKING: # pylint:disable=unused-import,ungrouped-imports from ._generated.models import DataSource - from typing import Any, Dict, Optional, Sequence + from typing import Any, Dict, Optional, Sequence, Union from azure.core.credentials import AzureKeyCredential diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py index 0e5f530e6c13..a63004f28843 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py @@ -6,22 +6,12 @@ from typing import TYPE_CHECKING from azure.core.tracing.decorator import distributed_trace -from azure.core import MatchConditions -from azure.core.exceptions import ( - ResourceExistsError, - ResourceNotFoundError, - ResourceModifiedError, - ResourceNotModifiedError, -) from azure.core.paging import ItemPaged from ._generated import SearchServiceClient as _SearchServiceClient -from ._generated.models import AccessCondition from ._utils import ( delistize_flags_for_index, listize_flags_for_index, - prep_if_match, - prep_if_none_match, get_access_conditions ) from .._headers_mixin import HeadersMixin @@ -30,7 +20,7 @@ if TYPE_CHECKING: # pylint:disable=unused-import,ungrouped-imports from ._generated.models import AnalyzeRequest, AnalyzeResult, Index - from typing import Any, Dict, List + from typing import Any, Dict, List, Union from azure.core.credentials import AzureKeyCredential diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py index af410a8c23f9..b0efac243db9 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py @@ -16,7 +16,7 @@ if TYPE_CHECKING: # pylint:disable=unused-import,ungrouped-imports from ._generated.models import Skill - from typing import Any, List, Sequence + from typing import Any, List, Sequence, Union from azure.core.credentials import AzureKeyCredential @@ -213,4 +213,4 @@ def create_or_update_skillset(self, name, **kwargs): skillset=skillset, access_condition=access_condition, **kwargs - ) \ No newline at end of file + ) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py index b6a8ea9c83d0..f5e3767de2a3 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py @@ -16,7 +16,7 @@ if TYPE_CHECKING: # pylint:disable=unused-import,ungrouped-imports from ._generated.models import Skill - from typing import Any, Dict, List, Sequence + from typing import Any, Dict, List, Sequence, Union, Optional from azure.core.credentials import AzureKeyCredential diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py index 690e4a358759..bd87ec3491cf 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py @@ -155,7 +155,7 @@ def listize_synonyms(synonym_map): def get_access_conditions(model, only_if_unchanged=False): if not only_if_unchanged: - return + return None try: return AccessCondition(if_match=model.e_tag) except AttributeError: diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py index 72d529a6d685..22f54d72bc5b 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py @@ -15,7 +15,7 @@ if TYPE_CHECKING: # pylint:disable=unused-import,ungrouped-imports from .._generated.models import DataSource - from typing import Any, Dict, Optional, Sequence + from typing import Any, Dict, Optional, Sequence, Union from azure.core.credentials import AzureKeyCredential diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py index 936d449b857e..87453c6cc1e8 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py @@ -6,22 +6,11 @@ from typing import TYPE_CHECKING from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core import MatchConditions -from azure.core.exceptions import ( - ResourceExistsError, - ResourceNotFoundError, - ResourceModifiedError, - ResourceNotModifiedError, -) from azure.core.async_paging import AsyncItemPaged - from .._generated.aio import SearchServiceClient as _SearchServiceClient -from .._generated.models import AccessCondition from .._utils import ( delistize_flags_for_index, listize_flags_for_index, - prep_if_match, - prep_if_none_match, get_access_conditions ) from ..._headers_mixin import HeadersMixin @@ -30,7 +19,7 @@ if TYPE_CHECKING: # pylint:disable=unused-import,ungrouped-imports from .._generated.models import AnalyzeRequest, AnalyzeResult, Index - from typing import Any, Dict, List + from typing import Any, Dict, List, Union from azure.core.credentials import AzureKeyCredential diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py index 109bbafb147c..d61f402445b6 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py @@ -16,7 +16,7 @@ if TYPE_CHECKING: # pylint:disable=unused-import,ungrouped-imports from .._generated.models import Skill - from typing import Any, List, Sequence + from typing import Any, List, Sequence, Union from azure.core.credentials import AzureKeyCredential diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py index dfe17d843671..b040049bcfd7 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py @@ -16,7 +16,7 @@ if TYPE_CHECKING: # pylint:disable=unused-import,ungrouped-imports from .._generated.models import Skill - from typing import Any, Dict, List, Sequence + from typing import Any, Dict, List, Sequence, Union, Optional from azure.core.credentials import AzureKeyCredential From 288b46b15e2b1699b9a3507a2a7d51517e07450a Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 28 Apr 2020 22:56:51 -0700 Subject: [PATCH 04/17] Update sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py --- .../azure/search/documents/_service/_datasources_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py index bac95dbf26d0..f3757a9b7278 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py @@ -79,7 +79,7 @@ def create_datasource(self, data_source, **kwargs): @distributed_trace def create_or_update_datasource(self, data_source, name=None, **kwargs): - # type: (str, DataSource, Optional[str], **Any) -> Dict[str, Any] + # type: (DataSource, Optional[str], **Any) -> Dict[str, Any] """Creates a new datasource or updates a datasource if it already exists. :param name: The name of the datasource to create or update. :type name: str From 96d1318895ee92be98c0df7482c16abad48f3a4d Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Thu, 30 Apr 2020 02:00:37 -0700 Subject: [PATCH 05/17] tests fix --- .../tests/async_tests/test_service_live_async.py | 14 +++++++------- .../tests/test_service_live.py | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py b/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py index 1faa4468d040..37d1a9c82177 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py +++ b/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py @@ -153,7 +153,7 @@ async def test_delete_indexes_if_unchanged(self, api_key, endpoint, index_name, with pytest.raises(HttpResponseError): await client.delete_index(index, only_if_unchanged=True) - @ResourceGroupPreparer(random_name_enabled=True) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) async def test_create_index(self, api_key, endpoint, index_name, **kwargs): name = "hotels" @@ -267,7 +267,7 @@ async def test_create_or_update_indexes_if_unchanged(self, api_key, endpoint, in with pytest.raises(HttpResponseError): await client.create_or_update_index(index.name, index, only_if_unchanged=True) - @ResourceGroupPreparer(random_name_enabled=True) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) async def test_analyze_text(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_indexes_client() @@ -331,7 +331,7 @@ async def test_delete_synonym_map_if_unchanged(self, api_key, endpoint, index_na await client.delete_synonym_map(sm_result, only_if_unchanged=True) assert len(client.get_synonym_maps()) == 1 - @ResourceGroupPreparer(random_name_enabled=True) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) async def test_get_synonym_map(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_synonym_maps_client() @@ -433,7 +433,7 @@ async def test_delete_skillset_if_unchanged(self, api_key, endpoint, index_name, with pytest.raises(HttpResponseError): await client.delete_skillset(updated, only_if_unchanged=True) - @ResourceGroupPreparer(random_name_enabled=True) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) async def test_get_skillset(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_skillsets_client() @@ -497,7 +497,7 @@ async def test_create_or_update_skillset_inplace(self, api_key, endpoint, index_ assert result.name == "test-ss" assert result.description == "desc2" - @ResourceGroupPreparer(random_name_enabled=True) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) async def test_create_or_update_skillset_if_unchanged(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_skillsets_client() @@ -582,7 +582,7 @@ async def test_create_or_update_datasource_async(self, api_key, endpoint, index_ assert result.name == "sample-datasource" assert result.description == "updated" - @ResourceGroupPreparer(random_name_enabled=True) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) async def test_create_or_update_datasource_if_unchanged(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_datasources_client() @@ -601,7 +601,7 @@ async def test_create_or_update_datasource_if_unchanged(self, api_key, endpoint, await client.create_or_update_datasource(data_source, only_if_unchanged=True) assert len(await client.get_datasources()) == 1 - @ResourceGroupPreparer(random_name_enabled=True) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) async def test_delete_datasource_if_unchanged(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_datasources_client() diff --git a/sdk/search/azure-search-documents/tests/test_service_live.py b/sdk/search/azure-search-documents/tests/test_service_live.py index 113760a047e8..016e62491832 100644 --- a/sdk/search/azure-search-documents/tests/test_service_live.py +++ b/sdk/search/azure-search-documents/tests/test_service_live.py @@ -136,7 +136,7 @@ def test_delete_indexes_if_unchanged(self, api_key, endpoint, index_name, **kwar with pytest.raises(HttpResponseError): client.delete_index(index, only_if_unchanged=True) - @ResourceGroupPreparer(random_name_enabled=True) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) def test_create_index(self, api_key, endpoint, index_name, **kwargs): name = "hotels" @@ -250,7 +250,7 @@ def test_create_or_update_indexes_if_unchanged(self, api_key, endpoint, index_na with pytest.raises(HttpResponseError): client.create_or_update_index(index.name, index, only_if_unchanged=True) - @ResourceGroupPreparer(random_name_enabled=True) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) def test_analyze_text(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_indexes_client() @@ -314,7 +314,7 @@ def test_delete_synonym_map_if_unchanged(self, api_key, endpoint, index_name, ** client.delete_synonym_map(sm_result, only_if_unchanged=True) assert len(client.get_synonym_maps()) == 1 - @ResourceGroupPreparer(random_name_enabled=True) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) def test_get_synonym_map(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_synonym_maps_client() @@ -365,7 +365,7 @@ def test_create_or_update_synonym_map(self, api_key, endpoint, index_name, **kwa "Washington, Wash. => WA", ] - @ResourceGroupPreparer(random_name_enabled=True) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) def test_create_or_update_synonym_map_if_unchanged(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_synonym_maps_client() @@ -432,7 +432,7 @@ def test_delete_skillset_if_unchanged(self, api_key, endpoint, index_name, **kwa with pytest.raises(HttpResponseError): client.delete_skillset(updated, only_if_unchanged=True) - @ResourceGroupPreparer(random_name_enabled=True) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) def test_get_skillset(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_skillsets_client() @@ -496,7 +496,7 @@ def test_create_or_update_skillset_inplace(self, api_key, endpoint, index_name, assert result.name == "test-ss" assert result.description == "desc2" - @ResourceGroupPreparer(random_name_enabled=True) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) def test_create_or_update_skillset_if_unchanged(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_skillsets_client() @@ -580,7 +580,7 @@ def test_create_or_update_datasource(self, api_key, endpoint, index_name, **kwar assert result.name == "sample-datasource" assert result.description == "updated" - @ResourceGroupPreparer(random_name_enabled=True) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) def test_create_or_update_datasource_if_unchanged(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_datasources_client() @@ -599,7 +599,7 @@ def test_create_or_update_datasource_if_unchanged(self, api_key, endpoint, index client.create_or_update_datasource(data_source, only_if_unchanged=True) assert len(client.get_datasources()) == 1 - @ResourceGroupPreparer(random_name_enabled=True) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) def test_delete_datasource_if_unchanged(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_datasources_client() From f026a13c718b9f28e7426e9c5ccb6148ef0bf1af Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Thu, 30 Apr 2020 18:50:02 -0700 Subject: [PATCH 06/17] use match conditiond --- .../documents/_service/_datasources_client.py | 23 +++++---- .../documents/_service/_indexes_client.py | 23 +++++---- .../documents/_service/_skillsets_client.py | 23 +++++---- .../_service/_synonym_maps_client.py | 23 +++++---- .../azure/search/documents/_service/_utils.py | 24 ++++++++-- .../_service/aio/_datasources_client.py | 23 +++++---- .../documents/_service/aio/_indexes_client.py | 23 +++++---- .../_service/aio/_skillsets_client.py | 23 +++++---- .../_service/aio/_synonym_maps_client.py | 25 ++++++---- ...ate_or_update_datasource_if_unchanged.yaml | 36 +++++++------- ...create_or_update_indexes_if_unchanged.yaml | 36 +++++++------- ...reate_or_update_skillset_if_unchanged.yaml | 48 +++++++++---------- ...c.test_delete_datasource_if_unchanged.yaml | 36 +++++++------- ...sync.test_delete_indexes_if_unchanged.yaml | 34 ++++++------- ...ync.test_delete_skillset_if_unchanged.yaml | 34 ++++++------- ....test_delete_synonym_map_if_unchanged.yaml | 32 ++++++------- .../async_tests/test_service_live_async.py | 15 +++--- ...ate_or_update_datasource_if_unchanged.yaml | 36 +++++++------- ...create_or_update_indexes_if_unchanged.yaml | 36 +++++++------- ...reate_or_update_skillset_if_unchanged.yaml | 48 +++++++++---------- ...te_or_update_synonym_map_if_unchanged.yaml | 36 +++++++------- ...e.test_delete_datasource_if_unchanged.yaml | 34 ++++++------- ...live.test_delete_indexes_if_unchanged.yaml | 34 ++++++------- ...ive.test_delete_skillset_if_unchanged.yaml | 34 ++++++------- ....test_delete_synonym_map_if_unchanged.yaml | 34 ++++++------- .../tests/test_service_live.py | 17 +++---- 26 files changed, 424 insertions(+), 366 deletions(-) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py index f3757a9b7278..4c5bbcd01021 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py @@ -5,6 +5,7 @@ # -------------------------------------------------------------------------- from typing import TYPE_CHECKING +from azure.core import MatchConditions from azure.core.tracing.decorator import distributed_trace from ._generated import SearchServiceClient as _SearchServiceClient @@ -85,14 +86,16 @@ def create_or_update_datasource(self, data_source, name=None, **kwargs): :type name: str :param data_source: The definition of the datasource to create or update. :type data_source: ~search.models.DataSource - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed data_source. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions :return: The created DataSource :rtype: dict """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - access_condition = get_access_conditions(data_source, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + data_source, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) if not name: name = data_source.name result = self._client.data_sources.create_or_update( @@ -150,15 +153,14 @@ def get_datasources(self, **kwargs): @distributed_trace def delete_datasource(self, data_source, **kwargs): # type: (Union[str, DataSource], **Any) -> None - """Deletes a datasource. To use only_if_unchanged, the Datasource model must be + """Deletes a datasource. To use access conditions, the Datasource model must be provided instead of the name. It is enough to provide the name of the datasource to delete unconditionally :param data_source: The datasource to delete. :type data_source: str or ~search.models.DataSource - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed data_source. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions :return: None :rtype: None @@ -175,7 +177,10 @@ def delete_datasource(self, data_source, **kwargs): access_condition = None try: name = data_source.name - access_condition = get_access_conditions(data_source, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + data_source, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) except AttributeError: name = data_source self._client.data_sources.delete( diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py index a63004f28843..170c918cd960 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py @@ -5,6 +5,7 @@ # -------------------------------------------------------------------------- from typing import TYPE_CHECKING +from azure.core import MatchConditions from azure.core.tracing.decorator import distributed_trace from azure.core.paging import ItemPaged @@ -124,13 +125,12 @@ def get_index_statistics(self, index_name, **kwargs): def delete_index(self, index, **kwargs): # type: (Union[str, Index], **Any) -> None """Deletes a search index and all the documents it contains. The model must be - provided instead of the name to use the access condition only_if_unchanged + provided instead of the name to use the access conditions. :param index: The index to retrieve. :type index: str or ~search.models.Index - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed index. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions :raises: ~azure.core.exceptions.HttpResponseError .. admonition:: Example: @@ -146,7 +146,10 @@ def delete_index(self, index, **kwargs): access_condition = None try: index_name = index.name - access_condition = get_access_conditions(index, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + index, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) except AttributeError: index_name = index self._client.indexes.delete(index_name=index_name, access_condition=access_condition, **kwargs) @@ -197,9 +200,8 @@ def create_or_update_index( the index can be impaired for several minutes after the index is updated, or longer for very large indexes. :type allow_index_downtime: bool - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed index. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions :return: The index created or updated :rtype: :class:`~azure.search.documents.Index` :raises: :class:`~azure.core.exceptions.ResourceNotFoundError`, \ @@ -217,7 +219,10 @@ def create_or_update_index( :dedent: 4 :caption: Update an index. """ - access_condition = get_access_conditions(index, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + index, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) patched_index = delistize_flags_for_index(index) result = self._client.indexes.create_or_update( diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py index b0efac243db9..453f61be1922 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py @@ -5,6 +5,7 @@ # -------------------------------------------------------------------------- from typing import TYPE_CHECKING +from azure.core import MatchConditions from azure.core.tracing.decorator import distributed_trace from ._generated import SearchServiceClient as _SearchServiceClient @@ -105,15 +106,14 @@ def get_skillset(self, name, **kwargs): @distributed_trace def delete_skillset(self, skillset, **kwargs): # type: (Union[str, Skillset], **Any) -> None - """Delete a named Skillset in an Azure Search service. To use only_if_unchanged, + """Delete a named Skillset in an Azure Search service. To use access conditions, the Skillset model must be provided instead of the name. It is enough to provide the name of the skillset to delete unconditionally :param name: The Skillset to delete :type name: str or ~search.models.Skillset - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed skillset. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions .. admonition:: Example: @@ -129,7 +129,10 @@ def delete_skillset(self, skillset, **kwargs): access_condition = None try: name = skillset.name - access_condition = get_access_conditions(skillset, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + skillset, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) except AttributeError: name = skillset self._client.skillsets.delete(name, access_condition=access_condition, **kwargs) @@ -179,9 +182,8 @@ def create_or_update_skillset(self, name, **kwargs): :type description: Optional[str] :keyword skillset: A Skillset to create or update. :type skillset: :class:`~azure.search.documents.Skillset` - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed skillset. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions :return: The created or updated Skillset :rtype: dict @@ -194,7 +196,10 @@ def create_or_update_skillset(self, name, **kwargs): if "skillset" in kwargs: skillset = kwargs.pop("skillset") - access_condition = get_access_conditions(skillset, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + skillset, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) skillset = Skillset.deserialize(skillset.serialize()) skillset.name = name for param in ("description", "skills"): diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py index f5e3767de2a3..bf30c4e7159d 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py @@ -5,6 +5,7 @@ # -------------------------------------------------------------------------- from typing import TYPE_CHECKING +from azure.core import MatchConditions from azure.core.tracing.decorator import distributed_trace from ._generated import SearchServiceClient as _SearchServiceClient @@ -106,15 +107,14 @@ def get_synonym_map(self, name, **kwargs): @distributed_trace def delete_synonym_map(self, synonym_map, **kwargs): # type: (Union[str, SynonymMap], **Any) -> None - """Delete a named Synonym Map in an Azure Search service. To use only_if_unchanged, + """Delete a named Synonym Map in an Azure Search service. To use access conditions, the SynonymMap model must be provided instead of the name. It is enough to provide the name of the synonym map to delete unconditionally. :param name: The Synonym Map to delete :type name: str or ~search.models.SynonymMap - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed synonym_map. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions :return: None :rtype: None @@ -132,7 +132,10 @@ def delete_synonym_map(self, synonym_map, **kwargs): access_condition = None try: name = synonym_map.name - access_condition = get_access_conditions(synonym_map, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + synonym_map, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) except AttributeError: name = synonym_map self._client.synonym_maps.delete(synonym_map_name=name, access_condition=access_condition, **kwargs) @@ -175,9 +178,8 @@ def create_or_update_synonym_map(self, synonym_map, synonyms=None, **kwargs): :type synonym_map: str or ~azure.search.documents.SynonymMap :param synonyms: A list of synonyms in SOLR format :type synonyms: List[str] - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed synonym_map. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions :return: The created or updated Synonym Map :rtype: dict @@ -186,7 +188,10 @@ def create_or_update_synonym_map(self, synonym_map, synonyms=None, **kwargs): access_condition = None try: name = synonym_map.name - access_condition = get_access_conditions(synonym_map, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + synonym_map, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) if synonyms: synonym_map.synonyms = "\n".join(synonyms) except AttributeError: diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py index bd87ec3491cf..b1306e527353 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py @@ -6,6 +6,12 @@ from typing import TYPE_CHECKING from azure.core import MatchConditions +from azure.core.exceptions import ( + ResourceExistsError, + ResourceNotFoundError, + ResourceModifiedError, + ResourceNotModifiedError, +) from ._generated.models import ( Index, PatternAnalyzer as _PatternAnalyzer, @@ -153,10 +159,20 @@ def listize_synonyms(synonym_map): synonym_map["synonyms"] = synonym_map["synonyms"].split("\n") return synonym_map -def get_access_conditions(model, only_if_unchanged=False): - if not only_if_unchanged: - return None +def get_access_conditions(model, match_condition=MatchConditions.Unconditionally): + # type: (Any, MatchConditions) -> Tuple[Dict[int, Any], AccessCondition] + error_map = {404: ResourceNotFoundError} # type: Dict[int, Any] try: - return AccessCondition(if_match=model.e_tag) + if_match = prep_if_match(model.e_tag, match_condition) + if_none_match = prep_if_none_match(model.e_tag, match_condition) + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + if match_condition == MatchConditions.IfModified: + error_map[304] = ResourceNotModifiedError + if match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + if match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + return (error_map, AccessCondition(if_match=if_match, if_none_match=if_none_match)) except AttributeError: raise ValueError("Unable to get e_tag from the model") diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py index 22f54d72bc5b..f241e00b1657 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py @@ -5,6 +5,7 @@ # -------------------------------------------------------------------------- from typing import TYPE_CHECKING +from azure.core import MatchConditions from azure.core.tracing.decorator_async import distributed_trace_async from .._generated.aio import SearchServiceClient as _SearchServiceClient @@ -84,14 +85,16 @@ async def create_or_update_datasource(self, data_source, name=None, **kwargs): :type name: str :param data_source: The definition of the datasource to create or update. :type data_source: ~search.models.DataSource - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed data_source. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions :return: The created DataSource :rtype: dict """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - access_condition = get_access_conditions(data_source, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + data_source, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) if not name: name = data_source.name result = await self._client.data_sources.create_or_update( @@ -105,15 +108,14 @@ async def create_or_update_datasource(self, data_source, name=None, **kwargs): @distributed_trace_async async def delete_datasource(self, data_source, **kwargs): # type: (Union[str, DataSource], **Any) -> None - """Deletes a datasource. To use only_if_unchanged, the Datasource model must be + """Deletes a datasource. To use access conditions, the Datasource model must be provided instead of the name. It is enough to provide the name of the datasource to delete unconditionally :param data_source: The datasource to delete. :type data_source: str or ~search.models.DataSource - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed data_source. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions :return: None :rtype: None @@ -130,7 +132,10 @@ async def delete_datasource(self, data_source, **kwargs): access_condition = None try: name = data_source.name - access_condition = get_access_conditions(data_source, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + data_source, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) except AttributeError: name = data_source await self._client.data_sources.delete( diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py index 87453c6cc1e8..7be1259b53ee 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py @@ -5,6 +5,7 @@ # -------------------------------------------------------------------------- from typing import TYPE_CHECKING +from azure.core import MatchConditions from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.async_paging import AsyncItemPaged from .._generated.aio import SearchServiceClient as _SearchServiceClient @@ -123,13 +124,12 @@ async def get_index_statistics(self, index_name, **kwargs): async def delete_index(self, index, **kwargs): # type: (Union[str, Index], **Any) -> None """Deletes a search index and all the documents it contains. The model must be - provided instead of the name to use the access condition only_if_unchanged + provided instead of the name to use the access conditions :param index: The index to retrieve. :type index: str or ~search.models.Index - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed index. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions :raises: ~azure.core.exceptions.HttpResponseError .. admonition:: Example: @@ -145,7 +145,10 @@ async def delete_index(self, index, **kwargs): access_condition = None try: index_name = index.name - access_condition = get_access_conditions(index, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + index, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) except AttributeError: index_name = index await self._client.indexes.delete(index_name=index_name, access_condition=access_condition, **kwargs) @@ -196,9 +199,8 @@ async def create_or_update_index( the index can be impaired for several minutes after the index is updated, or longer for very large indexes. :type allow_index_downtime: bool - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed index. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions :return: The index created or updated :rtype: :class:`~azure.search.documents.Index` :raises: :class:`~azure.core.exceptions.ResourceNotFoundError`, \ @@ -216,7 +218,10 @@ async def create_or_update_index( :dedent: 4 :caption: Update an index. """ - access_condition = get_access_conditions(index, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + index, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) patched_index = delistize_flags_for_index(index) result = await self._client.indexes.create_or_update( diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py index d61f402445b6..9fb33469ae88 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py @@ -5,6 +5,7 @@ # -------------------------------------------------------------------------- from typing import TYPE_CHECKING +from azure.core import MatchConditions from azure.core.tracing.decorator_async import distributed_trace_async from .._generated.aio import SearchServiceClient as _SearchServiceClient @@ -105,15 +106,14 @@ async def get_skillset(self, name, **kwargs): @distributed_trace_async async def delete_skillset(self, skillset, **kwargs): # type: (Union[str, Skillset], **Any) -> None - """Delete a named Skillset in an Azure Search service. To use only_if_unchanged, + """Delete a named Skillset in an Azure Search service. To use access conditions, the Skillset model must be provided instead of the name. It is enough to provide the name of the skillset to delete unconditionally :param name: The Skillset to delete :type name: str or ~search.models.Skillset - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed skillset. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions .. admonition:: Example: @@ -129,7 +129,10 @@ async def delete_skillset(self, skillset, **kwargs): access_condition = None try: name = skillset.name - access_condition = get_access_conditions(skillset, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + skillset, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) except AttributeError: name = skillset await self._client.skillsets.delete(name, access_condition=access_condition, **kwargs) @@ -179,9 +182,8 @@ async def create_or_update_skillset(self, name, **kwargs): :type description: Optional[str] :keyword skillset: A Skillset to create or update. :type skillset: :class:`~azure.search.documents.Skillset` - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed skillset. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions :return: The created or updated Skillset :rtype: dict @@ -195,7 +197,10 @@ async def create_or_update_skillset(self, name, **kwargs): if "skillset" in kwargs: skillset = kwargs.pop("skillset") - access_condition = get_access_conditions(skillset, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + skillset, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) skillset = Skillset.deserialize(skillset.serialize()) skillset.name = name for param in ("description", "skills"): diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py index b040049bcfd7..60b4c2468106 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py @@ -5,6 +5,7 @@ # -------------------------------------------------------------------------- from typing import TYPE_CHECKING +from azure.core import MatchConditions from azure.core.tracing.decorator_async import distributed_trace_async from .._generated.aio import SearchServiceClient as _SearchServiceClient @@ -106,15 +107,14 @@ async def get_synonym_map(self, name, **kwargs): @distributed_trace_async async def delete_synonym_map(self, synonym_map, **kwargs): # type: (Union[str, SynonymMap], **Any) -> None - """Delete a named Synonym Map in an Azure Search service. To use only_if_unchanged, + """Delete a named Synonym Map in an Azure Search service. To use access conditions, the SynonymMap model must be provided instead of the name. It is enough to provide the name of the synonym map to delete unconditionally. :param name: The Synonym Map to delete :type name: str or ~search.models.SynonymMap - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed synonym_map. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions :return: None :rtype: None @@ -133,7 +133,10 @@ async def delete_synonym_map(self, synonym_map, **kwargs): access_condition = None try: name = synonym_map.name - access_condition = get_access_conditions(synonym_map, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + synonym_map, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) except AttributeError: name = synonym_map await self._client.synonym_maps.delete(synonym_map_name=name, access_condition=access_condition, **kwargs) @@ -176,18 +179,20 @@ async def create_or_update_synonym_map(self, synonym_map, synonyms=None, **kwarg :type synonym_map: str or ~azure.search.documents.SynonymMap :param synonyms: A list of synonyms in SOLR format :type synonyms: List[str] - :keyword only_if_unchanged: If set to true, the operation is performed only if the - e_tag on the server matches the e_tag value of the passed synonym_map. - :type only_if_unchanged: bool + :keyword match_condition: The match condition to use upon the etag + :type match_condition: ~azure.core.MatchConditions :return: The created or updated Synonym Map :rtype: dict """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - access_condition = None + error_map, access_condition = None, None try: name = synonym_map.name - access_condition = get_access_conditions(synonym_map, kwargs.pop('only_if_unchanged', False)) + error_map, access_condition = get_access_conditions( + synonym_map, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) if synonyms: synonym_map.synonyms = "\n".join(synonyms) except AttributeError: diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_datasource_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_datasource_if_unchanged.yaml index 383d9fd8fd9a..84d3be04dc58 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_datasource_if_unchanged.yaml +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_datasource_if_unchanged.yaml @@ -13,25 +13,25 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 9934F9F394547FDB82394143EC2A49E5 + - EB07460BE71D34ECEB27F2F290910C52 method: POST uri: https://searche2561c44.search.windows.net/datasources?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searche2561c44.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBFED6E968C7\"","name":"sample-datasource","description":null,"type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + string: '{"@odata.context":"https://searche2561c44.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7ED71E13EFC4E\"","name":"sample-datasource","description":null,"type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' headers: cache-control: no-cache content-length: '370' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:33:25 GMT - elapsed-time: '57' - etag: W/"0x8D7EBFED6E968C7" + date: Fri, 01 May 2020 01:49:26 GMT + elapsed-time: '69' + etag: W/"0x8D7ED71E13EFC4E" expires: '-1' location: https://searche2561c44.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: f2604cd0-89da-11ea-a3f0-2816a845e8c6 + request-id: fd279352-8b4d-11ea-900d-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains status: code: 201 @@ -60,25 +60,25 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 9934F9F394547FDB82394143EC2A49E5 + - EB07460BE71D34ECEB27F2F290910C52 method: PUT uri: https://searche2561c44.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searche2561c44.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBFED6F92313\"","name":"sample-datasource","description":"updated","type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + string: '{"@odata.context":"https://searche2561c44.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7ED71E1512811\"","name":"sample-datasource","description":"updated","type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' headers: cache-control: no-cache content-encoding: gzip content-length: '365' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:33:25 GMT - elapsed-time: '46' - etag: W/"0x8D7EBFED6F92313" + date: Fri, 01 May 2020 01:49:26 GMT + elapsed-time: '66' + etag: W/"0x8D7ED71E1512811" expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: f29e1606-89da-11ea-8535-2816a845e8c6 + request-id: fd59a3da-8b4d-11ea-8749-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains vary: Accept-Encoding status: @@ -95,7 +95,7 @@ interactions: - request: body: '{"name": "sample-datasource", "description": "changed", "type": "azureblob", "credentials": {"connectionString": "DefaultEndpointsProtocol=https;AccountName=storagename;AccountKey=NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg==;EndpointSuffix=core.windows.net"}, - "container": {"name": "searchcontainer"}, "@odata.etag": "\"0x8D7EBFED6E968C7\""}' + "container": {"name": "searchcontainer"}, "@odata.etag": "\"0x8D7ED71E13EFC4E\""}' headers: Accept: - application/json;odata.metadata=minimal @@ -104,13 +104,13 @@ interactions: Content-Type: - application/json If-Match: - - '"0x8D7EBFED6E968C7"' + - '"0x8D7ED71E13EFC4E"' Prefer: - return=representation User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 9934F9F394547FDB82394143EC2A49E5 + - EB07460BE71D34ECEB27F2F290910C52 method: PUT uri: https://searche2561c44.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview response: @@ -123,13 +123,13 @@ interactions: content-language: en content-length: '160' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:33:25 GMT - elapsed-time: '6' + date: Fri, 01 May 2020 01:49:26 GMT + elapsed-time: '5' expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: f2ad9d64-89da-11ea-8625-2816a845e8c6 + request-id: fd6bc01c-8b4d-11ea-a9e1-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains status: code: 412 diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_indexes_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_indexes_if_unchanged.yaml index 2825b66979f2..199eebff5d04 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_indexes_if_unchanged.yaml +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_indexes_if_unchanged.yaml @@ -14,25 +14,25 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 3D334C55C9D5A2A42878933ACEDBF6E9 + - 27AABAAAD5E1BA1E8445B009D9CDC8D7 method: POST uri: https://search8e901b09.search.windows.net/indexes?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://search8e901b09.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBFDD175C98C\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[{"name":"MyProfile","functionAggregation":null,"text":null,"functions":[]}],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + string: '{"@odata.context":"https://search8e901b09.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7ED71A617AE43\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[{"name":"MyProfile","functionAggregation":null,"text":null,"functions":[]}],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' headers: cache-control: no-cache content-length: '890' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:26:07 GMT - elapsed-time: '894' - etag: W/"0x8D7EBFDD175C98C" + date: Fri, 01 May 2020 01:47:47 GMT + elapsed-time: '560' + etag: W/"0x8D7ED71A617AE43" expires: '-1' location: https://search8e901b09.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: ec8338d8-89d9-11ea-bf89-2816a845e8c6 + request-id: c1c3fbc8-8b4d-11ea-87ee-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains status: code: 201 @@ -62,25 +62,25 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 3D334C55C9D5A2A42878933ACEDBF6E9 + - 27AABAAAD5E1BA1E8445B009D9CDC8D7 method: PUT uri: https://search8e901b09.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://search8e901b09.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBFDD1947AAB\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + string: '{"@odata.context":"https://search8e901b09.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7ED71A636ADAA\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' headers: cache-control: no-cache content-encoding: gzip content-length: '506' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:26:07 GMT - elapsed-time: '131' - etag: W/"0x8D7EBFDD1947AAB" + date: Fri, 01 May 2020 01:47:47 GMT + elapsed-time: '129' + etag: W/"0x8D7ED71A636ADAA" expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: ed2ff258-89d9-11ea-831e-2816a845e8c6 + request-id: c23832f0-8b4d-11ea-be09-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains vary: Accept-Encoding status: @@ -98,7 +98,7 @@ interactions: body: '{"name": "hotels", "fields": [{"name": "hotelId", "type": "Edm.String", "key": true, "searchable": false}, {"name": "baseRate", "type": "Edm.Double"}], "scoringProfiles": [], "corsOptions": {"allowedOrigins": ["*"], "maxAgeInSeconds": - 60}, "@odata.etag": "\"0x8D7EBFDD175C98C\""}' + 60}, "@odata.etag": "\"0x8D7ED71A617AE43\""}' headers: Accept: - application/json;odata.metadata=minimal @@ -107,13 +107,13 @@ interactions: Content-Type: - application/json If-Match: - - '"0x8D7EBFDD175C98C"' + - '"0x8D7ED71A617AE43"' Prefer: - return=representation User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 3D334C55C9D5A2A42878933ACEDBF6E9 + - 27AABAAAD5E1BA1E8445B009D9CDC8D7 method: PUT uri: https://search8e901b09.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview response: @@ -126,13 +126,13 @@ interactions: content-language: en content-length: '160' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:26:07 GMT - elapsed-time: '27' + date: Fri, 01 May 2020 01:47:47 GMT + elapsed-time: '25' expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: ed4c19da-89d9-11ea-8928-2816a845e8c6 + request-id: c2543448-8b4d-11ea-b516-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains status: code: 412 diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_skillset_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_skillset_if_unchanged.yaml index 3d5b2b1c8755..9ff0930d8908 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_skillset_if_unchanged.yaml +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_create_or_update_skillset_if_unchanged.yaml @@ -16,25 +16,25 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 2793D4FA267F0520CBA834F3F73ADB14 + - 44D0AAF55BE852CA16BF1BD860CFB5D1 method: PUT uri: https://searchab6c1b84.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searchab6c1b84.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBFEAB2F1999\"","name":"test-ss","description":"desc1","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + string: '{"@odata.context":"https://searchab6c1b84.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7ED71C3B43149\"","name":"test-ss","description":"desc1","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' headers: cache-control: no-cache content-length: '588' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:32:11 GMT - elapsed-time: '147' - etag: W/"0x8D7EBFEAB2F1999" + date: Fri, 01 May 2020 01:48:35 GMT + elapsed-time: '63' + etag: W/"0x8D7ED71C3B43149" expires: '-1' location: https://searchab6c1b84.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: c69e43fa-89da-11ea-9542-2816a845e8c6 + request-id: dfa970b6-8b4d-11ea-aba9-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains status: code: 201 @@ -51,7 +51,7 @@ interactions: body: '{"name": "test-ss", "description": "desc2", "skills": [{"@odata.type": "#Microsoft.Skills.Text.EntityRecognitionSkill", "inputs": [{"name": "text", "source": "/document/content"}], "outputs": [{"name": "organizations", "targetName": - "organizations"}]}], "@odata.etag": "\"0x8D7EBFEAB2F1999\""}' + "organizations"}]}], "@odata.etag": "\"0x8D7ED71C3B43149\""}' headers: Accept: - application/json;odata.metadata=minimal @@ -64,25 +64,25 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 2793D4FA267F0520CBA834F3F73ADB14 + - 44D0AAF55BE852CA16BF1BD860CFB5D1 method: PUT uri: https://searchab6c1b84.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searchab6c1b84.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBFEAB42F34B\"","name":"test-ss","description":"desc2","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + string: '{"@odata.context":"https://searchab6c1b84.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7ED71C3C23D9E\"","name":"test-ss","description":"desc2","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' headers: cache-control: no-cache content-encoding: gzip content-length: '464' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:32:12 GMT - elapsed-time: '154' - etag: W/"0x8D7EBFEAB42F34B" + date: Fri, 01 May 2020 01:48:35 GMT + elapsed-time: '39' + etag: W/"0x8D7ED71C3C23D9E" expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: c6e553e2-89da-11ea-8220-2816a845e8c6 + request-id: dfcf0940-8b4d-11ea-833a-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains vary: Accept-Encoding status: @@ -104,24 +104,24 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 2793D4FA267F0520CBA834F3F73ADB14 + - 44D0AAF55BE852CA16BF1BD860CFB5D1 method: GET uri: https://searchab6c1b84.search.windows.net/skillsets?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searchab6c1b84.search.windows.net/$metadata#skillsets","value":[{"@odata.etag":"\"0x8D7EBFEAB42F34B\"","name":"test-ss","description":"desc2","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":"#1","description":null,"context":"/document","categories":["Person","Quantity","Organization","URL","Email","Location","DateTime"],"defaultLanguageCode":"en","minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}]}' + string: '{"@odata.context":"https://searchab6c1b84.search.windows.net/$metadata#skillsets","value":[{"@odata.etag":"\"0x8D7ED71C3C23D9E\"","name":"test-ss","description":"desc2","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":"#1","description":null,"context":"/document","categories":["Person","Quantity","Organization","URL","Email","Location","DateTime"],"defaultLanguageCode":"en","minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}]}' headers: cache-control: no-cache content-encoding: gzip content-length: '521' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:32:12 GMT - elapsed-time: '45' + date: Fri, 01 May 2020 01:48:35 GMT + elapsed-time: '22' expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: c706aeee-89da-11ea-a068-2816a845e8c6 + request-id: dfdc6bd2-8b4d-11ea-90dd-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains vary: Accept-Encoding status: @@ -139,7 +139,7 @@ interactions: body: '{"name": "test-ss", "description": "desc1", "skills": [{"@odata.type": "#Microsoft.Skills.Text.EntityRecognitionSkill", "inputs": [{"name": "text", "source": "/document/content"}], "outputs": [{"name": "organizations", "targetName": - "organizations"}]}], "@odata.etag": "\"0x8D7EBFEAB2F1999\""}' + "organizations"}]}], "@odata.etag": "\"0x8D7ED71C3B43149\""}' headers: Accept: - application/json;odata.metadata=minimal @@ -148,13 +148,13 @@ interactions: Content-Type: - application/json If-Match: - - '"0x8D7EBFEAB2F1999"' + - '"0x8D7ED71C3B43149"' Prefer: - return=representation User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 2793D4FA267F0520CBA834F3F73ADB14 + - 44D0AAF55BE852CA16BF1BD860CFB5D1 method: PUT uri: https://searchab6c1b84.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview response: @@ -167,13 +167,13 @@ interactions: content-language: en content-length: '160' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:32:12 GMT - elapsed-time: '13' + date: Fri, 01 May 2020 01:48:35 GMT + elapsed-time: '12' expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: c716caf6-89da-11ea-950e-2816a845e8c6 + request-id: dfe78992-8b4d-11ea-beb5-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains status: code: 412 diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_datasource_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_datasource_if_unchanged.yaml index dfb52f2e8da4..7994cdc4fc4e 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_datasource_if_unchanged.yaml +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_datasource_if_unchanged.yaml @@ -13,25 +13,25 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 8FB8762DCBC41254CE64DD3DB80AF75C + - EAB9451773DF47CC4948501A01AA8C5D method: POST uri: https://searchd88c1821.search.windows.net/datasources?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searchd88c1821.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBFEE09DC6D9\"","name":"sample-datasource","description":null,"type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + string: '{"@odata.context":"https://searchd88c1821.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7ED71EDA34383\"","name":"sample-datasource","description":null,"type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' headers: cache-control: no-cache content-length: '370' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:33:41 GMT - elapsed-time: '70' - etag: W/"0x8D7EBFEE09DC6D9" + date: Fri, 01 May 2020 01:49:46 GMT + elapsed-time: '52' + etag: W/"0x8D7ED71EDA34383" expires: '-1' location: https://searchd88c1821.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: fc27f286-89da-11ea-ae0d-2816a845e8c6 + request-id: 09913646-8b4e-11ea-bf52-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains status: code: 201 @@ -60,25 +60,25 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 8FB8762DCBC41254CE64DD3DB80AF75C + - EAB9451773DF47CC4948501A01AA8C5D method: PUT uri: https://searchd88c1821.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searchd88c1821.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBFEE0AA4C3B\"","name":"sample-datasource","description":"updated","type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + string: '{"@odata.context":"https://searchd88c1821.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7ED71EDB1C519\"","name":"sample-datasource","description":"updated","type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' headers: cache-control: no-cache content-encoding: gzip - content-length: '364' + content-length: '365' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:33:41 GMT - elapsed-time: '41' - etag: W/"0x8D7EBFEE0AA4C3B" + date: Fri, 01 May 2020 01:49:46 GMT + elapsed-time: '47' + etag: W/"0x8D7ED71EDB1C519" expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: fc51a506-89da-11ea-96e0-2816a845e8c6 + request-id: 09bdcd08-8b4e-11ea-96c1-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains vary: Accept-Encoding status: @@ -98,11 +98,11 @@ interactions: Accept: - application/json;odata.metadata=minimal If-Match: - - '"0x8D7EBFEE09DC6D9"' + - '"0x8D7ED71EDA34383"' User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 8FB8762DCBC41254CE64DD3DB80AF75C + - EAB9451773DF47CC4948501A01AA8C5D method: DELETE uri: https://searchd88c1821.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview response: @@ -115,13 +115,13 @@ interactions: content-language: en content-length: '160' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:33:41 GMT - elapsed-time: '6' + date: Fri, 01 May 2020 01:49:47 GMT + elapsed-time: '5' expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: fc5f2ec0-89da-11ea-b074-2816a845e8c6 + request-id: 09ccb6c2-8b4e-11ea-974c-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains status: code: 412 diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_indexes_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_indexes_if_unchanged.yaml index 2fd57765380f..c9d04782ade4 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_indexes_if_unchanged.yaml +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_indexes_if_unchanged.yaml @@ -14,25 +14,25 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 9AB5844141C2630ED3729D56C13F5B77 + - 80AE7802DD95A3AC15F78D806265235E method: POST uri: https://search912f16e6.search.windows.net/indexes?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://search912f16e6.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBFDEAE97C83\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[{"name":"MyProfile","functionAggregation":null,"text":null,"functions":[]}],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + string: '{"@odata.context":"https://search912f16e6.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7ED71B008B075\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[{"name":"MyProfile","functionAggregation":null,"text":null,"functions":[]}],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' headers: cache-control: no-cache content-length: '890' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:26:48 GMT - elapsed-time: '945' - etag: W/"0x8D7EBFDEAE97C83" + date: Fri, 01 May 2020 01:48:03 GMT + elapsed-time: '571' + etag: W/"0x8D7ED71B008B075" expires: '-1' location: https://search912f16e6.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: 05e79154-89da-11ea-8299-2816a845e8c6 + request-id: cba6183e-8b4d-11ea-9e27-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains status: code: 201 @@ -62,25 +62,25 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 9AB5844141C2630ED3729D56C13F5B77 + - 80AE7802DD95A3AC15F78D806265235E method: PUT uri: https://search912f16e6.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://search912f16e6.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBFDEB08CA07\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + string: '{"@odata.context":"https://search912f16e6.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7ED71B02BA833\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' headers: cache-control: no-cache content-encoding: gzip content-length: '506' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:26:49 GMT - elapsed-time: '156' - etag: W/"0x8D7EBFDEB08CA07" + date: Fri, 01 May 2020 01:48:03 GMT + elapsed-time: '129' + etag: W/"0x8D7ED71B02BA833" expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: 06a298fa-89da-11ea-9a6c-2816a845e8c6 + request-id: cc2b40f4-8b4d-11ea-aba8-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains vary: Accept-Encoding status: @@ -100,11 +100,11 @@ interactions: Accept: - application/json;odata.metadata=minimal If-Match: - - '"0x8D7EBFDEAE97C83"' + - '"0x8D7ED71B008B075"' User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 9AB5844141C2630ED3729D56C13F5B77 + - 80AE7802DD95A3AC15F78D806265235E method: DELETE uri: https://search912f16e6.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview response: @@ -117,13 +117,13 @@ interactions: content-language: en content-length: '160' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:26:49 GMT - elapsed-time: '18' + date: Fri, 01 May 2020 01:48:03 GMT + elapsed-time: '15' expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: 06c5e56e-89da-11ea-af40-2816a845e8c6 + request-id: cc49635c-8b4d-11ea-9b7f-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains status: code: 412 diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_skillset_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_skillset_if_unchanged.yaml index 808f2af956c7..cef66c94416f 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_skillset_if_unchanged.yaml +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_skillset_if_unchanged.yaml @@ -13,25 +13,25 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 36DD0265BF1F3517C97B8BDED46C4F81 + - 657C58F25F5510BEB3AB19482A2E8DD3 method: POST uri: https://searcha9e81761.search.windows.net/skillsets?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searcha9e81761.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBFE8EB6C23F\"","name":"test-ss","description":"desc","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + string: '{"@odata.context":"https://searcha9e81761.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7ED71D4C7EB65\"","name":"test-ss","description":"desc","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' headers: cache-control: no-cache content-length: '587' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:31:24 GMT - elapsed-time: '144' - etag: W/"0x8D7EBFE8EB6C23F" + date: Fri, 01 May 2020 01:49:05 GMT + elapsed-time: '46' + etag: W/"0x8D7ED71D4C7EB65" expires: '-1' location: https://searcha9e81761.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: aa38cb98-89da-11ea-a6f3-2816a845e8c6 + request-id: f0c0d15a-8b4d-11ea-a53c-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains status: code: 201 @@ -61,25 +61,25 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 36DD0265BF1F3517C97B8BDED46C4F81 + - 657C58F25F5510BEB3AB19482A2E8DD3 method: PUT uri: https://searcha9e81761.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searcha9e81761.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBFE8EC6A3A2\"","name":"test-ss","description":"updated","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + string: '{"@odata.context":"https://searcha9e81761.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7ED71D4DADAA4\"","name":"test-ss","description":"updated","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' headers: cache-control: no-cache content-encoding: gzip content-length: '466' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:31:24 GMT - elapsed-time: '48' - etag: W/"0x8D7EBFE8EC6A3A2" + date: Fri, 01 May 2020 01:49:05 GMT + elapsed-time: '64' + etag: W/"0x8D7ED71D4DADAA4" expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: aa6b50c0-89da-11ea-802d-2816a845e8c6 + request-id: f0e2e652-8b4d-11ea-ad8e-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains vary: Accept-Encoding status: @@ -99,11 +99,11 @@ interactions: Accept: - application/json;odata.metadata=minimal If-Match: - - '"0x8D7EBFE8EB6C23F"' + - '"0x8D7ED71D4C7EB65"' User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 36DD0265BF1F3517C97B8BDED46C4F81 + - 657C58F25F5510BEB3AB19482A2E8DD3 method: DELETE uri: https://searcha9e81761.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview response: @@ -116,13 +116,13 @@ interactions: content-language: en content-length: '160' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:31:24 GMT - elapsed-time: '13' + date: Fri, 01 May 2020 01:49:05 GMT + elapsed-time: '9' expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: aa7a8a06-89da-11ea-9d6c-2816a845e8c6 + request-id: f0f5521a-8b4d-11ea-bb06-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains status: code: 412 diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_synonym_map_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_synonym_map_if_unchanged.yaml index 24c6b878affc..67a5f805c66f 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_synonym_map_if_unchanged.yaml +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_service_live_async.test_delete_synonym_map_if_unchanged.yaml @@ -12,26 +12,26 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - E39678EFF623BB3835D835591F71923A + - 379F6C259E39EFF08F01F8D2429FF657 method: POST uri: https://searchf4b018b0.search.windows.net/synonymmaps?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searchf4b018b0.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7EBFE66105C68\"","name":"test-syn-map","format":"solr","synonyms":"USA, + string: '{"@odata.context":"https://searchf4b018b0.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7ED71BA2FE792\"","name":"test-syn-map","format":"solr","synonyms":"USA, United States, United States of America\nWashington, Wash. => WA","encryptionKey":null}' headers: cache-control: no-cache content-length: '272' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:30:16 GMT - elapsed-time: '21' - etag: W/"0x8D7EBFE66105C68" + date: Fri, 01 May 2020 01:48:20 GMT + elapsed-time: '23' + etag: W/"0x8D7ED71BA2FE792" expires: '-1' location: https://searchf4b018b0.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: 81a052b4-89da-11ea-9760-2816a845e8c6 + request-id: d62a27a6-8b4d-11ea-b123-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains status: code: 201 @@ -59,26 +59,26 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - E39678EFF623BB3835D835591F71923A + - 379F6C259E39EFF08F01F8D2429FF657 method: PUT uri: https://searchf4b018b0.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searchf4b018b0.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7EBFE661B5AE7\"","name":"test-syn-map","format":"solr","synonyms":"Washington, + string: '{"@odata.context":"https://searchf4b018b0.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7ED71BA3AE613\"","name":"test-syn-map","format":"solr","synonyms":"Washington, Wash. => WA","encryptionKey":null}' headers: cache-control: no-cache content-encoding: gzip content-length: '302' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:30:16 GMT + date: Fri, 01 May 2020 01:48:20 GMT elapsed-time: '17' - etag: W/"0x8D7EBFE661B5AE7" + etag: W/"0x8D7ED71BA3AE613" expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: 81c35314-89da-11ea-b434-2816a845e8c6 + request-id: d6493314-8b4d-11ea-90af-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains vary: Accept-Encoding status: @@ -98,11 +98,11 @@ interactions: Accept: - application/json;odata.metadata=minimal If-Match: - - '"0x8D7EBFE66105C68"' + - '"0x8D7ED71BA2FE792"' User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - E39678EFF623BB3835D835591F71923A + - 379F6C259E39EFF08F01F8D2429FF657 method: DELETE uri: https://searchf4b018b0.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview response: @@ -115,13 +115,13 @@ interactions: content-language: en content-length: '160' content-type: application/json; odata.metadata=minimal - date: Wed, 29 Apr 2020 05:30:16 GMT - elapsed-time: '10' + date: Fri, 01 May 2020 01:48:20 GMT + elapsed-time: '140' expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: 81cdae24-89da-11ea-bc5b-2816a845e8c6 + request-id: d653da30-8b4d-11ea-95d5-2816a845e8c6 strict-transport-security: max-age=15724800; includeSubDomains status: code: 412 diff --git a/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py b/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py index 37d1a9c82177..6d990324d22a 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py +++ b/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py @@ -10,6 +10,7 @@ import time import pytest +from azure.core import MatchConditions from azure.core.credentials import AzureKeyCredential from devtools_testutils import AzureMgmtTestCase @@ -151,7 +152,7 @@ async def test_delete_indexes_if_unchanged(self, api_key, endpoint, index_name, index.e_tag = etag with pytest.raises(HttpResponseError): - await client.delete_index(index, only_if_unchanged=True) + await client.delete_index(index, match_condition=MatchConditions.IfNotModified) @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) @@ -265,7 +266,7 @@ async def test_create_or_update_indexes_if_unchanged(self, api_key, endpoint, in index.e_tag = etag with pytest.raises(HttpResponseError): - await client.create_or_update_index(index.name, index, only_if_unchanged=True) + await client.create_or_update_index(index.name, index, match_condition=MatchConditions.IfNotModified) @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) @@ -328,7 +329,7 @@ async def test_delete_synonym_map_if_unchanged(self, api_key, endpoint, index_na sm_result.e_tag = etag with pytest.raises(HttpResponseError): - await client.delete_synonym_map(sm_result, only_if_unchanged=True) + await client.delete_synonym_map(sm_result, match_condition=MatchConditions.IfNotModified) assert len(client.get_synonym_maps()) == 1 @SearchResourceGroupPreparer(random_name_enabled=True) @@ -431,7 +432,7 @@ async def test_delete_skillset_if_unchanged(self, api_key, endpoint, index_name, updated.e_tag = etag with pytest.raises(HttpResponseError): - await client.delete_skillset(updated, only_if_unchanged=True) + await client.delete_skillset(updated, match_condition=MatchConditions.IfNotModified) @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) @@ -512,7 +513,7 @@ async def test_create_or_update_skillset_if_unchanged(self, api_key, endpoint, i ss.e_tag = etag with pytest.raises(HttpResponseError): - await client.create_or_update_skillset(name='test-ss', skills=[s], skillset=ss, only_if_unchanged=True) + await client.create_or_update_skillset(name='test-ss', skills=[s], skillset=ss, match_condition=MatchConditions.IfNotModified) class SearchDataSourcesClientTest(AzureMgmtTestCase): @@ -598,7 +599,7 @@ async def test_create_or_update_datasource_if_unchanged(self, api_key, endpoint, data_source.e_tag = etag # reset to the original datasource data_source.description = "changed" with pytest.raises(HttpResponseError): - await client.create_or_update_datasource(data_source, only_if_unchanged=True) + await client.create_or_update_datasource(data_source, match_condition=MatchConditions.IfNotModified) assert len(await client.get_datasources()) == 1 @SearchResourceGroupPreparer(random_name_enabled=True) @@ -616,5 +617,5 @@ async def test_delete_datasource_if_unchanged(self, api_key, endpoint, index_nam # prepare data source data_source.e_tag = etag # reset to the original datasource with pytest.raises(HttpResponseError): - await client.delete_datasource(data_source, only_if_unchanged=True) + await client.delete_datasource(data_source, match_condition=MatchConditions.IfNotModified) assert len(await client.get_datasources()) == 1 diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_datasource_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_datasource_if_unchanged.yaml index 12c1fe3b93f1..9f06288e8cd0 100644 --- a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_datasource_if_unchanged.yaml +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_datasource_if_unchanged.yaml @@ -17,12 +17,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - B6E6C1BF71B889B3CD59FCE617987E2C + - 0DBCB3E23D05E4915AB588A0A3E6A929 method: POST uri: https://search3c8b19c7.search.windows.net/datasources?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://search3c8b19c7.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBDEA25ADD51\"","name":"sample-datasource","description":null,"type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + string: '{"@odata.context":"https://search3c8b19c7.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7ED71775A7B36\"","name":"sample-datasource","description":null,"type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' headers: cache-control: - no-cache @@ -31,11 +31,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 01:42:52 GMT + - Fri, 01 May 2020 01:46:28 GMT elapsed-time: - - '70' + - '46' etag: - - W/"0x8D7EBDEA25ADD51" + - W/"0x8D7ED71775A7B36" expires: - '-1' location: @@ -47,7 +47,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - bdb36bb4-89ba-11ea-a706-2816a845e8c6 + - 9334e078-8b4d-11ea-a4ef-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: @@ -73,12 +73,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - B6E6C1BF71B889B3CD59FCE617987E2C + - 0DBCB3E23D05E4915AB588A0A3E6A929 method: PUT uri: https://search3c8b19c7.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://search3c8b19c7.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBDEA26EDE1F\"","name":"sample-datasource","description":"updated","type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + string: '{"@odata.context":"https://search3c8b19c7.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7ED717773D43C\"","name":"sample-datasource","description":"updated","type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' headers: cache-control: - no-cache @@ -87,11 +87,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 01:42:53 GMT + - Fri, 01 May 2020 01:46:28 GMT elapsed-time: - - '50' + - '53' etag: - - W/"0x8D7EBDEA26EDE1F" + - W/"0x8D7ED717773D43C" expires: - '-1' odata-version: @@ -101,7 +101,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - bdfd1386-89ba-11ea-a6a3-2816a845e8c6 + - 9374a408-8b4d-11ea-b48a-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains vary: @@ -112,7 +112,7 @@ interactions: - request: body: '{"name": "sample-datasource", "description": "changed", "type": "azureblob", "credentials": {"connectionString": "DefaultEndpointsProtocol=https;AccountName=storagename;AccountKey=NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg==;EndpointSuffix=core.windows.net"}, - "container": {"name": "searchcontainer"}, "@odata.etag": "\"0x8D7EBDEA25ADD51\""}' + "container": {"name": "searchcontainer"}, "@odata.etag": "\"0x8D7ED71775A7B36\""}' headers: Accept: - application/json;odata.metadata=minimal @@ -125,13 +125,13 @@ interactions: Content-Type: - application/json If-Match: - - '"0x8D7EBDEA25ADD51"' + - '"0x8D7ED71775A7B36"' Prefer: - return=representation User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - B6E6C1BF71B889B3CD59FCE617987E2C + - 0DBCB3E23D05E4915AB588A0A3E6A929 method: PUT uri: https://search3c8b19c7.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview response: @@ -149,9 +149,9 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 01:42:53 GMT + - Fri, 01 May 2020 01:46:28 GMT elapsed-time: - - '19' + - '4' expires: - '-1' odata-version: @@ -161,7 +161,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - be11c5d8-89ba-11ea-919b-2816a845e8c6 + - 9390c946-8b4d-11ea-a80b-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_indexes_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_indexes_if_unchanged.yaml index ed0ac61910d1..365fc8599bfa 100644 --- a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_indexes_if_unchanged.yaml +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_indexes_if_unchanged.yaml @@ -18,12 +18,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - FA0774CEFCEDF7C1DF7FC6F29A8CEB94 + - 7EDDD034F9B54CB2E3BC204320340D62 method: POST uri: https://searchf02d188c.search.windows.net/indexes?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searchf02d188c.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBE409D8C054\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[{"name":"MyProfile","functionAggregation":null,"text":null,"functions":[]}],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + string: '{"@odata.context":"https://searchf02d188c.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7ED713C61993A\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[{"name":"MyProfile","functionAggregation":null,"text":null,"functions":[]}],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' headers: cache-control: - no-cache @@ -32,11 +32,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 02:21:34 GMT + - Fri, 01 May 2020 01:44:49 GMT elapsed-time: - - '666' + - '625' etag: - - W/"0x8D7EBE409D8C054" + - W/"0x8D7ED713C61993A" expires: - '-1' location: @@ -48,7 +48,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - 24d28880-89c0-11ea-ad8d-2816a845e8c6 + - 57dcb4fa-8b4d-11ea-9996-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: @@ -75,12 +75,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - FA0774CEFCEDF7C1DF7FC6F29A8CEB94 + - 7EDDD034F9B54CB2E3BC204320340D62 method: PUT uri: https://searchf02d188c.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searchf02d188c.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBE409FFB049\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + string: '{"@odata.context":"https://searchf02d188c.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7ED713C80E6C7\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' headers: cache-control: - no-cache @@ -89,11 +89,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 02:21:34 GMT + - Fri, 01 May 2020 01:44:49 GMT elapsed-time: - - '123' + - '99' etag: - - W/"0x8D7EBE409FFB049" + - W/"0x8D7ED713C80E6C7" expires: - '-1' odata-version: @@ -103,7 +103,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - 2582c1e8-89c0-11ea-a867-2816a845e8c6 + - 58800e88-8b4d-11ea-8ef8-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains vary: @@ -115,7 +115,7 @@ interactions: body: '{"name": "hotels", "fields": [{"name": "hotelId", "type": "Edm.String", "key": true, "searchable": false}, {"name": "baseRate", "type": "Edm.Double"}], "scoringProfiles": [], "corsOptions": {"allowedOrigins": ["*"], "maxAgeInSeconds": - 60}, "@odata.etag": "\"0x8D7EBE409D8C054\""}' + 60}, "@odata.etag": "\"0x8D7ED713C61993A\""}' headers: Accept: - application/json;odata.metadata=minimal @@ -128,13 +128,13 @@ interactions: Content-Type: - application/json If-Match: - - '"0x8D7EBE409D8C054"' + - '"0x8D7ED713C61993A"' Prefer: - return=representation User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - FA0774CEFCEDF7C1DF7FC6F29A8CEB94 + - 7EDDD034F9B54CB2E3BC204320340D62 method: PUT uri: https://searchf02d188c.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview response: @@ -152,9 +152,9 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 02:21:34 GMT + - Fri, 01 May 2020 01:44:49 GMT elapsed-time: - - '45' + - '43' expires: - '-1' odata-version: @@ -164,7 +164,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - 25a96818-89c0-11ea-8721-2816a845e8c6 + - 589d8268-8b4d-11ea-ba65-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_skillset_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_skillset_if_unchanged.yaml index 8adca9a67ebd..ddc3cec1b1df 100644 --- a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_skillset_if_unchanged.yaml +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_skillset_if_unchanged.yaml @@ -20,12 +20,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 0C98EDCFB7EF2403F053EADAEAAE16E3 + - 898AD7814EFB81496ACE7ECB4B684BFD method: PUT uri: https://searcha9b1907.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searcha9b1907.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBF2E425F4FD\"","name":"test-ss","description":"desc1","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + string: '{"@odata.context":"https://searcha9b1907.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7ED716321E476\"","name":"test-ss","description":"desc1","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' headers: cache-control: - no-cache @@ -34,11 +34,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 04:07:53 GMT + - Fri, 01 May 2020 01:45:54 GMT elapsed-time: - - '39' + - '162' etag: - - W/"0x8D7EBF2E425F4FD" + - W/"0x8D7ED716321E476" expires: - '-1' location: @@ -50,7 +50,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - ff82be46-89ce-11ea-b113-2816a845e8c6 + - 7ef51806-8b4d-11ea-875d-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: @@ -60,7 +60,7 @@ interactions: body: '{"name": "test-ss", "description": "desc2", "skills": [{"@odata.type": "#Microsoft.Skills.Text.EntityRecognitionSkill", "inputs": [{"name": "text", "source": "/document/content"}], "outputs": [{"name": "organizations", "targetName": - "organizations"}]}], "@odata.etag": "\"0x8D7EBF2E425F4FD\""}' + "organizations"}]}], "@odata.etag": "\"0x8D7ED716321E476\""}' headers: Accept: - application/json;odata.metadata=minimal @@ -77,12 +77,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 0C98EDCFB7EF2403F053EADAEAAE16E3 + - 898AD7814EFB81496ACE7ECB4B684BFD method: PUT uri: https://searcha9b1907.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searcha9b1907.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBF2E44409AD\"","name":"test-ss","description":"desc2","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + string: '{"@odata.context":"https://searcha9b1907.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7ED716345788B\"","name":"test-ss","description":"desc2","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' headers: cache-control: - no-cache @@ -91,11 +91,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 04:07:53 GMT + - Fri, 01 May 2020 01:45:54 GMT elapsed-time: - - '66' + - '41' etag: - - W/"0x8D7EBF2E44409AD" + - W/"0x8D7ED716345788B" expires: - '-1' odata-version: @@ -105,7 +105,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - ffd4ecf6-89ce-11ea-bb24-2816a845e8c6 + - 7f45c05a-8b4d-11ea-84d4-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains vary: @@ -125,12 +125,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 0C98EDCFB7EF2403F053EADAEAAE16E3 + - 898AD7814EFB81496ACE7ECB4B684BFD method: GET uri: https://searcha9b1907.search.windows.net/skillsets?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searcha9b1907.search.windows.net/$metadata#skillsets","value":[{"@odata.etag":"\"0x8D7EBF2E44409AD\"","name":"test-ss","description":"desc2","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":"#1","description":null,"context":"/document","categories":["Person","Quantity","Organization","URL","Email","Location","DateTime"],"defaultLanguageCode":"en","minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}]}' + string: '{"@odata.context":"https://searcha9b1907.search.windows.net/$metadata#skillsets","value":[{"@odata.etag":"\"0x8D7ED716345788B\"","name":"test-ss","description":"desc2","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":"#1","description":null,"context":"/document","categories":["Person","Quantity","Organization","URL","Email","Location","DateTime"],"defaultLanguageCode":"en","minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}]}' headers: cache-control: - no-cache @@ -139,9 +139,9 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 04:07:53 GMT + - Fri, 01 May 2020 01:45:54 GMT elapsed-time: - - '33' + - '57' expires: - '-1' odata-version: @@ -151,7 +151,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - fff5f330-89ce-11ea-96ec-2816a845e8c6 + - 7f60123a-8b4d-11ea-9805-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains vary: @@ -163,7 +163,7 @@ interactions: body: '{"name": "test-ss", "description": "desc1", "skills": [{"@odata.type": "#Microsoft.Skills.Text.EntityRecognitionSkill", "inputs": [{"name": "text", "source": "/document/content"}], "outputs": [{"name": "organizations", "targetName": - "organizations"}]}], "@odata.etag": "\"0x8D7EBF2E425F4FD\""}' + "organizations"}]}], "@odata.etag": "\"0x8D7ED716321E476\""}' headers: Accept: - application/json;odata.metadata=minimal @@ -176,13 +176,13 @@ interactions: Content-Type: - application/json If-Match: - - '"0x8D7EBF2E425F4FD"' + - '"0x8D7ED716321E476"' Prefer: - return=representation User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 0C98EDCFB7EF2403F053EADAEAAE16E3 + - 898AD7814EFB81496ACE7ECB4B684BFD method: PUT uri: https://searcha9b1907.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview response: @@ -200,9 +200,9 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 04:07:53 GMT + - Fri, 01 May 2020 01:45:54 GMT elapsed-time: - - '15' + - '10' expires: - '-1' odata-version: @@ -212,7 +212,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - 0011f33e-89cf-11ea-9102-2816a845e8c6 + - 7f7d2740-8b4d-11ea-9321-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_synonym_map_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_synonym_map_if_unchanged.yaml index 52a815d85252..920cac84f591 100644 --- a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_synonym_map_if_unchanged.yaml +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_create_or_update_synonym_map_if_unchanged.yaml @@ -16,12 +16,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 725A70C9E63294C7FDB7947876C60C59 + - 46DF28A1622AC6557E74984EDD9A64E7 method: POST uri: https://search5a551a56.search.windows.net/synonymmaps?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://search5a551a56.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7EBFABA313996\"","name":"test-syn-map","format":"solr","synonyms":"USA, + string: '{"@odata.context":"https://search5a551a56.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7ED71502253A0\"","name":"test-syn-map","format":"solr","synonyms":"USA, United States, United States of America","encryptionKey":null}' headers: cache-control: @@ -31,11 +31,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 05:03:59 GMT + - Fri, 01 May 2020 01:45:22 GMT elapsed-time: - - '46' + - '36' etag: - - W/"0x8D7EBFABA313996" + - W/"0x8D7ED71502253A0" expires: - '-1' location: @@ -47,7 +47,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - d5a560d2-89d6-11ea-8831-2816a845e8c6 + - 6bf83b14-8b4d-11ea-b062-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: @@ -72,12 +72,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 725A70C9E63294C7FDB7947876C60C59 + - 46DF28A1622AC6557E74984EDD9A64E7 method: PUT uri: https://search5a551a56.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://search5a551a56.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7EBFABA4784C3\"","name":"test-syn-map","format":"solr","synonyms":"Washington, + string: '{"@odata.context":"https://search5a551a56.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7ED715031236D\"","name":"test-syn-map","format":"solr","synonyms":"Washington, Wash. => WA","encryptionKey":null}' headers: cache-control: @@ -87,11 +87,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 05:03:59 GMT + - Fri, 01 May 2020 01:45:22 GMT elapsed-time: - - '19' + - '16' etag: - - W/"0x8D7EBFABA4784C3" + - W/"0x8D7ED715031236D" expires: - '-1' odata-version: @@ -101,7 +101,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - d5e26958-89d6-11ea-a330-2816a845e8c6 + - 6c3a94da-8b4d-11ea-be03-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains vary: @@ -111,7 +111,7 @@ interactions: message: OK - request: body: '{"name": "test-syn-map", "format": "solr", "synonyms": "[''USA, United - States, United States of America'']", "@odata.etag": "\"0x8D7EBFABA313996\""}' + States, United States of America'']", "@odata.etag": "\"0x8D7ED71502253A0\""}' headers: Accept: - application/json;odata.metadata=minimal @@ -124,13 +124,13 @@ interactions: Content-Type: - application/json If-Match: - - '"0x8D7EBFABA313996"' + - '"0x8D7ED71502253A0"' Prefer: - return=representation User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 725A70C9E63294C7FDB7947876C60C59 + - 46DF28A1622AC6557E74984EDD9A64E7 method: PUT uri: https://search5a551a56.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview response: @@ -148,9 +148,9 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 05:03:59 GMT + - Fri, 01 May 2020 01:45:22 GMT elapsed-time: - - '10' + - '5' expires: - '-1' odata-version: @@ -160,7 +160,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - d5f82be6-89d6-11ea-9c97-2816a845e8c6 + - 6c4a90f6-8b4d-11ea-ac9a-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_datasource_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_datasource_if_unchanged.yaml index 29cad1be1597..7d52e66e1304 100644 --- a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_datasource_if_unchanged.yaml +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_datasource_if_unchanged.yaml @@ -17,12 +17,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 590713A0C8B9510FFE57929645E27732 + - F1F2BD64ED2A908278EBA8650A6C8DEE method: POST uri: https://search4ba315a4.search.windows.net/datasources?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://search4ba315a4.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBDE85E01289\"","name":"sample-datasource","description":null,"type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + string: '{"@odata.context":"https://search4ba315a4.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7ED7181869172\"","name":"sample-datasource","description":null,"type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' headers: cache-control: - no-cache @@ -31,11 +31,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 01:42:05 GMT + - Fri, 01 May 2020 01:46:45 GMT elapsed-time: - - '58' + - '48' etag: - - W/"0x8D7EBDE85E01289" + - W/"0x8D7ED7181869172" expires: - '-1' location: @@ -47,7 +47,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - a13a84b4-89ba-11ea-8175-2816a845e8c6 + - 9d5ef89e-8b4d-11ea-ab0b-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: @@ -73,12 +73,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 590713A0C8B9510FFE57929645E27732 + - F1F2BD64ED2A908278EBA8650A6C8DEE method: PUT uri: https://search4ba315a4.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://search4ba315a4.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EBDE85F684D1\"","name":"sample-datasource","description":"updated","type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + string: '{"@odata.context":"https://search4ba315a4.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7ED71819F26FD\"","name":"sample-datasource","description":"updated","type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' headers: cache-control: - no-cache @@ -87,11 +87,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 01:42:05 GMT + - Fri, 01 May 2020 01:46:45 GMT elapsed-time: - - '34' + - '27' etag: - - W/"0x8D7EBDE85F684D1" + - W/"0x8D7ED71819F26FD" expires: - '-1' odata-version: @@ -101,7 +101,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - a1825870-89ba-11ea-b725-2816a845e8c6 + - 9da104c6-8b4d-11ea-8bff-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains vary: @@ -121,11 +121,11 @@ interactions: Content-Length: - '0' If-Match: - - '"0x8D7EBDE85E01289"' + - '"0x8D7ED7181869172"' User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 590713A0C8B9510FFE57929645E27732 + - F1F2BD64ED2A908278EBA8650A6C8DEE method: DELETE uri: https://search4ba315a4.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview response: @@ -143,9 +143,9 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 01:42:05 GMT + - Fri, 01 May 2020 01:46:45 GMT elapsed-time: - - '9' + - '4' expires: - '-1' odata-version: @@ -155,7 +155,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - a198de08-89ba-11ea-ae8e-2816a845e8c6 + - 9db91138-8b4d-11ea-8df5-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_indexes_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_indexes_if_unchanged.yaml index a927a72c47a4..eb295a1b7e0b 100644 --- a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_indexes_if_unchanged.yaml +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_indexes_if_unchanged.yaml @@ -18,12 +18,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - AF52C3C90CE766533CDA6EAA964604AB + - 0ABC8B358D4D85386822B456F8767860 method: POST uri: https://searchbbd1469.search.windows.net/indexes?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searchbbd1469.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBE3D36EA891\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[{"name":"MyProfile","functionAggregation":null,"text":null,"functions":[]}],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + string: '{"@odata.context":"https://searchbbd1469.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7ED714678528F\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[{"name":"MyProfile","functionAggregation":null,"text":null,"functions":[]}],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' headers: cache-control: - no-cache @@ -32,11 +32,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 02:20:03 GMT + - Fri, 01 May 2020 01:45:06 GMT elapsed-time: - - '643' + - '627' etag: - - W/"0x8D7EBE3D36EA891" + - W/"0x8D7ED714678528F" expires: - '-1' location: @@ -48,7 +48,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - ee76b2c2-89bf-11ea-8c6b-2816a845e8c6 + - 61fbe900-8b4d-11ea-aac9-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: @@ -75,12 +75,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - AF52C3C90CE766533CDA6EAA964604AB + - 0ABC8B358D4D85386822B456F8767860 method: PUT uri: https://searchbbd1469.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://searchbbd1469.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7EBE3D393C372\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' + string: '{"@odata.context":"https://searchbbd1469.search.windows.net/$metadata#indexes/$entity","@odata.etag":"\"0x8D7ED714695F21D\"","name":"hotels","defaultScoringProfile":null,"fields":[{"name":"hotelId","type":"Edm.String","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":true,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]},{"name":"baseRate","type":"Edm.Double","searchable":false,"filterable":true,"retrievable":true,"sortable":true,"facetable":true,"key":false,"indexAnalyzer":null,"searchAnalyzer":null,"analyzer":null,"synonymMaps":[]}],"scoringProfiles":[],"corsOptions":{"allowedOrigins":["*"],"maxAgeInSeconds":60},"suggesters":[],"analyzers":[],"tokenizers":[],"tokenFilters":[],"charFilters":[],"encryptionKey":null,"similarity":null}' headers: cache-control: - no-cache @@ -89,11 +89,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 02:20:03 GMT + - Fri, 01 May 2020 01:45:06 GMT elapsed-time: - - '105' + - '104' etag: - - W/"0x8D7EBE3D393C372" + - W/"0x8D7ED714695F21D" expires: - '-1' odata-version: @@ -103,7 +103,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - ef18eda8-89bf-11ea-a573-2816a845e8c6 + - 629611e8-8b4d-11ea-ad52-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains vary: @@ -123,11 +123,11 @@ interactions: Content-Length: - '0' If-Match: - - '"0x8D7EBE3D36EA891"' + - '"0x8D7ED714678528F"' User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - AF52C3C90CE766533CDA6EAA964604AB + - 0ABC8B358D4D85386822B456F8767860 method: DELETE uri: https://searchbbd1469.search.windows.net/indexes('hotels')?api-version=2019-05-06-Preview response: @@ -145,9 +145,9 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 02:20:03 GMT + - Fri, 01 May 2020 01:45:06 GMT elapsed-time: - - '50' + - '15' expires: - '-1' odata-version: @@ -157,7 +157,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - ef3d7258-89bf-11ea-834b-2816a845e8c6 + - 62b2aff8-8b4d-11ea-8440-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_skillset_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_skillset_if_unchanged.yaml index 2c3f9a785492..4da2935dfcb9 100644 --- a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_skillset_if_unchanged.yaml +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_skillset_if_unchanged.yaml @@ -17,12 +17,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - DABF6CB43B698738C7939253D7A72E9F + - E5E890D66B801E7867C9E374922FC838 method: POST uri: https://search21f914e4.search.windows.net/skillsets?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://search21f914e4.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBF284749492\"","name":"test-ss","description":"desc","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + string: '{"@odata.context":"https://search21f914e4.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7ED716DB3B0F7\"","name":"test-ss","description":"desc","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' headers: cache-control: - no-cache @@ -31,11 +31,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 04:05:13 GMT + - Fri, 01 May 2020 01:46:12 GMT elapsed-time: - - '55' + - '37' etag: - - W/"0x8D7EBF284749492" + - W/"0x8D7ED716DB3B0F7" expires: - '-1' location: @@ -47,7 +47,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - 9fde43d2-89ce-11ea-b519-2816a845e8c6 + - 8979c398-8b4d-11ea-879a-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: @@ -74,12 +74,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - DABF6CB43B698738C7939253D7A72E9F + - E5E890D66B801E7867C9E374922FC838 method: PUT uri: https://search21f914e4.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://search21f914e4.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7EBF2848EB0EC\"","name":"test-ss","description":"updated","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' + string: '{"@odata.context":"https://search21f914e4.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D7ED716DCDF47B\"","name":"test-ss","description":"updated","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizations"}]}],"cognitiveServices":null,"knowledgeStore":null}' headers: cache-control: - no-cache @@ -88,11 +88,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 04:05:13 GMT + - Fri, 01 May 2020 01:46:12 GMT elapsed-time: - - '45' + - '52' etag: - - W/"0x8D7EBF2848EB0EC" + - W/"0x8D7ED716DCDF47B" expires: - '-1' odata-version: @@ -102,7 +102,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - a0230ef8-89ce-11ea-a53b-2816a845e8c6 + - 89ce1288-8b4d-11ea-973d-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains vary: @@ -122,11 +122,11 @@ interactions: Content-Length: - '0' If-Match: - - '"0x8D7EBF284749492"' + - '"0x8D7ED716DB3B0F7"' User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - DABF6CB43B698738C7939253D7A72E9F + - E5E890D66B801E7867C9E374922FC838 method: DELETE uri: https://search21f914e4.search.windows.net/skillsets('test-ss')?api-version=2019-05-06-Preview response: @@ -144,9 +144,9 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 04:05:13 GMT + - Fri, 01 May 2020 01:46:12 GMT elapsed-time: - - '14' + - '10' expires: - '-1' odata-version: @@ -156,7 +156,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - a03d629a-89ce-11ea-8f8d-2816a845e8c6 + - 89e92918-8b4d-11ea-882a-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_synonym_map_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_synonym_map_if_unchanged.yaml index 1353baba00e7..6ff7fb694176 100644 --- a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_synonym_map_if_unchanged.yaml +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_synonym_map_if_unchanged.yaml @@ -16,12 +16,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 13C25F60415C700FD39787BC02ACDFC0 + - 3C7456D14A4C1D58E3B5C8338B829E8D method: POST uri: https://search654a1633.search.windows.net/synonymmaps?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://search654a1633.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7EBFA7A96EF2E\"","name":"test-syn-map","format":"solr","synonyms":"USA, + string: '{"@odata.context":"https://search654a1633.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7ED715978F503\"","name":"test-syn-map","format":"solr","synonyms":"USA, United States, United States of America\nWashington, Wash. => WA","encryptionKey":null}' headers: cache-control: @@ -31,11 +31,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 05:02:12 GMT + - Fri, 01 May 2020 01:45:38 GMT elapsed-time: - - '52' + - '21' etag: - - W/"0x8D7EBFA7A96EF2E" + - W/"0x8D7ED715978F503" expires: - '-1' location: @@ -47,7 +47,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - 95f84e62-89d6-11ea-b612-2816a845e8c6 + - 754dfc4c-8b4d-11ea-abb2-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: @@ -72,12 +72,12 @@ interactions: User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 13C25F60415C700FD39787BC02ACDFC0 + - 3C7456D14A4C1D58E3B5C8338B829E8D method: PUT uri: https://search654a1633.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview response: body: - string: '{"@odata.context":"https://search654a1633.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7EBFA7AAEC138\"","name":"test-syn-map","format":"solr","synonyms":"Washington, + string: '{"@odata.context":"https://search654a1633.search.windows.net/$metadata#synonymmaps/$entity","@odata.etag":"\"0x8D7ED71598DB954\"","name":"test-syn-map","format":"solr","synonyms":"Washington, Wash. => WA","encryptionKey":null}' headers: cache-control: @@ -87,11 +87,11 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 05:02:12 GMT + - Fri, 01 May 2020 01:45:38 GMT elapsed-time: - - '27' + - '23' etag: - - W/"0x8D7EBFA7AAEC138" + - W/"0x8D7ED71598DB954" expires: - '-1' odata-version: @@ -101,7 +101,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - 9648590c-89d6-11ea-af8c-2816a845e8c6 + - 75922b10-8b4d-11ea-b5a8-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains vary: @@ -121,11 +121,11 @@ interactions: Content-Length: - '0' If-Match: - - '"0x8D7EBFA7A96EF2E"' + - '"0x8D7ED715978F503"' User-Agent: - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) api-key: - - 13C25F60415C700FD39787BC02ACDFC0 + - 3C7456D14A4C1D58E3B5C8338B829E8D method: DELETE uri: https://search654a1633.search.windows.net/synonymmaps('test-syn-map')?api-version=2019-05-06-Preview response: @@ -143,9 +143,9 @@ interactions: content-type: - application/json; odata.metadata=minimal date: - - Wed, 29 Apr 2020 05:02:12 GMT + - Fri, 01 May 2020 01:45:38 GMT elapsed-time: - - '14' + - '4' expires: - '-1' odata-version: @@ -155,7 +155,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - 965ff0ba-89d6-11ea-b83f-2816a845e8c6 + - 75a7793e-8b4d-11ea-9310-2816a845e8c6 strict-transport-security: - max-age=15724800; includeSubDomains status: diff --git a/sdk/search/azure-search-documents/tests/test_service_live.py b/sdk/search/azure-search-documents/tests/test_service_live.py index 016e62491832..32a7fa82b44c 100644 --- a/sdk/search/azure-search-documents/tests/test_service_live.py +++ b/sdk/search/azure-search-documents/tests/test_service_live.py @@ -13,6 +13,7 @@ from search_service_preparer import SearchServicePreparer, SearchResourceGroupPreparer +from azure.core import MatchConditions from azure.core.credentials import AzureKeyCredential from azure.core.exceptions import HttpResponseError from azure.search.documents import( @@ -134,7 +135,7 @@ def test_delete_indexes_if_unchanged(self, api_key, endpoint, index_name, **kwar index.e_tag = etag with pytest.raises(HttpResponseError): - client.delete_index(index, only_if_unchanged=True) + client.delete_index(index, match_condition=MatchConditions.IfNotModified) @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) @@ -248,7 +249,7 @@ def test_create_or_update_indexes_if_unchanged(self, api_key, endpoint, index_na index.e_tag = etag with pytest.raises(HttpResponseError): - client.create_or_update_index(index.name, index, only_if_unchanged=True) + client.create_or_update_index(index.name, index, match_condition=MatchConditions.IfNotModified) @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) @@ -311,7 +312,7 @@ def test_delete_synonym_map_if_unchanged(self, api_key, endpoint, index_name, ** sm_result.e_tag = etag with pytest.raises(HttpResponseError): - client.delete_synonym_map(sm_result, only_if_unchanged=True) + client.delete_synonym_map(sm_result, match_condition=MatchConditions.IfNotModified) assert len(client.get_synonym_maps()) == 1 @SearchResourceGroupPreparer(random_name_enabled=True) @@ -380,7 +381,7 @@ def test_create_or_update_synonym_map_if_unchanged(self, api_key, endpoint, inde result.e_tag = etag with pytest.raises(HttpResponseError): - client.create_or_update_synonym_map(result, only_if_unchanged=True) + client.create_or_update_synonym_map(result, match_condition=MatchConditions.IfNotModified) class SearchSkillsetClientTest(AzureMgmtTestCase): @@ -430,7 +431,7 @@ def test_delete_skillset_if_unchanged(self, api_key, endpoint, index_name, **kwa updated.e_tag = etag with pytest.raises(HttpResponseError): - client.delete_skillset(updated, only_if_unchanged=True) + client.delete_skillset(updated, match_condition=MatchConditions.IfNotModified) @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) @@ -511,7 +512,7 @@ def test_create_or_update_skillset_if_unchanged(self, api_key, endpoint, index_n ss.e_tag = etag with pytest.raises(HttpResponseError): - client.create_or_update_skillset(name='test-ss', skills=[s], skillset=ss, only_if_unchanged=True) + client.create_or_update_skillset(name='test-ss', skills=[s], skillset=ss, match_condition=MatchConditions.IfNotModified) class SearchDataSourcesClientTest(AzureMgmtTestCase): @@ -596,7 +597,7 @@ def test_create_or_update_datasource_if_unchanged(self, api_key, endpoint, index data_source.e_tag = etag # reset to the original datasource data_source.description = "changed" with pytest.raises(HttpResponseError): - client.create_or_update_datasource(data_source, only_if_unchanged=True) + client.create_or_update_datasource(data_source, match_condition=MatchConditions.IfNotModified) assert len(client.get_datasources()) == 1 @SearchResourceGroupPreparer(random_name_enabled=True) @@ -614,5 +615,5 @@ def test_delete_datasource_if_unchanged(self, api_key, endpoint, index_name, **k # prepare data source data_source.e_tag = etag # reset to the original datasource with pytest.raises(HttpResponseError): - client.delete_datasource(data_source, only_if_unchanged=True) + client.delete_datasource(data_source, match_condition=MatchConditions.IfNotModified) assert len(client.get_datasources()) == 1 From 4e01084d2d53b6f7f93dbcbdced6f5284a708777 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Thu, 30 Apr 2020 19:23:12 -0700 Subject: [PATCH 07/17] error map --- .../documents/_service/_datasources_client.py | 11 ++++---- .../documents/_service/_indexes_client.py | 17 +++++++----- .../documents/_service/_skillsets_client.py | 17 +++++++----- .../_service/_synonym_maps_client.py | 26 +++++++++++-------- .../azure/search/documents/_service/_utils.py | 10 ++++++- .../_service/aio/_datasources_client.py | 11 ++++---- .../documents/_service/aio/_indexes_client.py | 17 +++++++----- .../_service/aio/_skillsets_client.py | 17 +++++++----- .../_service/aio/_synonym_maps_client.py | 26 +++++++++++-------- 9 files changed, 95 insertions(+), 57 deletions(-) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py index 4c5bbcd01021..83ca286a1f36 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_datasources_client.py @@ -102,6 +102,7 @@ def create_or_update_datasource(self, data_source, name=None, **kwargs): data_source_name=name, data_source=data_source, access_condition=access_condition, + error_map=error_map, **kwargs ) return result @@ -174,17 +175,17 @@ def delete_datasource(self, data_source, **kwargs): :caption: Delete a DataSource """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - access_condition = None + error_map, access_condition = get_access_conditions( + data_source, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) try: name = data_source.name - error_map, access_condition = get_access_conditions( - data_source, - kwargs.pop('match_condition', MatchConditions.Unconditionally) - ) except AttributeError: name = data_source self._client.data_sources.delete( data_source_name=name, access_condition=access_condition, + error_map=error_map, **kwargs ) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py index 170c918cd960..355cffc065d9 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_indexes_client.py @@ -143,16 +143,20 @@ def delete_index(self, index, **kwargs): :caption: Delete an index. """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - access_condition = None + error_map, access_condition = get_access_conditions( + index, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) try: index_name = index.name - error_map, access_condition = get_access_conditions( - index, - kwargs.pop('match_condition', MatchConditions.Unconditionally) - ) except AttributeError: index_name = index - self._client.indexes.delete(index_name=index_name, access_condition=access_condition, **kwargs) + self._client.indexes.delete( + index_name=index_name, + access_condition=access_condition, + error_map=error_map, + **kwargs + ) @distributed_trace def create_index(self, index, **kwargs): @@ -230,6 +234,7 @@ def create_or_update_index( index=patched_index, allow_index_downtime=allow_index_downtime, access_condition=access_condition, + error_map=error_map, **kwargs ) return result diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py index 453f61be1922..5556aa26db03 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_skillsets_client.py @@ -7,6 +7,7 @@ from azure.core import MatchConditions from azure.core.tracing.decorator import distributed_trace +from azure.core.exceptions import ClientAuthenticationError, ResourceNotFoundError from ._generated import SearchServiceClient as _SearchServiceClient from ._generated.models import Skillset @@ -126,16 +127,15 @@ def delete_skillset(self, skillset, **kwargs): """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - access_condition = None + error_map, access_condition = get_access_conditions( + skillset, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) try: name = skillset.name - error_map, access_condition = get_access_conditions( - skillset, - kwargs.pop('match_condition', MatchConditions.Unconditionally) - ) except AttributeError: name = skillset - self._client.skillsets.delete(name, access_condition=access_condition, **kwargs) + self._client.skillsets.delete(name, access_condition=access_condition, error_map=error_map, **kwargs) @distributed_trace def create_skillset(self, name, skills, description, **kwargs): @@ -192,6 +192,10 @@ def create_or_update_skillset(self, name, **kwargs): """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError + } access_condition = None if "skillset" in kwargs: @@ -217,5 +221,6 @@ def create_or_update_skillset(self, name, **kwargs): skillset_name=name, skillset=skillset, access_condition=access_condition, + error_map=error_map, **kwargs ) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py index bf30c4e7159d..d5fe5ab9082a 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_synonym_maps_client.py @@ -129,16 +129,20 @@ def delete_synonym_map(self, synonym_map, **kwargs): """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - access_condition = None + error_map, access_condition = get_access_conditions( + synonym_map, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) try: name = synonym_map.name - error_map, access_condition = get_access_conditions( - synonym_map, - kwargs.pop('match_condition', MatchConditions.Unconditionally) - ) except AttributeError: name = synonym_map - self._client.synonym_maps.delete(synonym_map_name=name, access_condition=access_condition, **kwargs) + self._client.synonym_maps.delete( + synonym_map_name=name, + access_condition=access_condition, + error_map=error_map, + **kwargs + ) @distributed_trace def create_synonym_map(self, name, synonyms, **kwargs): @@ -185,13 +189,12 @@ def create_or_update_synonym_map(self, synonym_map, synonyms=None, **kwargs): """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - access_condition = None + error_map, access_condition = get_access_conditions( + synonym_map, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) try: name = synonym_map.name - error_map, access_condition = get_access_conditions( - synonym_map, - kwargs.pop('match_condition', MatchConditions.Unconditionally) - ) if synonyms: synonym_map.synonyms = "\n".join(synonyms) except AttributeError: @@ -202,6 +205,7 @@ def create_or_update_synonym_map(self, synonym_map, synonyms=None, **kwargs): synonym_map_name=name, synonym_map=synonym_map, access_condition=access_condition, + error_map=error_map, **kwargs ) return listize_synonyms(result.as_dict()) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py index b1306e527353..506996420374 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py @@ -7,6 +7,7 @@ from azure.core import MatchConditions from azure.core.exceptions import ( + ClientAuthenticationError, ResourceExistsError, ResourceNotFoundError, ResourceModifiedError, @@ -161,7 +162,14 @@ def listize_synonyms(synonym_map): def get_access_conditions(model, match_condition=MatchConditions.Unconditionally): # type: (Any, MatchConditions) -> Tuple[Dict[int, Any], AccessCondition] - error_map = {404: ResourceNotFoundError} # type: Dict[int, Any] + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError + } + + if isinstance(model, str): + return (error_map, None) + try: if_match = prep_if_match(model.e_tag, match_condition) if_none_match = prep_if_none_match(model.e_tag, match_condition) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py index f241e00b1657..65d5dd8ef88a 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_datasources_client.py @@ -101,6 +101,7 @@ async def create_or_update_datasource(self, data_source, name=None, **kwargs): data_source_name=name, data_source=data_source, access_condition=access_condition, + error_map=error_map, **kwargs ) return result @@ -129,18 +130,18 @@ async def delete_datasource(self, data_source, **kwargs): :caption: Delete a DataSource """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - access_condition = None + error_map, access_condition = get_access_conditions( + data_source, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) try: name = data_source.name - error_map, access_condition = get_access_conditions( - data_source, - kwargs.pop('match_condition', MatchConditions.Unconditionally) - ) except AttributeError: name = data_source await self._client.data_sources.delete( data_source_name=name, access_condition=access_condition, + error_map=error_map, **kwargs ) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py index 7be1259b53ee..c7571ef63566 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_indexes_client.py @@ -142,16 +142,20 @@ async def delete_index(self, index, **kwargs): :caption: Delete an index. """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - access_condition = None + error_map, access_condition = get_access_conditions( + index, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) try: index_name = index.name - error_map, access_condition = get_access_conditions( - index, - kwargs.pop('match_condition', MatchConditions.Unconditionally) - ) except AttributeError: index_name = index - await self._client.indexes.delete(index_name=index_name, access_condition=access_condition, **kwargs) + await self._client.indexes.delete( + index_name=index_name, + access_condition=access_condition, + error_map=error_map, + **kwargs + ) @distributed_trace_async async def create_index(self, index, **kwargs): @@ -229,6 +233,7 @@ async def create_or_update_index( index=patched_index, allow_index_downtime=allow_index_downtime, access_condition=access_condition, + error_map=error_map, **kwargs ) return result diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py index 9fb33469ae88..75bfadfaef47 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_skillsets_client.py @@ -6,6 +6,7 @@ from typing import TYPE_CHECKING from azure.core import MatchConditions +from azure.core.exceptions import ClientAuthenticationError, ResourceNotFoundError from azure.core.tracing.decorator_async import distributed_trace_async from .._generated.aio import SearchServiceClient as _SearchServiceClient @@ -126,16 +127,15 @@ async def delete_skillset(self, skillset, **kwargs): """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - access_condition = None + error_map, access_condition = get_access_conditions( + skillset, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) try: name = skillset.name - error_map, access_condition = get_access_conditions( - skillset, - kwargs.pop('match_condition', MatchConditions.Unconditionally) - ) except AttributeError: name = skillset - await self._client.skillsets.delete(name, access_condition=access_condition, **kwargs) + await self._client.skillsets.delete(name, access_condition=access_condition, error_map=error_map, **kwargs) @distributed_trace_async async def create_skillset(self, name, skills, description, **kwargs): @@ -193,6 +193,10 @@ async def create_or_update_skillset(self, name, **kwargs): """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError + } access_condition = None if "skillset" in kwargs: @@ -218,5 +222,6 @@ async def create_or_update_skillset(self, name, **kwargs): skillset_name=name, skillset=skillset, access_condition=access_condition, + error_map=error_map, **kwargs ) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py index 60b4c2468106..7818d6834cd0 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/aio/_synonym_maps_client.py @@ -130,16 +130,20 @@ async def delete_synonym_map(self, synonym_map, **kwargs): """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - access_condition = None + error_map, access_condition = get_access_conditions( + synonym_map, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) try: name = synonym_map.name - error_map, access_condition = get_access_conditions( - synonym_map, - kwargs.pop('match_condition', MatchConditions.Unconditionally) - ) except AttributeError: name = synonym_map - await self._client.synonym_maps.delete(synonym_map_name=name, access_condition=access_condition, **kwargs) + await self._client.synonym_maps.delete( + synonym_map_name=name, + access_condition=access_condition, + error_map=error_map, + **kwargs + ) @distributed_trace_async async def create_synonym_map(self, name, synonyms, **kwargs): @@ -186,13 +190,12 @@ async def create_or_update_synonym_map(self, synonym_map, synonyms=None, **kwarg """ kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) - error_map, access_condition = None, None + error_map, access_condition = get_access_conditions( + synonym_map, + kwargs.pop('match_condition', MatchConditions.Unconditionally) + ) try: name = synonym_map.name - error_map, access_condition = get_access_conditions( - synonym_map, - kwargs.pop('match_condition', MatchConditions.Unconditionally) - ) if synonyms: synonym_map.synonyms = "\n".join(synonyms) except AttributeError: @@ -203,6 +206,7 @@ async def create_or_update_synonym_map(self, synonym_map, synonyms=None, **kwarg synonym_map_name=name, synonym_map=synonym_map, access_condition=access_condition, + error_map=error_map, **kwargs ) return listize_synonyms(result.as_dict()) From 146b6b3df72fed5e1dc03343897aa9c15ef0d78a Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Thu, 30 Apr 2020 19:47:24 -0700 Subject: [PATCH 08/17] fix test --- .../azure/search/documents/_service/_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py index 506996420374..ed315653b37c 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # ------------------------------------------------------------------------- +import six from typing import TYPE_CHECKING from azure.core import MatchConditions @@ -167,7 +168,7 @@ def get_access_conditions(model, match_condition=MatchConditions.Unconditionally 404: ResourceNotFoundError } - if isinstance(model, str): + if isinstance(model, six.text_type): return (error_map, None) try: From a144727729daf25e808ca42ab84efafec0ac3af6 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Thu, 30 Apr 2020 20:00:02 -0700 Subject: [PATCH 09/17] lint --- .../azure/search/documents/_service/_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py index ed315653b37c..355157e08a1e 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py @@ -3,7 +3,6 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # ------------------------------------------------------------------------- -import six from typing import TYPE_CHECKING from azure.core import MatchConditions @@ -168,7 +167,7 @@ def get_access_conditions(model, match_condition=MatchConditions.Unconditionally 404: ResourceNotFoundError } - if isinstance(model, six.text_type): + if not hasattr(model, 'e_tag'): return (error_map, None) try: From 79da71a3687f1d055cbf2a6de2c1c9750664dbe0 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Fri, 1 May 2020 11:15:32 -0700 Subject: [PATCH 10/17] comments --- .../azure-search-documents/tests/test_service_live.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sdk/search/azure-search-documents/tests/test_service_live.py b/sdk/search/azure-search-documents/tests/test_service_live.py index 32a7fa82b44c..77490be8c286 100644 --- a/sdk/search/azure-search-documents/tests/test_service_live.py +++ b/sdk/search/azure-search-documents/tests/test_service_live.py @@ -129,7 +129,7 @@ def test_delete_indexes_if_unchanged(self, api_key, endpoint, index_name, **kwar cors_options=cors_options) result = client.create_index(index) etag = result.e_tag - # get e tag nd update + # get e tag and update index.scoring_profiles = [] client.create_or_update_index(index.name, index) @@ -243,7 +243,7 @@ def test_create_or_update_indexes_if_unchanged(self, api_key, endpoint, index_na cors_options=cors_options) result = client.create_index(index) etag = result.e_tag - # get e tag nd update + # get e tag and update index.scoring_profiles = [] client.create_or_update_index(index.name, index) @@ -307,8 +307,8 @@ def test_delete_synonym_map_if_unchanged(self, api_key, endpoint, index_name, ** etag = sm_result.e_tag client.create_or_update_synonym_map("test-syn-map", [ - "Washington, Wash. => WA", - ]) + "Washington, Wash. => WA", + ]) sm_result.e_tag = etag with pytest.raises(HttpResponseError): @@ -598,7 +598,6 @@ def test_create_or_update_datasource_if_unchanged(self, api_key, endpoint, index data_source.description = "changed" with pytest.raises(HttpResponseError): client.create_or_update_datasource(data_source, match_condition=MatchConditions.IfNotModified) - assert len(client.get_datasources()) == 1 @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) From 24b2180302ca6d4be34980a5c832fca2775d94da Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Fri, 1 May 2020 11:52:06 -0700 Subject: [PATCH 11/17] test_utils --- .../azure-search-documents/tests/_test_utils.py | 13 +++++++++++++ .../tests/async_tests/test_service_live_async.py | 10 ++-------- .../tests/test_service_live.py | 12 +++--------- 3 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 sdk/search/azure-search-documents/tests/_test_utils.py diff --git a/sdk/search/azure-search-documents/tests/_test_utils.py b/sdk/search/azure-search-documents/tests/_test_utils.py new file mode 100644 index 000000000000..844ff2a240b8 --- /dev/null +++ b/sdk/search/azure-search-documents/tests/_test_utils.py @@ -0,0 +1,13 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +from azure.search.documents import SynonymMap + + +def build_synonym_map_from_dict(synonym_map): + sm = SynonymMap(name=synonym_map["name"], synonyms=synonym_map["synonyms"]) + for k, v in synonym_map.items(): + setattr(sm, k, v) + return sm diff --git a/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py b/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py index 6d990324d22a..0ba4a3eaa043 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py +++ b/sdk/search/azure-search-documents/tests/async_tests/test_service_live_async.py @@ -37,6 +37,7 @@ SynonymMap ) from azure.search.documents.aio import SearchServiceClient +from _test_utils import build_synonym_map_from_dict CWD = dirname(realpath(__file__)) SCHEMA = open(join(CWD, "..", "hotel_schema.json")).read() @@ -277,13 +278,6 @@ async def test_analyze_text(self, api_key, endpoint, index_name, **kwargs): assert len(result.tokens) == 2 class SearchSynonymMapsClientTest(AzureMgmtTestCase): - def _build_synonym_map_from_dict(self, synonym_map): - sm = SynonymMap(name=synonym_map["name"], synonyms=synonym_map["synonyms"]) - for k, v in synonym_map.items(): - setattr(sm, k, v) - - return sm - @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) async def test_create_synonym_map(self, api_key, endpoint, index_name, **kwargs): @@ -320,7 +314,7 @@ async def test_delete_synonym_map_if_unchanged(self, api_key, endpoint, index_na "USA, United States, United States of America", "Washington, Wash. => WA", ]) - sm_result = self._build_synonym_map_from_dict(result) + sm_result = build_synonym_map_from_dict(result) etag = sm_result.e_tag await client.create_or_update_synonym_map("test-syn-map", [ diff --git a/sdk/search/azure-search-documents/tests/test_service_live.py b/sdk/search/azure-search-documents/tests/test_service_live.py index 77490be8c286..7c0412d2985b 100644 --- a/sdk/search/azure-search-documents/tests/test_service_live.py +++ b/sdk/search/azure-search-documents/tests/test_service_live.py @@ -33,6 +33,7 @@ DataContainer, SynonymMap ) +from _test_utils import build_synonym_map_from_dict CWD = dirname(realpath(__file__)) SCHEMA = open(join(CWD, "hotel_schema.json")).read() @@ -260,13 +261,6 @@ def test_analyze_text(self, api_key, endpoint, index_name, **kwargs): assert len(result.tokens) == 2 class SearchSynonymMapsClientTest(AzureMgmtTestCase): - def _build_synonym_map_from_dict(self, synonym_map): - sm = SynonymMap(name=synonym_map["name"], synonyms=synonym_map["synonyms"]) - for k, v in synonym_map.items(): - setattr(sm, k, v) - - return sm - @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) def test_create_synonym_map(self, api_key, endpoint, index_name, **kwargs): @@ -303,7 +297,7 @@ def test_delete_synonym_map_if_unchanged(self, api_key, endpoint, index_name, ** "USA, United States, United States of America", "Washington, Wash. => WA", ]) - sm_result = self._build_synonym_map_from_dict(result) + sm_result = build_synonym_map_from_dict(result) etag = sm_result.e_tag client.create_or_update_synonym_map("test-syn-map", [ @@ -370,7 +364,7 @@ def test_create_or_update_synonym_map(self, api_key, endpoint, index_name, **kwa @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) def test_create_or_update_synonym_map_if_unchanged(self, api_key, endpoint, index_name, **kwargs): client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_synonym_maps_client() - result = self._build_synonym_map_from_dict(client.create_synonym_map("test-syn-map", [ + result = build_synonym_map_from_dict(client.create_synonym_map("test-syn-map", [ "USA, United States, United States of America", ])) etag = result.e_tag From 0a84da3799b7eca3fd680cd269c0bf7a428dd036 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Fri, 1 May 2020 13:06:44 -0700 Subject: [PATCH 12/17] Update sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py --- .../azure/search/documents/_service/_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py index 355157e08a1e..be058e771292 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py @@ -176,7 +176,7 @@ def get_access_conditions(model, match_condition=MatchConditions.Unconditionally if match_condition == MatchConditions.IfNotModified: error_map[412] = ResourceModifiedError if match_condition == MatchConditions.IfModified: - error_map[304] = ResourceNotModifiedError + error_map[412] = ResourceNotModifiedError if match_condition == MatchConditions.IfPresent: error_map[412] = ResourceNotFoundError if match_condition == MatchConditions.IfMissing: From 4a3e126c0264f7a3d39c10dd8bb4961bca942fa8 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Fri, 1 May 2020 13:30:26 -0700 Subject: [PATCH 13/17] Update sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py Co-authored-by: Johan Stenberg (MSFT) --- .../azure/search/documents/_service/_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py index be058e771292..058a52462d7c 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py @@ -176,6 +176,7 @@ def get_access_conditions(model, match_condition=MatchConditions.Unconditionally if match_condition == MatchConditions.IfNotModified: error_map[412] = ResourceModifiedError if match_condition == MatchConditions.IfModified: + error_map[304] = ResourceNotModifiedError error_map[412] = ResourceNotModifiedError if match_condition == MatchConditions.IfPresent: error_map[412] = ResourceNotFoundError From b0ca1176327877dc08806c6baa36113c2296e54c Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Fri, 1 May 2020 14:48:30 -0700 Subject: [PATCH 14/17] Update sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py --- .../azure/search/documents/_service/_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py index 058a52462d7c..2e0a22a57c9a 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py @@ -167,7 +167,11 @@ def get_access_conditions(model, match_condition=MatchConditions.Unconditionally 404: ResourceNotFoundError } - if not hasattr(model, 'e_tag'): + try: + _unicode_type = unicode + except NameError: + _unicode_type = str + if isinstance(model, _unicode_type): return (error_map, None) try: From 756fd7a5aca9bbfa7da563dcaddbfa1814274fcb Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Fri, 1 May 2020 14:56:05 -0700 Subject: [PATCH 15/17] Revert "Update sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py" This reverts commit b0ca1176327877dc08806c6baa36113c2296e54c. --- .../azure/search/documents/_service/_utils.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py index 2e0a22a57c9a..058a52462d7c 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py @@ -167,11 +167,7 @@ def get_access_conditions(model, match_condition=MatchConditions.Unconditionally 404: ResourceNotFoundError } - try: - _unicode_type = unicode - except NameError: - _unicode_type = str - if isinstance(model, _unicode_type): + if not hasattr(model, 'e_tag'): return (error_map, None) try: From e8203d71e3d22e74b9fb184edef9b48fda38284c Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Fri, 1 May 2020 15:07:45 -0700 Subject: [PATCH 16/17] fix --- .../azure/search/documents/_service/_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py index 058a52462d7c..179cd75accc6 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- from typing import TYPE_CHECKING - +import six from azure.core import MatchConditions from azure.core.exceptions import ( ClientAuthenticationError, @@ -167,7 +167,7 @@ def get_access_conditions(model, match_condition=MatchConditions.Unconditionally 404: ResourceNotFoundError } - if not hasattr(model, 'e_tag'): + if isinstance(model, six.string_types): return (error_map, None) try: From 139c208158eb6a695caf7bfb9e99d7a9d2f9fa1e Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Fri, 1 May 2020 15:19:35 -0700 Subject: [PATCH 17/17] more changes --- .../azure/search/documents/_service/_utils.py | 2 + ...delete_datasource_string_if_unchanged.yaml | 112 ++++++++++++++++++ .../tests/test_service_live.py | 17 +++ 3 files changed, 131 insertions(+) create mode 100644 sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_datasource_string_if_unchanged.yaml diff --git a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py index 179cd75accc6..6ad76de52769 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_service/_utils.py @@ -168,6 +168,8 @@ def get_access_conditions(model, match_condition=MatchConditions.Unconditionally } if isinstance(model, six.string_types): + if match_condition is not MatchConditions.Unconditionally: + raise ValueError("A model must be passed to use access conditions") return (error_map, None) try: diff --git a/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_datasource_string_if_unchanged.yaml b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_datasource_string_if_unchanged.yaml new file mode 100644 index 000000000000..a19a6b9709f4 --- /dev/null +++ b/sdk/search/azure-search-documents/tests/recordings/test_service_live.test_delete_datasource_string_if_unchanged.yaml @@ -0,0 +1,112 @@ +interactions: +- request: + body: '{"name": "sample-datasource", "type": "azureblob", "credentials": {"connectionString": + "DefaultEndpointsProtocol=https;AccountName=storagename;AccountKey=NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg==;EndpointSuffix=core.windows.net"}, + "container": {"name": "searchcontainer"}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '319' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 371E8B1C08DCB8B5AEF87D7E375D42AE + method: POST + uri: https://searchf0dc189a.search.windows.net/datasources?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searchf0dc189a.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EE1DB1EEB45B\"","name":"sample-datasource","description":null,"type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + headers: + cache-control: + - no-cache + content-length: + - '370' + content-type: + - application/json; odata.metadata=minimal + date: + - Fri, 01 May 2020 22:19:19 GMT + elapsed-time: + - '38' + etag: + - W/"0x8D7EE1DB1EEB45B" + expires: + - '-1' + location: + - https://searchf0dc189a.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - ce408dc8-8bf9-11ea-9a33-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 201 + message: Created +- request: + body: '{"name": "sample-datasource", "description": "updated", "type": "azureblob", + "credentials": {"connectionString": "DefaultEndpointsProtocol=https;AccountName=storagename;AccountKey=NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg==;EndpointSuffix=core.windows.net"}, + "container": {"name": "searchcontainer"}}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '345' + Content-Type: + - application/json + Prefer: + - return=representation + User-Agent: + - azsdk-python-search-documents/1.0.0b3 Python/3.7.3 (Windows-10-10.0.17763-SP0) + api-key: + - 371E8B1C08DCB8B5AEF87D7E375D42AE + method: PUT + uri: https://searchf0dc189a.search.windows.net/datasources('sample-datasource')?api-version=2019-05-06-Preview + response: + body: + string: '{"@odata.context":"https://searchf0dc189a.search.windows.net/$metadata#datasources/$entity","@odata.etag":"\"0x8D7EE1DB20218D0\"","name":"sample-datasource","description":"updated","type":"azureblob","subtype":null,"credentials":{"connectionString":null},"container":{"name":"searchcontainer","query":null},"dataChangeDetectionPolicy":null,"dataDeletionDetectionPolicy":null}' + headers: + cache-control: + - no-cache + content-length: + - '375' + content-type: + - application/json; odata.metadata=minimal + date: + - Fri, 01 May 2020 22:19:20 GMT + elapsed-time: + - '36' + etag: + - W/"0x8D7EE1DB20218D0" + expires: + - '-1' + odata-version: + - '4.0' + pragma: + - no-cache + preference-applied: + - odata.include-annotations="*" + request-id: + - ce883c4c-8bf9-11ea-b342-2816a845e8c6 + strict-transport-security: + - max-age=15724800; includeSubDomains + vary: + - Accept-Encoding + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/search/azure-search-documents/tests/test_service_live.py b/sdk/search/azure-search-documents/tests/test_service_live.py index 7c0412d2985b..b565826757d4 100644 --- a/sdk/search/azure-search-documents/tests/test_service_live.py +++ b/sdk/search/azure-search-documents/tests/test_service_live.py @@ -610,3 +610,20 @@ def test_delete_datasource_if_unchanged(self, api_key, endpoint, index_name, **k with pytest.raises(HttpResponseError): client.delete_datasource(data_source, match_condition=MatchConditions.IfNotModified) assert len(client.get_datasources()) == 1 + + @SearchResourceGroupPreparer(random_name_enabled=True) + @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) + def test_delete_datasource_string_if_unchanged(self, api_key, endpoint, index_name, **kwargs): + client = SearchServiceClient(endpoint, AzureKeyCredential(api_key)).get_datasources_client() + data_source = self._create_datasource() + created = client.create_datasource(data_source) + etag = created.e_tag + + # Now update the data source + data_source.description = "updated" + client.create_or_update_datasource(data_source) + + # prepare data source + data_source.e_tag = etag # reset to the original datasource + with pytest.raises(ValueError): + client.delete_datasource(data_source.name, match_condition=MatchConditions.IfNotModified)