google-cloud-video_intelligence 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -7
- data/lib/google/cloud/video_intelligence.rb +109 -0
- data/lib/google/cloud/video_intelligence/credentials.rb +29 -0
- data/lib/google/cloud/video_intelligence/v1beta1/video_intelligence_service_client.rb +1 -1
- data/lib/google/cloud/video_intelligence/v1beta2.rb +100 -0
- data/lib/google/cloud/video_intelligence/v1beta2/doc/google/cloud/videointelligence/v1beta2/video_intelligence.rb +370 -0
- data/lib/google/cloud/video_intelligence/v1beta2/doc/google/protobuf/any.rb +114 -0
- data/lib/google/cloud/video_intelligence/v1beta2/doc/google/protobuf/duration.rb +77 -0
- data/lib/google/cloud/video_intelligence/v1beta2/doc/google/rpc/status.rb +83 -0
- data/lib/google/cloud/video_intelligence/v1beta2/video_intelligence_service_client.rb +285 -0
- data/lib/google/cloud/video_intelligence/v1beta2/video_intelligence_service_client_config.json +31 -0
- data/lib/google/cloud/videointelligence/v1beta2/video_intelligence_pb.rb +166 -0
- data/lib/google/cloud/videointelligence/v1beta2/video_intelligence_services_pb.rb +48 -0
- metadata +58 -5
@@ -0,0 +1,114 @@
|
|
1
|
+
# Copyright 2017, Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Protobuf
|
17
|
+
# +Any+ contains an arbitrary serialized protocol buffer message along with a
|
18
|
+
# URL that describes the type of the serialized message.
|
19
|
+
#
|
20
|
+
# Protobuf library provides support to pack/unpack Any values in the form
|
21
|
+
# of utility functions or additional generated methods of the Any type.
|
22
|
+
#
|
23
|
+
# Example 1: Pack and unpack a message in C++.
|
24
|
+
#
|
25
|
+
# Foo foo = ...;
|
26
|
+
# Any any;
|
27
|
+
# any.PackFrom(foo);
|
28
|
+
# ...
|
29
|
+
# if (any.UnpackTo(&foo)) {
|
30
|
+
# ...
|
31
|
+
# }
|
32
|
+
#
|
33
|
+
# Example 2: Pack and unpack a message in Java.
|
34
|
+
#
|
35
|
+
# Foo foo = ...;
|
36
|
+
# Any any = Any.pack(foo);
|
37
|
+
# ...
|
38
|
+
# if (any.is(Foo.class)) {
|
39
|
+
# foo = any.unpack(Foo.class);
|
40
|
+
# }
|
41
|
+
#
|
42
|
+
# Example 3: Pack and unpack a message in Python.
|
43
|
+
#
|
44
|
+
# foo = Foo(...)
|
45
|
+
# any = Any()
|
46
|
+
# any.Pack(foo)
|
47
|
+
# ...
|
48
|
+
# if any.Is(Foo.DESCRIPTOR):
|
49
|
+
# any.Unpack(foo)
|
50
|
+
# ...
|
51
|
+
#
|
52
|
+
# The pack methods provided by protobuf library will by default use
|
53
|
+
# 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
54
|
+
# methods only use the fully qualified type name after the last '/'
|
55
|
+
# in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
56
|
+
# name "y.z".
|
57
|
+
#
|
58
|
+
#
|
59
|
+
# = JSON
|
60
|
+
#
|
61
|
+
# The JSON representation of an +Any+ value uses the regular
|
62
|
+
# representation of the deserialized, embedded message, with an
|
63
|
+
# additional field +@type+ which contains the type URL. Example:
|
64
|
+
#
|
65
|
+
# package google.profile;
|
66
|
+
# message Person {
|
67
|
+
# string first_name = 1;
|
68
|
+
# string last_name = 2;
|
69
|
+
# }
|
70
|
+
#
|
71
|
+
# {
|
72
|
+
# "@type": "type.googleapis.com/google.profile.Person",
|
73
|
+
# "firstName": <string>,
|
74
|
+
# "lastName": <string>
|
75
|
+
# }
|
76
|
+
#
|
77
|
+
# If the embedded message type is well-known and has a custom JSON
|
78
|
+
# representation, that representation will be embedded adding a field
|
79
|
+
# +value+ which holds the custom JSON in addition to the +@type+
|
80
|
+
# field. Example (for message {Google::Protobuf::Duration}):
|
81
|
+
#
|
82
|
+
# {
|
83
|
+
# "@type": "type.googleapis.com/google.protobuf.Duration",
|
84
|
+
# "value": "1.212s"
|
85
|
+
# }
|
86
|
+
# @!attribute [rw] type_url
|
87
|
+
# @return [String]
|
88
|
+
# A URL/resource name whose content describes the type of the
|
89
|
+
# serialized protocol buffer message.
|
90
|
+
#
|
91
|
+
# For URLs which use the scheme +http+, +https+, or no scheme, the
|
92
|
+
# following restrictions and interpretations apply:
|
93
|
+
#
|
94
|
+
# * If no scheme is provided, +https+ is assumed.
|
95
|
+
# * The last segment of the URL's path must represent the fully
|
96
|
+
# qualified name of the type (as in +path/google.protobuf.Duration+).
|
97
|
+
# The name should be in a canonical form (e.g., leading "." is
|
98
|
+
# not accepted).
|
99
|
+
# * An HTTP GET on the URL must yield a {Google::Protobuf::Type}
|
100
|
+
# value in binary format, or produce an error.
|
101
|
+
# * Applications are allowed to cache lookup results based on the
|
102
|
+
# URL, or have them precompiled into a binary to avoid any
|
103
|
+
# lookup. Therefore, binary compatibility needs to be preserved
|
104
|
+
# on changes to types. (Use versioned type names to manage
|
105
|
+
# breaking changes.)
|
106
|
+
#
|
107
|
+
# Schemes other than +http+, +https+ (or the empty scheme) might be
|
108
|
+
# used with implementation specific semantics.
|
109
|
+
# @!attribute [rw] value
|
110
|
+
# @return [String]
|
111
|
+
# Must be a valid serialized protocol buffer of the above specified type.
|
112
|
+
class Any; end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# Copyright 2017, Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Protobuf
|
17
|
+
# A Duration represents a signed, fixed-length span of time represented
|
18
|
+
# as a count of seconds and fractions of seconds at nanosecond
|
19
|
+
# resolution. It is independent of any calendar and concepts like "day"
|
20
|
+
# or "month". It is related to Timestamp in that the difference between
|
21
|
+
# two Timestamp values is a Duration and it can be added or subtracted
|
22
|
+
# from a Timestamp. Range is approximately +-10,000 years.
|
23
|
+
#
|
24
|
+
# Example 1: Compute Duration from two Timestamps in pseudo code.
|
25
|
+
#
|
26
|
+
# Timestamp start = ...;
|
27
|
+
# Timestamp end = ...;
|
28
|
+
# Duration duration = ...;
|
29
|
+
#
|
30
|
+
# duration.seconds = end.seconds - start.seconds;
|
31
|
+
# duration.nanos = end.nanos - start.nanos;
|
32
|
+
#
|
33
|
+
# if (duration.seconds < 0 && duration.nanos > 0) {
|
34
|
+
# duration.seconds += 1;
|
35
|
+
# duration.nanos -= 1000000000;
|
36
|
+
# } else if (durations.seconds > 0 && duration.nanos < 0) {
|
37
|
+
# duration.seconds -= 1;
|
38
|
+
# duration.nanos += 1000000000;
|
39
|
+
# }
|
40
|
+
#
|
41
|
+
# Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
|
42
|
+
#
|
43
|
+
# Timestamp start = ...;
|
44
|
+
# Duration duration = ...;
|
45
|
+
# Timestamp end = ...;
|
46
|
+
#
|
47
|
+
# end.seconds = start.seconds + duration.seconds;
|
48
|
+
# end.nanos = start.nanos + duration.nanos;
|
49
|
+
#
|
50
|
+
# if (end.nanos < 0) {
|
51
|
+
# end.seconds -= 1;
|
52
|
+
# end.nanos += 1000000000;
|
53
|
+
# } else if (end.nanos >= 1000000000) {
|
54
|
+
# end.seconds += 1;
|
55
|
+
# end.nanos -= 1000000000;
|
56
|
+
# }
|
57
|
+
#
|
58
|
+
# Example 3: Compute Duration from datetime.timedelta in Python.
|
59
|
+
#
|
60
|
+
# td = datetime.timedelta(days=3, minutes=10)
|
61
|
+
# duration = Duration()
|
62
|
+
# duration.FromTimedelta(td)
|
63
|
+
# @!attribute [rw] seconds
|
64
|
+
# @return [Integer]
|
65
|
+
# Signed seconds of the span of time. Must be from -315,576,000,000
|
66
|
+
# to +315,576,000,000 inclusive.
|
67
|
+
# @!attribute [rw] nanos
|
68
|
+
# @return [Integer]
|
69
|
+
# Signed fractions of a second at nanosecond resolution of the span
|
70
|
+
# of time. Durations less than one second are represented with a 0
|
71
|
+
# +seconds+ field and a positive or negative +nanos+ field. For durations
|
72
|
+
# of one second or more, a non-zero value for the +nanos+ field must be
|
73
|
+
# of the same sign as the +seconds+ field. Must be from -999,999,999
|
74
|
+
# to +999,999,999 inclusive.
|
75
|
+
class Duration; end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# Copyright 2017, Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Rpc
|
17
|
+
# The +Status+ type defines a logical error model that is suitable for different
|
18
|
+
# programming environments, including REST APIs and RPC APIs. It is used by
|
19
|
+
# [gRPC](https://github.com/grpc). The error model is designed to be:
|
20
|
+
#
|
21
|
+
# * Simple to use and understand for most users
|
22
|
+
# * Flexible enough to meet unexpected needs
|
23
|
+
#
|
24
|
+
# = Overview
|
25
|
+
#
|
26
|
+
# The +Status+ message contains three pieces of data: error code, error message,
|
27
|
+
# and error details. The error code should be an enum value of
|
28
|
+
# {Google::Rpc::Code}, but it may accept additional error codes if needed. The
|
29
|
+
# error message should be a developer-facing English message that helps
|
30
|
+
# developers *understand* and *resolve* the error. If a localized user-facing
|
31
|
+
# error message is needed, put the localized message in the error details or
|
32
|
+
# localize it in the client. The optional error details may contain arbitrary
|
33
|
+
# information about the error. There is a predefined set of error detail types
|
34
|
+
# in the package +google.rpc+ which can be used for common error conditions.
|
35
|
+
#
|
36
|
+
# = Language mapping
|
37
|
+
#
|
38
|
+
# The +Status+ message is the logical representation of the error model, but it
|
39
|
+
# is not necessarily the actual wire format. When the +Status+ message is
|
40
|
+
# exposed in different client libraries and different wire protocols, it can be
|
41
|
+
# mapped differently. For example, it will likely be mapped to some exceptions
|
42
|
+
# in Java, but more likely mapped to some error codes in C.
|
43
|
+
#
|
44
|
+
# = Other uses
|
45
|
+
#
|
46
|
+
# The error model and the +Status+ message can be used in a variety of
|
47
|
+
# environments, either with or without APIs, to provide a
|
48
|
+
# consistent developer experience across different environments.
|
49
|
+
#
|
50
|
+
# Example uses of this error model include:
|
51
|
+
#
|
52
|
+
# * Partial errors. If a service needs to return partial errors to the client,
|
53
|
+
# it may embed the +Status+ in the normal response to indicate the partial
|
54
|
+
# errors.
|
55
|
+
#
|
56
|
+
# * Workflow errors. A typical workflow has multiple steps. Each step may
|
57
|
+
# have a +Status+ message for error reporting purpose.
|
58
|
+
#
|
59
|
+
# * Batch operations. If a client uses batch request and batch response, the
|
60
|
+
# +Status+ message should be used directly inside batch response, one for
|
61
|
+
# each error sub-response.
|
62
|
+
#
|
63
|
+
# * Asynchronous operations. If an API call embeds asynchronous operation
|
64
|
+
# results in its response, the status of those operations should be
|
65
|
+
# represented directly using the +Status+ message.
|
66
|
+
#
|
67
|
+
# * Logging. If some API errors are stored in logs, the message +Status+ could
|
68
|
+
# be used directly after any stripping needed for security/privacy reasons.
|
69
|
+
# @!attribute [rw] code
|
70
|
+
# @return [Integer]
|
71
|
+
# The status code, which should be an enum value of {Google::Rpc::Code}.
|
72
|
+
# @!attribute [rw] message
|
73
|
+
# @return [String]
|
74
|
+
# A developer-facing error message, which should be in English. Any
|
75
|
+
# user-facing error message should be localized and sent in the
|
76
|
+
# {Google::Rpc::Status#details} field, or localized by the client.
|
77
|
+
# @!attribute [rw] details
|
78
|
+
# @return [Array<Google::Protobuf::Any>]
|
79
|
+
# A list of messages that carry the error details. There will be a
|
80
|
+
# common set of message types for APIs to use.
|
81
|
+
class Status; end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,285 @@
|
|
1
|
+
# Copyright 2017, Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
#
|
15
|
+
# EDITING INSTRUCTIONS
|
16
|
+
# This file was generated from the file
|
17
|
+
# https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto,
|
18
|
+
# and updates to that file get reflected here through a refresh process.
|
19
|
+
# For the short term, the refresh process will only be runnable by Google
|
20
|
+
# engineers.
|
21
|
+
#
|
22
|
+
# The only allowed edits are to method and file documentation. A 3-way
|
23
|
+
# merge preserves those additions if the generated source changes.
|
24
|
+
|
25
|
+
require "json"
|
26
|
+
require "pathname"
|
27
|
+
|
28
|
+
require "google/gax"
|
29
|
+
require "google/gax/operation"
|
30
|
+
require "google/longrunning/operations_client"
|
31
|
+
|
32
|
+
require "google/cloud/videointelligence/v1beta2/video_intelligence_pb"
|
33
|
+
require "google/cloud/video_intelligence/credentials"
|
34
|
+
|
35
|
+
module Google
|
36
|
+
module Cloud
|
37
|
+
module VideoIntelligence
|
38
|
+
module V1beta2
|
39
|
+
# Service that implements Google Cloud Video Intelligence API.
|
40
|
+
#
|
41
|
+
# @!attribute [r] video_intelligence_service_stub
|
42
|
+
# @return [Google::Cloud::Videointelligence::V1beta2::VideoIntelligenceService::Stub]
|
43
|
+
class VideoIntelligenceServiceClient
|
44
|
+
attr_reader :video_intelligence_service_stub
|
45
|
+
|
46
|
+
# The default address of the service.
|
47
|
+
SERVICE_ADDRESS = "videointelligence.googleapis.com".freeze
|
48
|
+
|
49
|
+
# The default port of the service.
|
50
|
+
DEFAULT_SERVICE_PORT = 443
|
51
|
+
|
52
|
+
DEFAULT_TIMEOUT = 30
|
53
|
+
|
54
|
+
# The scopes needed to make gRPC calls to all of the methods defined in
|
55
|
+
# this service.
|
56
|
+
ALL_SCOPES = [
|
57
|
+
"https://www.googleapis.com/auth/cloud-platform"
|
58
|
+
].freeze
|
59
|
+
|
60
|
+
# @param credentials [Google::Gax::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
61
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
62
|
+
# be many types.
|
63
|
+
# A `Google::Gax::Credentials` uses a the properties of its represented keyfile for
|
64
|
+
# authenticating requests made by this client.
|
65
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
66
|
+
# credentials for this client.
|
67
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
68
|
+
# credentials for this client.
|
69
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
70
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
71
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
72
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
73
|
+
# metadata for requests, generally, to give OAuth credentials.
|
74
|
+
# @param scopes [Array<String>]
|
75
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
76
|
+
# an updater_proc is supplied.
|
77
|
+
# @param client_config [Hash]
|
78
|
+
# A Hash for call options for each method. See
|
79
|
+
# Google::Gax#construct_settings for the structure of
|
80
|
+
# this data. Falls back to the default config if not specified
|
81
|
+
# or the specified config is missing data points.
|
82
|
+
# @param timeout [Numeric]
|
83
|
+
# The default timeout, in seconds, for calls made through this client.
|
84
|
+
def initialize \
|
85
|
+
service_path: SERVICE_ADDRESS,
|
86
|
+
port: DEFAULT_SERVICE_PORT,
|
87
|
+
channel: nil,
|
88
|
+
chan_creds: nil,
|
89
|
+
updater_proc: nil,
|
90
|
+
credentials: nil,
|
91
|
+
scopes: ALL_SCOPES,
|
92
|
+
client_config: {},
|
93
|
+
timeout: DEFAULT_TIMEOUT,
|
94
|
+
lib_name: nil,
|
95
|
+
lib_version: ""
|
96
|
+
# These require statements are intentionally placed here to initialize
|
97
|
+
# the gRPC module only when it's required.
|
98
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
99
|
+
require "google/gax/grpc"
|
100
|
+
require "google/cloud/videointelligence/v1beta2/video_intelligence_services_pb"
|
101
|
+
|
102
|
+
if channel || chan_creds || updater_proc
|
103
|
+
warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
|
104
|
+
"on 2017/09/08"
|
105
|
+
credentials ||= channel
|
106
|
+
credentials ||= chan_creds
|
107
|
+
credentials ||= updater_proc
|
108
|
+
end
|
109
|
+
if service_path || port
|
110
|
+
warn "`service_path` and `port` parameters are deprecated and will be removed"
|
111
|
+
end
|
112
|
+
|
113
|
+
credentials ||= Google::Cloud::VideoIntelligence::Credentials.default
|
114
|
+
|
115
|
+
@operations_client = Google::Longrunning::OperationsClient.new(
|
116
|
+
credentials: credentials,
|
117
|
+
scopes: scopes,
|
118
|
+
client_config: client_config,
|
119
|
+
timeout: timeout,
|
120
|
+
lib_name: lib_name,
|
121
|
+
lib_version: lib_version,
|
122
|
+
)
|
123
|
+
|
124
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
125
|
+
updater_proc = Google::Cloud::VideoIntelligence::Credentials.new(credentials).updater_proc
|
126
|
+
end
|
127
|
+
if credentials.is_a?(GRPC::Core::Channel)
|
128
|
+
channel = credentials
|
129
|
+
end
|
130
|
+
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
131
|
+
chan_creds = credentials
|
132
|
+
end
|
133
|
+
if credentials.is_a?(Proc)
|
134
|
+
updater_proc = credentials
|
135
|
+
end
|
136
|
+
if credentials.is_a?(Google::Gax::Credentials)
|
137
|
+
updater_proc = credentials.updater_proc
|
138
|
+
end
|
139
|
+
|
140
|
+
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
141
|
+
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
142
|
+
google_api_client << " gapic/0.6.8 gax/#{Google::Gax::VERSION}"
|
143
|
+
google_api_client << " grpc/#{GRPC::VERSION}"
|
144
|
+
google_api_client.freeze
|
145
|
+
|
146
|
+
headers = { :"x-goog-api-client" => google_api_client }
|
147
|
+
client_config_file = Pathname.new(__dir__).join(
|
148
|
+
"video_intelligence_service_client_config.json"
|
149
|
+
)
|
150
|
+
defaults = client_config_file.open do |f|
|
151
|
+
Google::Gax.construct_settings(
|
152
|
+
"google.cloud.videointelligence.v1beta2.VideoIntelligenceService",
|
153
|
+
JSON.parse(f.read),
|
154
|
+
client_config,
|
155
|
+
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
156
|
+
timeout,
|
157
|
+
errors: Google::Gax::Grpc::API_ERRORS,
|
158
|
+
kwargs: headers
|
159
|
+
)
|
160
|
+
end
|
161
|
+
@video_intelligence_service_stub = Google::Gax::Grpc.create_stub(
|
162
|
+
service_path,
|
163
|
+
port,
|
164
|
+
chan_creds: chan_creds,
|
165
|
+
channel: channel,
|
166
|
+
updater_proc: updater_proc,
|
167
|
+
scopes: scopes,
|
168
|
+
&Google::Cloud::Videointelligence::V1beta2::VideoIntelligenceService::Stub.method(:new)
|
169
|
+
)
|
170
|
+
|
171
|
+
@annotate_video = Google::Gax.create_api_call(
|
172
|
+
@video_intelligence_service_stub.method(:annotate_video),
|
173
|
+
defaults["annotate_video"]
|
174
|
+
)
|
175
|
+
end
|
176
|
+
|
177
|
+
# Service calls
|
178
|
+
|
179
|
+
# Performs asynchronous video annotation. Progress and results can be
|
180
|
+
# retrieved through the +google.longrunning.Operations+ interface.
|
181
|
+
# +Operation.metadata+ contains +AnnotateVideoProgress+ (progress).
|
182
|
+
# +Operation.response+ contains +AnnotateVideoResponse+ (results).
|
183
|
+
#
|
184
|
+
# @param input_uri [String]
|
185
|
+
# Input video location. Currently, only
|
186
|
+
# [Google Cloud Storage](https://cloud.google.com/storage/) URIs are
|
187
|
+
# supported, which must be specified in the following format:
|
188
|
+
# +gs://bucket-id/object-id+ (other URI formats return
|
189
|
+
# {Google::Rpc::Code::INVALID_ARGUMENT}). For more information, see
|
190
|
+
# [Request URIs](https://cloud.google.com/storage/docs/reference-uris).
|
191
|
+
# A video URI may include wildcards in +object-id+, and thus identify
|
192
|
+
# multiple videos. Supported wildcards: '*' to match 0 or more characters;
|
193
|
+
# '?' to match 1 character. If unset, the input video should be embedded
|
194
|
+
# in the request as +input_content+. If set, +input_content+ should be unset.
|
195
|
+
# @param features [Array<Google::Cloud::Videointelligence::V1beta2::Feature>]
|
196
|
+
# Requested video annotation features.
|
197
|
+
# @param input_content [String]
|
198
|
+
# The video data bytes. Encoding: base64. If unset, the input video(s)
|
199
|
+
# should be specified via +input_uri+. If set, +input_uri+ should be unset.
|
200
|
+
# @param video_context [Google::Cloud::Videointelligence::V1beta2::VideoContext | Hash]
|
201
|
+
# Additional video context and/or feature-specific parameters.
|
202
|
+
# A hash of the same form as `Google::Cloud::Videointelligence::V1beta2::VideoContext`
|
203
|
+
# can also be provided.
|
204
|
+
# @param output_uri [String]
|
205
|
+
# Optional location where the output (in JSON format) should be stored.
|
206
|
+
# Currently, only [Google Cloud Storage](https://cloud.google.com/storage/)
|
207
|
+
# URIs are supported, which must be specified in the following format:
|
208
|
+
# +gs://bucket-id/object-id+ (other URI formats return
|
209
|
+
# {Google::Rpc::Code::INVALID_ARGUMENT}). For more information, see
|
210
|
+
# [Request URIs](https://cloud.google.com/storage/docs/reference-uris).
|
211
|
+
# @param location_id [String]
|
212
|
+
# Optional cloud region where annotation should take place. Supported cloud
|
213
|
+
# regions: +us-east1+, +us-west1+, +europe-west1+, +asia-east1+. If no region
|
214
|
+
# is specified, a region will be determined based on video file location.
|
215
|
+
# @param options [Google::Gax::CallOptions]
|
216
|
+
# Overrides the default settings for this call, e.g, timeout,
|
217
|
+
# retries, etc.
|
218
|
+
# @return [Google::Gax::Operation]
|
219
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
220
|
+
# @example
|
221
|
+
# require "google/cloud/video_intelligence/v1beta2"
|
222
|
+
#
|
223
|
+
# video_intelligence_service_client = Google::Cloud::VideoIntelligence::V1beta2.new
|
224
|
+
# input_uri = ''
|
225
|
+
# features = []
|
226
|
+
#
|
227
|
+
# # Register a callback during the method call.
|
228
|
+
# operation = video_intelligence_service_client.annotate_video(input_uri, features) do |op|
|
229
|
+
# raise op.results.message if op.error?
|
230
|
+
# op_results = op.results
|
231
|
+
# # Process the results.
|
232
|
+
#
|
233
|
+
# metadata = op.metadata
|
234
|
+
# # Process the metadata.
|
235
|
+
# end
|
236
|
+
#
|
237
|
+
# # Or use the return value to register a callback.
|
238
|
+
# operation.on_done do |op|
|
239
|
+
# raise op.results.message if op.error?
|
240
|
+
# op_results = op.results
|
241
|
+
# # Process the results.
|
242
|
+
#
|
243
|
+
# metadata = op.metadata
|
244
|
+
# # Process the metadata.
|
245
|
+
# end
|
246
|
+
#
|
247
|
+
# # Manually reload the operation.
|
248
|
+
# operation.reload!
|
249
|
+
#
|
250
|
+
# # Or block until the operation completes, triggering callbacks on
|
251
|
+
# # completion.
|
252
|
+
# operation.wait_until_done!
|
253
|
+
|
254
|
+
def annotate_video \
|
255
|
+
input_uri,
|
256
|
+
features,
|
257
|
+
input_content: nil,
|
258
|
+
video_context: nil,
|
259
|
+
output_uri: nil,
|
260
|
+
location_id: nil,
|
261
|
+
options: nil
|
262
|
+
req = {
|
263
|
+
input_uri: input_uri,
|
264
|
+
features: features,
|
265
|
+
input_content: input_content,
|
266
|
+
video_context: video_context,
|
267
|
+
output_uri: output_uri,
|
268
|
+
location_id: location_id
|
269
|
+
}.delete_if { |_, v| v.nil? }
|
270
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Videointelligence::V1beta2::AnnotateVideoRequest)
|
271
|
+
operation = Google::Gax::Operation.new(
|
272
|
+
@annotate_video.call(req, options),
|
273
|
+
@operations_client,
|
274
|
+
Google::Cloud::Videointelligence::V1beta2::AnnotateVideoResponse,
|
275
|
+
Google::Cloud::Videointelligence::V1beta2::AnnotateVideoProgress,
|
276
|
+
call_options: options
|
277
|
+
)
|
278
|
+
operation.on_done { |operation| yield(operation) } if block_given?
|
279
|
+
operation
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|