diff --git a/azure-devops/azure/devops/v5_0/client_factory.py b/azure-devops/azure/devops/v5_0/client_factory.py index 7ad503b1..d723cd07 100644 --- a/azure-devops/azure/devops/v5_0/client_factory.py +++ b/azure-devops/azure/devops/v5_0/client_factory.py @@ -246,6 +246,13 @@ def get_release_client(self): """ return self._connection.get_client('azure.devops.v5_0.release.release_client.ReleaseClient') + def get_search_client(self): + """get_search_client. + Gets the 5.0 version of the SearchClient + :rtype: :class:` ` + """ + return self._connection.get_client('azure.devops.v5_0.search.search_client.SearchClient') + def get_security_client(self): """get_security_client. Gets the 5.0 version of the SecurityClient diff --git a/azure-devops/azure/devops/v5_0/search/__init__.py b/azure-devops/azure/devops/v5_0/search/__init__.py new file mode 100644 index 00000000..247755cc --- /dev/null +++ b/azure-devops/azure/devops/v5_0/search/__init__.py @@ -0,0 +1,36 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# Generated file, DO NOT EDIT +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------------------------- + +from .models import * +from .search_client import SearchClient + +__all__ = [ + 'CodeResult', + 'CodeSearchRequest', + 'CodeSearchResponse', + 'Collection', + 'EntitySearchRequest', + 'EntitySearchRequestBase', + 'EntitySearchResponse', + 'Filter', + 'Hit', + 'Project', + 'ProjectReference', + 'Repository', + 'SortOption', + 'Wiki', + 'WikiHit', + 'WikiResult', + 'WikiSearchRequest', + 'WikiSearchResponse', + 'WorkItemHit', + 'WorkItemResult', + 'WorkItemSearchRequest', + 'WorkItemSearchResponse', + 'SearchClient' +] diff --git a/azure-devops/azure/devops/v5_0/search/models.py b/azure-devops/azure/devops/v5_0/search/models.py new file mode 100644 index 00000000..21160e97 --- /dev/null +++ b/azure-devops/azure/devops/v5_0/search/models.py @@ -0,0 +1,605 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# Generated file, DO NOT EDIT +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class CodeResult(Model): + """CodeResult. + + :param collection: Collection of the result file. + :type collection: :class:`Collection ` + :param content_id: ContentId of the result file. + :type content_id: str + :param file_name: Name of the result file. + :type file_name: str + :param matches: Dictionary of field to hit offsets in the result file. Key identifies the area in which hits were found, for ex: file content/file name etc. + :type matches: dict + :param path: Path at which result file is present. + :type path: str + :param project: Project of the result file. + :type project: :class:`Project ` + :param repository: Repository of the result file. + :type repository: :class:`Repository ` + :param versions: Versions of the result file. + :type versions: list of :class:`str ` + """ + + _attribute_map = { + 'collection': {'key': 'collection', 'type': 'Collection'}, + 'content_id': {'key': 'contentId', 'type': 'str'}, + 'file_name': {'key': 'fileName', 'type': 'str'}, + 'matches': {'key': 'matches', 'type': '{[Hit]}'}, + 'path': {'key': 'path', 'type': 'str'}, + 'project': {'key': 'project', 'type': 'Project'}, + 'repository': {'key': 'repository', 'type': 'Repository'}, + 'versions': {'key': 'versions', 'type': '[str]'} + } + + def __init__(self, collection=None, content_id=None, file_name=None, matches=None, path=None, project=None, repository=None, versions=None): + super(CodeResult, self).__init__() + self.collection = collection + self.content_id = content_id + self.file_name = file_name + self.matches = matches + self.path = path + self.project = project + self.repository = repository + self.versions = versions + + +class Collection(Model): + """Collection. + + :param name: Name of the collection. + :type name: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'} + } + + def __init__(self, name=None): + super(Collection, self).__init__() + self.name = name + + +class EntitySearchRequestBase(Model): + """EntitySearchRequestBase. + + :param filters: Filters to be applied. Set it to null if there are no filters to be applied. + :type filters: dict + :param search_text: The search text. + :type search_text: str + """ + + _attribute_map = { + 'filters': {'key': 'filters', 'type': '{[str]}'}, + 'search_text': {'key': 'searchText', 'type': 'str'} + } + + def __init__(self, filters=None, search_text=None): + super(EntitySearchRequestBase, self).__init__() + self.filters = filters + self.search_text = search_text + + +class EntitySearchResponse(Model): + """EntitySearchResponse. + + :param facets: A dictionary storing an array of Filter object against each facet. + :type facets: dict + :param info_code: Numeric code indicating any additional information: 0 - Ok, 1 - Account is being reindexed, 2 - Account indexing has not started, 3 - Invalid Request, 4 - Prefix wildcard query not supported, 5 - MultiWords with code facet not supported, 6 - Account is being onboarded, 7 - Account is being onboarded or reindexed, 8 - Top value trimmed to maxresult allowed 9 - Branches are being indexed, 10 - Faceting not enabled, 11 - Work items not accessible, 19 - Phrase queries with code type filters not supported, 20 - Wildcard queries with code type filters not supported. Any other info code is used for internal purpose. + :type info_code: int + """ + + _attribute_map = { + 'facets': {'key': 'facets', 'type': '{[Filter]}'}, + 'info_code': {'key': 'infoCode', 'type': 'int'} + } + + def __init__(self, facets=None, info_code=None): + super(EntitySearchResponse, self).__init__() + self.facets = facets + self.info_code = info_code + + +class Filter(Model): + """Filter. + + :param id: Id of the filter bucket. + :type id: str + :param name: Name of the filter bucket. + :type name: str + :param result_count: Count of matches in the filter bucket. + :type result_count: int + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'result_count': {'key': 'resultCount', 'type': 'int'} + } + + def __init__(self, id=None, name=None, result_count=None): + super(Filter, self).__init__() + self.id = id + self.name = name + self.result_count = result_count + + +class Hit(Model): + """Hit. + + :param char_offset: Gets or sets the start character offset of a piece of text. + :type char_offset: int + :param length: Gets or sets the length of a piece of text. + :type length: int + """ + + _attribute_map = { + 'char_offset': {'key': 'charOffset', 'type': 'int'}, + 'length': {'key': 'length', 'type': 'int'} + } + + def __init__(self, char_offset=None, length=None): + super(Hit, self).__init__() + self.char_offset = char_offset + self.length = length + + +class Project(Model): + """Project. + + :param id: Id of the project. + :type id: str + :param name: Name of the project. + :type name: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'} + } + + def __init__(self, id=None, name=None): + super(Project, self).__init__() + self.id = id + self.name = name + + +class ProjectReference(Model): + """ProjectReference. + + :param id: ID of the project. + :type id: str + :param name: Name of the project. + :type name: str + :param visibility: Visibility of the project. + :type visibility: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'visibility': {'key': 'visibility', 'type': 'str'} + } + + def __init__(self, id=None, name=None, visibility=None): + super(ProjectReference, self).__init__() + self.id = id + self.name = name + self.visibility = visibility + + +class Repository(Model): + """Repository. + + :param id: Id of the repository. + :type id: str + :param name: Name of the repository. + :type name: str + :param type: Version control type of the result file. + :type type: object + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'object'} + } + + def __init__(self, id=None, name=None, type=None): + super(Repository, self).__init__() + self.id = id + self.name = name + self.type = type + + +class SortOption(Model): + """SortOption. + + :param field: Field name on which sorting should be done. + :type field: str + :param sort_order: Order (ASC/DESC) in which the results should be sorted. + :type sort_order: str + """ + + _attribute_map = { + 'field': {'key': 'field', 'type': 'str'}, + 'sort_order': {'key': 'sortOrder', 'type': 'str'} + } + + def __init__(self, field=None, sort_order=None): + super(SortOption, self).__init__() + self.field = field + self.sort_order = sort_order + + +class Wiki(Model): + """Wiki. + + :param id: Id of the wiki. + :type id: str + :param mapped_path: Mapped path for the wiki. + :type mapped_path: str + :param name: Name of the wiki. + :type name: str + :param version: Version for wiki. + :type version: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'mapped_path': {'key': 'mappedPath', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'} + } + + def __init__(self, id=None, mapped_path=None, name=None, version=None): + super(Wiki, self).__init__() + self.id = id + self.mapped_path = mapped_path + self.name = name + self.version = version + + +class WikiHit(Model): + """WikiHit. + + :param field_reference_name: Reference name of the highlighted field. + :type field_reference_name: str + :param highlights: Matched/highlighted snippets of the field. + :type highlights: list of str + """ + + _attribute_map = { + 'field_reference_name': {'key': 'fieldReferenceName', 'type': 'str'}, + 'highlights': {'key': 'highlights', 'type': '[str]'} + } + + def __init__(self, field_reference_name=None, highlights=None): + super(WikiHit, self).__init__() + self.field_reference_name = field_reference_name + self.highlights = highlights + + +class WikiResult(Model): + """WikiResult. + + :param collection: Collection of the result file. + :type collection: :class:`Collection ` + :param content_id: ContentId of the result file. + :type content_id: str + :param file_name: Name of the result file. + :type file_name: str + :param hits: Highlighted snippets of fields that match the search request. The list is sorted by relevance of the snippets. + :type hits: list of :class:`WikiHit ` + :param path: Path at which result file is present. + :type path: str + :param project: Project details of the wiki document. + :type project: :class:`ProjectReference ` + :param wiki: Wiki information for the result. + :type wiki: :class:`Wiki ` + """ + + _attribute_map = { + 'collection': {'key': 'collection', 'type': 'Collection'}, + 'content_id': {'key': 'contentId', 'type': 'str'}, + 'file_name': {'key': 'fileName', 'type': 'str'}, + 'hits': {'key': 'hits', 'type': '[WikiHit]'}, + 'path': {'key': 'path', 'type': 'str'}, + 'project': {'key': 'project', 'type': 'ProjectReference'}, + 'wiki': {'key': 'wiki', 'type': 'Wiki'} + } + + def __init__(self, collection=None, content_id=None, file_name=None, hits=None, path=None, project=None, wiki=None): + super(WikiResult, self).__init__() + self.collection = collection + self.content_id = content_id + self.file_name = file_name + self.hits = hits + self.path = path + self.project = project + self.wiki = wiki + + +class WikiSearchResponse(EntitySearchResponse): + """WikiSearchResponse. + + :param facets: A dictionary storing an array of Filter object against each facet. + :type facets: dict + :param info_code: Numeric code indicating any additional information: 0 - Ok, 1 - Account is being reindexed, 2 - Account indexing has not started, 3 - Invalid Request, 4 - Prefix wildcard query not supported, 5 - MultiWords with code facet not supported, 6 - Account is being onboarded, 7 - Account is being onboarded or reindexed, 8 - Top value trimmed to maxresult allowed 9 - Branches are being indexed, 10 - Faceting not enabled, 11 - Work items not accessible, 19 - Phrase queries with code type filters not supported, 20 - Wildcard queries with code type filters not supported. Any other info code is used for internal purpose. + :type info_code: int + :param count: Total number of matched wiki documents. + :type count: int + :param results: List of top matched wiki documents. + :type results: list of :class:`WikiResult ` + """ + + _attribute_map = { + 'facets': {'key': 'facets', 'type': '{[Filter]}'}, + 'info_code': {'key': 'infoCode', 'type': 'int'}, + 'count': {'key': 'count', 'type': 'int'}, + 'results': {'key': 'results', 'type': '[WikiResult]'} + } + + def __init__(self, facets=None, info_code=None, count=None, results=None): + super(WikiSearchResponse, self).__init__(facets=facets, info_code=info_code) + self.count = count + self.results = results + + +class WorkItemHit(Model): + """WorkItemHit. + + :param field_reference_name: Reference name of the highlighted field. + :type field_reference_name: str + :param highlights: Matched/highlighted snippets of the field. + :type highlights: list of str + """ + + _attribute_map = { + 'field_reference_name': {'key': 'fieldReferenceName', 'type': 'str'}, + 'highlights': {'key': 'highlights', 'type': '[str]'} + } + + def __init__(self, field_reference_name=None, highlights=None): + super(WorkItemHit, self).__init__() + self.field_reference_name = field_reference_name + self.highlights = highlights + + +class WorkItemResult(Model): + """WorkItemResult. + + :param fields: A standard set of work item fields and their values. + :type fields: dict + :param hits: Highlighted snippets of fields that match the search request. The list is sorted by relevance of the snippets. + :type hits: list of :class:`WorkItemHit ` + :param project: Project details of the work item. + :type project: :class:`Project ` + :param url: Reference to the work item. + :type url: str + """ + + _attribute_map = { + 'fields': {'key': 'fields', 'type': '{str}'}, + 'hits': {'key': 'hits', 'type': '[WorkItemHit]'}, + 'project': {'key': 'project', 'type': 'Project'}, + 'url': {'key': 'url', 'type': 'str'} + } + + def __init__(self, fields=None, hits=None, project=None, url=None): + super(WorkItemResult, self).__init__() + self.fields = fields + self.hits = hits + self.project = project + self.url = url + + +class WorkItemSearchResponse(EntitySearchResponse): + """WorkItemSearchResponse. + + :param facets: A dictionary storing an array of Filter object against each facet. + :type facets: dict + :param info_code: Numeric code indicating any additional information: 0 - Ok, 1 - Account is being reindexed, 2 - Account indexing has not started, 3 - Invalid Request, 4 - Prefix wildcard query not supported, 5 - MultiWords with code facet not supported, 6 - Account is being onboarded, 7 - Account is being onboarded or reindexed, 8 - Top value trimmed to maxresult allowed 9 - Branches are being indexed, 10 - Faceting not enabled, 11 - Work items not accessible, 19 - Phrase queries with code type filters not supported, 20 - Wildcard queries with code type filters not supported. Any other info code is used for internal purpose. + :type info_code: int + :param count: Total number of matched work items. + :type count: int + :param results: List of top matched work items. + :type results: list of :class:`WorkItemResult ` + """ + + _attribute_map = { + 'facets': {'key': 'facets', 'type': '{[Filter]}'}, + 'info_code': {'key': 'infoCode', 'type': 'int'}, + 'count': {'key': 'count', 'type': 'int'}, + 'results': {'key': 'results', 'type': '[WorkItemResult]'} + } + + def __init__(self, facets=None, info_code=None, count=None, results=None): + super(WorkItemSearchResponse, self).__init__(facets=facets, info_code=info_code) + self.count = count + self.results = results + + +class CodeSearchResponse(EntitySearchResponse): + """CodeSearchResponse. + + :param facets: A dictionary storing an array of Filter object against each facet. + :type facets: dict + :param info_code: Numeric code indicating any additional information: 0 - Ok, 1 - Account is being reindexed, 2 - Account indexing has not started, 3 - Invalid Request, 4 - Prefix wildcard query not supported, 5 - MultiWords with code facet not supported, 6 - Account is being onboarded, 7 - Account is being onboarded or reindexed, 8 - Top value trimmed to maxresult allowed 9 - Branches are being indexed, 10 - Faceting not enabled, 11 - Work items not accessible, 19 - Phrase queries with code type filters not supported, 20 - Wildcard queries with code type filters not supported. Any other info code is used for internal purpose. + :type info_code: int + :param count: Total number of matched files. + :type count: int + :param results: List of matched files. + :type results: list of :class:`CodeResult ` + """ + + _attribute_map = { + 'facets': {'key': 'facets', 'type': '{[Filter]}'}, + 'info_code': {'key': 'infoCode', 'type': 'int'}, + 'count': {'key': 'count', 'type': 'int'}, + 'results': {'key': 'results', 'type': '[CodeResult]'} + } + + def __init__(self, facets=None, info_code=None, count=None, results=None): + super(CodeSearchResponse, self).__init__(facets=facets, info_code=info_code) + self.count = count + self.results = results + + +class EntitySearchRequest(EntitySearchRequestBase): + """EntitySearchRequest. + + :param filters: Filters to be applied. Set it to null if there are no filters to be applied. + :type filters: dict + :param search_text: The search text. + :type search_text: str + :param order_by: Options for sorting search results. If set to null, the results will be returned sorted by relevance. If more than one sort option is provided, the results are sorted in the order specified in the OrderBy. + :type order_by: list of :class:`SortOption ` + :param skip: Number of results to be skipped. + :type skip: int + :param top: Number of results to be returned. + :type top: int + :param include_facets: Flag to opt for faceting in the result. Default behavior is false. + :type include_facets: bool + """ + + _attribute_map = { + 'filters': {'key': 'filters', 'type': '{[str]}'}, + 'search_text': {'key': 'searchText', 'type': 'str'}, + 'order_by': {'key': '$orderBy', 'type': '[SortOption]'}, + 'skip': {'key': '$skip', 'type': 'int'}, + 'top': {'key': '$top', 'type': 'int'}, + 'include_facets': {'key': 'includeFacets', 'type': 'bool'} + } + + def __init__(self, filters=None, search_text=None, order_by=None, skip=None, top=None, include_facets=None): + super(EntitySearchRequest, self).__init__(filters=filters, search_text=search_text) + self.order_by = order_by + self.skip = skip + self.top = top + self.include_facets = include_facets + + +class WikiSearchRequest(EntitySearchRequest): + """WikiSearchRequest. + + :param filters: Filters to be applied. Set it to null if there are no filters to be applied. + :type filters: dict + :param search_text: The search text. + :type search_text: str + :param order_by: Options for sorting search results. If set to null, the results will be returned sorted by relevance. If more than one sort option is provided, the results are sorted in the order specified in the OrderBy. + :type order_by: list of :class:`SortOption ` + :param skip: Number of results to be skipped. + :type skip: int + :param top: Number of results to be returned. + :type top: int + :param include_facets: Flag to opt for faceting in the result. Default behavior is false. + :type include_facets: bool + """ + + _attribute_map = { + 'filters': {'key': 'filters', 'type': '{[str]}'}, + 'search_text': {'key': 'searchText', 'type': 'str'}, + 'order_by': {'key': '$orderBy', 'type': '[SortOption]'}, + 'skip': {'key': '$skip', 'type': 'int'}, + 'top': {'key': '$top', 'type': 'int'}, + 'include_facets': {'key': 'includeFacets', 'type': 'bool'}, + } + + def __init__(self, filters=None, search_text=None, order_by=None, skip=None, top=None, include_facets=None): + super(WikiSearchRequest, self).__init__(filters=filters, search_text=search_text, order_by=order_by, skip=skip, top=top, include_facets=include_facets) + + +class WorkItemSearchRequest(EntitySearchRequest): + """WorkItemSearchRequest. + + :param filters: Filters to be applied. Set it to null if there are no filters to be applied. + :type filters: dict + :param search_text: The search text. + :type search_text: str + :param order_by: Options for sorting search results. If set to null, the results will be returned sorted by relevance. If more than one sort option is provided, the results are sorted in the order specified in the OrderBy. + :type order_by: list of :class:`SortOption ` + :param skip: Number of results to be skipped. + :type skip: int + :param top: Number of results to be returned. + :type top: int + :param include_facets: Flag to opt for faceting in the result. Default behavior is false. + :type include_facets: bool + """ + + _attribute_map = { + 'filters': {'key': 'filters', 'type': '{[str]}'}, + 'search_text': {'key': 'searchText', 'type': 'str'}, + 'order_by': {'key': '$orderBy', 'type': '[SortOption]'}, + 'skip': {'key': '$skip', 'type': 'int'}, + 'top': {'key': '$top', 'type': 'int'}, + 'include_facets': {'key': 'includeFacets', 'type': 'bool'}, + } + + def __init__(self, filters=None, search_text=None, order_by=None, skip=None, top=None, include_facets=None): + super(WorkItemSearchRequest, self).__init__(filters=filters, search_text=search_text, order_by=order_by, skip=skip, top=top, include_facets=include_facets) + + +class CodeSearchRequest(EntitySearchRequest): + """CodeSearchRequest. + + :param filters: Filters to be applied. Set it to null if there are no filters to be applied. + :type filters: dict + :param search_text: The search text. + :type search_text: str + :param order_by: Options for sorting search results. If set to null, the results will be returned sorted by relevance. If more than one sort option is provided, the results are sorted in the order specified in the OrderBy. + :type order_by: list of :class:`SortOption ` + :param skip: Number of results to be skipped. + :type skip: int + :param top: Number of results to be returned. + :type top: int + :param include_facets: Flag to opt for faceting in the result. Default behavior is false. + :type include_facets: bool + """ + + _attribute_map = { + 'filters': {'key': 'filters', 'type': '{[str]}'}, + 'search_text': {'key': 'searchText', 'type': 'str'}, + 'order_by': {'key': '$orderBy', 'type': '[SortOption]'}, + 'skip': {'key': '$skip', 'type': 'int'}, + 'top': {'key': '$top', 'type': 'int'}, + 'include_facets': {'key': 'includeFacets', 'type': 'bool'}, + } + + def __init__(self, filters=None, search_text=None, order_by=None, skip=None, top=None, include_facets=None): + super(CodeSearchRequest, self).__init__(filters=filters, search_text=search_text, order_by=order_by, skip=skip, top=top, include_facets=include_facets) + + +__all__ = [ + 'CodeResult', + 'Collection', + 'EntitySearchRequestBase', + 'EntitySearchResponse', + 'Filter', + 'Hit', + 'Project', + 'ProjectReference', + 'Repository', + 'SortOption', + 'Wiki', + 'WikiHit', + 'WikiResult', + 'WikiSearchResponse', + 'WorkItemHit', + 'WorkItemResult', + 'WorkItemSearchResponse', + 'CodeSearchResponse', + 'EntitySearchRequest', + 'WikiSearchRequest', + 'WorkItemSearchRequest', + 'CodeSearchRequest', +] diff --git a/azure-devops/azure/devops/v5_0/search/search_client.py b/azure-devops/azure/devops/v5_0/search/search_client.py new file mode 100644 index 00000000..05d1c997 --- /dev/null +++ b/azure-devops/azure/devops/v5_0/search/search_client.py @@ -0,0 +1,81 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# Generated file, DO NOT EDIT +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------------------------- + +from msrest import Serializer, Deserializer +from ...client import Client +from . import models + + +class SearchClient(Client): + """Search + :param str base_url: Service URL + :param Authentication creds: Authenticated credentials. + """ + + def __init__(self, base_url=None, creds=None): + super(SearchClient, self).__init__(base_url, creds) + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + resource_area_identifier = None + + def fetch_code_search_results(self, request, project=None): + """FetchCodeSearchResults. + [Preview API] Provides a set of results for the search text. + :param :class:` ` request: The Code Search Request. + :param str project: Project ID or project name + :rtype: :class:` ` + """ + route_values = {} + if project is not None: + route_values['project'] = self._serialize.url('project', project, 'str') + content = self._serialize.body(request, 'CodeSearchRequest') + response = self._send(http_method='POST', + location_id='e7f29993-5b82-4fca-9386-f5cfe683d524', + version='5.0-preview.1', + route_values=route_values, + content=content) + return self._deserialize('CodeSearchResponse', response) + + def fetch_wiki_search_results(self, request, project=None): + """FetchWikiSearchResults. + [Preview API] Provides a set of results for the search request. + :param :class:` ` request: The Wiki Search Request. + :param str project: Project ID or project name + :rtype: :class:` ` + """ + route_values = {} + if project is not None: + route_values['project'] = self._serialize.url('project', project, 'str') + content = self._serialize.body(request, 'WikiSearchRequest') + response = self._send(http_method='POST', + location_id='e90e7664-7049-4100-9a86-66b161d81080', + version='5.0-preview.1', + route_values=route_values, + content=content) + return self._deserialize('WikiSearchResponse', response) + + def fetch_work_item_search_results(self, request, project=None): + """FetchWorkItemSearchResults. + [Preview API] Provides a set of results for the search text. + :param :class:` ` request: The Work Item Search Request. + :param str project: Project ID or project name + :rtype: :class:` ` + """ + route_values = {} + if project is not None: + route_values['project'] = self._serialize.url('project', project, 'str') + content = self._serialize.body(request, 'WorkItemSearchRequest') + response = self._send(http_method='POST', + location_id='73b2c9e2-ff9e-4447-8cda-5f5b21ff7cae', + version='5.0-preview.1', + route_values=route_values, + content=content) + return self._deserialize('WorkItemSearchResponse', response) + diff --git a/azure-devops/azure/devops/v5_1/client_factory.py b/azure-devops/azure/devops/v5_1/client_factory.py index 5cdd6e80..05301a75 100644 --- a/azure-devops/azure/devops/v5_1/client_factory.py +++ b/azure-devops/azure/devops/v5_1/client_factory.py @@ -253,6 +253,13 @@ def get_release_client(self): """ return self._connection.get_client('azure.devops.v5_1.release.release_client.ReleaseClient') + def get_search_client(self): + """get_search_client. + Gets the 5.1 version of the SearchClient + :rtype: :class:` ` + """ + return self._connection.get_client('azure.devops.v5_1.search.search_client.SearchClient') + def get_security_client(self): """get_security_client. Gets the 5.1 version of the SecurityClient diff --git a/azure-devops/azure/devops/v5_1/search/__init__.py b/azure-devops/azure/devops/v5_1/search/__init__.py new file mode 100644 index 00000000..2d9cee7d --- /dev/null +++ b/azure-devops/azure/devops/v5_1/search/__init__.py @@ -0,0 +1,43 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# Generated file, DO NOT EDIT +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------------------------- + +from .models import * +from .search_client import SearchClient + +__all__ = [ + 'CodeResult', + 'CodeSearchRequest', + 'CodeSearchResponse', + 'Collection', + 'EntitySearchRequest', + 'EntitySearchRequestBase', + 'EntitySearchResponse', + 'FeedInfo', + 'Filter', + 'Hit', + 'PackageHit', + 'PackageResult', + 'PackageSearchRequest', + 'PackageSearchResponse', + 'PackageSearchResponseContent', + 'Project', + 'ProjectReference', + 'Repository', + 'ScrollSearchRequest', + 'SortOption', + 'Wiki', + 'WikiHit', + 'WikiResult', + 'WikiSearchRequest', + 'WikiSearchResponse', + 'WorkItemHit', + 'WorkItemResult', + 'WorkItemSearchRequest', + 'WorkItemSearchResponse', + 'SearchClient' +] diff --git a/azure-devops/azure/devops/v5_1/search/models.py b/azure-devops/azure/devops/v5_1/search/models.py new file mode 100644 index 00000000..11693939 --- /dev/null +++ b/azure-devops/azure/devops/v5_1/search/models.py @@ -0,0 +1,841 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# Generated file, DO NOT EDIT +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class CodeResult(Model): + """ + Defines the code result containing information of the searched files and its metadata. + + :param collection: Collection of the result file. + :type collection: :class:`Collection ` + :param content_id: ContentId of the result file. + :type content_id: str + :param file_name: Name of the result file. + :type file_name: str + :param matches: Dictionary of field to hit offsets in the result file. Key identifies the area in which hits were found, for ex: file content/file name etc. + :type matches: dict + :param path: Path at which result file is present. + :type path: str + :param project: Project of the result file. + :type project: :class:`Project ` + :param repository: Repository of the result file. + :type repository: :class:`Repository ` + :param versions: Versions of the result file. + :type versions: list of :class:`str ` + """ + + _attribute_map = { + 'collection': {'key': 'collection', 'type': 'Collection'}, + 'content_id': {'key': 'contentId', 'type': 'str'}, + 'file_name': {'key': 'fileName', 'type': 'str'}, + 'matches': {'key': 'matches', 'type': '{[Hit]}'}, + 'path': {'key': 'path', 'type': 'str'}, + 'project': {'key': 'project', 'type': 'Project'}, + 'repository': {'key': 'repository', 'type': 'Repository'}, + 'versions': {'key': 'versions', 'type': '[str]'} + } + + def __init__(self, collection=None, content_id=None, file_name=None, matches=None, path=None, project=None, repository=None, versions=None): + super(CodeResult, self).__init__() + self.collection = collection + self.content_id = content_id + self.file_name = file_name + self.matches = matches + self.path = path + self.project = project + self.repository = repository + self.versions = versions + + +class Collection(Model): + """ + Defines the details of the collection. + + :param name: Name of the collection. + :type name: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'} + } + + def __init__(self, name=None): + super(Collection, self).__init__() + self.name = name + + +class EntitySearchRequestBase(Model): + """ + Base class for search request types. + + :param filters: Filters to be applied. Set it to null if there are no filters to be applied. + :type filters: dict + :param search_text: The search text. + :type search_text: str + """ + + _attribute_map = { + 'filters': {'key': 'filters', 'type': '{[str]}'}, + 'search_text': {'key': 'searchText', 'type': 'str'} + } + + def __init__(self, filters=None, search_text=None): + super(EntitySearchRequestBase, self).__init__() + self.filters = filters + self.search_text = search_text + + +class EntitySearchResponse(Model): + """ + Defines the base contract for search response. + + :param facets: A dictionary storing an array of Filter object against each facet. + :type facets: dict + :param info_code: Numeric code indicating any additional information: 0 - Ok, 1 - Account is being reindexed, 2 - Account indexing has not started, 3 - Invalid Request, 4 - Prefix wildcard query not supported, 5 - MultiWords with code facet not supported, 6 - Account is being onboarded, 7 - Account is being onboarded or reindexed, 8 - Top value trimmed to maxresult allowed 9 - Branches are being indexed, 10 - Faceting not enabled, 11 - Work items not accessible, 19 - Phrase queries with code type filters not supported, 20 - Wildcard queries with code type filters not supported. Any other info code is used for internal purpose. + :type info_code: int + """ + + _attribute_map = { + 'facets': {'key': 'facets', 'type': '{[Filter]}'}, + 'info_code': {'key': 'infoCode', 'type': 'int'} + } + + def __init__(self, facets=None, info_code=None): + super(EntitySearchResponse, self).__init__() + self.facets = facets + self.info_code = info_code + + +class FeedInfo(Model): + """ + Defines the details of a feed. + + :param collection_id: Id of the collection. + :type collection_id: str + :param collection_name: Name of the collection. + :type collection_name: str + :param feed_id: Id of the feed. + :type feed_id: str + :param feed_name: Name of the feed. + :type feed_name: str + :param latest_matched_version: Latest matched version of package in this Feed. + :type latest_matched_version: str + :param latest_version: Latest version of package in this Feed. + :type latest_version: str + :param package_url: Url of package in this Feed. + :type package_url: str + :param views: List of views which contain the matched package. + :type views: list of str + """ + + _attribute_map = { + 'collection_id': {'key': 'collectionId', 'type': 'str'}, + 'collection_name': {'key': 'collectionName', 'type': 'str'}, + 'feed_id': {'key': 'feedId', 'type': 'str'}, + 'feed_name': {'key': 'feedName', 'type': 'str'}, + 'latest_matched_version': {'key': 'latestMatchedVersion', 'type': 'str'}, + 'latest_version': {'key': 'latestVersion', 'type': 'str'}, + 'package_url': {'key': 'packageUrl', 'type': 'str'}, + 'views': {'key': 'views', 'type': '[str]'} + } + + def __init__(self, collection_id=None, collection_name=None, feed_id=None, feed_name=None, latest_matched_version=None, latest_version=None, package_url=None, views=None): + super(FeedInfo, self).__init__() + self.collection_id = collection_id + self.collection_name = collection_name + self.feed_id = feed_id + self.feed_name = feed_name + self.latest_matched_version = latest_matched_version + self.latest_version = latest_version + self.package_url = package_url + self.views = views + + +class Filter(Model): + """ + Describes a filter bucket item representing the total matches of search result, name and id. + + :param id: Id of the filter bucket. + :type id: str + :param name: Name of the filter bucket. + :type name: str + :param result_count: Count of matches in the filter bucket. + :type result_count: int + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'result_count': {'key': 'resultCount', 'type': 'int'} + } + + def __init__(self, id=None, name=None, result_count=None): + super(Filter, self).__init__() + self.id = id + self.name = name + self.result_count = result_count + + +class Hit(Model): + """ + Describes the position of a piece of text in a document. + + :param char_offset: Gets or sets the start character offset of a piece of text. + :type char_offset: int + :param length: Gets or sets the length of a piece of text. + :type length: int + """ + + _attribute_map = { + 'char_offset': {'key': 'charOffset', 'type': 'int'}, + 'length': {'key': 'length', 'type': 'int'} + } + + def __init__(self, char_offset=None, length=None): + super(Hit, self).__init__() + self.char_offset = char_offset + self.length = length + + +class PackageHit(Model): + """ + Defines the matched terms in the field of the package result. + + :param field_reference_name: Reference name of the highlighted field. + :type field_reference_name: str + :param highlights: Matched/highlighted snippets of the field. + :type highlights: list of str + """ + + _attribute_map = { + 'field_reference_name': {'key': 'fieldReferenceName', 'type': 'str'}, + 'highlights': {'key': 'highlights', 'type': '[str]'} + } + + def __init__(self, field_reference_name=None, highlights=None): + super(PackageHit, self).__init__() + self.field_reference_name = field_reference_name + self.highlights = highlights + + +class PackageResult(Model): + """ + Defines the package result that matched a package search request. + + :param description: Description of the package. + :type description: str + :param feeds: List of feeds which contain the matching package. + :type feeds: list of :class:`FeedInfo ` + :param hits: List of highlighted fields for the match. + :type hits: list of :class:`PackageHit ` + :param id: Id of the package. + :type id: str + :param name: Name of the package. + :type name: str + :param protocol_type: Type of the package. + :type protocol_type: str + """ + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'feeds': {'key': 'feeds', 'type': '[FeedInfo]'}, + 'hits': {'key': 'hits', 'type': '[PackageHit]'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'protocol_type': {'key': 'protocolType', 'type': 'str'} + } + + def __init__(self, description=None, feeds=None, hits=None, id=None, name=None, protocol_type=None): + super(PackageResult, self).__init__() + self.description = description + self.feeds = feeds + self.hits = hits + self.id = id + self.name = name + self.protocol_type = protocol_type + + +class PackageSearchResponse(Model): + """ + :param activity_id: + :type activity_id: list of str + :param content: + :type content: :class:`PackageSearchResponseContent ` + """ + + _attribute_map = { + 'activity_id': {'key': 'activityId', 'type': '[str]'}, + 'content': {'key': 'content', 'type': 'PackageSearchResponseContent'} + } + + def __init__(self, activity_id=None, content=None): + super(PackageSearchResponse, self).__init__() + self.activity_id = activity_id + self.content = content + + +class PackageSearchResponseContent(EntitySearchResponse): + """ + Defines a response item that is returned for a package search request. + + :param facets: A dictionary storing an array of Filter object against each facet. + :type facets: dict + :param info_code: Numeric code indicating any additional information: 0 - Ok, 1 - Account is being reindexed, 2 - Account indexing has not started, 3 - Invalid Request, 4 - Prefix wildcard query not supported, 5 - MultiWords with code facet not supported, 6 - Account is being onboarded, 7 - Account is being onboarded or reindexed, 8 - Top value trimmed to maxresult allowed 9 - Branches are being indexed, 10 - Faceting not enabled, 11 - Work items not accessible, 19 - Phrase queries with code type filters not supported, 20 - Wildcard queries with code type filters not supported. Any other info code is used for internal purpose. + :type info_code: int + :param count: Total number of matched packages. + :type count: int + :param results: List of matched packages. + :type results: list of :class:`PackageResult ` + """ + + _attribute_map = { + 'facets': {'key': 'facets', 'type': '{[Filter]}'}, + 'info_code': {'key': 'infoCode', 'type': 'int'}, + 'count': {'key': 'count', 'type': 'int'}, + 'results': {'key': 'results', 'type': '[PackageResult]'} + } + + def __init__(self, facets=None, info_code=None, count=None, results=None): + super(PackageSearchResponseContent, self).__init__(facets=facets, info_code=info_code) + self.count = count + self.results = results + + +class Project(Model): + """ + Defines the details of the project. + + :param id: Id of the project. + :type id: str + :param name: Name of the project. + :type name: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'} + } + + def __init__(self, id=None, name=None): + super(Project, self).__init__() + self.id = id + self.name = name + + +class ProjectReference(Model): + """ + Defines the details of the project. + + :param id: ID of the project. + :type id: str + :param name: Name of the project. + :type name: str + :param visibility: Visibility of the project. + :type visibility: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'visibility': {'key': 'visibility', 'type': 'str'} + } + + def __init__(self, id=None, name=None, visibility=None): + super(ProjectReference, self).__init__() + self.id = id + self.name = name + self.visibility = visibility + + +class Repository(Model): + """ + Defines the details of the repository. + + :param id: Id of the repository. + :type id: str + :param name: Name of the repository. + :type name: str + :param type: Version control type of the result file. + :type type: object + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'object'} + } + + def __init__(self, id=None, name=None, type=None): + super(Repository, self).__init__() + self.id = id + self.name = name + self.type = type + + +class ScrollSearchRequest(EntitySearchRequestBase): + """ + Defines a scroll code search request. + + :param filters: Filters to be applied. Set it to null if there are no filters to be applied. + :type filters: dict + :param search_text: The search text. + :type search_text: str + :param scroll_id: Scroll Id for scroll search query. + :type scroll_id: str + :param scroll_size: Size of data to return for scroll search query. Min value is 201. + :type scroll_size: int + """ + + _attribute_map = { + 'filters': {'key': 'filters', 'type': '{[str]}'}, + 'search_text': {'key': 'searchText', 'type': 'str'}, + 'scroll_id': {'key': '$scrollId', 'type': 'str'}, + 'scroll_size': {'key': '$scrollSize', 'type': 'int'} + } + + def __init__(self, filters=None, search_text=None, scroll_id=None, scroll_size=None): + super(ScrollSearchRequest, self).__init__(filters=filters, search_text=search_text) + self.scroll_id = scroll_id + self.scroll_size = scroll_size + + +class SortOption(Model): + """ + Defines how to sort the result. + + :param field: Field name on which sorting should be done. + :type field: str + :param sort_order: Order (ASC/DESC) in which the results should be sorted. + :type sort_order: str + """ + + _attribute_map = { + 'field': {'key': 'field', 'type': 'str'}, + 'sort_order': {'key': 'sortOrder', 'type': 'str'} + } + + def __init__(self, field=None, sort_order=None): + super(SortOption, self).__init__() + self.field = field + self.sort_order = sort_order + + +class Wiki(Model): + """ + Defines the details of wiki. + + :param id: Id of the wiki. + :type id: str + :param mapped_path: Mapped path for the wiki. + :type mapped_path: str + :param name: Name of the wiki. + :type name: str + :param version: Version for wiki. + :type version: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'mapped_path': {'key': 'mappedPath', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'} + } + + def __init__(self, id=None, mapped_path=None, name=None, version=None): + super(Wiki, self).__init__() + self.id = id + self.mapped_path = mapped_path + self.name = name + self.version = version + + +class WikiHit(Model): + """ + Defines the matched terms in the field of the wiki result. + + :param field_reference_name: Reference name of the highlighted field. + :type field_reference_name: str + :param highlights: Matched/highlighted snippets of the field. + :type highlights: list of str + """ + + _attribute_map = { + 'field_reference_name': {'key': 'fieldReferenceName', 'type': 'str'}, + 'highlights': {'key': 'highlights', 'type': '[str]'} + } + + def __init__(self, field_reference_name=None, highlights=None): + super(WikiHit, self).__init__() + self.field_reference_name = field_reference_name + self.highlights = highlights + + +class WikiResult(Model): + """ + Defines the wiki result that matched a wiki search request. + + :param collection: Collection of the result file. + :type collection: :class:`Collection ` + :param content_id: ContentId of the result file. + :type content_id: str + :param file_name: Name of the result file. + :type file_name: str + :param hits: Highlighted snippets of fields that match the search request. The list is sorted by relevance of the snippets. + :type hits: list of :class:`WikiHit ` + :param path: Path at which result file is present. + :type path: str + :param project: Project details of the wiki document. + :type project: :class:`ProjectReference ` + :param wiki: Wiki information for the result. + :type wiki: :class:`Wiki ` + """ + + _attribute_map = { + 'collection': {'key': 'collection', 'type': 'Collection'}, + 'content_id': {'key': 'contentId', 'type': 'str'}, + 'file_name': {'key': 'fileName', 'type': 'str'}, + 'hits': {'key': 'hits', 'type': '[WikiHit]'}, + 'path': {'key': 'path', 'type': 'str'}, + 'project': {'key': 'project', 'type': 'ProjectReference'}, + 'wiki': {'key': 'wiki', 'type': 'Wiki'} + } + + def __init__(self, collection=None, content_id=None, file_name=None, hits=None, path=None, project=None, wiki=None): + super(WikiResult, self).__init__() + self.collection = collection + self.content_id = content_id + self.file_name = file_name + self.hits = hits + self.path = path + self.project = project + self.wiki = wiki + + +class WikiSearchResponse(EntitySearchResponse): + """ + Defines a wiki search response item. + + :param facets: A dictionary storing an array of Filter object against each facet. + :type facets: dict + :param info_code: Numeric code indicating any additional information: 0 - Ok, 1 - Account is being reindexed, 2 - Account indexing has not started, 3 - Invalid Request, 4 - Prefix wildcard query not supported, 5 - MultiWords with code facet not supported, 6 - Account is being onboarded, 7 - Account is being onboarded or reindexed, 8 - Top value trimmed to maxresult allowed 9 - Branches are being indexed, 10 - Faceting not enabled, 11 - Work items not accessible, 19 - Phrase queries with code type filters not supported, 20 - Wildcard queries with code type filters not supported. Any other info code is used for internal purpose. + :type info_code: int + :param count: Total number of matched wiki documents. + :type count: int + :param results: List of top matched wiki documents. + :type results: list of :class:`WikiResult ` + """ + + _attribute_map = { + 'facets': {'key': 'facets', 'type': '{[Filter]}'}, + 'info_code': {'key': 'infoCode', 'type': 'int'}, + 'count': {'key': 'count', 'type': 'int'}, + 'results': {'key': 'results', 'type': '[WikiResult]'} + } + + def __init__(self, facets=None, info_code=None, count=None, results=None): + super(WikiSearchResponse, self).__init__(facets=facets, info_code=info_code) + self.count = count + self.results = results + + +class WorkItemHit(Model): + """ + Defines the matched terms in the field of the work item result. + + :param field_reference_name: Reference name of the highlighted field. + :type field_reference_name: str + :param highlights: Matched/highlighted snippets of the field. + :type highlights: list of str + """ + + _attribute_map = { + 'field_reference_name': {'key': 'fieldReferenceName', 'type': 'str'}, + 'highlights': {'key': 'highlights', 'type': '[str]'} + } + + def __init__(self, field_reference_name=None, highlights=None): + super(WorkItemHit, self).__init__() + self.field_reference_name = field_reference_name + self.highlights = highlights + + +class WorkItemResult(Model): + """ + Defines the work item result that matched a work item search request. + + :param fields: A standard set of work item fields and their values. + :type fields: dict + :param hits: Highlighted snippets of fields that match the search request. The list is sorted by relevance of the snippets. + :type hits: list of :class:`WorkItemHit ` + :param project: Project details of the work item. + :type project: :class:`Project ` + :param url: Reference to the work item. + :type url: str + """ + + _attribute_map = { + 'fields': {'key': 'fields', 'type': '{str}'}, + 'hits': {'key': 'hits', 'type': '[WorkItemHit]'}, + 'project': {'key': 'project', 'type': 'Project'}, + 'url': {'key': 'url', 'type': 'str'} + } + + def __init__(self, fields=None, hits=None, project=None, url=None): + super(WorkItemResult, self).__init__() + self.fields = fields + self.hits = hits + self.project = project + self.url = url + + +class WorkItemSearchResponse(EntitySearchResponse): + """ + Defines a response item that is returned for a work item search request. + + :param facets: A dictionary storing an array of Filter object against each facet. + :type facets: dict + :param info_code: Numeric code indicating any additional information: 0 - Ok, 1 - Account is being reindexed, 2 - Account indexing has not started, 3 - Invalid Request, 4 - Prefix wildcard query not supported, 5 - MultiWords with code facet not supported, 6 - Account is being onboarded, 7 - Account is being onboarded or reindexed, 8 - Top value trimmed to maxresult allowed 9 - Branches are being indexed, 10 - Faceting not enabled, 11 - Work items not accessible, 19 - Phrase queries with code type filters not supported, 20 - Wildcard queries with code type filters not supported. Any other info code is used for internal purpose. + :type info_code: int + :param count: Total number of matched work items. + :type count: int + :param results: List of top matched work items. + :type results: list of :class:`WorkItemResult ` + """ + + _attribute_map = { + 'facets': {'key': 'facets', 'type': '{[Filter]}'}, + 'info_code': {'key': 'infoCode', 'type': 'int'}, + 'count': {'key': 'count', 'type': 'int'}, + 'results': {'key': 'results', 'type': '[WorkItemResult]'} + } + + def __init__(self, facets=None, info_code=None, count=None, results=None): + super(WorkItemSearchResponse, self).__init__(facets=facets, info_code=info_code) + self.count = count + self.results = results + + +class CodeSearchResponse(EntitySearchResponse): + """ + Defines a code search response item. + + :param facets: A dictionary storing an array of Filter object against each facet. + :type facets: dict + :param info_code: Numeric code indicating any additional information: 0 - Ok, 1 - Account is being reindexed, 2 - Account indexing has not started, 3 - Invalid Request, 4 - Prefix wildcard query not supported, 5 - MultiWords with code facet not supported, 6 - Account is being onboarded, 7 - Account is being onboarded or reindexed, 8 - Top value trimmed to maxresult allowed 9 - Branches are being indexed, 10 - Faceting not enabled, 11 - Work items not accessible, 19 - Phrase queries with code type filters not supported, 20 - Wildcard queries with code type filters not supported. Any other info code is used for internal purpose. + :type info_code: int + :param count: Total number of matched files. + :type count: int + :param results: List of matched files. + :type results: list of :class:`CodeResult ` + """ + + _attribute_map = { + 'facets': {'key': 'facets', 'type': '{[Filter]}'}, + 'info_code': {'key': 'infoCode', 'type': 'int'}, + 'count': {'key': 'count', 'type': 'int'}, + 'results': {'key': 'results', 'type': '[CodeResult]'} + } + + def __init__(self, facets=None, info_code=None, count=None, results=None): + super(CodeSearchResponse, self).__init__(facets=facets, info_code=info_code) + self.count = count + self.results = results + + +class EntitySearchRequest(EntitySearchRequestBase): + """ + Base contract for search request types without scroll support. + + :param filters: Filters to be applied. Set it to null if there are no filters to be applied. + :type filters: dict + :param search_text: The search text. + :type search_text: str + :param order_by: Options for sorting search results. If set to null, the results will be returned sorted by relevance. If more than one sort option is provided, the results are sorted in the order specified in the OrderBy. + :type order_by: list of :class:`SortOption ` + :param skip: Number of results to be skipped. + :type skip: int + :param top: Number of results to be returned. + :type top: int + :param include_facets: Flag to opt for faceting in the result. Default behavior is false. + :type include_facets: bool + """ + + _attribute_map = { + 'filters': {'key': 'filters', 'type': '{[str]}'}, + 'search_text': {'key': 'searchText', 'type': 'str'}, + 'order_by': {'key': '$orderBy', 'type': '[SortOption]'}, + 'skip': {'key': '$skip', 'type': 'int'}, + 'top': {'key': '$top', 'type': 'int'}, + 'include_facets': {'key': 'includeFacets', 'type': 'bool'} + } + + def __init__(self, filters=None, search_text=None, order_by=None, skip=None, top=None, include_facets=None): + super(EntitySearchRequest, self).__init__(filters=filters, search_text=search_text) + self.order_by = order_by + self.skip = skip + self.top = top + self.include_facets = include_facets + + +class PackageSearchRequest(EntitySearchRequest): + """ + Defines a package search request. + + :param filters: Filters to be applied. Set it to null if there are no filters to be applied. + :type filters: dict + :param search_text: The search text. + :type search_text: str + :param order_by: Options for sorting search results. If set to null, the results will be returned sorted by relevance. If more than one sort option is provided, the results are sorted in the order specified in the OrderBy. + :type order_by: list of :class:`SortOption ` + :param skip: Number of results to be skipped. + :type skip: int + :param top: Number of results to be returned. + :type top: int + :param include_facets: Flag to opt for faceting in the result. Default behavior is false. + :type include_facets: bool + """ + + _attribute_map = { + 'filters': {'key': 'filters', 'type': '{[str]}'}, + 'search_text': {'key': 'searchText', 'type': 'str'}, + 'order_by': {'key': '$orderBy', 'type': '[SortOption]'}, + 'skip': {'key': '$skip', 'type': 'int'}, + 'top': {'key': '$top', 'type': 'int'}, + 'include_facets': {'key': 'includeFacets', 'type': 'bool'}, + } + + def __init__(self, filters=None, search_text=None, order_by=None, skip=None, top=None, include_facets=None): + super(PackageSearchRequest, self).__init__(filters=filters, search_text=search_text, order_by=order_by, skip=skip, top=top, include_facets=include_facets) + + +class WikiSearchRequest(EntitySearchRequest): + """ + Defines a wiki search request. + + :param filters: Filters to be applied. Set it to null if there are no filters to be applied. + :type filters: dict + :param search_text: The search text. + :type search_text: str + :param order_by: Options for sorting search results. If set to null, the results will be returned sorted by relevance. If more than one sort option is provided, the results are sorted in the order specified in the OrderBy. + :type order_by: list of :class:`SortOption ` + :param skip: Number of results to be skipped. + :type skip: int + :param top: Number of results to be returned. + :type top: int + :param include_facets: Flag to opt for faceting in the result. Default behavior is false. + :type include_facets: bool + """ + + _attribute_map = { + 'filters': {'key': 'filters', 'type': '{[str]}'}, + 'search_text': {'key': 'searchText', 'type': 'str'}, + 'order_by': {'key': '$orderBy', 'type': '[SortOption]'}, + 'skip': {'key': '$skip', 'type': 'int'}, + 'top': {'key': '$top', 'type': 'int'}, + 'include_facets': {'key': 'includeFacets', 'type': 'bool'}, + } + + def __init__(self, filters=None, search_text=None, order_by=None, skip=None, top=None, include_facets=None): + super(WikiSearchRequest, self).__init__(filters=filters, search_text=search_text, order_by=order_by, skip=skip, top=top, include_facets=include_facets) + + +class WorkItemSearchRequest(EntitySearchRequest): + """ + Defines a work item search request. + + :param filters: Filters to be applied. Set it to null if there are no filters to be applied. + :type filters: dict + :param search_text: The search text. + :type search_text: str + :param order_by: Options for sorting search results. If set to null, the results will be returned sorted by relevance. If more than one sort option is provided, the results are sorted in the order specified in the OrderBy. + :type order_by: list of :class:`SortOption ` + :param skip: Number of results to be skipped. + :type skip: int + :param top: Number of results to be returned. + :type top: int + :param include_facets: Flag to opt for faceting in the result. Default behavior is false. + :type include_facets: bool + """ + + _attribute_map = { + 'filters': {'key': 'filters', 'type': '{[str]}'}, + 'search_text': {'key': 'searchText', 'type': 'str'}, + 'order_by': {'key': '$orderBy', 'type': '[SortOption]'}, + 'skip': {'key': '$skip', 'type': 'int'}, + 'top': {'key': '$top', 'type': 'int'}, + 'include_facets': {'key': 'includeFacets', 'type': 'bool'}, + } + + def __init__(self, filters=None, search_text=None, order_by=None, skip=None, top=None, include_facets=None): + super(WorkItemSearchRequest, self).__init__(filters=filters, search_text=search_text, order_by=order_by, skip=skip, top=top, include_facets=include_facets) + + +class CodeSearchRequest(EntitySearchRequest): + """ + Defines a code search request. + + :param filters: Filters to be applied. Set it to null if there are no filters to be applied. + :type filters: dict + :param search_text: The search text. + :type search_text: str + :param order_by: Options for sorting search results. If set to null, the results will be returned sorted by relevance. If more than one sort option is provided, the results are sorted in the order specified in the OrderBy. + :type order_by: list of :class:`SortOption ` + :param skip: Number of results to be skipped. + :type skip: int + :param top: Number of results to be returned. + :type top: int + :param include_facets: Flag to opt for faceting in the result. Default behavior is false. + :type include_facets: bool + """ + + _attribute_map = { + 'filters': {'key': 'filters', 'type': '{[str]}'}, + 'search_text': {'key': 'searchText', 'type': 'str'}, + 'order_by': {'key': '$orderBy', 'type': '[SortOption]'}, + 'skip': {'key': '$skip', 'type': 'int'}, + 'top': {'key': '$top', 'type': 'int'}, + 'include_facets': {'key': 'includeFacets', 'type': 'bool'}, + } + + def __init__(self, filters=None, search_text=None, order_by=None, skip=None, top=None, include_facets=None): + super(CodeSearchRequest, self).__init__(filters=filters, search_text=search_text, order_by=order_by, skip=skip, top=top, include_facets=include_facets) + + +__all__ = [ + 'CodeResult', + 'Collection', + 'EntitySearchRequestBase', + 'EntitySearchResponse', + 'FeedInfo', + 'Filter', + 'Hit', + 'PackageHit', + 'PackageResult', + 'PackageSearchResponse', + 'PackageSearchResponseContent', + 'Project', + 'ProjectReference', + 'Repository', + 'ScrollSearchRequest', + 'SortOption', + 'Wiki', + 'WikiHit', + 'WikiResult', + 'WikiSearchResponse', + 'WorkItemHit', + 'WorkItemResult', + 'WorkItemSearchResponse', + 'CodeSearchResponse', + 'EntitySearchRequest', + 'PackageSearchRequest', + 'WikiSearchRequest', + 'WorkItemSearchRequest', + 'CodeSearchRequest', +] diff --git a/azure-devops/azure/devops/v5_1/search/search_client.py b/azure-devops/azure/devops/v5_1/search/search_client.py new file mode 100644 index 00000000..4200b3fc --- /dev/null +++ b/azure-devops/azure/devops/v5_1/search/search_client.py @@ -0,0 +1,115 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# Generated file, DO NOT EDIT +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------------------------- + +from msrest import Serializer, Deserializer +from ...client import Client +from . import models + + +class SearchClient(Client): + """Search + :param str base_url: Service URL + :param Authentication creds: Authenticated credentials. + """ + + def __init__(self, base_url=None, creds=None): + super(SearchClient, self).__init__(base_url, creds) + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + resource_area_identifier = None + + def fetch_scroll_code_search_results(self, request, project=None): + """FetchScrollCodeSearchResults. + [Preview API] Provides a set of results for the search text. + :param :class:` ` request: The Code Search Request. + :param str project: Project ID or project name + :rtype: :class:` ` + """ + route_values = {} + if project is not None: + route_values['project'] = self._serialize.url('project', project, 'str') + content = self._serialize.body(request, 'ScrollSearchRequest') + response = self._send(http_method='POST', + location_id='852dac94-e8f7-45a2-9910-927ae35766a2', + version='5.1-preview.1', + route_values=route_values, + content=content) + return self._deserialize('CodeSearchResponse', response) + + def fetch_code_search_results(self, request, project=None): + """FetchCodeSearchResults. + [Preview API] Provides a set of results for the search text. + :param :class:` ` request: The Code Search Request. + :param str project: Project ID or project name + :rtype: :class:` ` + """ + route_values = {} + if project is not None: + route_values['project'] = self._serialize.url('project', project, 'str') + content = self._serialize.body(request, 'CodeSearchRequest') + response = self._send(http_method='POST', + location_id='e7f29993-5b82-4fca-9386-f5cfe683d524', + version='5.1-preview.1', + route_values=route_values, + content=content) + return self._deserialize('CodeSearchResponse', response) + + def fetch_package_search_results(self, request): + """FetchPackageSearchResults. + [Preview API] Provides a set of results for the search text. + :param :class:` ` request: The Package Search Request. + :rtype: :class:` ` + """ + content = self._serialize.body(request, 'PackageSearchRequest') + response = self._send(http_method='POST', + location_id='f62ada48-eedc-4c8e-93f0-de870e4ecce0', + version='5.1-preview.1', + content=content) + response_object = models.PackageSearchResponse() + response_object.content = self._deserialize('PackageSearchResponseContent', response) + response_object.activity_id = response.headers.get('ActivityId') + return response_object + + def fetch_wiki_search_results(self, request, project=None): + """FetchWikiSearchResults. + [Preview API] Provides a set of results for the search request. + :param :class:` ` request: The Wiki Search Request. + :param str project: Project ID or project name + :rtype: :class:` ` + """ + route_values = {} + if project is not None: + route_values['project'] = self._serialize.url('project', project, 'str') + content = self._serialize.body(request, 'WikiSearchRequest') + response = self._send(http_method='POST', + location_id='e90e7664-7049-4100-9a86-66b161d81080', + version='5.1-preview.1', + route_values=route_values, + content=content) + return self._deserialize('WikiSearchResponse', response) + + def fetch_work_item_search_results(self, request, project=None): + """FetchWorkItemSearchResults. + [Preview API] Provides a set of results for the search text. + :param :class:` ` request: The Work Item Search Request. + :param str project: Project ID or project name + :rtype: :class:` ` + """ + route_values = {} + if project is not None: + route_values['project'] = self._serialize.url('project', project, 'str') + content = self._serialize.body(request, 'WorkItemSearchRequest') + response = self._send(http_method='POST', + location_id='73b2c9e2-ff9e-4447-8cda-5f5b21ff7cae', + version='5.1-preview.1', + route_values=route_values, + content=content) + return self._deserialize('WorkItemSearchResponse', response) +