Class: Google::Cloud::Vision::Service
- Inherits:
-
Object
- Object
- Google::Cloud::Vision::Service
- Defined in:
- lib/google/cloud/vision/service.rb
Overview
Represents the service to Vision, exposing the API calls.
Instance Attribute Summary collapse
-
#client_config ⇒ Object
Returns the value of attribute client_config.
-
#credentials ⇒ Object
Returns the value of attribute credentials.
-
#host ⇒ Object
Returns the value of attribute host.
-
#mocked_service ⇒ Object
Returns the value of attribute mocked_service.
-
#project ⇒ Object
Returns the value of attribute project.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#annotate(requests) ⇒ Object
Returns API::BatchAnnotateImagesResponse.
- #chan_creds ⇒ Object
- #channel ⇒ Object
-
#initialize(project, credentials, host: nil, timeout: nil, client_config: nil) ⇒ Service
constructor
Creates a new Service instance.
- #insecure? ⇒ Boolean
- #inspect ⇒ Object
- #service ⇒ Object
Constructor Details
#initialize(project, credentials, host: nil, timeout: nil, client_config: nil) ⇒ Service
Creates a new Service instance.
32 33 34 35 36 37 38 39 |
# File 'lib/google/cloud/vision/service.rb', line 32 def initialize project, credentials, host: nil, timeout: nil, client_config: nil @project = project @credentials = credentials @host = host || V1::ImageAnnotatorApi::SERVICE_ADDRESS @timeout = timeout @client_config = client_config || {} end |
Instance Attribute Details
#client_config ⇒ Object
Returns the value of attribute client_config.
28 29 30 |
# File 'lib/google/cloud/vision/service.rb', line 28 def client_config @client_config end |
#credentials ⇒ Object
Returns the value of attribute credentials.
28 29 30 |
# File 'lib/google/cloud/vision/service.rb', line 28 def credentials @credentials end |
#host ⇒ Object
Returns the value of attribute host.
28 29 30 |
# File 'lib/google/cloud/vision/service.rb', line 28 def host @host end |
#mocked_service ⇒ Object
Returns the value of attribute mocked_service.
64 65 66 |
# File 'lib/google/cloud/vision/service.rb', line 64 def mocked_service @mocked_service end |
#project ⇒ Object
Returns the value of attribute project.
28 29 30 |
# File 'lib/google/cloud/vision/service.rb', line 28 def project @project end |
#timeout ⇒ Object
Returns the value of attribute timeout.
28 29 30 |
# File 'lib/google/cloud/vision/service.rb', line 28 def timeout @timeout end |
Instance Method Details
#annotate(requests) ⇒ Object
Returns API::BatchAnnotateImagesResponse
72 73 74 75 76 |
# File 'lib/google/cloud/vision/service.rb', line 72 def annotate requests execute do service.batch_annotate_images requests, options: end end |
#chan_creds ⇒ Object
46 47 48 49 50 51 |
# File 'lib/google/cloud/vision/service.rb', line 46 def chan_creds return credentials if insecure? require "grpc" GRPC::Core::ChannelCredentials.new.compose \ GRPC::Core::CallCredentials.new credentials.client.updater_proc end |
#channel ⇒ Object
41 42 43 44 |
# File 'lib/google/cloud/vision/service.rb', line 41 def channel require "grpc" GRPC::Core::Channel.new host, nil, chan_creds end |
#insecure? ⇒ Boolean
66 67 68 |
# File 'lib/google/cloud/vision/service.rb', line 66 def insecure? credentials == :this_channel_is_insecure end |
#inspect ⇒ Object
78 79 80 |
# File 'lib/google/cloud/vision/service.rb', line 78 def inspect "#{self.class}(#{@project})" end |
#service ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/google/cloud/vision/service.rb', line 53 def service return mocked_service if mocked_service @service ||= \ V1::ImageAnnotatorApi.new( service_path: host, channel: channel, timeout: timeout, client_config: client_config, app_name: "gcloud-ruby", app_version: Google::Cloud::Vision::VERSION) end |