-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove DataSourceCredentials #11605
Merged
Merged
remove DataSourceCredentials #11605
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,12 @@ | |
|
||
from ._generated import SearchServiceClient as _SearchServiceClient | ||
from ._generated.models import SearchIndexerSkillset | ||
from ._utils import get_access_conditions, normalize_endpoint | ||
from ._utils import ( | ||
get_access_conditions, | ||
normalize_endpoint, | ||
pack_search_indexer_data_source, | ||
unpack_search_indexer_data_source, | ||
) | ||
from ..._headers_mixin import HeadersMixin | ||
from ..._version import SDK_MONIKER | ||
|
||
|
@@ -251,13 +256,13 @@ def get_indexer_status(self, name, **kwargs): | |
|
||
@distributed_trace | ||
def create_datasource(self, data_source, **kwargs): | ||
# type: (SearchIndexerDataSource, **Any) -> Dict[str, Any] | ||
# type: (SearchIndexerDataSourceConnection, **Any) -> SearchIndexerDataSourceConnection | ||
"""Creates a new datasource. | ||
|
||
:param data_source: The definition of the datasource to create. | ||
:type data_source: ~search.models.SearchIndexerDataSource | ||
:return: The created SearchIndexerDataSource | ||
:rtype: dict | ||
:type data_source: ~search.models.SearchIndexerDataSourceConnection | ||
:return: The created SearchIndexerDataSourceConnection | ||
:rtype: ~search.models.SearchIndexerDataSourceConnection | ||
|
||
.. admonition:: Example: | ||
|
||
|
@@ -269,21 +274,22 @@ def create_datasource(self, data_source, **kwargs): | |
:caption: Create a Data Source | ||
""" | ||
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) | ||
result = self._client.data_sources.create(data_source, **kwargs) | ||
return result | ||
packed_data_source = pack_search_indexer_data_source(data_source) | ||
result = self._client.data_sources.create(packed_data_source, **kwargs) | ||
return unpack_search_indexer_data_source(result) | ||
|
||
@distributed_trace | ||
def create_or_update_datasource(self, data_source, name=None, **kwargs): | ||
# type: (SearchIndexerDataSource, Optional[str], **Any) -> Dict[str, Any] | ||
# type: (SearchIndexerDataSourceConnection, Optional[str], **Any) -> SearchIndexerDataSourceConnection | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should do this in a different PR prolly - but we must allow individual keywords only to update the datasource - which if present would override the datasource. (See skillsets for example) |
||
"""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.SearchIndexerDataSource | ||
:type data_source: ~search.models.SearchIndexerDataSourceConnection | ||
:keyword match_condition: The match condition to use upon the etag | ||
:type match_condition: ~azure.core.MatchConditions | ||
:return: The created SearchIndexerDataSource | ||
:rtype: dict | ||
:return: The created SearchIndexerDataSourceConnection | ||
:rtype: ~search.models.SearchIndexerDataSourceConnection | ||
""" | ||
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) | ||
error_map, access_condition = get_access_conditions( | ||
|
@@ -292,23 +298,24 @@ def create_or_update_datasource(self, data_source, name=None, **kwargs): | |
kwargs.update(access_condition) | ||
if not name: | ||
name = data_source.name | ||
packed_data_source = pack_search_indexer_data_source(data_source) | ||
result = self._client.data_sources.create_or_update( | ||
data_source_name=name, | ||
data_source=data_source, | ||
data_source=packed_data_source, | ||
error_map=error_map, | ||
**kwargs | ||
) | ||
return result | ||
return unpack_search_indexer_data_source(result) | ||
|
||
@distributed_trace | ||
def get_datasource(self, name, **kwargs): | ||
# type: (str, **Any) -> Dict[str, Any] | ||
# type: (str, **Any) -> SearchIndexerDataSourceConnection | ||
"""Retrieves a datasource definition. | ||
|
||
:param name: The name of the datasource to retrieve. | ||
:type name: str | ||
:return: The SearchIndexerDataSource that is fetched. | ||
:rtype: dict | ||
:return: The SearchIndexerDataSourceConnection that is fetched. | ||
:rtype: ~search.models.SearchIndexerDataSourceConnection | ||
|
||
.. admonition:: Example: | ||
|
||
|
@@ -317,19 +324,19 @@ def get_datasource(self, name, **kwargs): | |
:end-before: [END get_data_source] | ||
:language: python | ||
:dedent: 4 | ||
:caption: Retrieve a SearchIndexerDataSource | ||
:caption: Retrieve a SearchIndexerDataSourceConnection | ||
""" | ||
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) | ||
result = self._client.data_sources.get(name, **kwargs) | ||
return result | ||
return unpack_search_indexer_data_source(result) | ||
|
||
@distributed_trace | ||
def get_datasources(self, **kwargs): | ||
# type: (**Any) -> Sequence[SearchIndexerDataSource] | ||
# type: (**Any) -> Sequence[SearchIndexerDataSourceConnection] | ||
"""Lists all datasources available for a search service. | ||
|
||
:return: List of all the data sources. | ||
:rtype: `list[dict]` | ||
:rtype: `list[~search.models.SearchIndexerDataSourceConnection]` | ||
|
||
.. admonition:: Example: | ||
|
||
|
@@ -338,21 +345,21 @@ def get_datasources(self, **kwargs): | |
:end-before: [END list_data_source] | ||
:language: python | ||
:dedent: 4 | ||
:caption: List all the SearchIndexerDataSources | ||
:caption: List all the SearchIndexerDataSourceConnections | ||
""" | ||
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) | ||
result = self._client.data_sources.list(**kwargs) | ||
return result.data_sources | ||
return [unpack_search_indexer_data_source(x) for x in result.data_sources] | ||
|
||
@distributed_trace | ||
def delete_datasource(self, data_source, **kwargs): | ||
# type: (Union[str, SearchIndexerDataSource], **Any) -> None | ||
# type: (Union[str, SearchIndexerDataSourceConnection], **Any) -> None | ||
"""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.SearchIndexerDataSource | ||
:type data_source: str or ~search.models.SearchIndexerDataSourceConnection | ||
:keyword match_condition: The match condition to use upon the etag | ||
:type match_condition: ~azure.core.MatchConditions | ||
:return: None | ||
|
@@ -365,7 +372,7 @@ def delete_datasource(self, data_source, **kwargs): | |
:end-before: [END delete_data_source] | ||
:language: python | ||
:dedent: 4 | ||
:caption: Delete a SearchIndexerDataSource | ||
:caption: Delete a SearchIndexerDataSourceConnection | ||
""" | ||
kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) | ||
error_map, access_condition = get_access_conditions( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be "flattenned" too like the connection string? perhaps just take in a container name + kwargs and create the DataContainer ourselves? Just a possible suggestion - no strong opinion