diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/custom_search_api.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/custom_search_api.py index 4804fae6a637..84180bb113ab 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/custom_search_api.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/custom_search_api.py @@ -9,7 +9,7 @@ # regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import ServiceClient +from msrest.service_client import SDKClient from msrest import Configuration, Serializer, Deserializer from .version import VERSION from .operations.custom_instance_operations import CustomInstanceOperations @@ -42,7 +42,7 @@ def __init__( self.credentials = credentials -class CustomSearchAPI(object): +class CustomSearchAPI(SDKClient): """The Bing Custom Search API lets you send a search query to Bing and get back search results customized to meet your custom search definition. :ivar config: Configuration for client. @@ -61,7 +61,7 @@ def __init__( self, credentials, base_url=None): self.config = CustomSearchAPIConfiguration(credentials, base_url) - self._client = ServiceClient(self.config.credentials, self.config) + super(CustomSearchAPI, self).__init__(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self.api_version = '1.0' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/__init__.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/__init__.py index c8ae3f2bd636..89301a0c7a0d 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/__init__.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/__init__.py @@ -9,21 +9,38 @@ # regenerated. # -------------------------------------------------------------------------- -from .query_context import QueryContext -from .web_meta_tag import WebMetaTag -from .web_page import WebPage -from .web_web_answer import WebWebAnswer -from .search_response import SearchResponse -from .response import Response -from .search_results_answer import SearchResultsAnswer -from .identifiable import Identifiable -from .error import Error -from .error_response import ErrorResponse, ErrorResponseException -from .query import Query -from .answer import Answer -from .thing import Thing -from .creative_work import CreativeWork -from .response_base import ResponseBase +try: + from .query_context_py3 import QueryContext + from .web_meta_tag_py3 import WebMetaTag + from .web_page_py3 import WebPage + from .web_web_answer_py3 import WebWebAnswer + from .search_response_py3 import SearchResponse + from .response_py3 import Response + from .search_results_answer_py3 import SearchResultsAnswer + from .identifiable_py3 import Identifiable + from .error_py3 import Error + from .error_response_py3 import ErrorResponse, ErrorResponseException + from .query_py3 import Query + from .answer_py3 import Answer + from .thing_py3 import Thing + from .creative_work_py3 import CreativeWork + from .response_base_py3 import ResponseBase +except (SyntaxError, ImportError): + from .query_context import QueryContext + from .web_meta_tag import WebMetaTag + from .web_page import WebPage + from .web_web_answer import WebWebAnswer + from .search_response import SearchResponse + from .response import Response + from .search_results_answer import SearchResultsAnswer + from .identifiable import Identifiable + from .error import Error + from .error_response import ErrorResponse, ErrorResponseException + from .query import Query + from .answer import Answer + from .thing import Thing + from .creative_work import CreativeWork + from .response_base import ResponseBase from .custom_search_api_enums import ( ErrorCode, ErrorSubCode, diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/answer.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/answer.py index 50dd4581e363..643c7621a034 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/answer.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/answer.py @@ -21,7 +21,9 @@ class Answer(Response): Variables are only populated by the server, and will be ignored when sending a request. - :param _type: Constant filled by server. + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. :type _type: str :ivar id: A String identifier. :vartype id: str @@ -50,7 +52,7 @@ class Answer(Response): '_type': {'SearchResultsAnswer': 'SearchResultsAnswer'} } - def __init__(self): - super(Answer, self).__init__() + def __init__(self, **kwargs): + super(Answer, self).__init__(**kwargs) self.follow_up_queries = None self._type = 'Answer' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/answer_py3.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/answer_py3.py new file mode 100644 index 000000000000..db1b9e6ef1d5 --- /dev/null +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/answer_py3.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .response_py3 import Response + + +class Answer(Response): + """Answer. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: SearchResultsAnswer + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. + :type _type: str + :ivar id: A String identifier. + :vartype id: str + :ivar web_search_url: The URL To Bing's search result for this item. + :vartype web_search_url: str + :ivar follow_up_queries: + :vartype follow_up_queries: + list[~azure.cognitiveservices.search.customsearch.models.Query] + """ + + _validation = { + '_type': {'required': True}, + 'id': {'readonly': True}, + 'web_search_url': {'readonly': True}, + 'follow_up_queries': {'readonly': True}, + } + + _attribute_map = { + '_type': {'key': '_type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'web_search_url': {'key': 'webSearchUrl', 'type': 'str'}, + 'follow_up_queries': {'key': 'followUpQueries', 'type': '[Query]'}, + } + + _subtype_map = { + '_type': {'SearchResultsAnswer': 'SearchResultsAnswer'} + } + + def __init__(self, **kwargs) -> None: + super(Answer, self).__init__(**kwargs) + self.follow_up_queries = None + self._type = 'Answer' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/creative_work.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/creative_work.py index 4c3f34256369..117fb6eb062e 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/creative_work.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/creative_work.py @@ -21,7 +21,9 @@ class CreativeWork(Thing): Variables are only populated by the server, and will be ignored when sending a request. - :param _type: Constant filled by server. + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. :type _type: str :ivar id: A String identifier. :vartype id: str @@ -75,8 +77,8 @@ class CreativeWork(Thing): '_type': {'WebPage': 'WebPage'} } - def __init__(self): - super(CreativeWork, self).__init__() + def __init__(self, **kwargs): + super(CreativeWork, self).__init__(**kwargs) self.thumbnail_url = None self.provider = None self.text = None diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/creative_work_py3.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/creative_work_py3.py new file mode 100644 index 000000000000..ae7d34b9ac3b --- /dev/null +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/creative_work_py3.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .thing_py3 import Thing + + +class CreativeWork(Thing): + """CreativeWork. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: WebPage + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. + :type _type: str + :ivar id: A String identifier. + :vartype id: str + :ivar web_search_url: The URL To Bing's search result for this item. + :vartype web_search_url: str + :ivar name: The name of the thing represented by this object. + :vartype name: str + :ivar url: The URL to get more information about the thing represented by + this object. + :vartype url: str + :ivar description: A short description of the item. + :vartype description: str + :ivar bing_id: An ID that uniquely identifies this item. + :vartype bing_id: str + :ivar thumbnail_url: The URL to a thumbnail of the item. + :vartype thumbnail_url: str + :ivar provider: The source of the creative work. + :vartype provider: + list[~azure.cognitiveservices.search.customsearch.models.Thing] + :ivar text: + :vartype text: str + """ + + _validation = { + '_type': {'required': True}, + 'id': {'readonly': True}, + 'web_search_url': {'readonly': True}, + 'name': {'readonly': True}, + 'url': {'readonly': True}, + 'description': {'readonly': True}, + 'bing_id': {'readonly': True}, + 'thumbnail_url': {'readonly': True}, + 'provider': {'readonly': True}, + 'text': {'readonly': True}, + } + + _attribute_map = { + '_type': {'key': '_type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'web_search_url': {'key': 'webSearchUrl', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'bing_id': {'key': 'bingId', 'type': 'str'}, + 'thumbnail_url': {'key': 'thumbnailUrl', 'type': 'str'}, + 'provider': {'key': 'provider', 'type': '[Thing]'}, + 'text': {'key': 'text', 'type': 'str'}, + } + + _subtype_map = { + '_type': {'WebPage': 'WebPage'} + } + + def __init__(self, **kwargs) -> None: + super(CreativeWork, self).__init__(**kwargs) + self.thumbnail_url = None + self.provider = None + self.text = None + self._type = 'CreativeWork' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/custom_search_api_enums.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/custom_search_api_enums.py index 5d369cb9be38..7cac41b1f38c 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/custom_search_api_enums.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/custom_search_api_enums.py @@ -12,7 +12,7 @@ from enum import Enum -class ErrorCode(Enum): +class ErrorCode(str, Enum): none = "None" server_error = "ServerError" @@ -22,7 +22,7 @@ class ErrorCode(Enum): insufficient_authorization = "InsufficientAuthorization" -class ErrorSubCode(Enum): +class ErrorSubCode(str, Enum): unexpected_error = "UnexpectedError" resource_error = "ResourceError" @@ -37,14 +37,14 @@ class ErrorSubCode(Enum): authorization_expired = "AuthorizationExpired" -class SafeSearch(Enum): +class SafeSearch(str, Enum): off = "Off" moderate = "Moderate" strict = "Strict" -class TextFormat(Enum): +class TextFormat(str, Enum): raw = "Raw" html = "Html" diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/error.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/error.py index 5e0da1332380..ca15821bf050 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/error.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/error.py @@ -18,8 +18,10 @@ class Error(Model): Variables are only populated by the server, and will be ignored when sending a request. - :param code: The error code that identifies the category of error. - Possible values include: 'None', 'ServerError', 'InvalidRequest', + All required parameters must be populated in order to send to Azure. + + :param code: Required. The error code that identifies the category of + error. Possible values include: 'None', 'ServerError', 'InvalidRequest', 'RateLimitExceeded', 'InvalidAuthorization', 'InsufficientAuthorization'. Default value: "None" . :type code: str or @@ -31,7 +33,7 @@ class Error(Model): 'AuthorizationRedundancy', 'AuthorizationDisabled', 'AuthorizationExpired' :vartype sub_code: str or ~azure.cognitiveservices.search.customsearch.models.ErrorSubCode - :param message: A description of the error. + :param message: Required. A description of the error. :type message: str :ivar more_details: A description that provides additional information about the error. @@ -60,11 +62,11 @@ class Error(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, message, code="None"): - super(Error, self).__init__() - self.code = code + def __init__(self, **kwargs): + super(Error, self).__init__(**kwargs) + self.code = kwargs.get('code', "None") self.sub_code = None - self.message = message + self.message = kwargs.get('message', None) self.more_details = None self.parameter = None self.value = None diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/error_py3.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/error_py3.py new file mode 100644 index 000000000000..e23c4cbb6054 --- /dev/null +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/error_py3.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Error(Model): + """Defines the error that occurred. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. The error code that identifies the category of + error. Possible values include: 'None', 'ServerError', 'InvalidRequest', + 'RateLimitExceeded', 'InvalidAuthorization', 'InsufficientAuthorization'. + Default value: "None" . + :type code: str or + ~azure.cognitiveservices.search.customsearch.models.ErrorCode + :ivar sub_code: The error code that further helps to identify the error. + Possible values include: 'UnexpectedError', 'ResourceError', + 'NotImplemented', 'ParameterMissing', 'ParameterInvalidValue', + 'HttpNotAllowed', 'Blocked', 'AuthorizationMissing', + 'AuthorizationRedundancy', 'AuthorizationDisabled', 'AuthorizationExpired' + :vartype sub_code: str or + ~azure.cognitiveservices.search.customsearch.models.ErrorSubCode + :param message: Required. A description of the error. + :type message: str + :ivar more_details: A description that provides additional information + about the error. + :vartype more_details: str + :ivar parameter: The parameter in the request that caused the error. + :vartype parameter: str + :ivar value: The parameter's value in the request that was not valid. + :vartype value: str + """ + + _validation = { + 'code': {'required': True}, + 'sub_code': {'readonly': True}, + 'message': {'required': True}, + 'more_details': {'readonly': True}, + 'parameter': {'readonly': True}, + 'value': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'sub_code': {'key': 'subCode', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'more_details': {'key': 'moreDetails', 'type': 'str'}, + 'parameter': {'key': 'parameter', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__(self, *, message: str, code="None", **kwargs) -> None: + super(Error, self).__init__(**kwargs) + self.code = code + self.sub_code = None + self.message = message + self.more_details = None + self.parameter = None + self.value = None diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/error_response.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/error_response.py index 5300a6937eb2..8c6c08da049d 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/error_response.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/error_response.py @@ -19,14 +19,16 @@ class ErrorResponse(Response): Variables are only populated by the server, and will be ignored when sending a request. - :param _type: Constant filled by server. + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. :type _type: str :ivar id: A String identifier. :vartype id: str :ivar web_search_url: The URL To Bing's search result for this item. :vartype web_search_url: str - :param errors: A list of errors that describe the reasons why the request - failed. + :param errors: Required. A list of errors that describe the reasons why + the request failed. :type errors: list[~azure.cognitiveservices.search.customsearch.models.Error] """ @@ -45,9 +47,9 @@ class ErrorResponse(Response): 'errors': {'key': 'errors', 'type': '[Error]'}, } - def __init__(self, errors): - super(ErrorResponse, self).__init__() - self.errors = errors + def __init__(self, **kwargs): + super(ErrorResponse, self).__init__(**kwargs) + self.errors = kwargs.get('errors', None) self._type = 'ErrorResponse' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/error_response_py3.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/error_response_py3.py new file mode 100644 index 000000000000..405e466ad93d --- /dev/null +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/error_response_py3.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .response_py3 import Response +from msrest.exceptions import HttpOperationError + + +class ErrorResponse(Response): + """The top-level response that represents a failed request. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. + :type _type: str + :ivar id: A String identifier. + :vartype id: str + :ivar web_search_url: The URL To Bing's search result for this item. + :vartype web_search_url: str + :param errors: Required. A list of errors that describe the reasons why + the request failed. + :type errors: + list[~azure.cognitiveservices.search.customsearch.models.Error] + """ + + _validation = { + '_type': {'required': True}, + 'id': {'readonly': True}, + 'web_search_url': {'readonly': True}, + 'errors': {'required': True}, + } + + _attribute_map = { + '_type': {'key': '_type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'web_search_url': {'key': 'webSearchUrl', 'type': 'str'}, + 'errors': {'key': 'errors', 'type': '[Error]'}, + } + + def __init__(self, *, errors, **kwargs) -> None: + super(ErrorResponse, self).__init__(**kwargs) + self.errors = errors + self._type = 'ErrorResponse' + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/identifiable.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/identifiable.py index 133e93fa8f94..513e53d238bb 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/identifiable.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/identifiable.py @@ -21,7 +21,9 @@ class Identifiable(ResponseBase): Variables are only populated by the server, and will be ignored when sending a request. - :param _type: Constant filled by server. + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. :type _type: str :ivar id: A String identifier. :vartype id: str @@ -41,7 +43,7 @@ class Identifiable(ResponseBase): '_type': {'Response': 'Response'} } - def __init__(self): - super(Identifiable, self).__init__() + def __init__(self, **kwargs): + super(Identifiable, self).__init__(**kwargs) self.id = None self._type = 'Identifiable' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/identifiable_py3.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/identifiable_py3.py new file mode 100644 index 000000000000..2d24a2c45775 --- /dev/null +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/identifiable_py3.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .response_base_py3 import ResponseBase + + +class Identifiable(ResponseBase): + """Defines the identity of a resource. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: Response + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. + :type _type: str + :ivar id: A String identifier. + :vartype id: str + """ + + _validation = { + '_type': {'required': True}, + 'id': {'readonly': True}, + } + + _attribute_map = { + '_type': {'key': '_type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + } + + _subtype_map = { + '_type': {'Response': 'Response'} + } + + def __init__(self, **kwargs) -> None: + super(Identifiable, self).__init__(**kwargs) + self.id = None + self._type = 'Identifiable' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/query.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/query.py index adf7f2bbcef7..2cc49f11f355 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/query.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/query.py @@ -18,8 +18,10 @@ class Query(Model): Variables are only populated by the server, and will be ignored when sending a request. - :param text: The query string. Use this string as the query term in a new - search request. + All required parameters must be populated in order to send to Azure. + + :param text: Required. The query string. Use this string as the query term + in a new search request. :type text: str :ivar display_text: The display version of the query term. This version of the query term may contain special characters that highlight the search @@ -47,9 +49,9 @@ class Query(Model): 'search_link': {'key': 'searchLink', 'type': 'str'}, } - def __init__(self, text): - super(Query, self).__init__() - self.text = text + def __init__(self, **kwargs): + super(Query, self).__init__(**kwargs) + self.text = kwargs.get('text', None) self.display_text = None self.web_search_url = None self.search_link = None diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/query_context.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/query_context.py index 0a1be85aaef0..410f31e10e27 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/query_context.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/query_context.py @@ -18,7 +18,10 @@ class QueryContext(Model): Variables are only populated by the server, and will be ignored when sending a request. - :param original_query: The query string as specified in the request. + All required parameters must be populated in order to send to Azure. + + :param original_query: Required. The query string as specified in the + request. :type original_query: str :ivar altered_query: The query string used by Bing to perform the query. Bing uses the altered query string if the original query string contained @@ -53,9 +56,9 @@ class QueryContext(Model): 'adult_intent': {'key': 'adultIntent', 'type': 'bool'}, } - def __init__(self, original_query): - super(QueryContext, self).__init__() - self.original_query = original_query + def __init__(self, **kwargs): + super(QueryContext, self).__init__(**kwargs) + self.original_query = kwargs.get('original_query', None) self.altered_query = None self.alteration_override_query = None self.adult_intent = None diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/query_context_py3.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/query_context_py3.py new file mode 100644 index 000000000000..01c7f429d01e --- /dev/null +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/query_context_py3.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class QueryContext(Model): + """Defines the query context that Bing used for the request. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param original_query: Required. The query string as specified in the + request. + :type original_query: str + :ivar altered_query: The query string used by Bing to perform the query. + Bing uses the altered query string if the original query string contained + spelling mistakes. For example, if the query string is "saling downwind", + the altered query string will be "sailing downwind". This field is + included only if the original query string contains a spelling mistake. + :vartype altered_query: str + :ivar alteration_override_query: The query string to use to force Bing to + use the original string. For example, if the query string is "saling + downwind", the override query string will be "+saling downwind". Remember + to encode the query string which results in "%2Bsaling+downwind". This + field is included only if the original query string contains a spelling + mistake. + :vartype alteration_override_query: str + :ivar adult_intent: A Boolean value that indicates whether the specified + query has adult intent. The value is true if the query has adult intent; + otherwise, false. + :vartype adult_intent: bool + """ + + _validation = { + 'original_query': {'required': True}, + 'altered_query': {'readonly': True}, + 'alteration_override_query': {'readonly': True}, + 'adult_intent': {'readonly': True}, + } + + _attribute_map = { + 'original_query': {'key': 'originalQuery', 'type': 'str'}, + 'altered_query': {'key': 'alteredQuery', 'type': 'str'}, + 'alteration_override_query': {'key': 'alterationOverrideQuery', 'type': 'str'}, + 'adult_intent': {'key': 'adultIntent', 'type': 'bool'}, + } + + def __init__(self, *, original_query: str, **kwargs) -> None: + super(QueryContext, self).__init__(**kwargs) + self.original_query = original_query + self.altered_query = None + self.alteration_override_query = None + self.adult_intent = None diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/query_py3.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/query_py3.py new file mode 100644 index 000000000000..059f963bc37f --- /dev/null +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/query_py3.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Query(Model): + """Defines a search query. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param text: Required. The query string. Use this string as the query term + in a new search request. + :type text: str + :ivar display_text: The display version of the query term. This version of + the query term may contain special characters that highlight the search + term found in the query string. The string contains the highlighting + characters only if the query enabled hit highlighting + :vartype display_text: str + :ivar web_search_url: The URL that takes the user to the Bing search + results page for the query.Only related search results include this field. + :vartype web_search_url: str + :ivar search_link: + :vartype search_link: str + """ + + _validation = { + 'text': {'required': True}, + 'display_text': {'readonly': True}, + 'web_search_url': {'readonly': True}, + 'search_link': {'readonly': True}, + } + + _attribute_map = { + 'text': {'key': 'text', 'type': 'str'}, + 'display_text': {'key': 'displayText', 'type': 'str'}, + 'web_search_url': {'key': 'webSearchUrl', 'type': 'str'}, + 'search_link': {'key': 'searchLink', 'type': 'str'}, + } + + def __init__(self, *, text: str, **kwargs) -> None: + super(Query, self).__init__(**kwargs) + self.text = text + self.display_text = None + self.web_search_url = None + self.search_link = None diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/response.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/response.py index 8f6f7ef2ed37..370004ddb0d7 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/response.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/response.py @@ -22,7 +22,9 @@ class Response(Identifiable): Variables are only populated by the server, and will be ignored when sending a request. - :param _type: Constant filled by server. + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. :type _type: str :ivar id: A String identifier. :vartype id: str @@ -46,7 +48,7 @@ class Response(Identifiable): '_type': {'SearchResponse': 'SearchResponse', 'ErrorResponse': 'ErrorResponse', 'Answer': 'Answer', 'Thing': 'Thing'} } - def __init__(self): - super(Response, self).__init__() + def __init__(self, **kwargs): + super(Response, self).__init__(**kwargs) self.web_search_url = None self._type = 'Response' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/response_base.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/response_base.py index 0b5b11b43039..5a09ce0f95d6 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/response_base.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/response_base.py @@ -18,7 +18,9 @@ class ResponseBase(Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: Identifiable - :param _type: Constant filled by server. + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. :type _type: str """ @@ -34,6 +36,6 @@ class ResponseBase(Model): '_type': {'Identifiable': 'Identifiable'} } - def __init__(self): - super(ResponseBase, self).__init__() + def __init__(self, **kwargs): + super(ResponseBase, self).__init__(**kwargs) self._type = None diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/response_base_py3.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/response_base_py3.py new file mode 100644 index 000000000000..0ac9762f5cd7 --- /dev/null +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/response_base_py3.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ResponseBase(Model): + """ResponseBase. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: Identifiable + + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. + :type _type: str + """ + + _validation = { + '_type': {'required': True}, + } + + _attribute_map = { + '_type': {'key': '_type', 'type': 'str'}, + } + + _subtype_map = { + '_type': {'Identifiable': 'Identifiable'} + } + + def __init__(self, **kwargs) -> None: + super(ResponseBase, self).__init__(**kwargs) + self._type = None diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/response_py3.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/response_py3.py new file mode 100644 index 000000000000..76fcfc583c01 --- /dev/null +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/response_py3.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .identifiable_py3 import Identifiable + + +class Response(Identifiable): + """Defines a response. All schemas that could be returned at the root of a + response should inherit from this. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: SearchResponse, ErrorResponse, Answer, Thing + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. + :type _type: str + :ivar id: A String identifier. + :vartype id: str + :ivar web_search_url: The URL To Bing's search result for this item. + :vartype web_search_url: str + """ + + _validation = { + '_type': {'required': True}, + 'id': {'readonly': True}, + 'web_search_url': {'readonly': True}, + } + + _attribute_map = { + '_type': {'key': '_type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'web_search_url': {'key': 'webSearchUrl', 'type': 'str'}, + } + + _subtype_map = { + '_type': {'SearchResponse': 'SearchResponse', 'ErrorResponse': 'ErrorResponse', 'Answer': 'Answer', 'Thing': 'Thing'} + } + + def __init__(self, **kwargs) -> None: + super(Response, self).__init__(**kwargs) + self.web_search_url = None + self._type = 'Response' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/search_response.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/search_response.py index 6fe6dddaa472..3d3c95ef5424 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/search_response.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/search_response.py @@ -19,7 +19,9 @@ class SearchResponse(Response): Variables are only populated by the server, and will be ignored when sending a request. - :param _type: Constant filled by server. + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. :type _type: str :ivar id: A String identifier. :vartype id: str @@ -52,8 +54,8 @@ class SearchResponse(Response): 'web_pages': {'key': 'webPages', 'type': 'WebWebAnswer'}, } - def __init__(self): - super(SearchResponse, self).__init__() + def __init__(self, **kwargs): + super(SearchResponse, self).__init__(**kwargs) self.query_context = None self.web_pages = None self._type = 'SearchResponse' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/search_response_py3.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/search_response_py3.py new file mode 100644 index 000000000000..ac1a9455a539 --- /dev/null +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/search_response_py3.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .response_py3 import Response + + +class SearchResponse(Response): + """Defines the top-level object that the response includes when the request + succeeds. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. + :type _type: str + :ivar id: A String identifier. + :vartype id: str + :ivar web_search_url: The URL To Bing's search result for this item. + :vartype web_search_url: str + :ivar query_context: An object that contains the query string that Bing + used for the request. This object contains the query string as entered by + the user. It may also contain an altered query string that Bing used for + the query if the query string contained a spelling mistake. + :vartype query_context: + ~azure.cognitiveservices.search.customsearch.models.QueryContext + :ivar web_pages: A list of webpages that are relevant to the search query. + :vartype web_pages: + ~azure.cognitiveservices.search.customsearch.models.WebWebAnswer + """ + + _validation = { + '_type': {'required': True}, + 'id': {'readonly': True}, + 'web_search_url': {'readonly': True}, + 'query_context': {'readonly': True}, + 'web_pages': {'readonly': True}, + } + + _attribute_map = { + '_type': {'key': '_type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'web_search_url': {'key': 'webSearchUrl', 'type': 'str'}, + 'query_context': {'key': 'queryContext', 'type': 'QueryContext'}, + 'web_pages': {'key': 'webPages', 'type': 'WebWebAnswer'}, + } + + def __init__(self, **kwargs) -> None: + super(SearchResponse, self).__init__(**kwargs) + self.query_context = None + self.web_pages = None + self._type = 'SearchResponse' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/search_results_answer.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/search_results_answer.py index 3255878ef159..c0e0620953dd 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/search_results_answer.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/search_results_answer.py @@ -21,7 +21,9 @@ class SearchResultsAnswer(Answer): Variables are only populated by the server, and will be ignored when sending a request. - :param _type: Constant filled by server. + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. :type _type: str :ivar id: A String identifier. :vartype id: str @@ -65,8 +67,8 @@ class SearchResultsAnswer(Answer): '_type': {'Web/WebAnswer': 'WebWebAnswer'} } - def __init__(self): - super(SearchResultsAnswer, self).__init__() + def __init__(self, **kwargs): + super(SearchResultsAnswer, self).__init__(**kwargs) self.query_context = None self.total_estimated_matches = None self.is_family_friendly = None diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/search_results_answer_py3.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/search_results_answer_py3.py new file mode 100644 index 000000000000..678c7ab989cb --- /dev/null +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/search_results_answer_py3.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .answer_py3 import Answer + + +class SearchResultsAnswer(Answer): + """SearchResultsAnswer. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: WebWebAnswer + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. + :type _type: str + :ivar id: A String identifier. + :vartype id: str + :ivar web_search_url: The URL To Bing's search result for this item. + :vartype web_search_url: str + :ivar follow_up_queries: + :vartype follow_up_queries: + list[~azure.cognitiveservices.search.customsearch.models.Query] + :ivar query_context: + :vartype query_context: + ~azure.cognitiveservices.search.customsearch.models.QueryContext + :ivar total_estimated_matches: The estimated number of webpages that are + relevant to the query. Use this number along with the count and offset + query parameters to page the results. + :vartype total_estimated_matches: long + :ivar is_family_friendly: + :vartype is_family_friendly: bool + """ + + _validation = { + '_type': {'required': True}, + 'id': {'readonly': True}, + 'web_search_url': {'readonly': True}, + 'follow_up_queries': {'readonly': True}, + 'query_context': {'readonly': True}, + 'total_estimated_matches': {'readonly': True}, + 'is_family_friendly': {'readonly': True}, + } + + _attribute_map = { + '_type': {'key': '_type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'web_search_url': {'key': 'webSearchUrl', 'type': 'str'}, + 'follow_up_queries': {'key': 'followUpQueries', 'type': '[Query]'}, + 'query_context': {'key': 'queryContext', 'type': 'QueryContext'}, + 'total_estimated_matches': {'key': 'totalEstimatedMatches', 'type': 'long'}, + 'is_family_friendly': {'key': 'isFamilyFriendly', 'type': 'bool'}, + } + + _subtype_map = { + '_type': {'Web/WebAnswer': 'WebWebAnswer'} + } + + def __init__(self, **kwargs) -> None: + super(SearchResultsAnswer, self).__init__(**kwargs) + self.query_context = None + self.total_estimated_matches = None + self.is_family_friendly = None + self._type = 'SearchResultsAnswer' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/thing.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/thing.py index d387cad847fd..9430456b9ff6 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/thing.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/thing.py @@ -21,7 +21,9 @@ class Thing(Response): Variables are only populated by the server, and will be ignored when sending a request. - :param _type: Constant filled by server. + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. :type _type: str :ivar id: A String identifier. :vartype id: str @@ -62,8 +64,8 @@ class Thing(Response): '_type': {'CreativeWork': 'CreativeWork'} } - def __init__(self): - super(Thing, self).__init__() + def __init__(self, **kwargs): + super(Thing, self).__init__(**kwargs) self.name = None self.url = None self.description = None diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/thing_py3.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/thing_py3.py new file mode 100644 index 000000000000..57b9aa17688c --- /dev/null +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/thing_py3.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .response_py3 import Response + + +class Thing(Response): + """Thing. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: CreativeWork + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. + :type _type: str + :ivar id: A String identifier. + :vartype id: str + :ivar web_search_url: The URL To Bing's search result for this item. + :vartype web_search_url: str + :ivar name: The name of the thing represented by this object. + :vartype name: str + :ivar url: The URL to get more information about the thing represented by + this object. + :vartype url: str + :ivar description: A short description of the item. + :vartype description: str + :ivar bing_id: An ID that uniquely identifies this item. + :vartype bing_id: str + """ + + _validation = { + '_type': {'required': True}, + 'id': {'readonly': True}, + 'web_search_url': {'readonly': True}, + 'name': {'readonly': True}, + 'url': {'readonly': True}, + 'description': {'readonly': True}, + 'bing_id': {'readonly': True}, + } + + _attribute_map = { + '_type': {'key': '_type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'web_search_url': {'key': 'webSearchUrl', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'bing_id': {'key': 'bingId', 'type': 'str'}, + } + + _subtype_map = { + '_type': {'CreativeWork': 'CreativeWork'} + } + + def __init__(self, **kwargs) -> None: + super(Thing, self).__init__(**kwargs) + self.name = None + self.url = None + self.description = None + self.bing_id = None + self._type = 'Thing' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_meta_tag.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_meta_tag.py index 157658cda668..372f99be707a 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_meta_tag.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_meta_tag.py @@ -34,7 +34,7 @@ class WebMetaTag(Model): 'content': {'key': 'content', 'type': 'str'}, } - def __init__(self): - super(WebMetaTag, self).__init__() + def __init__(self, **kwargs): + super(WebMetaTag, self).__init__(**kwargs) self.name = None self.content = None diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_meta_tag_py3.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_meta_tag_py3.py new file mode 100644 index 000000000000..042a76bfb86d --- /dev/null +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_meta_tag_py3.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class WebMetaTag(Model): + """Defines a webpage's metadata. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar name: The metadata. + :vartype name: str + :ivar content: The name of the metadata. + :vartype content: str + """ + + _validation = { + 'name': {'readonly': True}, + 'content': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'content': {'key': 'content', 'type': 'str'}, + } + + def __init__(self, **kwargs) -> None: + super(WebMetaTag, self).__init__(**kwargs) + self.name = None + self.content = None diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_page.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_page.py index bc27ab16bd86..6fd7b5b9a7dd 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_page.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_page.py @@ -18,7 +18,9 @@ class WebPage(CreativeWork): Variables are only populated by the server, and will be ignored when sending a request. - :param _type: Constant filled by server. + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. :type _type: str :ivar id: A String identifier. :vartype id: str @@ -100,8 +102,8 @@ class WebPage(CreativeWork): 'search_tags': {'key': 'searchTags', 'type': '[WebMetaTag]'}, } - def __init__(self): - super(WebPage, self).__init__() + def __init__(self, **kwargs): + super(WebPage, self).__init__(**kwargs) self.display_url = None self.snippet = None self.deep_links = None diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_page_py3.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_page_py3.py new file mode 100644 index 000000000000..03765d9eef0f --- /dev/null +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_page_py3.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .creative_work_py3 import CreativeWork + + +class WebPage(CreativeWork): + """Defines a webpage that is relevant to the query. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. + :type _type: str + :ivar id: A String identifier. + :vartype id: str + :ivar web_search_url: The URL To Bing's search result for this item. + :vartype web_search_url: str + :ivar name: The name of the thing represented by this object. + :vartype name: str + :ivar url: The URL to get more information about the thing represented by + this object. + :vartype url: str + :ivar description: A short description of the item. + :vartype description: str + :ivar bing_id: An ID that uniquely identifies this item. + :vartype bing_id: str + :ivar thumbnail_url: The URL to a thumbnail of the item. + :vartype thumbnail_url: str + :ivar provider: The source of the creative work. + :vartype provider: + list[~azure.cognitiveservices.search.customsearch.models.Thing] + :ivar text: + :vartype text: str + :ivar display_url: The display URL of the webpage. The URL is meant for + display purposes only and is not well formed. + :vartype display_url: str + :ivar snippet: A snippet of text from the webpage that describes its + contents. + :vartype snippet: str + :ivar deep_links: A list of links to related content that Bing found in + the website that contains this webpage. The Webpage object in this context + includes only the name, url, urlPingSuffix, and snippet fields. + :vartype deep_links: + list[~azure.cognitiveservices.search.customsearch.models.WebPage] + :ivar date_last_crawled: The last time that Bing crawled the webpage. The + date is in the form, YYYY-MM-DDTHH:MM:SS. For example, + 2015-04-13T05:23:39. + :vartype date_last_crawled: str + :ivar search_tags: A list of search tags that the webpage owner specified + on the webpage. The API returns only indexed search tags. The name field + of the MetaTag object contains the indexed search tag. Search tags begin + with search.* (for example, search.assetId). The content field contains + the tag's value. + :vartype search_tags: + list[~azure.cognitiveservices.search.customsearch.models.WebMetaTag] + """ + + _validation = { + '_type': {'required': True}, + 'id': {'readonly': True}, + 'web_search_url': {'readonly': True}, + 'name': {'readonly': True}, + 'url': {'readonly': True}, + 'description': {'readonly': True}, + 'bing_id': {'readonly': True}, + 'thumbnail_url': {'readonly': True}, + 'provider': {'readonly': True}, + 'text': {'readonly': True}, + 'display_url': {'readonly': True}, + 'snippet': {'readonly': True}, + 'deep_links': {'readonly': True}, + 'date_last_crawled': {'readonly': True}, + 'search_tags': {'readonly': True}, + } + + _attribute_map = { + '_type': {'key': '_type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'web_search_url': {'key': 'webSearchUrl', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'bing_id': {'key': 'bingId', 'type': 'str'}, + 'thumbnail_url': {'key': 'thumbnailUrl', 'type': 'str'}, + 'provider': {'key': 'provider', 'type': '[Thing]'}, + 'text': {'key': 'text', 'type': 'str'}, + 'display_url': {'key': 'displayUrl', 'type': 'str'}, + 'snippet': {'key': 'snippet', 'type': 'str'}, + 'deep_links': {'key': 'deepLinks', 'type': '[WebPage]'}, + 'date_last_crawled': {'key': 'dateLastCrawled', 'type': 'str'}, + 'search_tags': {'key': 'searchTags', 'type': '[WebMetaTag]'}, + } + + def __init__(self, **kwargs) -> None: + super(WebPage, self).__init__(**kwargs) + self.display_url = None + self.snippet = None + self.deep_links = None + self.date_last_crawled = None + self.search_tags = None + self._type = 'WebPage' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_web_answer.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_web_answer.py index f2cf3706b1f3..8a28c6c9273f 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_web_answer.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_web_answer.py @@ -18,7 +18,9 @@ class WebWebAnswer(SearchResultsAnswer): Variables are only populated by the server, and will be ignored when sending a request. - :param _type: Constant filled by server. + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. :type _type: str :ivar id: A String identifier. :vartype id: str @@ -36,7 +38,7 @@ class WebWebAnswer(SearchResultsAnswer): :vartype total_estimated_matches: long :ivar is_family_friendly: :vartype is_family_friendly: bool - :param value: A list of webpages that are relevant to the query. + :param value: Required. A list of webpages that are relevant to the query. :type value: list[~azure.cognitiveservices.search.customsearch.models.WebPage] :ivar some_results_removed: A Boolean value that indicates whether the @@ -69,8 +71,8 @@ class WebWebAnswer(SearchResultsAnswer): 'some_results_removed': {'key': 'someResultsRemoved', 'type': 'bool'}, } - def __init__(self, value): - super(WebWebAnswer, self).__init__() - self.value = value + def __init__(self, **kwargs): + super(WebWebAnswer, self).__init__(**kwargs) + self.value = kwargs.get('value', None) self.some_results_removed = None self._type = 'Web/WebAnswer' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_web_answer_py3.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_web_answer_py3.py new file mode 100644 index 000000000000..62bedaaa5da3 --- /dev/null +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/web_web_answer_py3.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .search_results_answer_py3 import SearchResultsAnswer + + +class WebWebAnswer(SearchResultsAnswer): + """Defines a list of relevant webpage links. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param _type: Required. Constant filled by server. + :type _type: str + :ivar id: A String identifier. + :vartype id: str + :ivar web_search_url: The URL To Bing's search result for this item. + :vartype web_search_url: str + :ivar follow_up_queries: + :vartype follow_up_queries: + list[~azure.cognitiveservices.search.customsearch.models.Query] + :ivar query_context: + :vartype query_context: + ~azure.cognitiveservices.search.customsearch.models.QueryContext + :ivar total_estimated_matches: The estimated number of webpages that are + relevant to the query. Use this number along with the count and offset + query parameters to page the results. + :vartype total_estimated_matches: long + :ivar is_family_friendly: + :vartype is_family_friendly: bool + :param value: Required. A list of webpages that are relevant to the query. + :type value: + list[~azure.cognitiveservices.search.customsearch.models.WebPage] + :ivar some_results_removed: A Boolean value that indicates whether the + response excluded some results from the answer. If Bing excluded some + results, the value is true. + :vartype some_results_removed: bool + """ + + _validation = { + '_type': {'required': True}, + 'id': {'readonly': True}, + 'web_search_url': {'readonly': True}, + 'follow_up_queries': {'readonly': True}, + 'query_context': {'readonly': True}, + 'total_estimated_matches': {'readonly': True}, + 'is_family_friendly': {'readonly': True}, + 'value': {'required': True}, + 'some_results_removed': {'readonly': True}, + } + + _attribute_map = { + '_type': {'key': '_type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'web_search_url': {'key': 'webSearchUrl', 'type': 'str'}, + 'follow_up_queries': {'key': 'followUpQueries', 'type': '[Query]'}, + 'query_context': {'key': 'queryContext', 'type': 'QueryContext'}, + 'total_estimated_matches': {'key': 'totalEstimatedMatches', 'type': 'long'}, + 'is_family_friendly': {'key': 'isFamilyFriendly', 'type': 'bool'}, + 'value': {'key': 'value', 'type': '[WebPage]'}, + 'some_results_removed': {'key': 'someResultsRemoved', 'type': 'bool'}, + } + + def __init__(self, *, value, **kwargs) -> None: + super(WebWebAnswer, self).__init__(**kwargs) + self.value = value + self.some_results_removed = None + self._type = 'Web/WebAnswer' diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/operations/custom_instance_operations.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/operations/custom_instance_operations.py index cf2e0a63be67..62a2605540bb 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/operations/custom_instance_operations.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/operations/custom_instance_operations.py @@ -36,10 +36,13 @@ def __init__(self, client, config, serializer, deserializer): self.x_bing_apis_sdk = "true" def search( - self, query, accept_language=None, user_agent=None, client_id=None, client_ip=None, location=None, custom_config=None, country_code=None, count=None, market="en-us", offset=None, safe_search=None, set_lang=None, text_decorations=None, text_format=None, custom_headers=None, raw=False, **operation_config): + self, custom_config, query, accept_language=None, user_agent=None, client_id=None, client_ip=None, location=None, country_code=None, count=None, market="en-us", offset=None, safe_search=None, set_lang=None, text_decorations=None, text_format=None, custom_headers=None, raw=False, **operation_config): """The Custom Search API lets you send a search query to Bing and get back web pages found in your custom view of the web. + :param custom_config: The identifier for the custom search + configuration + :type custom_config: long :param query: The user's search query term. The term may not be empty. The term may contain Bing Advanced Operators. For example, to limit results to a specific domain, use the site: operator. @@ -151,9 +154,6 @@ def search( you should include this header and the X-MSEdge-ClientIP header, but at a minimum, you should include this header. :type location: str - :param custom_config: The identifier for the custom search - configuration - :type custom_config: int :param country_code: A 2-character country code of the country where the results come from. This API supports only the United States market. If you specify this query parameter, it must be set to us. If @@ -258,12 +258,11 @@ def search( :class:`ErrorResponseException` """ # Construct URL - url = '/search' + url = self.search.metadata['url'] # Construct parameters query_parameters = {} - if custom_config is not None: - query_parameters['customConfig'] = self._serialize.query("custom_config", custom_config, 'int') + query_parameters['customConfig'] = self._serialize.query("custom_config", custom_config, 'long', minimum=0) if country_code is not None: query_parameters['cc'] = self._serialize.query("country_code", country_code, 'str') if count is not None: @@ -316,3 +315,4 @@ def search( return client_raw_response return deserialized + search.metadata = {'url': '/search'} diff --git a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/version.py b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/version.py index e0ec669828cb..63d89bfb54fa 100644 --- a/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/version.py +++ b/azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "0.1.0" +VERSION = "1.0"