google-cloud-ai_platform-v1 0.39.0 → 0.41.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.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/lib/google/cloud/ai_platform/v1/bindings_override.rb +399 -0
  3. data/lib/google/cloud/ai_platform/v1/dataset_service/client.rb +138 -18
  4. data/lib/google/cloud/ai_platform/v1/dataset_service/operations.rb +13 -5
  5. data/lib/google/cloud/ai_platform/v1/dataset_service/rest/client.rb +2280 -0
  6. data/lib/google/cloud/ai_platform/v1/dataset_service/rest/operations.rb +3971 -0
  7. data/lib/google/cloud/ai_platform/v1/dataset_service/rest/service_stub.rb +1196 -0
  8. data/lib/google/cloud/ai_platform/v1/dataset_service/rest.rb +54 -0
  9. data/lib/google/cloud/ai_platform/v1/dataset_service.rb +6 -0
  10. data/lib/google/cloud/ai_platform/v1/deployment_resource_pool_service/client.rb +13 -5
  11. data/lib/google/cloud/ai_platform/v1/deployment_resource_pool_service/operations.rb +13 -5
  12. data/lib/google/cloud/ai_platform/v1/deployment_resource_pool_service/rest/client.rb +851 -0
  13. data/lib/google/cloud/ai_platform/v1/deployment_resource_pool_service/rest/operations.rb +3971 -0
  14. data/lib/google/cloud/ai_platform/v1/deployment_resource_pool_service/rest/service_stub.rb +365 -0
  15. data/lib/google/cloud/ai_platform/v1/deployment_resource_pool_service/rest.rb +54 -0
  16. data/lib/google/cloud/ai_platform/v1/deployment_resource_pool_service.rb +6 -0
  17. data/lib/google/cloud/ai_platform/v1/endpoint_service/client.rb +19 -8
  18. data/lib/google/cloud/ai_platform/v1/endpoint_service/operations.rb +13 -5
  19. data/lib/google/cloud/ai_platform/v1/endpoint_service/rest/client.rb +1215 -0
  20. data/lib/google/cloud/ai_platform/v1/endpoint_service/rest/operations.rb +3971 -0
  21. data/lib/google/cloud/ai_platform/v1/endpoint_service/rest/service_stub.rb +546 -0
  22. data/lib/google/cloud/ai_platform/v1/endpoint_service/rest.rb +54 -0
  23. data/lib/google/cloud/ai_platform/v1/endpoint_service.rb +6 -0
  24. data/lib/google/cloud/ai_platform/v1/feature_online_store_admin_service/client.rb +29 -13
  25. data/lib/google/cloud/ai_platform/v1/feature_online_store_admin_service/operations.rb +13 -5
  26. data/lib/google/cloud/ai_platform/v1/feature_online_store_admin_service/rest/client.rb +1732 -0
  27. data/lib/google/cloud/ai_platform/v1/feature_online_store_admin_service/rest/operations.rb +3971 -0
  28. data/lib/google/cloud/ai_platform/v1/feature_online_store_admin_service/rest/service_stub.rb +841 -0
  29. data/lib/google/cloud/ai_platform/v1/feature_online_store_admin_service/rest.rb +55 -0
  30. data/lib/google/cloud/ai_platform/v1/feature_online_store_admin_service.rb +6 -0
  31. data/lib/google/cloud/ai_platform/v1/feature_online_store_service/client.rb +7 -2
  32. data/lib/google/cloud/ai_platform/v1/feature_online_store_service/rest/client.rb +534 -0
  33. data/lib/google/cloud/ai_platform/v1/feature_online_store_service/rest/service_stub.rb +189 -0
  34. data/lib/google/cloud/ai_platform/v1/feature_online_store_service/rest.rb +53 -0
  35. data/lib/google/cloud/ai_platform/v1/feature_online_store_service.rb +6 -0
  36. data/lib/google/cloud/ai_platform/v1/feature_registry_service/client.rb +24 -11
  37. data/lib/google/cloud/ai_platform/v1/feature_registry_service/operations.rb +13 -5
  38. data/lib/google/cloud/ai_platform/v1/feature_registry_service/rest/client.rb +1450 -0
  39. data/lib/google/cloud/ai_platform/v1/feature_registry_service/rest/operations.rb +3971 -0
  40. data/lib/google/cloud/ai_platform/v1/feature_registry_service/rest/service_stub.rb +663 -0
  41. data/lib/google/cloud/ai_platform/v1/feature_registry_service/rest.rb +55 -0
  42. data/lib/google/cloud/ai_platform/v1/feature_registry_service.rb +6 -0
  43. data/lib/google/cloud/ai_platform/v1/featurestore_online_serving_service/client.rb +9 -3
  44. data/lib/google/cloud/ai_platform/v1/featurestore_online_serving_service/rest/client.rb +645 -0
  45. data/lib/google/cloud/ai_platform/v1/featurestore_online_serving_service/rest/service_stub.rb +244 -0
  46. data/lib/google/cloud/ai_platform/v1/featurestore_online_serving_service/rest.rb +53 -0
  47. data/lib/google/cloud/ai_platform/v1/featurestore_online_serving_service.rb +6 -0
  48. data/lib/google/cloud/ai_platform/v1/featurestore_service/client.rb +45 -21
  49. data/lib/google/cloud/ai_platform/v1/featurestore_service/operations.rb +13 -5
  50. data/lib/google/cloud/ai_platform/v1/featurestore_service/rest/client.rb +2765 -0
  51. data/lib/google/cloud/ai_platform/v1/featurestore_service/rest/operations.rb +3971 -0
  52. data/lib/google/cloud/ai_platform/v1/featurestore_service/rest/service_stub.rb +1319 -0
  53. data/lib/google/cloud/ai_platform/v1/featurestore_service/rest.rb +54 -0
  54. data/lib/google/cloud/ai_platform/v1/featurestore_service.rb +6 -0
  55. data/lib/google/cloud/ai_platform/v1/gen_ai_tuning_service/client.rb +11 -4
  56. data/lib/google/cloud/ai_platform/v1/gen_ai_tuning_service/rest/client.rb +720 -0
  57. data/lib/google/cloud/ai_platform/v1/gen_ai_tuning_service/rest/service_stub.rb +307 -0
  58. data/lib/google/cloud/ai_platform/v1/gen_ai_tuning_service/rest.rb +53 -0
  59. data/lib/google/cloud/ai_platform/v1/gen_ai_tuning_service.rb +6 -0
  60. data/lib/google/cloud/ai_platform/v1/index_endpoint_service/client.rb +19 -8
  61. data/lib/google/cloud/ai_platform/v1/index_endpoint_service/operations.rb +13 -5
  62. data/lib/google/cloud/ai_platform/v1/index_endpoint_service/rest/client.rb +1151 -0
  63. data/lib/google/cloud/ai_platform/v1/index_endpoint_service/rest/operations.rb +3971 -0
  64. data/lib/google/cloud/ai_platform/v1/index_endpoint_service/rest/service_stub.rb +546 -0
  65. data/lib/google/cloud/ai_platform/v1/index_endpoint_service/rest.rb +54 -0
  66. data/lib/google/cloud/ai_platform/v1/index_endpoint_service.rb +6 -0
  67. data/lib/google/cloud/ai_platform/v1/index_service/client.rb +17 -7
  68. data/lib/google/cloud/ai_platform/v1/index_service/operations.rb +13 -5
  69. data/lib/google/cloud/ai_platform/v1/index_service/rest/client.rb +1034 -0
  70. data/lib/google/cloud/ai_platform/v1/index_service/rest/operations.rb +3971 -0
  71. data/lib/google/cloud/ai_platform/v1/index_service/rest/service_stub.rb +486 -0
  72. data/lib/google/cloud/ai_platform/v1/index_service/rest.rb +54 -0
  73. data/lib/google/cloud/ai_platform/v1/index_service.rb +6 -0
  74. data/lib/google/cloud/ai_platform/v1/job_service/client.rb +73 -35
  75. data/lib/google/cloud/ai_platform/v1/job_service/operations.rb +13 -5
  76. data/lib/google/cloud/ai_platform/v1/job_service/rest/client.rb +3841 -0
  77. data/lib/google/cloud/ai_platform/v1/job_service/rest/operations.rb +3971 -0
  78. data/lib/google/cloud/ai_platform/v1/job_service/rest/service_stub.rb +2149 -0
  79. data/lib/google/cloud/ai_platform/v1/job_service/rest.rb +54 -0
  80. data/lib/google/cloud/ai_platform/v1/job_service.rb +6 -0
  81. data/lib/google/cloud/ai_platform/v1/llm_utility_service/client.rb +7 -2
  82. data/lib/google/cloud/ai_platform/v1/llm_utility_service/rest/client.rb +533 -0
  83. data/lib/google/cloud/ai_platform/v1/llm_utility_service/rest/service_stub.rb +205 -0
  84. data/lib/google/cloud/ai_platform/v1/llm_utility_service/rest.rb +53 -0
  85. data/lib/google/cloud/ai_platform/v1/llm_utility_service.rb +6 -0
  86. data/lib/google/cloud/ai_platform/v1/match_service/client.rb +7 -2
  87. data/lib/google/cloud/ai_platform/v1/match_service/rest/client.rb +541 -0
  88. data/lib/google/cloud/ai_platform/v1/match_service/rest/service_stub.rb +189 -0
  89. data/lib/google/cloud/ai_platform/v1/match_service/rest.rb +54 -0
  90. data/lib/google/cloud/ai_platform/v1/match_service.rb +6 -0
  91. data/lib/google/cloud/ai_platform/v1/metadata_service/client.rb +67 -32
  92. data/lib/google/cloud/ai_platform/v1/metadata_service/operations.rb +13 -5
  93. data/lib/google/cloud/ai_platform/v1/metadata_service/rest/client.rb +3634 -0
  94. data/lib/google/cloud/ai_platform/v1/metadata_service/rest/operations.rb +3971 -0
  95. data/lib/google/cloud/ai_platform/v1/metadata_service/rest/service_stub.rb +1972 -0
  96. data/lib/google/cloud/ai_platform/v1/metadata_service/rest.rb +54 -0
  97. data/lib/google/cloud/ai_platform/v1/metadata_service.rb +6 -0
  98. data/lib/google/cloud/ai_platform/v1/migration_service/client.rb +7 -2
  99. data/lib/google/cloud/ai_platform/v1/migration_service/operations.rb +13 -5
  100. data/lib/google/cloud/ai_platform/v1/migration_service/rest/client.rb +574 -0
  101. data/lib/google/cloud/ai_platform/v1/migration_service/rest/operations.rb +3971 -0
  102. data/lib/google/cloud/ai_platform/v1/migration_service/rest/service_stub.rb +189 -0
  103. data/lib/google/cloud/ai_platform/v1/migration_service/rest.rb +55 -0
  104. data/lib/google/cloud/ai_platform/v1/migration_service.rb +6 -0
  105. data/lib/google/cloud/ai_platform/v1/model_garden_service/client.rb +5 -1
  106. data/lib/google/cloud/ai_platform/v1/model_garden_service/rest/client.rb +438 -0
  107. data/lib/google/cloud/ai_platform/v1/model_garden_service/rest/service_stub.rb +128 -0
  108. data/lib/google/cloud/ai_platform/v1/model_garden_service/rest.rb +53 -0
  109. data/lib/google/cloud/ai_platform/v1/model_garden_service.rb +6 -0
  110. data/lib/google/cloud/ai_platform/v1/model_service/client.rb +39 -18
  111. data/lib/google/cloud/ai_platform/v1/model_service/operations.rb +13 -5
  112. data/lib/google/cloud/ai_platform/v1/model_service/rest/client.rb +2213 -0
  113. data/lib/google/cloud/ai_platform/v1/model_service/rest/operations.rb +3971 -0
  114. data/lib/google/cloud/ai_platform/v1/model_service/rest/service_stub.rb +1140 -0
  115. data/lib/google/cloud/ai_platform/v1/model_service/rest.rb +54 -0
  116. data/lib/google/cloud/ai_platform/v1/model_service.rb +6 -0
  117. data/lib/google/cloud/ai_platform/v1/notebook_service/client.rb +123 -10
  118. data/lib/google/cloud/ai_platform/v1/notebook_service/operations.rb +13 -5
  119. data/lib/google/cloud/ai_platform/v1/notebook_service/rest/client.rb +1503 -0
  120. data/lib/google/cloud/ai_platform/v1/notebook_service/rest/operations.rb +3971 -0
  121. data/lib/google/cloud/ai_platform/v1/notebook_service/rest/service_stub.rb +723 -0
  122. data/lib/google/cloud/ai_platform/v1/notebook_service/rest.rb +54 -0
  123. data/lib/google/cloud/ai_platform/v1/notebook_service.rb +6 -0
  124. data/lib/google/cloud/ai_platform/v1/persistent_resource_service/client.rb +15 -6
  125. data/lib/google/cloud/ai_platform/v1/persistent_resource_service/operations.rb +13 -5
  126. data/lib/google/cloud/ai_platform/v1/persistent_resource_service/rest/client.rb +942 -0
  127. data/lib/google/cloud/ai_platform/v1/persistent_resource_service/rest/operations.rb +3971 -0
  128. data/lib/google/cloud/ai_platform/v1/persistent_resource_service/rest/service_stub.rb +426 -0
  129. data/lib/google/cloud/ai_platform/v1/persistent_resource_service/rest.rb +54 -0
  130. data/lib/google/cloud/ai_platform/v1/persistent_resource_service.rb +6 -0
  131. data/lib/google/cloud/ai_platform/v1/pipeline_service/client.rb +27 -12
  132. data/lib/google/cloud/ai_platform/v1/pipeline_service/operations.rb +13 -5
  133. data/lib/google/cloud/ai_platform/v1/pipeline_service/rest/client.rb +1600 -0
  134. data/lib/google/cloud/ai_platform/v1/pipeline_service/rest/operations.rb +3971 -0
  135. data/lib/google/cloud/ai_platform/v1/pipeline_service/rest/service_stub.rb +783 -0
  136. data/lib/google/cloud/ai_platform/v1/pipeline_service/rest.rb +56 -0
  137. data/lib/google/cloud/ai_platform/v1/pipeline_service.rb +6 -0
  138. data/lib/google/cloud/ai_platform/v1/prediction_service/client.rb +37 -15
  139. data/lib/google/cloud/ai_platform/v1/prediction_service/credentials.rb +2 -1
  140. data/lib/google/cloud/ai_platform/v1/prediction_service/rest/client.rb +1303 -0
  141. data/lib/google/cloud/ai_platform/v1/prediction_service/rest/service_stub.rb +658 -0
  142. data/lib/google/cloud/ai_platform/v1/prediction_service/rest.rb +53 -0
  143. data/lib/google/cloud/ai_platform/v1/prediction_service.rb +6 -0
  144. data/lib/google/cloud/ai_platform/v1/rest.rb +63 -0
  145. data/lib/google/cloud/ai_platform/v1/schedule_service/client.rb +17 -7
  146. data/lib/google/cloud/ai_platform/v1/schedule_service/operations.rb +13 -5
  147. data/lib/google/cloud/ai_platform/v1/schedule_service/rest/client.rb +1076 -0
  148. data/lib/google/cloud/ai_platform/v1/schedule_service/rest/operations.rb +3971 -0
  149. data/lib/google/cloud/ai_platform/v1/schedule_service/rest/service_stub.rb +486 -0
  150. data/lib/google/cloud/ai_platform/v1/schedule_service/rest.rb +55 -0
  151. data/lib/google/cloud/ai_platform/v1/schedule_service.rb +6 -0
  152. data/lib/google/cloud/ai_platform/v1/specialist_pool_service/client.rb +13 -5
  153. data/lib/google/cloud/ai_platform/v1/specialist_pool_service/operations.rb +13 -5
  154. data/lib/google/cloud/ai_platform/v1/specialist_pool_service/rest/client.rb +847 -0
  155. data/lib/google/cloud/ai_platform/v1/specialist_pool_service/rest/operations.rb +3971 -0
  156. data/lib/google/cloud/ai_platform/v1/specialist_pool_service/rest/service_stub.rb +366 -0
  157. data/lib/google/cloud/ai_platform/v1/specialist_pool_service/rest.rb +59 -0
  158. data/lib/google/cloud/ai_platform/v1/specialist_pool_service.rb +6 -0
  159. data/lib/google/cloud/ai_platform/v1/tensorboard_service/client.rb +63 -30
  160. data/lib/google/cloud/ai_platform/v1/tensorboard_service/operations.rb +13 -5
  161. data/lib/google/cloud/ai_platform/v1/tensorboard_service/rest/client.rb +3274 -0
  162. data/lib/google/cloud/ai_platform/v1/tensorboard_service/rest/operations.rb +3971 -0
  163. data/lib/google/cloud/ai_platform/v1/tensorboard_service/rest/service_stub.rb +1847 -0
  164. data/lib/google/cloud/ai_platform/v1/tensorboard_service/rest.rb +54 -0
  165. data/lib/google/cloud/ai_platform/v1/tensorboard_service.rb +6 -0
  166. data/lib/google/cloud/ai_platform/v1/version.rb +1 -1
  167. data/lib/google/cloud/ai_platform/v1/vizier_service/client.rb +33 -15
  168. data/lib/google/cloud/ai_platform/v1/vizier_service/operations.rb +13 -5
  169. data/lib/google/cloud/ai_platform/v1/vizier_service/rest/client.rb +1788 -0
  170. data/lib/google/cloud/ai_platform/v1/vizier_service/rest/operations.rb +3971 -0
  171. data/lib/google/cloud/ai_platform/v1/vizier_service/rest/service_stub.rb +963 -0
  172. data/lib/google/cloud/ai_platform/v1/vizier_service/rest.rb +58 -0
  173. data/lib/google/cloud/ai_platform/v1/vizier_service.rb +6 -0
  174. data/lib/google/cloud/ai_platform/v1.rb +6 -1
  175. data/lib/google/cloud/aiplatform/v1/accelerator_type_pb.rb +1 -1
  176. data/lib/google/cloud/aiplatform/v1/content_pb.rb +4 -4
  177. data/lib/google/cloud/aiplatform/v1/dataset_pb.rb +1 -1
  178. data/lib/google/cloud/aiplatform/v1/dataset_service_pb.rb +3 -2
  179. data/lib/google/cloud/aiplatform/v1/dataset_service_services_pb.rb +2 -0
  180. data/lib/google/cloud/aiplatform/v1/dataset_version_pb.rb +1 -1
  181. data/lib/google/cloud/aiplatform/v1/deployment_resource_pool_pb.rb +3 -1
  182. data/lib/google/cloud/aiplatform/v1/endpoint_pb.rb +3 -1
  183. data/lib/google/cloud/aiplatform/v1/feature_online_store_pb.rb +3 -1
  184. data/lib/google/cloud/aiplatform/v1/feature_pb.rb +1 -1
  185. data/lib/google/cloud/aiplatform/v1/featurestore_online_service_pb.rb +3 -1
  186. data/lib/google/cloud/aiplatform/v1/index_pb.rb +2 -1
  187. data/lib/google/cloud/aiplatform/v1/index_service_pb.rb +1 -1
  188. data/lib/google/cloud/aiplatform/v1/match_service_pb.rb +2 -1
  189. data/lib/google/cloud/aiplatform/v1/metadata_store_pb.rb +2 -1
  190. data/lib/google/cloud/aiplatform/v1/notebook_runtime_pb.rb +3 -1
  191. data/lib/google/cloud/aiplatform/v1/notebook_service_pb.rb +2 -1
  192. data/lib/google/cloud/aiplatform/v1/notebook_service_services_pb.rb +2 -0
  193. data/lib/google/cloud/aiplatform/v1/persistent_resource_pb.rb +2 -1
  194. data/lib/google/cloud/aiplatform/v1/prediction_service_pb.rb +1 -1
  195. data/lib/google/cloud/aiplatform/v1/publisher_model_pb.rb +1 -1
  196. data/lib/google/cloud/aiplatform/v1/tool_pb.rb +4 -1
  197. data/proto_docs/google/cloud/aiplatform/v1/accelerator_type.rb +3 -0
  198. data/proto_docs/google/cloud/aiplatform/v1/content.rb +26 -48
  199. data/proto_docs/google/cloud/aiplatform/v1/dataset.rb +4 -0
  200. data/proto_docs/google/cloud/aiplatform/v1/dataset_service.rb +17 -0
  201. data/proto_docs/google/cloud/aiplatform/v1/dataset_version.rb +4 -0
  202. data/proto_docs/google/cloud/aiplatform/v1/deployment_resource_pool.rb +23 -0
  203. data/proto_docs/google/cloud/aiplatform/v1/endpoint.rb +7 -0
  204. data/proto_docs/google/cloud/aiplatform/v1/feature.rb +3 -0
  205. data/proto_docs/google/cloud/aiplatform/v1/feature_group.rb +3 -3
  206. data/proto_docs/google/cloud/aiplatform/v1/feature_online_store.rb +4 -0
  207. data/proto_docs/google/cloud/aiplatform/v1/feature_registry_service.rb +1 -1
  208. data/proto_docs/google/cloud/aiplatform/v1/featurestore_online_service.rb +24 -0
  209. data/proto_docs/google/cloud/aiplatform/v1/index.rb +23 -3
  210. data/proto_docs/google/cloud/aiplatform/v1/index_service.rb +20 -2
  211. data/proto_docs/google/cloud/aiplatform/v1/match_service.rb +18 -1
  212. data/proto_docs/google/cloud/aiplatform/v1/metadata_store.rb +13 -0
  213. data/proto_docs/google/cloud/aiplatform/v1/model.rb +1 -1
  214. data/proto_docs/google/cloud/aiplatform/v1/notebook_runtime.rb +17 -2
  215. data/proto_docs/google/cloud/aiplatform/v1/notebook_service.rb +18 -0
  216. data/proto_docs/google/cloud/aiplatform/v1/persistent_resource.rb +63 -0
  217. data/proto_docs/google/cloud/aiplatform/v1/prediction_service.rb +4 -0
  218. data/proto_docs/google/cloud/aiplatform/v1/publisher_model.rb +4 -0
  219. data/proto_docs/google/cloud/aiplatform/v1/tool.rb +43 -5
  220. data/proto_docs/google/cloud/aiplatform/v1/tuning_job.rb +8 -7
  221. metadata +101 -2
