google-cloud-video_intelligence 2.1.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/AUTHENTICATION.md +51 -54
  4. data/LICENSE.md +203 -0
  5. data/MIGRATING.md +274 -0
  6. data/README.md +36 -62
  7. data/lib/{google/cloud/video_intelligence/credentials.rb → google-cloud-video_intelligence.rb} +5 -13
  8. data/lib/google/cloud/video_intelligence.rb +87 -156
  9. data/lib/google/cloud/video_intelligence/version.rb +6 -2
  10. metadata +99 -83
  11. data/LICENSE +0 -201
  12. data/lib/google/cloud/video_intelligence/v1.rb +0 -186
  13. data/lib/google/cloud/video_intelligence/v1/credentials.rb +0 -41
  14. data/lib/google/cloud/video_intelligence/v1/doc/google/cloud/videointelligence/v1/video_intelligence.rb +0 -789
  15. data/lib/google/cloud/video_intelligence/v1/doc/google/longrunning/operations.rb +0 -51
  16. data/lib/google/cloud/video_intelligence/v1/doc/google/protobuf/any.rb +0 -131
  17. data/lib/google/cloud/video_intelligence/v1/doc/google/protobuf/duration.rb +0 -91
  18. data/lib/google/cloud/video_intelligence/v1/doc/google/rpc/status.rb +0 -39
  19. data/lib/google/cloud/video_intelligence/v1/video_intelligence_service_client.rb +0 -309
  20. data/lib/google/cloud/video_intelligence/v1/video_intelligence_service_client_config.json +0 -31
  21. data/lib/google/cloud/video_intelligence/v1beta2.rb +0 -149
  22. data/lib/google/cloud/video_intelligence/v1beta2/credentials.rb +0 -41
  23. data/lib/google/cloud/video_intelligence/v1beta2/doc/google/cloud/videointelligence/v1beta2/video_intelligence.rb +0 -372
  24. data/lib/google/cloud/video_intelligence/v1beta2/doc/google/longrunning/operations.rb +0 -51
  25. data/lib/google/cloud/video_intelligence/v1beta2/doc/google/protobuf/any.rb +0 -131
  26. data/lib/google/cloud/video_intelligence/v1beta2/doc/google/protobuf/duration.rb +0 -91
  27. data/lib/google/cloud/video_intelligence/v1beta2/doc/google/rpc/status.rb +0 -39
  28. data/lib/google/cloud/video_intelligence/v1beta2/video_intelligence_service_client.rb +0 -309
  29. data/lib/google/cloud/video_intelligence/v1beta2/video_intelligence_service_client_config.json +0 -31
  30. data/lib/google/cloud/video_intelligence/v1p1beta1.rb +0 -187
  31. data/lib/google/cloud/video_intelligence/v1p1beta1/credentials.rb +0 -41
  32. data/lib/google/cloud/video_intelligence/v1p1beta1/doc/google/cloud/videointelligence/v1p1beta1/video_intelligence.rb +0 -410
  33. data/lib/google/cloud/video_intelligence/v1p1beta1/doc/google/longrunning/operations.rb +0 -51
  34. data/lib/google/cloud/video_intelligence/v1p1beta1/doc/google/protobuf/any.rb +0 -131
  35. data/lib/google/cloud/video_intelligence/v1p1beta1/doc/google/protobuf/duration.rb +0 -91
  36. data/lib/google/cloud/video_intelligence/v1p1beta1/doc/google/rpc/status.rb +0 -39
  37. data/lib/google/cloud/video_intelligence/v1p1beta1/video_intelligence_service_client.rb +0 -309
  38. data/lib/google/cloud/video_intelligence/v1p1beta1/video_intelligence_service_client_config.json +0 -31
  39. data/lib/google/cloud/video_intelligence/v1p2beta1.rb +0 -187
  40. data/lib/google/cloud/video_intelligence/v1p2beta1/credentials.rb +0 -41
  41. data/lib/google/cloud/video_intelligence/v1p2beta1/doc/google/cloud/videointelligence/v1p2beta1/video_intelligence.rb +0 -442
  42. data/lib/google/cloud/video_intelligence/v1p2beta1/doc/google/longrunning/operations.rb +0 -51
  43. data/lib/google/cloud/video_intelligence/v1p2beta1/doc/google/protobuf/any.rb +0 -131
  44. data/lib/google/cloud/video_intelligence/v1p2beta1/doc/google/protobuf/duration.rb +0 -91
  45. data/lib/google/cloud/video_intelligence/v1p2beta1/doc/google/rpc/status.rb +0 -39
  46. data/lib/google/cloud/video_intelligence/v1p2beta1/video_intelligence_service_client.rb +0 -309
  47. data/lib/google/cloud/video_intelligence/v1p2beta1/video_intelligence_service_client_config.json +0 -31
  48. data/lib/google/cloud/videointelligence/v1/video_intelligence_pb.rb +0 -304
  49. data/lib/google/cloud/videointelligence/v1/video_intelligence_services_pb.rb +0 -50
  50. data/lib/google/cloud/videointelligence/v1beta2/video_intelligence_pb.rb +0 -170
  51. data/lib/google/cloud/videointelligence/v1beta2/video_intelligence_services_pb.rb +0 -51
  52. data/lib/google/cloud/videointelligence/v1p1beta1/video_intelligence_pb.rb +0 -172
  53. data/lib/google/cloud/videointelligence/v1p1beta1/video_intelligence_services_pb.rb +0 -51
  54. data/lib/google/cloud/videointelligence/v1p2beta1/video_intelligence_pb.rb +0 -193
  55. data/lib/google/cloud/videointelligence/v1p2beta1/video_intelligence_services_pb.rb +0 -51
