Class CloudVisionAutoConfiguration
java.lang.Object
com.google.cloud.spring.autoconfigure.vision.CloudVisionAutoConfiguration
@AutoConfiguration
@EnableConfigurationProperties(CloudVisionProperties.class)
@ConditionalOnClass(CloudVisionTemplate.class)
@ConditionalOnProperty(value="spring.cloud.gcp.vision.enabled",
matchIfMissing=true)
public class CloudVisionAutoConfiguration
extends Object
Provides Spring Beans for using Cloud Vision API.
- Since:
- 1.1
-
Constructor Summary
ConstructorDescriptionCloudVisionAutoConfiguration
(CloudVisionProperties properties, com.google.api.gax.core.CredentialsProvider credentialsProvider) -
Method Summary
Modifier and TypeMethodDescriptioncloudVisionTemplate
(com.google.cloud.vision.v1.ImageAnnotatorClient imageAnnotatorClient) com.google.cloud.vision.v1.ImageAnnotatorClient
Configure the Cloud Vision API clientImageAnnotatorClient
.
-
Constructor Details
-
CloudVisionAutoConfiguration
public CloudVisionAutoConfiguration(CloudVisionProperties properties, com.google.api.gax.core.CredentialsProvider credentialsProvider) throws IOException - Throws:
IOException
-
-
Method Details
-
imageAnnotatorClient
@Bean @ConditionalOnMissingBean public com.google.cloud.vision.v1.ImageAnnotatorClient imageAnnotatorClient() throws IOExceptionConfigure the Cloud Vision API clientImageAnnotatorClient
. The spring-cloud-gcp-starter autowires aCredentialsProvider
object that provides the GCP credentials, required to authenticate and authorize Vision API calls.Cloud Vision API client implements
AutoCloseable
, which is automatically honored by Spring bean lifecycle.Most of the Google Cloud API clients are thread-safe heavy objects. I.e., it's better to produce a singleton and re-using the client object for multiple requests.
- Returns:
- a Cloud Vision API client
- Throws:
IOException
- if an exception occurs creating the ImageAnnotatorClient
-
cloudVisionTemplate
@Bean @ConditionalOnMissingBean public CloudVisionTemplate cloudVisionTemplate(com.google.cloud.vision.v1.ImageAnnotatorClient imageAnnotatorClient) -
cloudVisionExecutor
-