@@ -0,0 +1,1303 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2024 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/aiplatform/v1/prediction_service_pb"
21
+ require "google/cloud/ai_platform/v1/prediction_service/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+ require "google/iam/v1/rest"
24
+
25
+ module Google
26
+ module Cloud
27
+ module AIPlatform
28
+ module V1
29
+ module PredictionService
30
+ module Rest
31
+ ##
32
+ # REST client for the PredictionService service.
33
+ #
34
+ # A service for online predictions and explanations.
35
+ #
36
+ class Client
37
+ # @private
38
+ API_VERSION = ""
39
+
40
+ # @private
41
+ DEFAULT_ENDPOINT_TEMPLATE = "aiplatform.$UNIVERSE_DOMAIN$"
42
+
43
+ include Paths
44
+
45
+ # @private
46
+ attr_reader :prediction_service_stub
47
+
48
+ ##
49
+ # Configure the PredictionService Client class.
50
+ #
51
+ # See {::Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client::Configuration}
52
+ # for a description of the configuration fields.
53
+ #
54
+ # @example
55
+ #
56
+ # # Modify the configuration for all PredictionService clients
57
+ # ::Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client.configure do |config|
58
+ # config.timeout = 10.0
59
+ # end
60
+ #
61
+ # @yield [config] Configure the Client client.
62
+ # @yieldparam config [Client::Configuration]
63
+ #
64
+ # @return [Client::Configuration]
65
+ #
66
+ def self.configure
67
+ @configure ||= begin
68
+ namespace = ["Google", "Cloud", "AIPlatform", "V1"]
69
+ parent_config = while namespace.any?
70
+ parent_name = namespace.join "::"
71
+ parent_const = const_get parent_name
72
+ break parent_const.configure if parent_const.respond_to? :configure
73
+ namespace.pop
74
+ end
75
+ default_config = Client::Configuration.new parent_config
76
+
77
+ default_config
78
+ end
79
+ yield @configure if block_given?
80
+ @configure
81
+ end
82
+
83
+ ##
84
+ # Configure the PredictionService Client instance.
85
+ #
86
+ # The configuration is set to the derived mode, meaning that values can be changed,
87
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
88
+ # should be made on {Client.configure}.
89
+ #
90
+ # See {::Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client::Configuration}
91
+ # for a description of the configuration fields.
92
+ #
93
+ # @yield [config] Configure the Client client.
94
+ # @yieldparam config [Client::Configuration]
95
+ #
96
+ # @return [Client::Configuration]
97
+ #
98
+ def configure
99
+ yield @config if block_given?
100
+ @config
101
+ end
102
+
103
+ ##
104
+ # The effective universe domain
105
+ #
106
+ # @return [String]
107
+ #
108
+ def universe_domain
109
+ @prediction_service_stub.universe_domain
110
+ end
111
+
112
+ ##
113
+ # Create a new PredictionService REST client object.
114
+ #
115
+ # @example
116
+ #
117
+ # # Create a client using the default configuration
118
+ # client = ::Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client.new
119
+ #
120
+ # # Create a client using a custom configuration
121
+ # client = ::Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client.new do |config|
122
+ # config.timeout = 10.0
123
+ # end
124
+ #
125
+ # @yield [config] Configure the PredictionService client.
126
+ # @yieldparam config [Client::Configuration]
127
+ #
128
+ def initialize
129
+ # Create the configuration object
130
+ @config = Configuration.new Client.configure
131
+
132
+ # Yield the configuration if needed
133
+ yield @config if block_given?
134
+
135
+ # Create credentials
136
+ credentials = @config.credentials
137
+ # Use self-signed JWT if the endpoint is unchanged from default,
138
+ # but only if the default endpoint does not have a region prefix.
139
+ enable_self_signed_jwt = @config.endpoint.nil? ||
140
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
141
+ !@config.endpoint.split(".").first.include?("-"))
142
+ credentials ||= Credentials.default scope: @config.scope,
143
+ enable_self_signed_jwt: enable_self_signed_jwt
144
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
145
+ credentials = Credentials.new credentials, scope: @config.scope
146
+ end
147
+
148
+ @quota_project_id = @config.quota_project
149
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
150
+
151
+ @prediction_service_stub = ::Google::Cloud::AIPlatform::V1::PredictionService::Rest::ServiceStub.new(
152
+ endpoint: @config.endpoint,
153
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
154
+ universe_domain: @config.universe_domain,
155
+ credentials: credentials
156
+ )
157
+
158
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
159
+ config.credentials = credentials
160
+ config.quota_project = @quota_project_id
161
+ config.endpoint = @prediction_service_stub.endpoint
162
+ config.universe_domain = @prediction_service_stub.universe_domain
163
+ config.bindings_override = @config.bindings_override
164
+ end
165
+
166
+ @iam_policy_client = Google::Iam::V1::IAMPolicy::Rest::Client.new do |config|
167
+ config.credentials = credentials
168
+ config.quota_project = @quota_project_id
169
+ config.endpoint = @prediction_service_stub.endpoint
170
+ config.universe_domain = @prediction_service_stub.universe_domain
171
+ config.bindings_override = @config.bindings_override
172
+ end
173
+ end
174
+
175
+ ##
176
+ # Get the associated client for mix-in of the Locations.
177
+ #
178
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
179
+ #
180
+ attr_reader :location_client
181
+
182
+ ##
183
+ # Get the associated client for mix-in of the IAMPolicy.
184
+ #
185
+ # @return [Google::Iam::V1::IAMPolicy::Rest::Client]
186
+ #
187
+ attr_reader :iam_policy_client
188
+
189
+ # Service calls
190
+
191
+ ##
192
+ # Perform an online prediction.
193
+ #
194
+ # @overload predict(request, options = nil)
195
+ # Pass arguments to `predict` via a request object, either of type
196
+ # {::Google::Cloud::AIPlatform::V1::PredictRequest} or an equivalent Hash.
197
+ #
198
+ # @param request [::Google::Cloud::AIPlatform::V1::PredictRequest, ::Hash]
199
+ # A request object representing the call parameters. Required. To specify no
200
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
201
+ # @param options [::Gapic::CallOptions, ::Hash]
202
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
203
+ #
204
+ # @overload predict(endpoint: nil, instances: nil, parameters: nil)
205
+ # Pass arguments to `predict` via keyword arguments. Note that at
206
+ # least one keyword argument is required. To specify no parameters, or to keep all
207
+ # the default parameter values, pass an empty Hash as a request object (see above).
208
+ #
209
+ # @param endpoint [::String]
210
+ # Required. The name of the Endpoint requested to serve the prediction.
211
+ # Format:
212
+ # `projects/{project}/locations/{location}/endpoints/{endpoint}`
213
+ # @param instances [::Array<::Google::Protobuf::Value, ::Hash>]
214
+ # Required. The instances that are the input to the prediction call.
215
+ # A DeployedModel may have an upper limit on the number of instances it
216
+ # supports per request, and when it is exceeded the prediction call errors
217
+ # in case of AutoML Models, or, in case of customer created Models, the
218
+ # behaviour is as documented by that Model.
219
+ # The schema of any single instance may be specified via Endpoint's
220
+ # DeployedModels' [Model's][google.cloud.aiplatform.v1.DeployedModel.model]
221
+ # [PredictSchemata's][google.cloud.aiplatform.v1.Model.predict_schemata]
222
+ # {::Google::Cloud::AIPlatform::V1::PredictSchemata#instance_schema_uri instance_schema_uri}.
223
+ # @param parameters [::Google::Protobuf::Value, ::Hash]
224
+ # The parameters that govern the prediction. The schema of the parameters may
225
+ # be specified via Endpoint's DeployedModels' [Model's
226
+ # ][google.cloud.aiplatform.v1.DeployedModel.model]
227
+ # [PredictSchemata's][google.cloud.aiplatform.v1.Model.predict_schemata]
228
+ # {::Google::Cloud::AIPlatform::V1::PredictSchemata#parameters_schema_uri parameters_schema_uri}.
229
+ # @yield [result, operation] Access the result along with the TransportOperation object
230
+ # @yieldparam result [::Google::Cloud::AIPlatform::V1::PredictResponse]
231
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
232
+ #
233
+ # @return [::Google::Cloud::AIPlatform::V1::PredictResponse]
234
+ #
235
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
236
+ #
237
+ # @example Basic example
238
+ # require "google/cloud/ai_platform/v1"
239
+ #
240
+ # # Create a client object. The client can be reused for multiple calls.
241
+ # client = Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client.new
242
+ #
243
+ # # Create a request. To set request fields, pass in keyword arguments.
244
+ # request = Google::Cloud::AIPlatform::V1::PredictRequest.new
245
+ #
246
+ # # Call the predict method.
247
+ # result = client.predict request
248
+ #
249
+ # # The returned object is of type Google::Cloud::AIPlatform::V1::PredictResponse.
250
+ # p result
251
+ #
252
+ def predict request, options = nil
253
+ raise ::ArgumentError, "request must be provided" if request.nil?
254
+
255
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::PredictRequest
256
+
257
+ # Converts hash and nil to an options object
258
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
259
+
260
+ # Customize the options with defaults
261
+ call_metadata = @config.rpcs.predict.metadata.to_h
262
+
263
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
264
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
265
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
266
+ gapic_version: ::Google::Cloud::AIPlatform::V1::VERSION,
267
+ transports_version_send: [:rest]
268
+
269
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
270
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
271
+
272
+ options.apply_defaults timeout: @config.rpcs.predict.timeout,
273
+ metadata: call_metadata,
274
+ retry_policy: @config.rpcs.predict.retry_policy
275
+
276
+ options.apply_defaults timeout: @config.timeout,
277
+ metadata: @config.metadata,
278
+ retry_policy: @config.retry_policy
279
+
280
+ @prediction_service_stub.predict request, options do |result, operation|
281
+ yield result, operation if block_given?
282
+ return result
283
+ end
284
+ rescue ::Gapic::Rest::Error => e
285
+ raise ::Google::Cloud::Error.from_error(e)
286
+ end
287
+
288
+ ##
289
+ # Perform an online prediction with an arbitrary HTTP payload.
290
+ #
291
+ # The response includes the following HTTP headers:
292
+ #
293
+ # * `X-Vertex-AI-Endpoint-Id`: ID of the
294
+ # {::Google::Cloud::AIPlatform::V1::Endpoint Endpoint} that served this
295
+ # prediction.
296
+ #
297
+ # * `X-Vertex-AI-Deployed-Model-Id`: ID of the Endpoint's
298
+ # {::Google::Cloud::AIPlatform::V1::DeployedModel DeployedModel} that served this
299
+ # prediction.
300
+ #
301
+ # @overload raw_predict(request, options = nil)
302
+ # Pass arguments to `raw_predict` via a request object, either of type
303
+ # {::Google::Cloud::AIPlatform::V1::RawPredictRequest} or an equivalent Hash.
304
+ #
305
+ # @param request [::Google::Cloud::AIPlatform::V1::RawPredictRequest, ::Hash]
306
+ # A request object representing the call parameters. Required. To specify no
307
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
308
+ # @param options [::Gapic::CallOptions, ::Hash]
309
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
310
+ #
311
+ # @overload raw_predict(endpoint: nil, http_body: nil)
312
+ # Pass arguments to `raw_predict` via keyword arguments. Note that at
313
+ # least one keyword argument is required. To specify no parameters, or to keep all
314
+ # the default parameter values, pass an empty Hash as a request object (see above).
315
+ #
316
+ # @param endpoint [::String]
317
+ # Required. The name of the Endpoint requested to serve the prediction.
318
+ # Format:
319
+ # `projects/{project}/locations/{location}/endpoints/{endpoint}`
320
+ # @param http_body [::Google::Api::HttpBody, ::Hash]
321
+ # The prediction input. Supports HTTP headers and arbitrary data payload.
322
+ #
323
+ # A {::Google::Cloud::AIPlatform::V1::DeployedModel DeployedModel} may have an
324
+ # upper limit on the number of instances it supports per request. When this
325
+ # limit it is exceeded for an AutoML model, the
326
+ # {::Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client#raw_predict RawPredict}
327
+ # method returns an error. When this limit is exceeded for a custom-trained
328
+ # model, the behavior varies depending on the model.
329
+ #
330
+ # You can specify the schema for each instance in the
331
+ # {::Google::Cloud::AIPlatform::V1::PredictSchemata#instance_schema_uri predict_schemata.instance_schema_uri}
332
+ # field when you create a {::Google::Cloud::AIPlatform::V1::Model Model}. This
333
+ # schema applies when you deploy the `Model` as a `DeployedModel` to an
334
+ # {::Google::Cloud::AIPlatform::V1::Endpoint Endpoint} and use the `RawPredict`
335
+ # method.
336
+ # @yield [result, operation] Access the result along with the TransportOperation object
337
+ # @yieldparam result [::Google::Api::HttpBody]
338
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
339
+ #
340
+ # @return [::Google::Api::HttpBody]
341
+ #
342
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
343
+ #
344
+ # @example Basic example
345
+ # require "google/cloud/ai_platform/v1"
346
+ #
347
+ # # Create a client object. The client can be reused for multiple calls.
348
+ # client = Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client.new
349
+ #
350
+ # # Create a request. To set request fields, pass in keyword arguments.
351
+ # request = Google::Cloud::AIPlatform::V1::RawPredictRequest.new
352
+ #
353
+ # # Call the raw_predict method.
354
+ # result = client.raw_predict request
355
+ #
356
+ # # The returned object is of type Google::Api::HttpBody.
357
+ # p result
358
+ #
359
+ def raw_predict request, options = nil
360
+ raise ::ArgumentError, "request must be provided" if request.nil?
361
+
362
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::RawPredictRequest
363
+
364
+ # Converts hash and nil to an options object
365
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
366
+
367
+ # Customize the options with defaults
368
+ call_metadata = @config.rpcs.raw_predict.metadata.to_h
369
+
370
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
371
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
372
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
373
+ gapic_version: ::Google::Cloud::AIPlatform::V1::VERSION,
374
+ transports_version_send: [:rest]
375
+
376
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
377
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
378
+
379
+ options.apply_defaults timeout: @config.rpcs.raw_predict.timeout,
380
+ metadata: call_metadata,
381
+ retry_policy: @config.rpcs.raw_predict.retry_policy
382
+
383
+ options.apply_defaults timeout: @config.timeout,
384
+ metadata: @config.metadata,
385
+ retry_policy: @config.retry_policy
386
+
387
+ @prediction_service_stub.raw_predict request, options do |result, operation|
388
+ yield result, operation if block_given?
389
+ return result
390
+ end
391
+ rescue ::Gapic::Rest::Error => e
392
+ raise ::Google::Cloud::Error.from_error(e)
393
+ end
394
+
395
+ ##
396
+ # Perform a streaming online prediction with an arbitrary HTTP payload.
397
+ #
398
+ # @overload stream_raw_predict(request, options = nil)
399
+ # Pass arguments to `stream_raw_predict` via a request object, either of type
400
+ # {::Google::Cloud::AIPlatform::V1::StreamRawPredictRequest} or an equivalent Hash.
401
+ #
402
+ # @param request [::Google::Cloud::AIPlatform::V1::StreamRawPredictRequest, ::Hash]
403
+ # A request object representing the call parameters. Required. To specify no
404
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
405
+ # @param options [::Gapic::CallOptions, ::Hash]
406
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
407
+ #
408
+ # @overload stream_raw_predict(endpoint: nil, http_body: nil)
409
+ # Pass arguments to `stream_raw_predict` via keyword arguments. Note that at
410
+ # least one keyword argument is required. To specify no parameters, or to keep all
411
+ # the default parameter values, pass an empty Hash as a request object (see above).
412
+ #
413
+ # @param endpoint [::String]
414
+ # Required. The name of the Endpoint requested to serve the prediction.
415
+ # Format:
416
+ # `projects/{project}/locations/{location}/endpoints/{endpoint}`
417
+ # @param http_body [::Google::Api::HttpBody, ::Hash]
418
+ # The prediction input. Supports HTTP headers and arbitrary data payload.
419
+ # @return [::Enumerable<::Google::Api::HttpBody>]
420
+ #
421
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
422
+ #
423
+ # @example Basic example
424
+ # require "google/cloud/ai_platform/v1"
425
+ #
426
+ # # Create a client object. The client can be reused for multiple calls.
427
+ # client = Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client.new
428
+ #
429
+ # # Create a request. To set request fields, pass in keyword arguments.
430
+ # request = Google::Cloud::AIPlatform::V1::StreamRawPredictRequest.new
431
+ #
432
+ # # Call the stream_raw_predict method to start streaming.
433
+ # output = client.stream_raw_predict request
434
+ #
435
+ # # The returned object is a streamed enumerable yielding elements of type
436
+ # # ::Google::Api::HttpBody
437
+ # output.each do |current_response|
438
+ # p current_response
439
+ # end
440
+ #
441
+ def stream_raw_predict request, options = nil
442
+ raise ::ArgumentError, "request must be provided" if request.nil?
443
+
444
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::StreamRawPredictRequest
445
+
446
+ # Converts hash and nil to an options object
447
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
448
+
449
+ # Customize the options with defaults
450
+ call_metadata = @config.rpcs.stream_raw_predict.metadata.to_h
451
+
452
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
453
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
454
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
455
+ gapic_version: ::Google::Cloud::AIPlatform::V1::VERSION,
456
+ transports_version_send: [:rest]
457
+
458
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
459
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
460
+
461
+ options.apply_defaults timeout: @config.rpcs.stream_raw_predict.timeout,
462
+ metadata: call_metadata,
463
+ retry_policy: @config.rpcs.stream_raw_predict.retry_policy
464
+
465
+ options.apply_defaults timeout: @config.timeout,
466
+ metadata: @config.metadata,
467
+ retry_policy: @config.retry_policy
468
+
469
+ ::Gapic::Rest::ServerStream.new(
470
+ ::Google::Api::HttpBody,
471
+ ::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q|
472
+ @prediction_service_stub.stream_raw_predict request, options do |chunk|
473
+ in_q.deq
474
+ out_q.enq chunk
475
+ end
476
+ end
477
+ )
478
+ rescue ::Gapic::Rest::Error => e
479
+ raise ::Google::Cloud::Error.from_error(e)
480
+ end
481
+
482
+ ##
483
+ # Perform an unary online prediction request to a gRPC model server for
484
+ # Vertex first-party products and frameworks.
485
+ #
486
+ # @overload direct_predict(request, options = nil)
487
+ # Pass arguments to `direct_predict` via a request object, either of type
488
+ # {::Google::Cloud::AIPlatform::V1::DirectPredictRequest} or an equivalent Hash.
489
+ #
490
+ # @param request [::Google::Cloud::AIPlatform::V1::DirectPredictRequest, ::Hash]
491
+ # A request object representing the call parameters. Required. To specify no
492
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
493
+ # @param options [::Gapic::CallOptions, ::Hash]
494
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
495
+ #
496
+ # @overload direct_predict(endpoint: nil, inputs: nil, parameters: nil)
497
+ # Pass arguments to `direct_predict` via keyword arguments. Note that at
498
+ # least one keyword argument is required. To specify no parameters, or to keep all
499
+ # the default parameter values, pass an empty Hash as a request object (see above).
500
+ #
501
+ # @param endpoint [::String]
502
+ # Required. The name of the Endpoint requested to serve the prediction.
503
+ # Format:
504
+ # `projects/{project}/locations/{location}/endpoints/{endpoint}`
505
+ # @param inputs [::Array<::Google::Cloud::AIPlatform::V1::Tensor, ::Hash>]
506
+ # The prediction input.
507
+ # @param parameters [::Google::Cloud::AIPlatform::V1::Tensor, ::Hash]
508
+ # The parameters that govern the prediction.
509
+ # @yield [result, operation] Access the result along with the TransportOperation object
510
+ # @yieldparam result [::Google::Cloud::AIPlatform::V1::DirectPredictResponse]
511
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
512
+ #
513
+ # @return [::Google::Cloud::AIPlatform::V1::DirectPredictResponse]
514
+ #
515
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
516
+ #
517
+ # @example Basic example
518
+ # require "google/cloud/ai_platform/v1"
519
+ #
520
+ # # Create a client object. The client can be reused for multiple calls.
521
+ # client = Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client.new
522
+ #
523
+ # # Create a request. To set request fields, pass in keyword arguments.
524
+ # request = Google::Cloud::AIPlatform::V1::DirectPredictRequest.new
525
+ #
526
+ # # Call the direct_predict method.
527
+ # result = client.direct_predict request
528
+ #
529
+ # # The returned object is of type Google::Cloud::AIPlatform::V1::DirectPredictResponse.
530
+ # p result
531
+ #
532
+ def direct_predict request, options = nil
533
+ raise ::ArgumentError, "request must be provided" if request.nil?
534
+
535
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::DirectPredictRequest
536
+
537
+ # Converts hash and nil to an options object
538
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
539
+
540
+ # Customize the options with defaults
541
+ call_metadata = @config.rpcs.direct_predict.metadata.to_h
542
+
543
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
544
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
545
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
546
+ gapic_version: ::Google::Cloud::AIPlatform::V1::VERSION,
547
+ transports_version_send: [:rest]
548
+
549
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
550
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
551
+
552
+ options.apply_defaults timeout: @config.rpcs.direct_predict.timeout,
553
+ metadata: call_metadata,
554
+ retry_policy: @config.rpcs.direct_predict.retry_policy
555
+
556
+ options.apply_defaults timeout: @config.timeout,
557
+ metadata: @config.metadata,
558
+ retry_policy: @config.retry_policy
559
+
560
+ @prediction_service_stub.direct_predict request, options do |result, operation|
561
+ yield result, operation if block_given?
562
+ return result
563
+ end
564
+ rescue ::Gapic::Rest::Error => e
565
+ raise ::Google::Cloud::Error.from_error(e)
566
+ end
567
+
568
+ ##
569
+ # Perform an unary online prediction request to a gRPC model server for
570
+ # custom containers.
571
+ #
572
+ # @overload direct_raw_predict(request, options = nil)
573
+ # Pass arguments to `direct_raw_predict` via a request object, either of type
574
+ # {::Google::Cloud::AIPlatform::V1::DirectRawPredictRequest} or an equivalent Hash.
575
+ #
576
+ # @param request [::Google::Cloud::AIPlatform::V1::DirectRawPredictRequest, ::Hash]
577
+ # A request object representing the call parameters. Required. To specify no
578
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
579
+ # @param options [::Gapic::CallOptions, ::Hash]
580
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
581
+ #
582
+ # @overload direct_raw_predict(endpoint: nil, method_name: nil, input: nil)
583
+ # Pass arguments to `direct_raw_predict` via keyword arguments. Note that at
584
+ # least one keyword argument is required. To specify no parameters, or to keep all
585
+ # the default parameter values, pass an empty Hash as a request object (see above).
586
+ #
587
+ # @param endpoint [::String]
588
+ # Required. The name of the Endpoint requested to serve the prediction.
589
+ # Format:
590
+ # `projects/{project}/locations/{location}/endpoints/{endpoint}`
591
+ # @param method_name [::String]
592
+ # Fully qualified name of the API method being invoked to perform
593
+ # predictions.
594
+ #
595
+ # Format:
596
+ # `/namespace.Service/Method/`
597
+ # Example:
598
+ # `/tensorflow.serving.PredictionService/Predict`
599
+ # @param input [::String]
600
+ # The prediction input.
601
+ # @yield [result, operation] Access the result along with the TransportOperation object
602
+ # @yieldparam result [::Google::Cloud::AIPlatform::V1::DirectRawPredictResponse]
603
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
604
+ #
605
+ # @return [::Google::Cloud::AIPlatform::V1::DirectRawPredictResponse]
606
+ #
607
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
608
+ #
609
+ # @example Basic example
610
+ # require "google/cloud/ai_platform/v1"
611
+ #
612
+ # # Create a client object. The client can be reused for multiple calls.
613
+ # client = Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client.new
614
+ #
615
+ # # Create a request. To set request fields, pass in keyword arguments.
616
+ # request = Google::Cloud::AIPlatform::V1::DirectRawPredictRequest.new
617
+ #
618
+ # # Call the direct_raw_predict method.
619
+ # result = client.direct_raw_predict request
620
+ #
621
+ # # The returned object is of type Google::Cloud::AIPlatform::V1::DirectRawPredictResponse.
622
+ # p result
623
+ #
624
+ def direct_raw_predict request, options = nil
625
+ raise ::ArgumentError, "request must be provided" if request.nil?
626
+
627
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::DirectRawPredictRequest
628
+
629
+ # Converts hash and nil to an options object
630
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
631
+
632
+ # Customize the options with defaults
633
+ call_metadata = @config.rpcs.direct_raw_predict.metadata.to_h
634
+
635
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
636
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
637
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
638
+ gapic_version: ::Google::Cloud::AIPlatform::V1::VERSION,
639
+ transports_version_send: [:rest]
640
+
641
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
642
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
643
+
644
+ options.apply_defaults timeout: @config.rpcs.direct_raw_predict.timeout,
645
+ metadata: call_metadata,
646
+ retry_policy: @config.rpcs.direct_raw_predict.retry_policy
647
+
648
+ options.apply_defaults timeout: @config.timeout,
649
+ metadata: @config.metadata,
650
+ retry_policy: @config.retry_policy
651
+
652
+ @prediction_service_stub.direct_raw_predict request, options do |result, operation|
653
+ yield result, operation if block_given?
654
+ return result
655
+ end
656
+ rescue ::Gapic::Rest::Error => e
657
+ raise ::Google::Cloud::Error.from_error(e)
658
+ end
659
+
660
+ ##
661
+ # Perform a server-side streaming online prediction request for Vertex
662
+ # LLM streaming.
663
+ #
664
+ # @overload server_streaming_predict(request, options = nil)
665
+ # Pass arguments to `server_streaming_predict` via a request object, either of type
666
+ # {::Google::Cloud::AIPlatform::V1::StreamingPredictRequest} or an equivalent Hash.
667
+ #
668
+ # @param request [::Google::Cloud::AIPlatform::V1::StreamingPredictRequest, ::Hash]
669
+ # A request object representing the call parameters. Required. To specify no
670
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
671
+ # @param options [::Gapic::CallOptions, ::Hash]
672
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
673
+ #
674
+ # @overload server_streaming_predict(endpoint: nil, inputs: nil, parameters: nil)
675
+ # Pass arguments to `server_streaming_predict` via keyword arguments. Note that at
676
+ # least one keyword argument is required. To specify no parameters, or to keep all
677
+ # the default parameter values, pass an empty Hash as a request object (see above).
678
+ #
679
+ # @param endpoint [::String]
680
+ # Required. The name of the Endpoint requested to serve the prediction.
681
+ # Format:
682
+ # `projects/{project}/locations/{location}/endpoints/{endpoint}`
683
+ # @param inputs [::Array<::Google::Cloud::AIPlatform::V1::Tensor, ::Hash>]
684
+ # The prediction input.
685
+ # @param parameters [::Google::Cloud::AIPlatform::V1::Tensor, ::Hash]
686
+ # The parameters that govern the prediction.
687
+ # @return [::Enumerable<::Google::Cloud::AIPlatform::V1::StreamingPredictResponse>]
688
+ #
689
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
690
+ #
691
+ # @example Basic example
692
+ # require "google/cloud/ai_platform/v1"
693
+ #
694
+ # # Create a client object. The client can be reused for multiple calls.
695
+ # client = Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client.new
696
+ #
697
+ # # Create a request. To set request fields, pass in keyword arguments.
698
+ # request = Google::Cloud::AIPlatform::V1::StreamingPredictRequest.new
699
+ #
700
+ # # Call the server_streaming_predict method to start streaming.
701
+ # output = client.server_streaming_predict request
702
+ #
703
+ # # The returned object is a streamed enumerable yielding elements of type
704
+ # # ::Google::Cloud::AIPlatform::V1::StreamingPredictResponse
705
+ # output.each do |current_response|
706
+ # p current_response
707
+ # end
708
+ #
709
+ def server_streaming_predict request, options = nil
710
+ raise ::ArgumentError, "request must be provided" if request.nil?
711
+
712
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::StreamingPredictRequest
713
+
714
+ # Converts hash and nil to an options object
715
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
716
+
717
+ # Customize the options with defaults
718
+ call_metadata = @config.rpcs.server_streaming_predict.metadata.to_h
719
+
720
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
721
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
722
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
723
+ gapic_version: ::Google::Cloud::AIPlatform::V1::VERSION,
724
+ transports_version_send: [:rest]
725
+
726
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
727
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
728
+
729
+ options.apply_defaults timeout: @config.rpcs.server_streaming_predict.timeout,
730
+ metadata: call_metadata,
731
+ retry_policy: @config.rpcs.server_streaming_predict.retry_policy
732
+
733
+ options.apply_defaults timeout: @config.timeout,
734
+ metadata: @config.metadata,
735
+ retry_policy: @config.retry_policy
736
+
737
+ ::Gapic::Rest::ServerStream.new(
738
+ ::Google::Cloud::AIPlatform::V1::StreamingPredictResponse,
739
+ ::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q|
740
+ @prediction_service_stub.server_streaming_predict request, options do |chunk|
741
+ in_q.deq
742
+ out_q.enq chunk
743
+ end
744
+ end
745
+ )
746
+ rescue ::Gapic::Rest::Error => e
747
+ raise ::Google::Cloud::Error.from_error(e)
748
+ end
749
+
750
+ ##
751
+ # Perform an online explanation.
752
+ #
753
+ # If
754
+ # {::Google::Cloud::AIPlatform::V1::ExplainRequest#deployed_model_id deployed_model_id}
755
+ # is specified, the corresponding DeployModel must have
756
+ # {::Google::Cloud::AIPlatform::V1::DeployedModel#explanation_spec explanation_spec}
757
+ # populated. If
758
+ # {::Google::Cloud::AIPlatform::V1::ExplainRequest#deployed_model_id deployed_model_id}
759
+ # is not specified, all DeployedModels must have
760
+ # {::Google::Cloud::AIPlatform::V1::DeployedModel#explanation_spec explanation_spec}
761
+ # populated.
762
+ #
763
+ # @overload explain(request, options = nil)
764
+ # Pass arguments to `explain` via a request object, either of type
765
+ # {::Google::Cloud::AIPlatform::V1::ExplainRequest} or an equivalent Hash.
766
+ #
767
+ # @param request [::Google::Cloud::AIPlatform::V1::ExplainRequest, ::Hash]
768
+ # A request object representing the call parameters. Required. To specify no
769
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
770
+ # @param options [::Gapic::CallOptions, ::Hash]
771
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
772
+ #
773
+ # @overload explain(endpoint: nil, instances: nil, parameters: nil, explanation_spec_override: nil, deployed_model_id: nil)
774
+ # Pass arguments to `explain` via keyword arguments. Note that at
775
+ # least one keyword argument is required. To specify no parameters, or to keep all
776
+ # the default parameter values, pass an empty Hash as a request object (see above).
777
+ #
778
+ # @param endpoint [::String]
779
+ # Required. The name of the Endpoint requested to serve the explanation.
780
+ # Format:
781
+ # `projects/{project}/locations/{location}/endpoints/{endpoint}`
782
+ # @param instances [::Array<::Google::Protobuf::Value, ::Hash>]
783
+ # Required. The instances that are the input to the explanation call.
784
+ # A DeployedModel may have an upper limit on the number of instances it
785
+ # supports per request, and when it is exceeded the explanation call errors
786
+ # in case of AutoML Models, or, in case of customer created Models, the
787
+ # behaviour is as documented by that Model.
788
+ # The schema of any single instance may be specified via Endpoint's
789
+ # DeployedModels' [Model's][google.cloud.aiplatform.v1.DeployedModel.model]
790
+ # [PredictSchemata's][google.cloud.aiplatform.v1.Model.predict_schemata]
791
+ # {::Google::Cloud::AIPlatform::V1::PredictSchemata#instance_schema_uri instance_schema_uri}.
792
+ # @param parameters [::Google::Protobuf::Value, ::Hash]
793
+ # The parameters that govern the prediction. The schema of the parameters may
794
+ # be specified via Endpoint's DeployedModels' [Model's
795
+ # ][google.cloud.aiplatform.v1.DeployedModel.model]
796
+ # [PredictSchemata's][google.cloud.aiplatform.v1.Model.predict_schemata]
797
+ # {::Google::Cloud::AIPlatform::V1::PredictSchemata#parameters_schema_uri parameters_schema_uri}.
798
+ # @param explanation_spec_override [::Google::Cloud::AIPlatform::V1::ExplanationSpecOverride, ::Hash]
799
+ # If specified, overrides the
800
+ # {::Google::Cloud::AIPlatform::V1::DeployedModel#explanation_spec explanation_spec}
801
+ # of the DeployedModel. Can be used for explaining prediction results with
802
+ # different configurations, such as:
803
+ # - Explaining top-5 predictions results as opposed to top-1;
804
+ # - Increasing path count or step count of the attribution methods to reduce
805
+ # approximate errors;
806
+ # - Using different baselines for explaining the prediction results.
807
+ # @param deployed_model_id [::String]
808
+ # If specified, this ExplainRequest will be served by the chosen
809
+ # DeployedModel, overriding
810
+ # {::Google::Cloud::AIPlatform::V1::Endpoint#traffic_split Endpoint.traffic_split}.
811
+ # @yield [result, operation] Access the result along with the TransportOperation object
812
+ # @yieldparam result [::Google::Cloud::AIPlatform::V1::ExplainResponse]
813
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
814
+ #
815
+ # @return [::Google::Cloud::AIPlatform::V1::ExplainResponse]
816
+ #
817
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
818
+ #
819
+ # @example Basic example
820
+ # require "google/cloud/ai_platform/v1"
821
+ #
822
+ # # Create a client object. The client can be reused for multiple calls.
823
+ # client = Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client.new
824
+ #
825
+ # # Create a request. To set request fields, pass in keyword arguments.
826
+ # request = Google::Cloud::AIPlatform::V1::ExplainRequest.new
827
+ #
828
+ # # Call the explain method.
829
+ # result = client.explain request
830
+ #
831
+ # # The returned object is of type Google::Cloud::AIPlatform::V1::ExplainResponse.
832
+ # p result
833
+ #
834
+ def explain request, options = nil
835
+ raise ::ArgumentError, "request must be provided" if request.nil?
836
+
837
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::ExplainRequest
838
+
839
+ # Converts hash and nil to an options object
840
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
841
+
842
+ # Customize the options with defaults
843
+ call_metadata = @config.rpcs.explain.metadata.to_h
844
+
845
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
846
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
847
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
848
+ gapic_version: ::Google::Cloud::AIPlatform::V1::VERSION,
849
+ transports_version_send: [:rest]
850
+
851
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
852
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
853
+
854
+ options.apply_defaults timeout: @config.rpcs.explain.timeout,
855
+ metadata: call_metadata,
856
+ retry_policy: @config.rpcs.explain.retry_policy
857
+
858
+ options.apply_defaults timeout: @config.timeout,
859
+ metadata: @config.metadata,
860
+ retry_policy: @config.retry_policy
861
+
862
+ @prediction_service_stub.explain request, options do |result, operation|
863
+ yield result, operation if block_given?
864
+ return result
865
+ end
866
+ rescue ::Gapic::Rest::Error => e
867
+ raise ::Google::Cloud::Error.from_error(e)
868
+ end
869
+
870
+ ##
871
+ # Generate content with multimodal inputs.
872
+ #
873
+ # @overload generate_content(request, options = nil)
874
+ # Pass arguments to `generate_content` via a request object, either of type
875
+ # {::Google::Cloud::AIPlatform::V1::GenerateContentRequest} or an equivalent Hash.
876
+ #
877
+ # @param request [::Google::Cloud::AIPlatform::V1::GenerateContentRequest, ::Hash]
878
+ # A request object representing the call parameters. Required. To specify no
879
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
880
+ # @param options [::Gapic::CallOptions, ::Hash]
881
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
882
+ #
883
+ # @overload generate_content(model: nil, contents: nil, system_instruction: nil, tools: nil, tool_config: nil, safety_settings: nil, generation_config: nil)
884
+ # Pass arguments to `generate_content` via keyword arguments. Note that at
885
+ # least one keyword argument is required. To specify no parameters, or to keep all
886
+ # the default parameter values, pass an empty Hash as a request object (see above).
887
+ #
888
+ # @param model [::String]
889
+ # Required. The name of the publisher model requested to serve the
890
+ # prediction. Format:
891
+ # `projects/{project}/locations/{location}/publishers/*/models/*`
892
+ # @param contents [::Array<::Google::Cloud::AIPlatform::V1::Content, ::Hash>]
893
+ # Required. The content of the current conversation with the model.
894
+ #
895
+ # For single-turn queries, this is a single instance. For multi-turn queries,
896
+ # this is a repeated field that contains conversation history + latest
897
+ # request.
898
+ # @param system_instruction [::Google::Cloud::AIPlatform::V1::Content, ::Hash]
899
+ # Optional. The user provided system instructions for the model.
900
+ # Note: only text should be used in parts and content in each part will be in
901
+ # a separate paragraph.
902
+ # @param tools [::Array<::Google::Cloud::AIPlatform::V1::Tool, ::Hash>]
903
+ # Optional. A list of `Tools` the model may use to generate the next
904
+ # response.
905
+ #
906
+ # A `Tool` is a piece of code that enables the system to interact with
907
+ # external systems to perform an action, or set of actions, outside of
908
+ # knowledge and scope of the model.
909
+ # @param tool_config [::Google::Cloud::AIPlatform::V1::ToolConfig, ::Hash]
910
+ # Optional. Tool config. This config is shared for all tools provided in the
911
+ # request.
912
+ # @param safety_settings [::Array<::Google::Cloud::AIPlatform::V1::SafetySetting, ::Hash>]
913
+ # Optional. Per request settings for blocking unsafe content.
914
+ # Enforced on GenerateContentResponse.candidates.
915
+ # @param generation_config [::Google::Cloud::AIPlatform::V1::GenerationConfig, ::Hash]
916
+ # Optional. Generation config.
917
+ # @yield [result, operation] Access the result along with the TransportOperation object
918
+ # @yieldparam result [::Google::Cloud::AIPlatform::V1::GenerateContentResponse]
919
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
920
+ #
921
+ # @return [::Google::Cloud::AIPlatform::V1::GenerateContentResponse]
922
+ #
923
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
924
+ #
925
+ # @example Basic example
926
+ # require "google/cloud/ai_platform/v1"
927
+ #
928
+ # # Create a client object. The client can be reused for multiple calls.
929
+ # client = Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client.new
930
+ #
931
+ # # Create a request. To set request fields, pass in keyword arguments.
932
+ # request = Google::Cloud::AIPlatform::V1::GenerateContentRequest.new
933
+ #
934
+ # # Call the generate_content method.
935
+ # result = client.generate_content request
936
+ #
937
+ # # The returned object is of type Google::Cloud::AIPlatform::V1::GenerateContentResponse.
938
+ # p result
939
+ #
940
+ def generate_content request, options = nil
941
+ raise ::ArgumentError, "request must be provided" if request.nil?
942
+
943
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::GenerateContentRequest
944
+
945
+ # Converts hash and nil to an options object
946
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
947
+
948
+ # Customize the options with defaults
949
+ call_metadata = @config.rpcs.generate_content.metadata.to_h
950
+
951
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
952
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
953
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
954
+ gapic_version: ::Google::Cloud::AIPlatform::V1::VERSION,
955
+ transports_version_send: [:rest]
956
+
957
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
958
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
959
+
960
+ options.apply_defaults timeout: @config.rpcs.generate_content.timeout,
961
+ metadata: call_metadata,
962
+ retry_policy: @config.rpcs.generate_content.retry_policy
963
+
964
+ options.apply_defaults timeout: @config.timeout,
965
+ metadata: @config.metadata,
966
+ retry_policy: @config.retry_policy
967
+
968
+ @prediction_service_stub.generate_content request, options do |result, operation|
969
+ yield result, operation if block_given?
970
+ return result
971
+ end
972
+ rescue ::Gapic::Rest::Error => e
973
+ raise ::Google::Cloud::Error.from_error(e)
974
+ end
975
+
976
+ ##
977
+ # Generate content with multimodal inputs with streaming support.
978
+ #
979
+ # @overload stream_generate_content(request, options = nil)
980
+ # Pass arguments to `stream_generate_content` via a request object, either of type
981
+ # {::Google::Cloud::AIPlatform::V1::GenerateContentRequest} or an equivalent Hash.
982
+ #
983
+ # @param request [::Google::Cloud::AIPlatform::V1::GenerateContentRequest, ::Hash]
984
+ # A request object representing the call parameters. Required. To specify no
985
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
986
+ # @param options [::Gapic::CallOptions, ::Hash]
987
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
988
+ #
989
+ # @overload stream_generate_content(model: nil, contents: nil, system_instruction: nil, tools: nil, tool_config: nil, safety_settings: nil, generation_config: nil)
990
+ # Pass arguments to `stream_generate_content` via keyword arguments. Note that at
991
+ # least one keyword argument is required. To specify no parameters, or to keep all
992
+ # the default parameter values, pass an empty Hash as a request object (see above).
993
+ #
994
+ # @param model [::String]
995
+ # Required. The name of the publisher model requested to serve the
996
+ # prediction. Format:
997
+ # `projects/{project}/locations/{location}/publishers/*/models/*`
998
+ # @param contents [::Array<::Google::Cloud::AIPlatform::V1::Content, ::Hash>]
999
+ # Required. The content of the current conversation with the model.
1000
+ #
1001
+ # For single-turn queries, this is a single instance. For multi-turn queries,
1002
+ # this is a repeated field that contains conversation history + latest
1003
+ # request.
1004
+ # @param system_instruction [::Google::Cloud::AIPlatform::V1::Content, ::Hash]
1005
+ # Optional. The user provided system instructions for the model.
1006
+ # Note: only text should be used in parts and content in each part will be in
1007
+ # a separate paragraph.
1008
+ # @param tools [::Array<::Google::Cloud::AIPlatform::V1::Tool, ::Hash>]
1009
+ # Optional. A list of `Tools` the model may use to generate the next
1010
+ # response.
1011
+ #
1012
+ # A `Tool` is a piece of code that enables the system to interact with
1013
+ # external systems to perform an action, or set of actions, outside of
1014
+ # knowledge and scope of the model.
1015
+ # @param tool_config [::Google::Cloud::AIPlatform::V1::ToolConfig, ::Hash]
1016
+ # Optional. Tool config. This config is shared for all tools provided in the
1017
+ # request.
1018
+ # @param safety_settings [::Array<::Google::Cloud::AIPlatform::V1::SafetySetting, ::Hash>]
1019
+ # Optional. Per request settings for blocking unsafe content.
1020
+ # Enforced on GenerateContentResponse.candidates.
1021
+ # @param generation_config [::Google::Cloud::AIPlatform::V1::GenerationConfig, ::Hash]
1022
+ # Optional. Generation config.
1023
+ # @return [::Enumerable<::Google::Cloud::AIPlatform::V1::GenerateContentResponse>]
1024
+ #
1025
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1026
+ #
1027
+ # @example Basic example
1028
+ # require "google/cloud/ai_platform/v1"
1029
+ #
1030
+ # # Create a client object. The client can be reused for multiple calls.
1031
+ # client = Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client.new
1032
+ #
1033
+ # # Create a request. To set request fields, pass in keyword arguments.
1034
+ # request = Google::Cloud::AIPlatform::V1::GenerateContentRequest.new
1035
+ #
1036
+ # # Call the stream_generate_content method to start streaming.
1037
+ # output = client.stream_generate_content request
1038
+ #
1039
+ # # The returned object is a streamed enumerable yielding elements of type
1040
+ # # ::Google::Cloud::AIPlatform::V1::GenerateContentResponse
1041
+ # output.each do |current_response|
1042
+ # p current_response
1043
+ # end
1044
+ #
1045
+ def stream_generate_content request, options = nil
1046
+ raise ::ArgumentError, "request must be provided" if request.nil?
1047
+
1048
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::GenerateContentRequest
1049
+
1050
+ # Converts hash and nil to an options object
1051
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1052
+
1053
+ # Customize the options with defaults
1054
+ call_metadata = @config.rpcs.stream_generate_content.metadata.to_h
1055
+
1056
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
1057
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1058
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1059
+ gapic_version: ::Google::Cloud::AIPlatform::V1::VERSION,
1060
+ transports_version_send: [:rest]
1061
+
1062
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
1063
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1064
+
1065
+ options.apply_defaults timeout: @config.rpcs.stream_generate_content.timeout,
1066
+ metadata: call_metadata,
1067
+ retry_policy: @config.rpcs.stream_generate_content.retry_policy
1068
+
1069
+ options.apply_defaults timeout: @config.timeout,
1070
+ metadata: @config.metadata,
1071
+ retry_policy: @config.retry_policy
1072
+
1073
+ ::Gapic::Rest::ServerStream.new(
1074
+ ::Google::Cloud::AIPlatform::V1::GenerateContentResponse,
1075
+ ::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q|
1076
+ @prediction_service_stub.stream_generate_content request, options do |chunk|
1077
+ in_q.deq
1078
+ out_q.enq chunk
1079
+ end
1080
+ end
1081
+ )
1082
+ rescue ::Gapic::Rest::Error => e
1083
+ raise ::Google::Cloud::Error.from_error(e)
1084
+ end
1085
+
1086
+ ##
1087
+ # Configuration class for the PredictionService REST API.
1088
+ #
1089
+ # This class represents the configuration for PredictionService REST,
1090
+ # providing control over timeouts, retry behavior, logging, transport
1091
+ # parameters, and other low-level controls. Certain parameters can also be
1092
+ # applied individually to specific RPCs. See
1093
+ # {::Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client::Configuration::Rpcs}
1094
+ # for a list of RPCs that can be configured independently.
1095
+ #
1096
+ # Configuration can be applied globally to all clients, or to a single client
1097
+ # on construction.
1098
+ #
1099
+ # @example
1100
+ #
1101
+ # # Modify the global config, setting the timeout for
1102
+ # # predict to 20 seconds,
1103
+ # # and all remaining timeouts to 10 seconds.
1104
+ # ::Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client.configure do |config|
1105
+ # config.timeout = 10.0
1106
+ # config.rpcs.predict.timeout = 20.0
1107
+ # end
1108
+ #
1109
+ # # Apply the above configuration only to a new client.
1110
+ # client = ::Google::Cloud::AIPlatform::V1::PredictionService::Rest::Client.new do |config|
1111
+ # config.timeout = 10.0
1112
+ # config.rpcs.predict.timeout = 20.0
1113
+ # end
1114
+ #
1115
+ # @!attribute [rw] endpoint
1116
+ # A custom service endpoint, as a hostname or hostname:port. The default is
1117
+ # nil, indicating to use the default endpoint in the current universe domain.
1118
+ # @return [::String,nil]
1119
+ # @!attribute [rw] credentials
1120
+ # Credentials to send with calls. You may provide any of the following types:
1121
+ # * (`String`) The path to a service account key file in JSON format
1122
+ # * (`Hash`) A service account key as a Hash
1123
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
1124
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
1125
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
1126
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
1127
+ # * (`nil`) indicating no credentials
1128
+ # @return [::Object]
1129
+ # @!attribute [rw] scope
1130
+ # The OAuth scopes
1131
+ # @return [::Array<::String>]
1132
+ # @!attribute [rw] lib_name
1133
+ # The library name as recorded in instrumentation and logging
1134
+ # @return [::String]
1135
+ # @!attribute [rw] lib_version
1136
+ # The library version as recorded in instrumentation and logging
1137
+ # @return [::String]
1138
+ # @!attribute [rw] timeout
1139
+ # The call timeout in seconds.
1140
+ # @return [::Numeric]
1141
+ # @!attribute [rw] metadata
1142
+ # Additional headers to be sent with the call.
1143
+ # @return [::Hash{::Symbol=>::String}]
1144
+ # @!attribute [rw] retry_policy
1145
+ # The retry policy. The value is a hash with the following keys:
1146
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1147
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1148
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1149
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1150
+ # trigger a retry.
1151
+ # @return [::Hash]
1152
+ # @!attribute [rw] quota_project
1153
+ # A separate project against which to charge quota.
1154
+ # @return [::String]
1155
+ # @!attribute [rw] universe_domain
1156
+ # The universe domain within which to make requests. This determines the
1157
+ # default endpoint URL. The default value of nil uses the environment
1158
+ # universe (usually the default "googleapis.com" universe).
1159
+ # @return [::String,nil]
1160
+ #
1161
+ class Configuration
1162
+ extend ::Gapic::Config
1163
+
1164
+ # @private
1165
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
1166
+ DEFAULT_ENDPOINT = "aiplatform.googleapis.com"
1167
+
1168
+ config_attr :endpoint, nil, ::String, nil
1169
+ config_attr :credentials, nil do |value|
1170
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1171
+ allowed.any? { |klass| klass === value }
1172
+ end
1173
+ config_attr :scope, nil, ::String, ::Array, nil
1174
+ config_attr :lib_name, nil, ::String, nil
1175
+ config_attr :lib_version, nil, ::String, nil
1176
+ config_attr :timeout, nil, ::Numeric, nil
1177
+ config_attr :metadata, nil, ::Hash, nil
1178
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1179
+ config_attr :quota_project, nil, ::String, nil
1180
+ config_attr :universe_domain, nil, ::String, nil
1181
+
1182
+ # @private
1183
+ # Overrides for http bindings for the RPCs of this service
1184
+ # are only used when this service is used as mixin, and only
1185
+ # by the host service.
1186
+ # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
1187
+ config_attr :bindings_override, {}, ::Hash, nil
1188
+
1189
+ # @private
1190
+ def initialize parent_config = nil
1191
+ @parent_config = parent_config unless parent_config.nil?
1192
+
1193
+ yield self if block_given?
1194
+ end
1195
+
1196
+ ##
1197
+ # Configurations for individual RPCs
1198
+ # @return [Rpcs]
1199
+ #
1200
+ def rpcs
1201
+ @rpcs ||= begin
1202
+ parent_rpcs = nil
1203
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
1204
+ Rpcs.new parent_rpcs
1205
+ end
1206
+ end
1207
+
1208
+ ##
1209
+ # Configuration RPC class for the PredictionService API.
1210
+ #
1211
+ # Includes fields providing the configuration for each RPC in this service.
1212
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1213
+ # the following configuration fields:
1214
+ #
1215
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
1216
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
1217
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1218
+ # include the following keys:
1219
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1220
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1221
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1222
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1223
+ # trigger a retry.
1224
+ #
1225
+ class Rpcs
1226
+ ##
1227
+ # RPC-specific configuration for `predict`
1228
+ # @return [::Gapic::Config::Method]
1229
+ #
1230
+ attr_reader :predict
1231
+ ##
1232
+ # RPC-specific configuration for `raw_predict`
1233
+ # @return [::Gapic::Config::Method]
1234
+ #
1235
+ attr_reader :raw_predict
1236
+ ##
1237
+ # RPC-specific configuration for `stream_raw_predict`
1238
+ # @return [::Gapic::Config::Method]
1239
+ #
1240
+ attr_reader :stream_raw_predict
1241
+ ##
1242
+ # RPC-specific configuration for `direct_predict`
1243
+ # @return [::Gapic::Config::Method]
1244
+ #
1245
+ attr_reader :direct_predict
1246
+ ##
1247
+ # RPC-specific configuration for `direct_raw_predict`
1248
+ # @return [::Gapic::Config::Method]
1249
+ #
1250
+ attr_reader :direct_raw_predict
1251
+ ##
1252
+ # RPC-specific configuration for `server_streaming_predict`
1253
+ # @return [::Gapic::Config::Method]
1254
+ #
1255
+ attr_reader :server_streaming_predict
1256
+ ##
1257
+ # RPC-specific configuration for `explain`
1258
+ # @return [::Gapic::Config::Method]
1259
+ #
1260
+ attr_reader :explain
1261
+ ##
1262
+ # RPC-specific configuration for `generate_content`
1263
+ # @return [::Gapic::Config::Method]
1264
+ #
1265
+ attr_reader :generate_content
1266
+ ##
1267
+ # RPC-specific configuration for `stream_generate_content`
1268
+ # @return [::Gapic::Config::Method]
1269
+ #
1270
+ attr_reader :stream_generate_content
1271
+
1272
+ # @private
1273
+ def initialize parent_rpcs = nil
1274
+ predict_config = parent_rpcs.predict if parent_rpcs.respond_to? :predict
1275
+ @predict = ::Gapic::Config::Method.new predict_config
1276
+ raw_predict_config = parent_rpcs.raw_predict if parent_rpcs.respond_to? :raw_predict
1277
+ @raw_predict = ::Gapic::Config::Method.new raw_predict_config
1278
+ stream_raw_predict_config = parent_rpcs.stream_raw_predict if parent_rpcs.respond_to? :stream_raw_predict
1279
+ @stream_raw_predict = ::Gapic::Config::Method.new stream_raw_predict_config
1280
+ direct_predict_config = parent_rpcs.direct_predict if parent_rpcs.respond_to? :direct_predict
1281
+ @direct_predict = ::Gapic::Config::Method.new direct_predict_config
1282
+ direct_raw_predict_config = parent_rpcs.direct_raw_predict if parent_rpcs.respond_to? :direct_raw_predict
1283
+ @direct_raw_predict = ::Gapic::Config::Method.new direct_raw_predict_config
1284
+ server_streaming_predict_config = parent_rpcs.server_streaming_predict if parent_rpcs.respond_to? :server_streaming_predict
1285
+ @server_streaming_predict = ::Gapic::Config::Method.new server_streaming_predict_config
1286
+ explain_config = parent_rpcs.explain if parent_rpcs.respond_to? :explain
1287
+ @explain = ::Gapic::Config::Method.new explain_config
1288
+ generate_content_config = parent_rpcs.generate_content if parent_rpcs.respond_to? :generate_content
1289
+ @generate_content = ::Gapic::Config::Method.new generate_content_config
1290
+ stream_generate_content_config = parent_rpcs.stream_generate_content if parent_rpcs.respond_to? :stream_generate_content
1291
+ @stream_generate_content = ::Gapic::Config::Method.new stream_generate_content_config
1292
+
1293
+ yield self if block_given?
1294
+ end
1295
+ end
1296
+ end
1297
+ end
1298
+ end
1299
+ end
1300
+ end
1301
+ end
1302
+ end
1303
+ end