@@ -1,51 +0,0 @@
1
- # Copyright 2020 Google LLC
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
- # https://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
-
16
- module Google
17
- module Longrunning
18
- # This resource represents a long-running operation that is the result of a
19
- # network API call.
20
- # @!attribute [rw] name
21
- # @return [String]
22
- # The server-assigned name, which is only unique within the same service that
23
- # originally returns it. If you use the default HTTP mapping, the
24
- # `name` should be a resource name ending with `operations/{unique_id}`.
25
- # @!attribute [rw] metadata
26
- # @return [Google::Protobuf::Any]
27
- # Service-specific metadata associated with the operation. It typically
28
- # contains progress information and common metadata such as create time.
29
- # Some services might not provide such metadata. Any method that returns a
30
- # long-running operation should document the metadata type, if any.
31
- # @!attribute [rw] done
32
- # @return [true, false]
33
- # If the value is `false`, it means the operation is still in progress.
34
- # If `true`, the operation is completed, and either `error` or `response` is
35
- # available.
36
- # @!attribute [rw] error
37
- # @return [Google::Rpc::Status]
38
- # The error result of the operation in case of failure or cancellation.
39
- # @!attribute [rw] response
40
- # @return [Google::Protobuf::Any]
41
- # The normal response of the operation in case of success. If the original
42
- # method returns no data on success, such as `Delete`, the response is
43
- # `google.protobuf.Empty`. If the original method is standard
44
- # `Get`/`Create`/`Update`, the response should be the resource. For other
45
- # methods, the response should have the type `XxxResponse`, where `Xxx`
46
- # is the original method name. For example, if the original method name
47
- # is `TakeSnapshot()`, the inferred response type is
48
- # `TakeSnapshotResponse`.
49
- class Operation; end
50
- end
51
- end
@@ -1,131 +0,0 @@
1
- # Copyright 2020 Google LLC
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
- # https://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
-
16
- module Google
17
- module Protobuf
18
- # `Any` contains an arbitrary serialized protocol buffer message along with a
19
- # URL that describes the type of the serialized message.
20
- #
21
- # Protobuf library provides support to pack/unpack Any values in the form
22
- # of utility functions or additional generated methods of the Any type.
23
- #
24
- # Example 1: Pack and unpack a message in C++.
25
- #
26
- # Foo foo = ...;
27
- # Any any;
28
- # any.PackFrom(foo);
29
- # ...
30
- # if (any.UnpackTo(&foo)) {
31
- # ...
32
- # }
33
- #
34
- # Example 2: Pack and unpack a message in Java.
35
- #
36
- # Foo foo = ...;
37
- # Any any = Any.pack(foo);
38
- # ...
39
- # if (any.is(Foo.class)) {
40
- # foo = any.unpack(Foo.class);
41
- # }
42
- #
43
- # Example 3: Pack and unpack a message in Python.
44
- #
45
- # foo = Foo(...)
46
- # any = Any()
47
- # any.Pack(foo)
48
- # ...
49
- # if any.Is(Foo.DESCRIPTOR):
50
- # any.Unpack(foo)
51
- # ...
52
- #
53
- # Example 4: Pack and unpack a message in Go
54
- #
55
- # foo := &pb.Foo{...}
56
- # any, err := ptypes.MarshalAny(foo)
57
- # ...
58
- # foo := &pb.Foo{}
59
- # if err := ptypes.UnmarshalAny(any, foo); err != nil {
60
- # ...
61
- # }
62
- #
63
- # The pack methods provided by protobuf library will by default use
64
- # 'type.googleapis.com/full.type.name' as the type URL and the unpack
65
- # methods only use the fully qualified type name after the last '/'
66
- # in the type URL, for example "foo.bar.com/x/y.z" will yield type
67
- # name "y.z".
68
- #
69
- #
70
- # = JSON
71
- #
72
- # The JSON representation of an `Any` value uses the regular
73
- # representation of the deserialized, embedded message, with an
74
- # additional field `@type` which contains the type URL. Example:
75
- #
76
- # package google.profile;
77
- # message Person {
78
- # string first_name = 1;
79
- # string last_name = 2;
80
- # }
81
- #
82
- # {
83
- # "@type": "type.googleapis.com/google.profile.Person",
84
- # "firstName": <string>,
85
- # "lastName": <string>
86
- # }
87
- #
88
- # If the embedded message type is well-known and has a custom JSON
89
- # representation, that representation will be embedded adding a field
90
- # `value` which holds the custom JSON in addition to the `@type`
91
- # field. Example (for message {Google::Protobuf::Duration}):
92
- #
93
- # {
94
- # "@type": "type.googleapis.com/google.protobuf.Duration",
95
- # "value": "1.212s"
96
- # }
97
- # @!attribute [rw] type_url
98
- # @return [String]
99
- # A URL/resource name that uniquely identifies the type of the serialized
100
- # protocol buffer message. This string must contain at least
101
- # one "/" character. The last segment of the URL's path must represent
102
- # the fully qualified name of the type (as in
103
- # `path/google.protobuf.Duration`). The name should be in a canonical form
104
- # (e.g., leading "." is not accepted).
105
- #
106
- # In practice, teams usually precompile into the binary all types that they
107
- # expect it to use in the context of Any. However, for URLs which use the
108
- # scheme `http`, `https`, or no scheme, one can optionally set up a type
109
- # server that maps type URLs to message definitions as follows:
110
- #
111
- # * If no scheme is provided, `https` is assumed.
112
- # * An HTTP GET on the URL must yield a {Google::Protobuf::Type}
113
- # value in binary format, or produce an error.
114
- # * Applications are allowed to cache lookup results based on the
115
- # URL, or have them precompiled into a binary to avoid any
116
- # lookup. Therefore, binary compatibility needs to be preserved
117
- # on changes to types. (Use versioned type names to manage
118
- # breaking changes.)
119
- #
120
- # Note: this functionality is not currently available in the official
121
- # protobuf release, and it is not used for type URLs beginning with
122
- # type.googleapis.com.
123
- #
124
- # Schemes other than `http`, `https` (or the empty scheme) might be
125
- # used with implementation specific semantics.
126
- # @!attribute [rw] value
127
- # @return [String]
128
- # Must be a valid serialized protocol buffer of the above specified type.
129
- class Any; end
130
- end
131
- end
@@ -1,91 +0,0 @@
1
- # Copyright 2020 Google LLC
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
- # https://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
-
16
- module Google
17
- module Protobuf
18
- # A Duration represents a signed, fixed-length span of time represented
19
- # as a count of seconds and fractions of seconds at nanosecond
20
- # resolution. It is independent of any calendar and concepts like "day"
21
- # or "month". It is related to Timestamp in that the difference between
22
- # two Timestamp values is a Duration and it can be added or subtracted
23
- # from a Timestamp. Range is approximately +-10,000 years.
24
- #
25
- # = Examples
26
- #
27
- # Example 1: Compute Duration from two Timestamps in pseudo code.
28
- #
29
- # Timestamp start = ...;
30
- # Timestamp end = ...;
31
- # Duration duration = ...;
32
- #
33
- # duration.seconds = end.seconds - start.seconds;
34
- # duration.nanos = end.nanos - start.nanos;
35
- #
36
- # if (duration.seconds < 0 && duration.nanos > 0) {
37
- # duration.seconds += 1;
38
- # duration.nanos -= 1000000000;
39
- # } else if (durations.seconds > 0 && duration.nanos < 0) {
40
- # duration.seconds -= 1;
41
- # duration.nanos += 1000000000;
42
- # }
43
- #
44
- # Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
45
- #
46
- # Timestamp start = ...;
47
- # Duration duration = ...;
48
- # Timestamp end = ...;
49
- #
50
- # end.seconds = start.seconds + duration.seconds;
51
- # end.nanos = start.nanos + duration.nanos;
52
- #
53
- # if (end.nanos < 0) {
54
- # end.seconds -= 1;
55
- # end.nanos += 1000000000;
56
- # } else if (end.nanos >= 1000000000) {
57
- # end.seconds += 1;
58
- # end.nanos -= 1000000000;
59
- # }
60
- #
61
- # Example 3: Compute Duration from datetime.timedelta in Python.
62
- #
63
- # td = datetime.timedelta(days=3, minutes=10)
64
- # duration = Duration()
65
- # duration.FromTimedelta(td)
66
- #
67
- # = JSON Mapping
68
- #
69
- # In JSON format, the Duration type is encoded as a string rather than an
70
- # object, where the string ends in the suffix "s" (indicating seconds) and
71
- # is preceded by the number of seconds, with nanoseconds expressed as
72
- # fractional seconds. For example, 3 seconds with 0 nanoseconds should be
73
- # encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
74
- # be expressed in JSON format as "3.000000001s", and 3 seconds and 1
75
- # microsecond should be expressed in JSON format as "3.000001s".
76
- # @!attribute [rw] seconds
77
- # @return [Integer]
78
- # Signed seconds of the span of time. Must be from -315,576,000,000
79
- # to +315,576,000,000 inclusive. Note: these bounds are computed from:
80
- # 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
81
- # @!attribute [rw] nanos
82
- # @return [Integer]
83
- # Signed fractions of a second at nanosecond resolution of the span
84
- # of time. Durations less than one second are represented with a 0
85
- # `seconds` field and a positive or negative `nanos` field. For durations
86
- # of one second or more, a non-zero value for the `nanos` field must be
87
- # of the same sign as the `seconds` field. Must be from -999,999,999
88
- # to +999,999,999 inclusive.
89
- class Duration; end
90
- end
91
- end
@@ -1,39 +0,0 @@
1
- # Copyright 2020 Google LLC
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
- # https://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
-
16
- module Google
17
- module Rpc
18
- # The `Status` type defines a logical error model that is suitable for
19
- # different programming environments, including REST APIs and RPC APIs. It is
20
- # used by [gRPC](https://github.com/grpc). Each `Status` message contains
21
- # three pieces of data: error code, error message, and error details.
22
- #
23
- # You can find out more about this error model and how to work with it in the
24
- # [API Design Guide](https://cloud.google.com/apis/design/errors).
25
- # @!attribute [rw] code
26
- # @return [Integer]
27
- # The status code, which should be an enum value of {Google::Rpc::Code}.
28
- # @!attribute [rw] message
29
- # @return [String]
30
- # A developer-facing error message, which should be in English. Any
31
- # user-facing error message should be localized and sent in the
32
- # {Google::Rpc::Status#details} field, or localized by the client.
33
- # @!attribute [rw] details
34
- # @return [Array<Google::Protobuf::Any>]
35
- # A list of messages that carry the error details. There is a common set of
36
- # message types for APIs to use.
37
- class Status; end
38
- end
39
- end
@@ -1,309 +0,0 @@
1
- # Copyright 2020 Google LLC
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
- # https://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/v1p2beta1/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
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
- require "google/gax/operation"
28
- require "google/longrunning/operations_client"
29
-
30
- require "google/cloud/videointelligence/v1p2beta1/video_intelligence_pb"
31
- require "google/cloud/video_intelligence/v1p2beta1/credentials"
32
- require "google/cloud/video_intelligence/version"
33
-
34
- module Google
35
- module Cloud
36
- module VideoIntelligence
37
- module V1p2beta1
38
- # Service that implements Google Cloud Video Intelligence API.
39
- #
40
- # @!attribute [r] video_intelligence_service_stub
41
- # @return [Google::Cloud::VideoIntelligence::V1p2beta1::VideoIntelligenceService::Stub]
42
- class VideoIntelligenceServiceClient
43
- # @private
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
- # The default set of gRPC interceptors.
53
- GRPC_INTERCEPTORS = []
54
-
55
- DEFAULT_TIMEOUT = 30
56
-
57
- # The scopes needed to make gRPC calls to all of the methods defined in
58
- # this service.
59
- ALL_SCOPES = [
60
- "https://www.googleapis.com/auth/cloud-platform"
61
- ].freeze
62
-
63
- # @private
64
- class OperationsClient < Google::Longrunning::OperationsClient
65
- self::SERVICE_ADDRESS = VideoIntelligenceServiceClient::SERVICE_ADDRESS
66
- self::GRPC_INTERCEPTORS = VideoIntelligenceServiceClient::GRPC_INTERCEPTORS
67
- end
68
-
69
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
70
- # Provides the means for authenticating requests made by the client. This parameter can
71
- # be many types.
72
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
73
- # authenticating requests made by this client.
74
- # A `String` will be treated as the path to the keyfile to be used for the construction of
75
- # credentials for this client.
76
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
77
- # credentials for this client.
78
- # A `GRPC::Core::Channel` will be used to make calls through.
79
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
80
- # should already be composed with a `GRPC::Core::CallCredentials` object.
81
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
82
- # metadata for requests, generally, to give OAuth credentials.
83
- # @param scopes [Array<String>]
84
- # The OAuth scopes for this service. This parameter is ignored if
85
- # an updater_proc is supplied.
86
- # @param client_config [Hash]
87
- # A Hash for call options for each method. See
88
- # Google::Gax#construct_settings for the structure of
89
- # this data. Falls back to the default config if not specified
90
- # or the specified config is missing data points.
91
- # @param timeout [Numeric]
92
- # The default timeout, in seconds, for calls made through this client.
93
- # @param metadata [Hash]
94
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
95
- # @param service_address [String]
96
- # Override for the service hostname, or `nil` to leave as the default.
97
- # @param service_port [Integer]
98
- # Override for the service port, or `nil` to leave as the default.
99
- # @param exception_transformer [Proc]
100
- # An optional proc that intercepts any exceptions raised during an API call to inject
101
- # custom error handling.
102
- def initialize \
103
- credentials: nil,
104
- scopes: ALL_SCOPES,
105
- client_config: {},
106
- timeout: DEFAULT_TIMEOUT,
107
- metadata: nil,
108
- service_address: nil,
109
- service_port: nil,
110
- exception_transformer: nil,
111
- lib_name: nil,
112
- lib_version: ""
113
- # These require statements are intentionally placed here to initialize
114
- # the gRPC module only when it's required.
115
- # See https://github.com/googleapis/toolkit/issues/446
116
- require "google/gax/grpc"
117
- require "google/cloud/videointelligence/v1p2beta1/video_intelligence_services_pb"
118
-
119
- credentials ||= Google::Cloud::VideoIntelligence::V1p2beta1::Credentials.default
120
-
121
- @operations_client = OperationsClient.new(
122
- credentials: credentials,
123
- scopes: scopes,
124
- client_config: client_config,
125
- timeout: timeout,
126
- lib_name: lib_name,
127
- service_address: service_address,
128
- service_port: service_port,
129
- lib_version: lib_version,
130
- metadata: metadata,
131
- )
132
-
133
- if credentials.is_a?(String) || credentials.is_a?(Hash)
134
- updater_proc = Google::Cloud::VideoIntelligence::V1p2beta1::Credentials.new(credentials).updater_proc
135
- end
136
- if credentials.is_a?(GRPC::Core::Channel)
137
- channel = credentials
138
- end
139
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
140
- chan_creds = credentials
141
- end
142
- if credentials.is_a?(Proc)
143
- updater_proc = credentials
144
- end
145
- if credentials.is_a?(Google::Auth::Credentials)
146
- updater_proc = credentials.updater_proc
147
- end
148
-
149
- package_version = Google::Cloud::VideoIntelligence::VERSION
150
-
151
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
152
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
153
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
154
- google_api_client << " grpc/#{GRPC::VERSION}"
155
- google_api_client.freeze
156
-
157
- headers = { :"x-goog-api-client" => google_api_client }
158
- if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
159
- headers[:"x-goog-user-project"] = credentials.quota_project_id
160
- end
161
- headers.merge!(metadata) unless metadata.nil?
162
- client_config_file = Pathname.new(__dir__).join(
163
- "video_intelligence_service_client_config.json"
164
- )
165
- defaults = client_config_file.open do |f|
166
- Google::Gax.construct_settings(
167
- "google.cloud.videointelligence.v1p2beta1.VideoIntelligenceService",
168
- JSON.parse(f.read),
169
- client_config,
170
- Google::Gax::Grpc::STATUS_CODE_NAMES,
171
- timeout,
172
- errors: Google::Gax::Grpc::API_ERRORS,
173
- metadata: headers
174
- )
175
- end
176
-
177
- # Allow overriding the service path/port in subclasses.
178
- service_path = service_address || self.class::SERVICE_ADDRESS
179
- port = service_port || self.class::DEFAULT_SERVICE_PORT
180
- interceptors = self.class::GRPC_INTERCEPTORS
181
- @video_intelligence_service_stub = Google::Gax::Grpc.create_stub(
182
- service_path,
183
- port,
184
- chan_creds: chan_creds,
185
- channel: channel,
186
- updater_proc: updater_proc,
187
- scopes: scopes,
188
- interceptors: interceptors,
189
- &Google::Cloud::VideoIntelligence::V1p2beta1::VideoIntelligenceService::Stub.method(:new)
190
- )
191
-
192
- @annotate_video = Google::Gax.create_api_call(
193
- @video_intelligence_service_stub.method(:annotate_video),
194
- defaults["annotate_video"],
195
- exception_transformer: exception_transformer
196
- )
197
- end
198
-
199
- # Service calls
200
-
201
- # Performs asynchronous video annotation. Progress and results can be
202
- # retrieved through the `google.longrunning.Operations` interface.
203
- # `Operation.metadata` contains `AnnotateVideoProgress` (progress).
204
- # `Operation.response` contains `AnnotateVideoResponse` (results).
205
- #
206
- # @param input_uri [String]
207
- # Input video location. Currently, only
208
- # [Google Cloud Storage](https://cloud.google.com/storage/) URIs are
209
- # supported, which must be specified in the following format:
210
- # `gs://bucket-id/object-id` (other URI formats return
211
- # {Google::Rpc::Code::INVALID_ARGUMENT}). For more information, see
212
- # [Request URIs](https://cloud.google.com/storage/docs/request-endpoints).
213
- # A video URI may include wildcards in `object-id`, and thus identify
214
- # multiple videos. Supported wildcards: '*' to match 0 or more characters;
215
- # '?' to match 1 character. If unset, the input video should be embedded
216
- # in the request as `input_content`. If set, `input_content` should be unset.
217
- # @param input_content [String]
218
- # The video data bytes.
219
- # If unset, the input video(s) should be specified via `input_uri`.
220
- # If set, `input_uri` should be unset.
221
- # @param features [Array<Google::Cloud::VideoIntelligence::V1p2beta1::Feature>]
222
- # Required. Requested video annotation features.
223
- # @param video_context [Google::Cloud::VideoIntelligence::V1p2beta1::VideoContext | Hash]
224
- # Additional video context and/or feature-specific parameters.
225
- # A hash of the same form as `Google::Cloud::VideoIntelligence::V1p2beta1::VideoContext`
226
- # can also be provided.
227
- # @param output_uri [String]
228
- # Optional. Location where the output (in JSON format) should be stored.
229
- # Currently, only [Google Cloud Storage](https://cloud.google.com/storage/)
230
- # URIs are supported, which must be specified in the following format:
231
- # `gs://bucket-id/object-id` (other URI formats return
232
- # {Google::Rpc::Code::INVALID_ARGUMENT}). For more information, see
233
- # [Request URIs](https://cloud.google.com/storage/docs/request-endpoints).
234
- # @param location_id [String]
235
- # Optional. Cloud region where annotation should take place. Supported cloud
236
- # regions: `us-east1`, `us-west1`, `europe-west1`, `asia-east1`. If no region
237
- # is specified, a region will be determined based on video file location.
238
- # @param options [Google::Gax::CallOptions]
239
- # Overrides the default settings for this call, e.g, timeout,
240
- # retries, etc.
241
- # @return [Google::Gax::Operation]
242
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
243
- # @example
244
- # require "google/cloud/video_intelligence"
245
- #
246
- # video_intelligence_client = Google::Cloud::VideoIntelligence.new(version: :v1p2beta1)
247
- # input_uri = "gs://cloud-samples-data/video/cat.mp4"
248
- # features_element = :LABEL_DETECTION
249
- # features = [features_element]
250
- #
251
- # # Register a callback during the method call.
252
- # operation = video_intelligence_client.annotate_video(input_uri: input_uri, features: features) do |op|
253
- # raise op.results.message if op.error?
254
- # op_results = op.results
255
- # # Process the results.
256
- #
257
- # metadata = op.metadata
258
- # # Process the metadata.
259
- # end
260
- #
261
- # # Or use the return value to register a callback.
262
- # operation.on_done do |op|
263
- # raise op.results.message if op.error?
264
- # op_results = op.results
265
- # # Process the results.
266
- #
267
- # metadata = op.metadata
268
- # # Process the metadata.
269
- # end
270
- #
271
- # # Manually reload the operation.
272
- # operation.reload!
273
- #
274
- # # Or block until the operation completes, triggering callbacks on
275
- # # completion.
276
- # operation.wait_until_done!
277
-
278
- def annotate_video \
279
- input_uri: nil,
280
- input_content: nil,
281
- features: nil,
282
- video_context: nil,
283
- output_uri: nil,
284
- location_id: nil,
285
- options: nil
286
- req = {
287
- input_uri: input_uri,
288
- input_content: input_content,
289
- features: features,
290
- video_context: video_context,
291
- output_uri: output_uri,
292
- location_id: location_id
293
- }.delete_if { |_, v| v.nil? }
294
- req = Google::Gax::to_proto(req, Google::Cloud::VideoIntelligence::V1p2beta1::AnnotateVideoRequest)
295
- operation = Google::Gax::Operation.new(
296
- @annotate_video.call(req, options),
297
- @operations_client,
298
- Google::Cloud::VideoIntelligence::V1p2beta1::AnnotateVideoResponse,
299
- Google::Cloud::VideoIntelligence::V1p2beta1::AnnotateVideoProgress,
300
- call_options: options
301
- )
302
- operation.on_done { |operation| yield(operation) } if block_given?
303
- operation
304
- end
305
- end
306
- end
307
- end
308
- end
309
- end