ProductSearchAsyncClient(*, credentials: typing.Optional[google.auth.credentials.Credentials] = None, transport: typing.Union[str, google.cloud.vision_v1p3beta1.services.product_search.transports.base.ProductSearchTransport] = 'grpc_asyncio', client_options: typing.Optional[google.api_core.client_options.ClientOptions] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)
Manages Products and ProductSets of reference images for use in product search. It uses the following resource model:
- The API has a collection of
ProductSet resources,
named
projects/*/locations/*/productSets/*
, which acts as a way to put different products into groups to limit identification.
In parallel,
The API has a collection of Product resources, named
projects/*/locations/*/products/*
Each Product has a collection of ReferenceImage resources, named
projects/*/locations/*/products/*/referenceImages/*
Properties
transport
Returns the transport used by the client instance.
Returns | |
---|---|
Type | Description |
ProductSearchTransport | The transport used by the client instance. |
Methods
ProductSearchAsyncClient
ProductSearchAsyncClient(*, credentials: typing.Optional[google.auth.credentials.Credentials] = None, transport: typing.Union[str, google.cloud.vision_v1p3beta1.services.product_search.transports.base.ProductSearchTransport] = 'grpc_asyncio', client_options: typing.Optional[google.api_core.client_options.ClientOptions] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)
Instantiates the product search client.
Parameters | |
---|---|
Name | Description |
credentials |
Optional[google.auth.credentials.Credentials]
The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. |
transport |
Union[str,
The transport to use. If set to None, a transport is chosen automatically. |
client_options |
ClientOptions
Custom options for the client. It won't take effect if a |
Exceptions | |
---|---|
Type | Description |
google.auth.exceptions.MutualTlsChannelError | If mutual TLS transport creation failed for any reason. |
add_product_to_product_set
add_product_to_product_set(
request: typing.Optional[
typing.Union[
google.cloud.vision_v1p3beta1.types.product_search_service.AddProductToProductSetRequest,
dict,
]
] = None,
*,
name: typing.Optional[str] = None,
product: typing.Optional[str] = None,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> None
Adds a Product to the specified ProductSet. If the Product is already present, no change is made.
One Product can be added to at most 100 ProductSets.
Possible errors:
- Returns NOT_FOUND if the Product or the ProductSet doesn't exist.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import vision_v1p3beta1
async def sample_add_product_to_product_set():
# Create a client
client = vision_v1p3beta1.ProductSearchAsyncClient()
# Initialize request argument(s)
request = vision_v1p3beta1.AddProductToProductSetRequest(
name="name_value",
product="product_value",
)
# Make the request
await client.add_product_to_product_set(request=request)
Parameters | |
---|---|
Name | Description |
request |
Optional[Union[google.cloud.vision_v1p3beta1.types.AddProductToProductSetRequest, dict]]
The request object. Request message for the |
name |
Required. The resource name for the ProductSet to modify. Format is: |
product |
Required. The resource name for the Product to be added to this ProductSet. Format is: |
retry |
google.api_core.retry.Retry
Designation of what errors, if any, should be retried. |
timeout |
float
The timeout for this request. |
metadata |
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
common_billing_account_path
common_billing_account_path(billing_account: str) -> str
Returns a fully-qualified billing_account string.
common_folder_path
common_folder_path(folder: str) -> str
Returns a fully-qualified folder string.
common_location_path
common_location_path(project: str, location: str) -> str
Returns a fully-qualified location string.
common_organization_path
common_organization_path(organization: str) -> str
Returns a fully-qualified organization string.
common_project_path
common_project_path(project: str) -> str
Returns a fully-qualified project string.
create_product
create_product(
request: typing.Optional[
typing.Union[
google.cloud.vision_v1p3beta1.types.product_search_service.CreateProductRequest,
dict,
]
] = None,
*,
parent: typing.Optional[str] = None,
product: typing.Optional[
google.cloud.vision_v1p3beta1.types.product_search_service.Product
] = None,
product_id: typing.Optional[str] = None,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.vision_v1p3beta1.types.product_search_service.Product
Creates and returns a new product resource.
Possible errors:
- Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters.
- Returns INVALID_ARGUMENT if description is longer than 4096 characters.
- Returns INVALID_ARGUMENT if product_category is missing or invalid.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import vision_v1p3beta1
async def sample_create_product():
# Create a client
client = vision_v1p3beta1.ProductSearchAsyncClient()
# Initialize request argument(s)
request = vision_v1p3beta1.CreateProductRequest(
parent="parent_value",
)
# Make the request
response = await client.create_product(request=request)
# Handle the response
print(response)
Parameters | |
---|---|
Name | Description |
request |
Optional[Union[google.cloud.vision_v1p3beta1.types.CreateProductRequest, dict]]
The request object. Request message for the |
parent |
Required. The project in which the Product should be created. Format is |
product |
Product
Required. The product to create. This corresponds to the |
product_id |
A user-supplied resource id for this Product. If set, the server will attempt to use this value as the resource id. If it is already in use, an error is returned with code ALREADY_EXISTS. Must be at most 128 characters long. It cannot contain the character |
retry |
google.api_core.retry.Retry
Designation of what errors, if any, should be retried. |
timeout |
float
The timeout for this request. |
metadata |
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
Type | Description |
google.cloud.vision_v1p3beta1.types.Product | A Product contains ReferenceImages. |
create_product_set
create_product_set(
request: typing.Optional[
typing.Union[
google.cloud.vision_v1p3beta1.types.product_search_service.CreateProductSetRequest,
dict,
]
] = None,
*,
parent: typing.Optional[str] = None,
product_set: typing.Optional[
google.cloud.vision_v1p3beta1.types.product_search_service.ProductSet
] = None,
product_set_id: typing.Optional[str] = None,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.vision_v1p3beta1.types.product_search_service.ProductSet
Creates and returns a new ProductSet resource.
Possible errors:
- Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import vision_v1p3beta1
async def sample_create_product_set():
# Create a client
client = vision_v1p3beta1.ProductSearchAsyncClient()
# Initialize request argument(s)
request = vision_v1p3beta1.CreateProductSetRequest(
parent="parent_value",
)
# Make the request
response = await client.create_product_set(request=request)
# Handle the response
print(response)
Parameters | |
---|---|
Name | Description |
request |
Optional[Union[google.cloud.vision_v1p3beta1.types.CreateProductSetRequest, dict]]
The request object. Request message for the |
parent |
Required. The project in which the ProductSet should be created. Format is |
product_set |
ProductSet
Required. The ProductSet to create. This corresponds to the |
product_set_id |
A user-supplied resource id for this ProductSet. If set, the server will attempt to use this value as the resource id. If it is already in use, an error is returned with code ALREADY_EXISTS. Must be at most 128 characters long. It cannot contain the character |
retry |
google.api_core.retry.Retry
Designation of what errors, if any, should be retried. |
timeout |
float
The timeout for this request. |
metadata |
Sequence[Tuple[str, str]]
Strings which should be sent along with the request as metadata. |
Returns | |
---|---|
Type | Description |
google.cloud.vision_v1p3beta1.types.ProductSet | A ProductSet contains Products. A ProductSet can contain a maximum of 1 million reference images. If the limit is exceeded, periodic indexing will fail. |
create_reference_image
create_reference_image(
request: typing.Optional[
typing.Union[
google.cloud.vision_v1p3beta1.types.product_search_service.CreateReferenceImageRequest,
dict,
]
] = None,
*,
parent: typing.Optional[str] = None,
reference_image: typing.Optional[
google.cloud.vision_v1p3beta1.types.product_search_service.ReferenceImage
] = None,
reference_image_id: typing.Optional[str] = None,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.vision_v1p3beta1.types.product_search_service.ReferenceImage
Creates and returns a new ReferenceImage resource.
The bounding_poly
field is optional. If bounding_poly
is
not specified, the system will try to detect regions of interest
in the image that are compatible with the product_category on
the parent product. If it is specified, detection is ALWAYS
skipped. The system converts polygons into non-rotated
rectangles.
Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP).
Possible errors:
- Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters.
- Returns INVALID_ARGUMENT if the product does not exist.
- Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected.
- Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import vision_v1p3beta1
async def sample_create_reference_image():
# Create a client
client = vision_v1p3beta1.ProductSearchAsyncClient()
# Initialize request argument(s)
reference_image = vision_v1p3beta1.ReferenceImage()
reference_image.uri = "uri_value"
request = vision_v1p3beta1.CreateReferenceImageRequest(
parent="parent_value",
reference_image=reference_image,
)
# Make the request
response = await client.create_reference_image(request=request)
# Handle the response
print(response)
Parameters | |
---|---|
Name | Description |
request |
Optional[Union[google.cloud.vision_v1p3beta1.types.CreateReferenceImageRequest, dict]]
The request object. Request message for the |
parent |
Required. Resource name of the product in which to create the reference image. Format is |
reference_image |
ReferenceImage
Required. The reference image to create. If an image ID is specified, it is ignored. This corresponds to the |