本文整理匯總了Python中airflow.contrib.hooks.gcp_vision_hook.CloudVisionHook.get_product方法的典型用法代碼示例。如果您正苦於以下問題:Python CloudVisionHook.get_product方法的具體用法?Python CloudVisionHook.get_product怎麽用?Python CloudVisionHook.get_product使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類airflow.contrib.hooks.gcp_vision_hook.CloudVisionHook
的用法示例。
在下文中一共展示了CloudVisionHook.get_product方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: CloudVisionProductGetOperator
# 需要導入模塊: from airflow.contrib.hooks.gcp_vision_hook import CloudVisionHook [as 別名]
# 或者: from airflow.contrib.hooks.gcp_vision_hook.CloudVisionHook import get_product [as 別名]
class CloudVisionProductGetOperator(BaseOperator):
"""
Gets information associated with a `Product`.
Possible errors:
- Returns NOT_FOUND if the `Product` does not exist.
.. seealso::
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:CloudVisionProductGetOperator`
:param location: (Required) The region where the Product is located. Valid regions (as of 2019-02-05) are:
us-east1, us-west1, europe-west1, asia-east1
:type location: str
:param product_id: (Required) The resource id of this Product.
:type product_id: str
:param project_id: (Optional) The project in which the Product is located. If set to
None or missing, the default project_id from the GCP connection is used.
:type project_id: str
:param retry: (Optional) A retry object used to retry requests. If `None` is
specified, requests will not be retried.
:type retry: google.api_core.retry.Retry
:param timeout: (Optional) The amount of time, in seconds, to wait for the request to
complete. Note that if retry is specified, the timeout applies to each individual
attempt.
:type timeout: float
:param metadata: (Optional) Additional metadata that is provided to the method.
:type metadata: Sequence[Tuple[str, str]]
:param gcp_conn_id: The connection ID used to connect to Google Cloud Platform.
:type gcp_conn_id: str
"""
# [START vision_product_get_template_fields]
template_fields = ('location', 'project_id', 'product_id', 'gcp_conn_id')
# [END vision_product_get_template_fields]
@apply_defaults
def __init__(
self,
location,
product_id,
project_id=None,
retry=None,
timeout=None,
metadata=None,
gcp_conn_id='google_cloud_default',
*args,
**kwargs
):
super(CloudVisionProductGetOperator, self).__init__(*args, **kwargs)
self.location = location
self.product_id = product_id
self.project_id = project_id
self.retry = retry
self.timeout = timeout
self.metadata = metadata
self.gcp_conn_id = gcp_conn_id
self._hook = CloudVisionHook(gcp_conn_id=self.gcp_conn_id)
def execute(self, context):
return self._hook.get_product(
location=self.location,
product_id=self.product_id,
project_id=self.project_id,
retry=self.retry,
timeout=self.timeout,
metadata=self.metadata,
)