Skip to content
Merged
Prev Previous commit
Next Next commit
Generated from 59d29e5b9ede1195ac7ef5b826889226ad9a240d (#3771)
Py conf in its own file
  • Loading branch information
AutorestCI authored Nov 9, 2018
commit dc56cfa9c444fd88c7f2b1652cb2de8103992c32
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 @@ -16,8 +16,8 @@
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(SDKClient):
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(SDKClient):
def __init__(
self, credentials, base_url=None):

self.config = CustomSearchAPIConfiguration(credentials, base_url)
super(CustomSearchAPI, self).__init__(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 @@ -41,7 +41,7 @@
from .thing import Thing
from .creative_work import CreativeWork
from .response_base import ResponseBase
from .custom_search_api_enums import (
from .custom_search_client_enums import (
ErrorCode,
ErrorSubCode,
SafeSearch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def search(

:param custom_config: The identifier for the custom search
configuration
:type custom_config: long
:type custom_config: str
: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.
Expand Down Expand Up @@ -262,7 +262,7 @@ def search(

# Construct parameters
query_parameters = {}
query_parameters['customConfig'] = self._serialize.query("custom_config", custom_config, 'long', minimum=0)
query_parameters['customConfig'] = self._serialize.query("custom_config", custom_config, 'str')
if country_code is not None:
query_parameters['cc'] = self._serialize.query("country_code", country_code, 'str')
if count is not None:
Expand All @@ -283,7 +283,7 @@ def search(

# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
header_parameters['Accept'] = 'application/json'
if custom_headers:
header_parameters.update(custom_headers)
header_parameters['X-BingApis-SDK'] = self._serialize.header("self.x_bing_apis_sdk", self.x_bing_apis_sdk, 'str')
Expand All @@ -299,8 +299,8 @@ def search(
header_parameters['X-Search-Location'] = self._serialize.header("location", location, 'str')

# Construct and send request
request = self._client.get(url, query_parameters)
response = self._client.send(request, header_parameters, stream=False, **operation_config)
request = self._client.get(url, query_parameters, header_parameters)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200]:
raise models.ErrorResponseException(self._deserialize, response)
Expand Down