Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
# regenerated.
# --------------------------------------------------------------------------

from .visual_search_api import VisualSearchAPI
from .visual_search_client import VisualSearchClient
from .version import VERSION

__all__ = ['VisualSearchAPI']
__all__ = ['VisualSearchClient']

__version__ = VERSION

Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
from .filters import Filters
from .knowledge_request import KnowledgeRequest
from .visual_search_request import VisualSearchRequest
from .visual_search_api_enums import (
from .visual_search_client_enums import (
Currency,
ItemAvailability,
ErrorCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ImageObject(MediaObject):
image is of an apple pie, this object includes a count of the number of
websites where you can buy an apple pie. To indicate the number of offers
in your UX, include badging such as a shopping cart icon that contains the
count. When the user clicks on the icon, use imageInisghtsToken in a
count. When the user clicks on the icon, use imageInsightsToken in a
subsequent Visual Search API call to get the list of shopping websites.
:vartype insights_metadata:
~azure.cognitiveservices.search.visualsearch.models.ImagesImageMetadata
Expand All @@ -93,7 +93,7 @@ class ImageObject(MediaObject):
color that dominates the image. Use the color as the temporary background
in your client until the image is loaded.
:vartype accent_color: str
:ivar visual_words: For interal use only.
:ivar visual_words: For internal use only.
:vartype visual_words: str
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ImageObject(MediaObject):
image is of an apple pie, this object includes a count of the number of
websites where you can buy an apple pie. To indicate the number of offers
in your UX, include badging such as a shopping cart icon that contains the
count. When the user clicks on the icon, use imageInisghtsToken in a
count. When the user clicks on the icon, use imageInsightsToken in a
subsequent Visual Search API call to get the list of shopping websites.
:vartype insights_metadata:
~azure.cognitiveservices.search.visualsearch.models.ImagesImageMetadata
Expand All @@ -93,7 +93,7 @@ class ImageObject(MediaObject):
color that dominates the image. Use the color as the temporary background
in your client until the image is loaded.
:vartype accent_color: str
:ivar visual_words: For interal use only.
:ivar visual_words: For internal use only.
:vartype visual_words: str
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ def visual_search(
"""
# Construct URL
url = self.visual_search.metadata['url']
path_format_arguments = {
'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True)
}
url = self._client.format_url(url, **path_format_arguments)

# Construct parameters
query_parameters = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
# regenerated.
# --------------------------------------------------------------------------

VERSION = "0.2.0"
VERSION = "1.0"

Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,60 @@
from . import models


class VisualSearchAPIConfiguration(Configuration):
"""Configuration for VisualSearchAPI
class VisualSearchClientConfiguration(Configuration):
"""Configuration for VisualSearchClient
Note that all parameters used to create this instance are saved as instance
attributes.

:param endpoint: Supported Cognitive Services endpoints (protocol and
hostname, for example: "https://westus.api.cognitive.microsoft.com",
"https://api.cognitive.microsoft.com").
:type endpoint: str
:param credentials: Subscription credentials which uniquely identify
client subscription.
:type credentials: None
:param str base_url: Service URL
"""

def __init__(
self, credentials, base_url=None):
self, endpoint, credentials):

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
if credentials is None:
raise ValueError("Parameter 'credentials' must not be None.")
if not base_url:
base_url = 'https://api.cognitive.microsoft.com/bing/v7.0'
base_url = '{Endpoint}/bing/v7.0'

super(VisualSearchAPIConfiguration, self).__init__(base_url)
super(VisualSearchClientConfiguration, self).__init__(base_url)

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

self.endpoint = endpoint
self.credentials = credentials


class VisualSearchAPI(SDKClient):
class VisualSearchClient(SDKClient):
"""Visual Search API lets you discover insights about an image such as visually similar images, shopping sources, and related searches. The API can also perform text recognition, identify entities (people, places, things), return other topical content for the user to explore, and more. For more information, see [Visual Search Overview](https://docs.microsoft.com/azure/cognitive-services/bing-visual-search/overview).

:ivar config: Configuration for client.
:vartype config: VisualSearchAPIConfiguration
:vartype config: VisualSearchClientConfiguration

:ivar images: Images operations
:vartype images: azure.cognitiveservices.search.visualsearch.operations.ImagesOperations

:param endpoint: Supported Cognitive Services endpoints (protocol and
hostname, for example: "https://westus.api.cognitive.microsoft.com",
"https://api.cognitive.microsoft.com").
:type endpoint: str
:param credentials: Subscription credentials which uniquely identify
client subscription.
:type credentials: None
:param str base_url: Service URL
"""

def __init__(
self, credentials, base_url=None):
self, endpoint, credentials):

self.config = VisualSearchAPIConfiguration(credentials, base_url)
super(VisualSearchAPI, self).__init__(self.config.credentials, self.config)
self.config = VisualSearchClientConfiguration(endpoint, credentials)
super(VisualSearchClient, 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