Skip to content

[AutoPR] cognitiveservices/data-plane/CustomWebSearch #2597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
31 changes: 31 additions & 0 deletions azure-cognitiveservices-search-customsearch/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,37 @@
Release History
===============

0.2.0 (2018-12-11)
++++++++++++++++++

**Features**

- Client class can be used as a context manager to keep the underlying HTTP session open for performance

**Breaking changes**

- CustomSearchAPI main client has been renamed CustomSearchClient
- "search" method has changes in positional arguments

**General Breaking changes**

This version uses a next-generation code generator that *might* introduce breaking changes.

- Model signatures now use only keyword-argument syntax. All positional arguments must be re-written as keyword-arguments.
To keep auto-completion in most cases, models are now generated for Python 2 and Python 3. Python 3 uses the "*" syntax for keyword-only arguments.
- Enum types now use the "str" mixin (class AzureEnum(str, Enum)) to improve the behavior when unrecognized enum values are encountered.
While this is not a breaking change, the distinctions are important, and are documented here:
https://docs.python.org/3/library/enum.html#others
At a glance:

- "is" should not be used at all.
- "format" will return the string value, where "%s" string formatting will return `NameOfEnum.stringvalue`. Format syntax should be prefered.

**Bugfixes**

- Compatibility of the sdist with wheel 0.31.0


0.1.0 (2018-01-12)
++++++++++++++++++

Expand Down
4 changes: 4 additions & 0 deletions azure-cognitiveservices-search-customsearch/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
include *.rst
include azure/__init__.py
include azure/cognitiveservices/__init__.py
include azure/cognitiveservices/search/__init__.py

Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
# regenerated.
# --------------------------------------------------------------------------

from .custom_search_api import CustomSearchAPI
from .custom_search_client import CustomSearchClient
from .version import VERSION

__all__ = ['CustomSearchAPI']
__all__ = ['CustomSearchClient']

__version__ = VERSION

Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
# 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
from . import models


class CustomSearchAPIConfiguration(Configuration):
"""Configuration for CustomSearchAPI
class CustomSearchClientConfiguration(Configuration):
"""Configuration for CustomSearchClient
Note that all parameters used to create this instance are saved as instance
attributes.

Expand All @@ -35,18 +35,18 @@ def __init__(
if not base_url:
base_url = 'https://api.cognitive.microsoft.com/bingcustomsearch/v7.0'

super(CustomSearchAPIConfiguration, self).__init__(base_url)
super(CustomSearchClientConfiguration, self).__init__(base_url)

self.add_user_agent('azure-cognitiveservices-search-customsearch/{}'.format(VERSION))

self.credentials = credentials


class CustomSearchAPI(object):
class CustomSearchClient(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.
:vartype config: CustomSearchAPIConfiguration
:vartype config: CustomSearchClientConfiguration

:ivar custom_instance: CustomInstance operations
:vartype custom_instance: azure.cognitiveservices.search.customsearch.operations.CustomInstanceOperations
Expand All @@ -60,8 +60,8 @@ class CustomSearchAPI(object):
def __init__(
self, credentials, base_url=None):

self.config = CustomSearchAPIConfiguration(credentials, base_url)
self._client = ServiceClient(self.config.credentials, self.config)
self.config = CustomSearchClientConfiguration(credentials, base_url)
super(CustomSearchClient, 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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,39 @@
# 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
from .custom_search_api_enums import (
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_client_enums import (
ErrorCode,
ErrorSubCode,
SafeSearch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from enum import Enum


class ErrorCode(Enum):
class ErrorCode(str, Enum):

none = "None"
server_error = "ServerError"
Expand All @@ -22,7 +22,7 @@ class ErrorCode(Enum):
insufficient_authorization = "InsufficientAuthorization"


class ErrorSubCode(Enum):
class ErrorSubCode(str, Enum):

unexpected_error = "UnexpectedError"
resource_error = "ResourceError"
Expand All @@ -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"
Loading