Skip to content

Commit ba179ea

Browse files
AutorestCIlmazuel
authored andcommitted
[AutoPR] cognitiveservices/data-plane/CustomWebSearch (#2597)
* Generated from 8f44fce8ff071d239a14dbb1e074d39dccf38b3d (#2578) renaming custom search to custom web search * Generated from 59d29e5b9ede1195ac7ef5b826889226ad9a240d (#3771) Py conf in its own file * Update version.py * Deprecated file * ChangeLog * Packaging update of azure-cognitiveservices-search-customsearch * Update sdk_packaging.toml * Packaging update of azure-cognitiveservices-search-customsearch * Update HISTORY.rst
1 parent 432cc6a commit ba179ea

40 files changed

+1163
-517
lines changed

azure-cognitiveservices-search-customsearch/HISTORY.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,37 @@
33
Release History
44
===============
55

6+
0.2.0 (2018-12-11)
7+
++++++++++++++++++
8+
9+
**Features**
10+
11+
- Client class can be used as a context manager to keep the underlying HTTP session open for performance
12+
13+
**Breaking changes**
14+
15+
- CustomSearchAPI main client has been renamed CustomSearchClient
16+
- "search" method has changes in positional arguments
17+
18+
**General Breaking changes**
19+
20+
This version uses a next-generation code generator that *might* introduce breaking changes.
21+
22+
- Model signatures now use only keyword-argument syntax. All positional arguments must be re-written as keyword-arguments.
23+
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.
24+
- Enum types now use the "str" mixin (class AzureEnum(str, Enum)) to improve the behavior when unrecognized enum values are encountered.
25+
While this is not a breaking change, the distinctions are important, and are documented here:
26+
https://docs.python.org/3/library/enum.html#others
27+
At a glance:
28+
29+
- "is" should not be used at all.
30+
- "format" will return the string value, where "%s" string formatting will return `NameOfEnum.stringvalue`. Format syntax should be prefered.
31+
32+
**Bugfixes**
33+
34+
- Compatibility of the sdist with wheel 0.31.0
35+
36+
637
0.1.0 (2018-01-12)
738
++++++++++++++++++
839

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
include *.rst
2+
include azure/__init__.py
3+
include azure/cognitiveservices/__init__.py
4+
include azure/cognitiveservices/search/__init__.py
5+

azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
# regenerated.
1010
# --------------------------------------------------------------------------
1111

12-
from .custom_search_api import CustomSearchAPI
12+
from .custom_search_client import CustomSearchClient
1313
from .version import VERSION
1414

15-
__all__ = ['CustomSearchAPI']
15+
__all__ = ['CustomSearchClient']
1616

1717
__version__ = VERSION
1818

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
# regenerated.
1010
# --------------------------------------------------------------------------
1111

12-
from msrest.service_client import ServiceClient
12+
from msrest.service_client import SDKClient
1313
from msrest import Configuration, Serializer, Deserializer
1414
from .version import VERSION
1515
from .operations.custom_instance_operations import CustomInstanceOperations
1616
from . import models
1717

1818

19-
class CustomSearchAPIConfiguration(Configuration):
20-
"""Configuration for CustomSearchAPI
19+
class CustomSearchClientConfiguration(Configuration):
20+
"""Configuration for CustomSearchClient
2121
Note that all parameters used to create this instance are saved as instance
2222
attributes.
2323
@@ -35,18 +35,18 @@ def __init__(
3535
if not base_url:
3636
base_url = 'https://api.cognitive.microsoft.com/bingcustomsearch/v7.0'
3737

38-
super(CustomSearchAPIConfiguration, self).__init__(base_url)
38+
super(CustomSearchClientConfiguration, self).__init__(base_url)
3939

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

4242
self.credentials = credentials
4343

4444

45-
class CustomSearchAPI(object):
45+
class CustomSearchClient(SDKClient):
4646
"""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.
4747
4848
:ivar config: Configuration for client.
49-
:vartype config: CustomSearchAPIConfiguration
49+
:vartype config: CustomSearchClientConfiguration
5050
5151
:ivar custom_instance: CustomInstance operations
5252
:vartype custom_instance: azure.cognitiveservices.search.customsearch.operations.CustomInstanceOperations
@@ -60,8 +60,8 @@ class CustomSearchAPI(object):
6060
def __init__(
6161
self, credentials, base_url=None):
6262

63-
self.config = CustomSearchAPIConfiguration(credentials, base_url)
64-
self._client = ServiceClient(self.config.credentials, self.config)
63+
self.config = CustomSearchClientConfiguration(credentials, base_url)
64+
super(CustomSearchClient, self).__init__(self.config.credentials, self.config)
6565

6666
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
6767
self.api_version = '1.0'

azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/__init__.py

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,39 @@
99
# regenerated.
1010
# --------------------------------------------------------------------------
1111

12-
from .query_context import QueryContext
13-
from .web_meta_tag import WebMetaTag
14-
from .web_page import WebPage
15-
from .web_web_answer import WebWebAnswer
16-
from .search_response import SearchResponse
17-
from .response import Response
18-
from .search_results_answer import SearchResultsAnswer
19-
from .identifiable import Identifiable
20-
from .error import Error
21-
from .error_response import ErrorResponse, ErrorResponseException
22-
from .query import Query
23-
from .answer import Answer
24-
from .thing import Thing
25-
from .creative_work import CreativeWork
26-
from .response_base import ResponseBase
27-
from .custom_search_api_enums import (
12+
try:
13+
from .query_context_py3 import QueryContext
14+
from .web_meta_tag_py3 import WebMetaTag
15+
from .web_page_py3 import WebPage
16+
from .web_web_answer_py3 import WebWebAnswer
17+
from .search_response_py3 import SearchResponse
18+
from .response_py3 import Response
19+
from .search_results_answer_py3 import SearchResultsAnswer
20+
from .identifiable_py3 import Identifiable
21+
from .error_py3 import Error
22+
from .error_response_py3 import ErrorResponse, ErrorResponseException
23+
from .query_py3 import Query
24+
from .answer_py3 import Answer
25+
from .thing_py3 import Thing
26+
from .creative_work_py3 import CreativeWork
27+
from .response_base_py3 import ResponseBase
28+
except (SyntaxError, ImportError):
29+
from .query_context import QueryContext
30+
from .web_meta_tag import WebMetaTag
31+
from .web_page import WebPage
32+
from .web_web_answer import WebWebAnswer
33+
from .search_response import SearchResponse
34+
from .response import Response
35+
from .search_results_answer import SearchResultsAnswer
36+
from .identifiable import Identifiable
37+
from .error import Error
38+
from .error_response import ErrorResponse, ErrorResponseException
39+
from .query import Query
40+
from .answer import Answer
41+
from .thing import Thing
42+
from .creative_work import CreativeWork
43+
from .response_base import ResponseBase
44+
from .custom_search_client_enums import (
2845
ErrorCode,
2946
ErrorSubCode,
3047
SafeSearch,

azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/answer.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ class Answer(Response):
2121
Variables are only populated by the server, and will be ignored when
2222
sending a request.
2323
24-
:param _type: Constant filled by server.
24+
All required parameters must be populated in order to send to Azure.
25+
26+
:param _type: Required. Constant filled by server.
2527
:type _type: str
2628
:ivar id: A String identifier.
2729
:vartype id: str
@@ -50,7 +52,7 @@ class Answer(Response):
5052
'_type': {'SearchResultsAnswer': 'SearchResultsAnswer'}
5153
}
5254

53-
def __init__(self):
54-
super(Answer, self).__init__()
55+
def __init__(self, **kwargs):
56+
super(Answer, self).__init__(**kwargs)
5557
self.follow_up_queries = None
5658
self._type = 'Answer'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for
5+
# license information.
6+
#
7+
# Code generated by Microsoft (R) AutoRest Code Generator.
8+
# Changes may cause incorrect behavior and will be lost if the code is
9+
# regenerated.
10+
# --------------------------------------------------------------------------
11+
12+
from .response_py3 import Response
13+
14+
15+
class Answer(Response):
16+
"""Answer.
17+
18+
You probably want to use the sub-classes and not this class directly. Known
19+
sub-classes are: SearchResultsAnswer
20+
21+
Variables are only populated by the server, and will be ignored when
22+
sending a request.
23+
24+
All required parameters must be populated in order to send to Azure.
25+
26+
:param _type: Required. Constant filled by server.
27+
:type _type: str
28+
:ivar id: A String identifier.
29+
:vartype id: str
30+
:ivar web_search_url: The URL To Bing's search result for this item.
31+
:vartype web_search_url: str
32+
:ivar follow_up_queries:
33+
:vartype follow_up_queries:
34+
list[~azure.cognitiveservices.search.customsearch.models.Query]
35+
"""
36+
37+
_validation = {
38+
'_type': {'required': True},
39+
'id': {'readonly': True},
40+
'web_search_url': {'readonly': True},
41+
'follow_up_queries': {'readonly': True},
42+
}
43+
44+
_attribute_map = {
45+
'_type': {'key': '_type', 'type': 'str'},
46+
'id': {'key': 'id', 'type': 'str'},
47+
'web_search_url': {'key': 'webSearchUrl', 'type': 'str'},
48+
'follow_up_queries': {'key': 'followUpQueries', 'type': '[Query]'},
49+
}
50+
51+
_subtype_map = {
52+
'_type': {'SearchResultsAnswer': 'SearchResultsAnswer'}
53+
}
54+
55+
def __init__(self, **kwargs) -> None:
56+
super(Answer, self).__init__(**kwargs)
57+
self.follow_up_queries = None
58+
self._type = 'Answer'

azure-cognitiveservices-search-customsearch/azure/cognitiveservices/search/customsearch/models/creative_work.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ class CreativeWork(Thing):
2121
Variables are only populated by the server, and will be ignored when
2222
sending a request.
2323
24-
:param _type: Constant filled by server.
24+
All required parameters must be populated in order to send to Azure.
25+
26+
:param _type: Required. Constant filled by server.
2527
:type _type: str
2628
:ivar id: A String identifier.
2729
:vartype id: str
@@ -75,8 +77,8 @@ class CreativeWork(Thing):
7577
'_type': {'WebPage': 'WebPage'}
7678
}
7779

78-
def __init__(self):
79-
super(CreativeWork, self).__init__()
80+
def __init__(self, **kwargs):
81+
super(CreativeWork, self).__init__(**kwargs)
8082
self.thumbnail_url = None
8183
self.provider = None
8284
self.text = None
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for
5+
# license information.
6+
#
7+
# Code generated by Microsoft (R) AutoRest Code Generator.
8+
# Changes may cause incorrect behavior and will be lost if the code is
9+
# regenerated.
10+
# --------------------------------------------------------------------------
11+
12+
from .thing_py3 import Thing
13+
14+
15+
class CreativeWork(Thing):
16+
"""CreativeWork.
17+
18+
You probably want to use the sub-classes and not this class directly. Known
19+
sub-classes are: WebPage
20+
21+
Variables are only populated by the server, and will be ignored when
22+
sending a request.
23+
24+
All required parameters must be populated in order to send to Azure.
25+
26+
:param _type: Required. Constant filled by server.
27+
:type _type: str
28+
:ivar id: A String identifier.
29+
:vartype id: str
30+
:ivar web_search_url: The URL To Bing's search result for this item.
31+
:vartype web_search_url: str
32+
:ivar name: The name of the thing represented by this object.
33+
:vartype name: str
34+
:ivar url: The URL to get more information about the thing represented by
35+
this object.
36+
:vartype url: str
37+
:ivar description: A short description of the item.
38+
:vartype description: str
39+
:ivar bing_id: An ID that uniquely identifies this item.
40+
:vartype bing_id: str
41+
:ivar thumbnail_url: The URL to a thumbnail of the item.
42+
:vartype thumbnail_url: str
43+
:ivar provider: The source of the creative work.
44+
:vartype provider:
45+
list[~azure.cognitiveservices.search.customsearch.models.Thing]
46+
:ivar text:
47+
:vartype text: str
48+
"""
49+
50+
_validation = {
51+
'_type': {'required': True},
52+
'id': {'readonly': True},
53+
'web_search_url': {'readonly': True},
54+
'name': {'readonly': True},
55+
'url': {'readonly': True},
56+
'description': {'readonly': True},
57+
'bing_id': {'readonly': True},
58+
'thumbnail_url': {'readonly': True},
59+
'provider': {'readonly': True},
60+
'text': {'readonly': True},
61+
}
62+
63+
_attribute_map = {
64+
'_type': {'key': '_type', 'type': 'str'},
65+
'id': {'key': 'id', 'type': 'str'},
66+
'web_search_url': {'key': 'webSearchUrl', 'type': 'str'},
67+
'name': {'key': 'name', 'type': 'str'},
68+
'url': {'key': 'url', 'type': 'str'},
69+
'description': {'key': 'description', 'type': 'str'},
70+
'bing_id': {'key': 'bingId', 'type': 'str'},
71+
'thumbnail_url': {'key': 'thumbnailUrl', 'type': 'str'},
72+
'provider': {'key': 'provider', 'type': '[Thing]'},
73+
'text': {'key': 'text', 'type': 'str'},
74+
}
75+
76+
_subtype_map = {
77+
'_type': {'WebPage': 'WebPage'}
78+
}
79+
80+
def __init__(self, **kwargs) -> None:
81+
super(CreativeWork, self).__init__(**kwargs)
82+
self.thumbnail_url = None
83+
self.provider = None
84+
self.text = None
85+
self._type = 'CreativeWork'
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from enum import Enum
1313

1414

15-
class ErrorCode(Enum):
15+
class ErrorCode(str, Enum):
1616

1717
none = "None"
1818
server_error = "ServerError"
@@ -22,7 +22,7 @@ class ErrorCode(Enum):
2222
insufficient_authorization = "InsufficientAuthorization"
2323

2424

25-
class ErrorSubCode(Enum):
25+
class ErrorSubCode(str, Enum):
2626

2727
unexpected_error = "UnexpectedError"
2828
resource_error = "ResourceError"
@@ -37,14 +37,14 @@ class ErrorSubCode(Enum):
3737
authorization_expired = "AuthorizationExpired"
3838

3939

40-
class SafeSearch(Enum):
40+
class SafeSearch(str, Enum):
4141

4242
off = "Off"
4343
moderate = "Moderate"
4444
strict = "Strict"
4545

4646

47-
class TextFormat(Enum):
47+
class TextFormat(str, Enum):
4848

4949
raw = "Raw"
5050
html = "Html"

0 commit comments

Comments
 (0)