google-cloud-capacity_planner-v1beta 0.a → 0.1.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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +122 -0
  4. data/README.md +153 -8
  5. data/lib/google/cloud/capacity_planner/v1beta/capacity_planning_service/client.rb +686 -0
  6. data/lib/google/cloud/capacity_planner/v1beta/capacity_planning_service/credentials.rb +48 -0
  7. data/lib/google/cloud/capacity_planner/v1beta/capacity_planning_service/paths.rb +64 -0
  8. data/lib/google/cloud/capacity_planner/v1beta/capacity_planning_service/rest/client.rb +639 -0
  9. data/lib/google/cloud/capacity_planner/v1beta/capacity_planning_service/rest/service_stub.rb +279 -0
  10. data/lib/google/cloud/capacity_planner/v1beta/capacity_planning_service/rest.rb +54 -0
  11. data/lib/google/cloud/capacity_planner/v1beta/capacity_planning_service.rb +57 -0
  12. data/lib/google/cloud/capacity_planner/v1beta/rest.rb +38 -0
  13. data/lib/google/cloud/capacity_planner/v1beta/usage_service/client.rb +1214 -0
  14. data/lib/google/cloud/capacity_planner/v1beta/usage_service/credentials.rb +48 -0
  15. data/lib/google/cloud/capacity_planner/v1beta/usage_service/operations.rb +813 -0
  16. data/lib/google/cloud/capacity_planner/v1beta/usage_service/paths.rb +50 -0
  17. data/lib/google/cloud/capacity_planner/v1beta/usage_service/rest/client.rb +1146 -0
  18. data/lib/google/cloud/capacity_planner/v1beta/usage_service/rest/operations.rb +914 -0
  19. data/lib/google/cloud/capacity_planner/v1beta/usage_service/rest/service_stub.rb +546 -0
  20. data/lib/google/cloud/capacity_planner/v1beta/usage_service/rest.rb +53 -0
  21. data/lib/google/cloud/capacity_planner/v1beta/usage_service.rb +56 -0
  22. data/lib/google/cloud/capacity_planner/v1beta/version.rb +7 -2
  23. data/lib/google/cloud/capacity_planner/v1beta.rb +46 -0
  24. data/lib/google/cloud/capacityplanner/v1beta/allocation_pb.rb +53 -0
  25. data/lib/google/cloud/capacityplanner/v1beta/capacity_planning_service_pb.rb +73 -0
  26. data/lib/google/cloud/capacityplanner/v1beta/capacity_planning_service_services_pb.rb +54 -0
  27. data/lib/google/cloud/capacityplanner/v1beta/future_reservation_pb.rb +51 -0
  28. data/lib/google/cloud/capacityplanner/v1beta/location_pb.rb +46 -0
  29. data/lib/google/cloud/capacityplanner/v1beta/resource_pb.rb +51 -0
  30. data/lib/google/cloud/capacityplanner/v1beta/usage_service_pb.rb +90 -0
  31. data/lib/google/cloud/capacityplanner/v1beta/usage_service_services_pb.rb +61 -0
  32. data/lib/google-cloud-capacity_planner-v1beta.rb +21 -0
  33. data/proto_docs/README.md +4 -0
  34. data/proto_docs/google/api/client.rb +473 -0
  35. data/proto_docs/google/api/field_behavior.rb +85 -0
  36. data/proto_docs/google/api/launch_stage.rb +71 -0
  37. data/proto_docs/google/api/resource.rb +227 -0
  38. data/proto_docs/google/cloud/capacityplanner/v1beta/allocation.rb +206 -0
  39. data/proto_docs/google/cloud/capacityplanner/v1beta/capacity_planning_service.rb +374 -0
  40. data/proto_docs/google/cloud/capacityplanner/v1beta/future_reservation.rb +185 -0
  41. data/proto_docs/google/cloud/capacityplanner/v1beta/location.rb +79 -0
  42. data/proto_docs/google/cloud/capacityplanner/v1beta/resource.rb +159 -0
  43. data/proto_docs/google/cloud/capacityplanner/v1beta/usage_service.rb +912 -0
  44. data/proto_docs/google/longrunning/operations.rb +173 -0
  45. data/proto_docs/google/protobuf/any.rb +145 -0
  46. data/proto_docs/google/protobuf/duration.rb +98 -0
  47. data/proto_docs/google/protobuf/empty.rb +34 -0
  48. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  49. data/proto_docs/google/rpc/status.rb +48 -0
  50. data/proto_docs/google/type/date.rb +53 -0
  51. metadata +83 -9
@@ -0,0 +1,1146 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2025 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/capacityplanner/v1beta/usage_service_pb"
21
+ require "google/cloud/capacity_planner/v1beta/usage_service/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module CapacityPlanner
26
+ module V1beta
27
+ module UsageService
28
+ module Rest
29
+ ##
30
+ # REST client for the UsageService service.
31
+ #
32
+ # Provides access to historical and forecasted usage data.
33
+ #
34
+ class Client
35
+ # @private
36
+ API_VERSION = ""
37
+
38
+ # @private
39
+ DEFAULT_ENDPOINT_TEMPLATE = "capacityplanner.$UNIVERSE_DOMAIN$"
40
+
41
+ include Paths
42
+
43
+ # @private
44
+ attr_reader :usage_service_stub
45
+
46
+ ##
47
+ # Configure the UsageService Client class.
48
+ #
49
+ # See {::Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Client::Configuration}
50
+ # for a description of the configuration fields.
51
+ #
52
+ # @example
53
+ #
54
+ # # Modify the configuration for all UsageService clients
55
+ # ::Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Client.configure do |config|
56
+ # config.timeout = 10.0
57
+ # end
58
+ #
59
+ # @yield [config] Configure the Client client.
60
+ # @yieldparam config [Client::Configuration]
61
+ #
62
+ # @return [Client::Configuration]
63
+ #
64
+ def self.configure
65
+ @configure ||= begin
66
+ namespace = ["Google", "Cloud", "CapacityPlanner", "V1beta"]
67
+ parent_config = while namespace.any?
68
+ parent_name = namespace.join "::"
69
+ parent_const = const_get parent_name
70
+ break parent_const.configure if parent_const.respond_to? :configure
71
+ namespace.pop
72
+ end
73
+ default_config = Client::Configuration.new parent_config
74
+
75
+ default_config.timeout = 60.0
76
+ default_config.retry_policy = {
77
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4, 13]
78
+ }
79
+
80
+ default_config
81
+ end
82
+ yield @configure if block_given?
83
+ @configure
84
+ end
85
+
86
+ ##
87
+ # Configure the UsageService Client instance.
88
+ #
89
+ # The configuration is set to the derived mode, meaning that values can be changed,
90
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
91
+ # should be made on {Client.configure}.
92
+ #
93
+ # See {::Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Client::Configuration}
94
+ # for a description of the configuration fields.
95
+ #
96
+ # @yield [config] Configure the Client client.
97
+ # @yieldparam config [Client::Configuration]
98
+ #
99
+ # @return [Client::Configuration]
100
+ #
101
+ def configure
102
+ yield @config if block_given?
103
+ @config
104
+ end
105
+
106
+ ##
107
+ # The effective universe domain
108
+ #
109
+ # @return [String]
110
+ #
111
+ def universe_domain
112
+ @usage_service_stub.universe_domain
113
+ end
114
+
115
+ ##
116
+ # Create a new UsageService REST client object.
117
+ #
118
+ # @example
119
+ #
120
+ # # Create a client using the default configuration
121
+ # client = ::Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Client.new
122
+ #
123
+ # # Create a client using a custom configuration
124
+ # client = ::Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Client.new do |config|
125
+ # config.timeout = 10.0
126
+ # end
127
+ #
128
+ # @yield [config] Configure the UsageService client.
129
+ # @yieldparam config [Client::Configuration]
130
+ #
131
+ def initialize
132
+ # Create the configuration object
133
+ @config = Configuration.new Client.configure
134
+
135
+ # Yield the configuration if needed
136
+ yield @config if block_given?
137
+
138
+ # Create credentials
139
+ credentials = @config.credentials
140
+ # Use self-signed JWT if the endpoint is unchanged from default,
141
+ # but only if the default endpoint does not have a region prefix.
142
+ enable_self_signed_jwt = @config.endpoint.nil? ||
143
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
144
+ !@config.endpoint.split(".").first.include?("-"))
145
+ credentials ||= Credentials.default scope: @config.scope,
146
+ enable_self_signed_jwt: enable_self_signed_jwt
147
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
148
+ credentials = Credentials.new credentials, scope: @config.scope
149
+ end
150
+
151
+ @quota_project_id = @config.quota_project
152
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
153
+
154
+ @operations_client = ::Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Operations.new do |config|
155
+ config.credentials = credentials
156
+ config.quota_project = @quota_project_id
157
+ config.endpoint = @config.endpoint
158
+ config.universe_domain = @config.universe_domain
159
+ end
160
+
161
+ @usage_service_stub = ::Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::ServiceStub.new(
162
+ endpoint: @config.endpoint,
163
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
164
+ universe_domain: @config.universe_domain,
165
+ credentials: credentials,
166
+ logger: @config.logger
167
+ )
168
+
169
+ @usage_service_stub.logger(stub: true)&.info do |entry|
170
+ entry.set_system_name
171
+ entry.set_service
172
+ entry.message = "Created client for #{entry.service}"
173
+ entry.set_credentials_fields credentials
174
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
175
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
176
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
177
+ end
178
+ end
179
+
180
+ ##
181
+ # Get the associated client for long-running operations.
182
+ #
183
+ # @return [::Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Operations]
184
+ #
185
+ attr_reader :operations_client
186
+
187
+ ##
188
+ # The logger used for request/response debug logging.
189
+ #
190
+ # @return [Logger]
191
+ #
192
+ def logger
193
+ @usage_service_stub.logger
194
+ end
195
+
196
+ # Service calls
197
+
198
+ ##
199
+ # Returns a list of the usage histories that are in the parent parameter
200
+ # and match your specified filters.
201
+ #
202
+ # @overload query_usage_histories(request, options = nil)
203
+ # Pass arguments to `query_usage_histories` via a request object, either of type
204
+ # {::Google::Cloud::CapacityPlanner::V1beta::QueryUsageHistoriesRequest} or an equivalent Hash.
205
+ #
206
+ # @param request [::Google::Cloud::CapacityPlanner::V1beta::QueryUsageHistoriesRequest, ::Hash]
207
+ # A request object representing the call parameters. Required. To specify no
208
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
209
+ # @param options [::Gapic::CallOptions, ::Hash]
210
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
211
+ #
212
+ # @overload query_usage_histories(parent: nil, location_level: nil, is_spot: nil, machine_family: nil, machine_shape: nil, disk_type: nil, confidential_mode: nil, gpu_type: nil, tpu_type: nil, cloud_resource_type: nil, usage_aggregation_method: nil, start_date: nil, end_date: nil)
213
+ # Pass arguments to `query_usage_histories` via keyword arguments. Note that at
214
+ # least one keyword argument is required. To specify no parameters, or to keep all
215
+ # the default parameter values, pass an empty Hash as a request object (see above).
216
+ #
217
+ # @param parent [::String]
218
+ # Required. The compute engine resource and location for the time series
219
+ # values to return. The format is:
220
+ #
221
+ # projects/{project}/locations/{location} or
222
+ # organizations/{organization}/locations/{location} or
223
+ # folders/{folder}/locations/{location}
224
+ # @param location_level [::Google::Cloud::CapacityPlanner::V1beta::TimeSeries::LocationType]
225
+ # Optional. The location level of the reservations usage timeseries.
226
+ # @param is_spot [::Boolean]
227
+ # Optional. The is_spot flag is used to fetch the usage data for preemptible
228
+ # Resources.
229
+ # @param machine_family [::String]
230
+ # The machine family for the `UsageHistory` values to return. Possible values
231
+ # include "n1", and "n2d". See
232
+ # https://cloud.google.com/compute/docs/machine-types for more examples.
233
+ # Empty machine_family will return results matching all machine families.
234
+ # @param machine_shape [::Google::Cloud::CapacityPlanner::V1beta::MachineShape, ::Hash]
235
+ # Optional. The machine shape for the `UsageHistory` values to return.
236
+ # @param disk_type [::String]
237
+ # Optional. The disk_type for the `UsageHistory` values to return request
238
+ # with persistent-disk cloud_resource_type. Empty disk_type will return
239
+ # results matching all disk types.
240
+ # @param confidential_mode [::Boolean]
241
+ # Optional. Whether the persistent disk is in confidential mode.
242
+ # @param gpu_type [::String]
243
+ # Optional. The GPU type for the `UsageHistory` values to return. Sample
244
+ # values are "nvidia-tesla-t4", and "nvidia-tesla-a100". See
245
+ # https://cloud.google.com/compute/docs/gpus for a list. Empty gpu_type
246
+ # will return results matching all GPUs.
247
+ # @param tpu_type [::String]
248
+ # Optional. The TPU type for the `UsageHistory` values to return. Empty
249
+ # tpu_type will return results matching all TPUs.
250
+ # @param cloud_resource_type [::String]
251
+ # The resource for the `UsageHistory` values to return. Possible values
252
+ # include "gce-vcpus", "gce-ram", "gce-local-ssd", "gce-persistent-disk",
253
+ # "gce-gpu" and "gce-tpu".
254
+ # Empty cloud_resource_type will return results matching all resources.
255
+ # @param usage_aggregation_method [::Google::Cloud::CapacityPlanner::V1beta::UsageHistory::AggregationMethod]
256
+ # The method that should be used to convert sampled usage data to daily
257
+ # usage values.
258
+ # AGGREGATION_METHOD_UNSPECIFIED will return results matching all the
259
+ # aggregation methods.
260
+ # @param start_date [::Google::Type::Date, ::Hash]
261
+ # Optional. The start date of reservations usage.
262
+ # @param end_date [::Google::Type::Date, ::Hash]
263
+ # Optional. The end date of reservations usage.
264
+ # @yield [result, operation] Access the result along with the TransportOperation object
265
+ # @yieldparam result [::Google::Cloud::CapacityPlanner::V1beta::QueryUsageHistoriesResponse]
266
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
267
+ #
268
+ # @return [::Google::Cloud::CapacityPlanner::V1beta::QueryUsageHistoriesResponse]
269
+ #
270
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
271
+ #
272
+ # @example Basic example
273
+ # require "google/cloud/capacity_planner/v1beta"
274
+ #
275
+ # # Create a client object. The client can be reused for multiple calls.
276
+ # client = Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Client.new
277
+ #
278
+ # # Create a request. To set request fields, pass in keyword arguments.
279
+ # request = Google::Cloud::CapacityPlanner::V1beta::QueryUsageHistoriesRequest.new
280
+ #
281
+ # # Call the query_usage_histories method.
282
+ # result = client.query_usage_histories request
283
+ #
284
+ # # The returned object is of type Google::Cloud::CapacityPlanner::V1beta::QueryUsageHistoriesResponse.
285
+ # p result
286
+ #
287
+ def query_usage_histories request, options = nil
288
+ raise ::ArgumentError, "request must be provided" if request.nil?
289
+
290
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CapacityPlanner::V1beta::QueryUsageHistoriesRequest
291
+
292
+ # Converts hash and nil to an options object
293
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
294
+
295
+ # Customize the options with defaults
296
+ call_metadata = @config.rpcs.query_usage_histories.metadata.to_h
297
+
298
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
299
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
300
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
301
+ gapic_version: ::Google::Cloud::CapacityPlanner::V1beta::VERSION,
302
+ transports_version_send: [:rest]
303
+
304
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
305
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
306
+
307
+ options.apply_defaults timeout: @config.rpcs.query_usage_histories.timeout,
308
+ metadata: call_metadata,
309
+ retry_policy: @config.rpcs.query_usage_histories.retry_policy
310
+
311
+ options.apply_defaults timeout: @config.timeout,
312
+ metadata: @config.metadata,
313
+ retry_policy: @config.retry_policy
314
+
315
+ @usage_service_stub.query_usage_histories request, options do |result, operation|
316
+ yield result, operation if block_given?
317
+ end
318
+ rescue ::Gapic::Rest::Error => e
319
+ raise ::Google::Cloud::Error.from_error(e)
320
+ end
321
+
322
+ ##
323
+ # Returns a list of the forecasts that are in the parent parameter
324
+ # and match your specified filters.
325
+ #
326
+ # @overload query_forecasts(request, options = nil)
327
+ # Pass arguments to `query_forecasts` via a request object, either of type
328
+ # {::Google::Cloud::CapacityPlanner::V1beta::QueryForecastsRequest} or an equivalent Hash.
329
+ #
330
+ # @param request [::Google::Cloud::CapacityPlanner::V1beta::QueryForecastsRequest, ::Hash]
331
+ # A request object representing the call parameters. Required. To specify no
332
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
333
+ # @param options [::Gapic::CallOptions, ::Hash]
334
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
335
+ #
336
+ # @overload query_forecasts(parent: nil, machine_family: nil, machine_shape: nil, disk_type: nil, confidential_mode: nil, gpu_type: nil, tpu_type: nil, cloud_resource_type: nil, forecast_type: nil, prediction_interval: nil, aggregation_method: nil)
337
+ # Pass arguments to `query_forecasts` via keyword arguments. Note that at
338
+ # least one keyword argument is required. To specify no parameters, or to keep all
339
+ # the default parameter values, pass an empty Hash as a request object (see above).
340
+ #
341
+ # @param parent [::String]
342
+ # Required. The compute engine resource and location for the time series
343
+ # values to return. The format is:
344
+ #
345
+ # projects/\\{project}/locations/\\{location} or
346
+ # organizations/\\{organization}/locations/\\{location} or
347
+ # folders/\\{folder}/locations/\\{location}
348
+ # @param machine_family [::String]
349
+ # The machine family to use to select the `Forecast` values to return.
350
+ # Possible values include "n1", and "n2d".
351
+ # Empty machine_family will return results matching all machine families.
352
+ # @param machine_shape [::Google::Cloud::CapacityPlanner::V1beta::MachineShape, ::Hash]
353
+ # Optional. The machine shape for the time series values to return.
354
+ # @param disk_type [::String]
355
+ # Optional. The disk_type for the `Forecast` values to return with request
356
+ # persistent-disk cloud_resource_type.
357
+ # Empty disk_type will return results matching all disk types.
358
+ # @param confidential_mode [::Boolean]
359
+ # Optional. Whether the persistent disk is in confidential mode.
360
+ # @param gpu_type [::String]
361
+ # Optional. The GPU type for the `Forecast` values to return. Sample values
362
+ # are "nvidia-tesla-t4", and "nvidia-tesla-a100". See
363
+ # https://cloud.google.com/compute/docs/gpus for a list. Empty gpu_type
364
+ # will return results matching all GPUs.
365
+ # @param tpu_type [::String]
366
+ # Optional. The TPU type for the `Forecast` values to return. Empty tpu_type
367
+ # will return results matching all TPUs.
368
+ # @param cloud_resource_type [::String]
369
+ # The resource for the `Forecast` values to return. Possible values include
370
+ # "gce-vcpus", "gce-ram", "gce-local-ssd", "gce-persistent-disk", "gce-gpu"
371
+ # and "gce-tpu".
372
+ # Empty cloud_resource_type will return results matching all resources.
373
+ # @param forecast_type [::Google::Cloud::CapacityPlanner::V1beta::Forecast::ForecastType]
374
+ # The type of forecast to use to select the `Forecast` values to return.
375
+ # FORECAST_TYPE_UNSPECIFIED will return results matching all the forecast
376
+ # types.
377
+ # @param prediction_interval [::Google::Cloud::CapacityPlanner::V1beta::Forecast::PredictionInterval]
378
+ # The prediction interval to use to select the `Forecast` values to return.
379
+ # PREDICTION_INTERVAL_UNSPECIFIED will return results matching all prediction
380
+ # intervals.
381
+ # @param aggregation_method [::Google::Cloud::CapacityPlanner::V1beta::UsageHistory::AggregationMethod]
382
+ # Aggregation Method of the historical usage for which the forecast is
383
+ # generated
384
+ # @yield [result, operation] Access the result along with the TransportOperation object
385
+ # @yieldparam result [::Google::Cloud::CapacityPlanner::V1beta::QueryForecastsResponse]
386
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
387
+ #
388
+ # @return [::Google::Cloud::CapacityPlanner::V1beta::QueryForecastsResponse]
389
+ #
390
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
391
+ #
392
+ # @example Basic example
393
+ # require "google/cloud/capacity_planner/v1beta"
394
+ #
395
+ # # Create a client object. The client can be reused for multiple calls.
396
+ # client = Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Client.new
397
+ #
398
+ # # Create a request. To set request fields, pass in keyword arguments.
399
+ # request = Google::Cloud::CapacityPlanner::V1beta::QueryForecastsRequest.new
400
+ #
401
+ # # Call the query_forecasts method.
402
+ # result = client.query_forecasts request
403
+ #
404
+ # # The returned object is of type Google::Cloud::CapacityPlanner::V1beta::QueryForecastsResponse.
405
+ # p result
406
+ #
407
+ def query_forecasts request, options = nil
408
+ raise ::ArgumentError, "request must be provided" if request.nil?
409
+
410
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CapacityPlanner::V1beta::QueryForecastsRequest
411
+
412
+ # Converts hash and nil to an options object
413
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
414
+
415
+ # Customize the options with defaults
416
+ call_metadata = @config.rpcs.query_forecasts.metadata.to_h
417
+
418
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
419
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
420
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
421
+ gapic_version: ::Google::Cloud::CapacityPlanner::V1beta::VERSION,
422
+ transports_version_send: [:rest]
423
+
424
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
425
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
426
+
427
+ options.apply_defaults timeout: @config.rpcs.query_forecasts.timeout,
428
+ metadata: call_metadata,
429
+ retry_policy: @config.rpcs.query_forecasts.retry_policy
430
+
431
+ options.apply_defaults timeout: @config.timeout,
432
+ metadata: @config.metadata,
433
+ retry_policy: @config.retry_policy
434
+
435
+ @usage_service_stub.query_forecasts request, options do |result, operation|
436
+ yield result, operation if block_given?
437
+ end
438
+ rescue ::Gapic::Rest::Error => e
439
+ raise ::Google::Cloud::Error.from_error(e)
440
+ end
441
+
442
+ ##
443
+ # Returns a list of the reservations that are in the parent parameter
444
+ # and match your specified filters.
445
+ #
446
+ # @overload query_reservations(request, options = nil)
447
+ # Pass arguments to `query_reservations` via a request object, either of type
448
+ # {::Google::Cloud::CapacityPlanner::V1beta::QueryReservationsRequest} or an equivalent Hash.
449
+ #
450
+ # @param request [::Google::Cloud::CapacityPlanner::V1beta::QueryReservationsRequest, ::Hash]
451
+ # A request object representing the call parameters. Required. To specify no
452
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
453
+ # @param options [::Gapic::CallOptions, ::Hash]
454
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
455
+ #
456
+ # @overload query_reservations(parent: nil, location_level: nil, machine_family: nil, machine_shape: nil, gpu_type: nil, cloud_resource_type: nil, reservation_type: nil, share_type: nil, ownership_type: nil, reservation_data_level: nil, include_unapproved_reservations: nil, aggregation_method: nil, start_date: nil, end_date: nil)
457
+ # Pass arguments to `query_reservations` via keyword arguments. Note that at
458
+ # least one keyword argument is required. To specify no parameters, or to keep all
459
+ # the default parameter values, pass an empty Hash as a request object (see above).
460
+ #
461
+ # @param parent [::String]
462
+ # Required. The compute engine resource and location for the time series
463
+ # values to return. The format is:
464
+ #
465
+ # projects/\\{project}/locations/\\{location} or
466
+ # organizations/\\{organization}/locations/\\{location} or
467
+ # folders/\\{folder}/locations/\\{location}
468
+ # @param location_level [::Google::Cloud::CapacityPlanner::V1beta::TimeSeries::LocationType]
469
+ # Optional. The location level of the reservations usage timeseries.
470
+ # @param machine_family [::String]
471
+ # Optional. The machine family to use to select the aggregate reserved values
472
+ # to return. Possible values include "n1", and "n2d" etc. Empty
473
+ # machine_family will return results matching all machine families.
474
+ # @param machine_shape [::Google::Cloud::CapacityPlanner::V1beta::MachineShape, ::Hash]
475
+ # Optional. The machine_shape as a filter to select matching reservations.
476
+ # @param gpu_type [::String]
477
+ # Optional. The GPU type for the reserved values to return. Sample values
478
+ # are "nvidia-tesla-t4", and "nvidia-tesla-a100". See
479
+ # https://cloud.google.com/compute/docs/gpus for a list. Empty gpu_type
480
+ # will return results matching all GPUs.
481
+ # @param cloud_resource_type [::String]
482
+ # Optional. The resource for the reserved values to return. Possible values
483
+ # include "gce-vcpus", "gce-ram", "gce-local-ssd", "gce-gpu" and "gce-vm".
484
+ # @param reservation_type [::Google::Cloud::CapacityPlanner::V1beta::QueryReservationsRequest::ReservationType]
485
+ # Optional. The Reservation type for example, future reservation request and
486
+ # allocation. If unspecified, all types are
487
+ # included.
488
+ # @param share_type [::Google::Cloud::CapacityPlanner::V1beta::QueryReservationsRequest::ShareType]
489
+ # Optional. Types of share settings to filter reservations in response. If
490
+ # unspecified, all types are included.
491
+ # @param ownership_type [::Google::Cloud::CapacityPlanner::V1beta::QueryReservationsRequest::OwnershipType]
492
+ # Optional. Types of ownerships to filter reservations based on.
493
+ # In case of OWNED, it filters reservations which are owned by selected
494
+ # parent project/folder/organization. If unspecified, all types are
495
+ # included.
496
+ # @param reservation_data_level [::Google::Cloud::CapacityPlanner::V1beta::QueryReservationsRequest::ReservationDataLevel]
497
+ # Optional. Reservations output data format.
498
+ # @param include_unapproved_reservations [::Boolean]
499
+ # Optional. Whether to include pending for approval reservations in the
500
+ # response. This field is only applicable for future reservations.
501
+ # @param aggregation_method [::Google::Cloud::CapacityPlanner::V1beta::UsageHistory::AggregationMethod]
502
+ # Optional. Aggregation Method of the historical reservation usage
503
+ # @param start_date [::Google::Type::Date, ::Hash]
504
+ # Optional. The start date of reservations usage.
505
+ # @param end_date [::Google::Type::Date, ::Hash]
506
+ # Optional. The end date of reservations usage.
507
+ # @yield [result, operation] Access the result along with the TransportOperation object
508
+ # @yieldparam result [::Google::Cloud::CapacityPlanner::V1beta::QueryReservationsResponse]
509
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
510
+ #
511
+ # @return [::Google::Cloud::CapacityPlanner::V1beta::QueryReservationsResponse]
512
+ #
513
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
514
+ #
515
+ # @example Basic example
516
+ # require "google/cloud/capacity_planner/v1beta"
517
+ #
518
+ # # Create a client object. The client can be reused for multiple calls.
519
+ # client = Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Client.new
520
+ #
521
+ # # Create a request. To set request fields, pass in keyword arguments.
522
+ # request = Google::Cloud::CapacityPlanner::V1beta::QueryReservationsRequest.new
523
+ #
524
+ # # Call the query_reservations method.
525
+ # result = client.query_reservations request
526
+ #
527
+ # # The returned object is of type Google::Cloud::CapacityPlanner::V1beta::QueryReservationsResponse.
528
+ # p result
529
+ #
530
+ def query_reservations request, options = nil
531
+ raise ::ArgumentError, "request must be provided" if request.nil?
532
+
533
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CapacityPlanner::V1beta::QueryReservationsRequest
534
+
535
+ # Converts hash and nil to an options object
536
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
537
+
538
+ # Customize the options with defaults
539
+ call_metadata = @config.rpcs.query_reservations.metadata.to_h
540
+
541
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
542
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
543
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
544
+ gapic_version: ::Google::Cloud::CapacityPlanner::V1beta::VERSION,
545
+ transports_version_send: [:rest]
546
+
547
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
548
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
549
+
550
+ options.apply_defaults timeout: @config.rpcs.query_reservations.timeout,
551
+ metadata: call_metadata,
552
+ retry_policy: @config.rpcs.query_reservations.retry_policy
553
+
554
+ options.apply_defaults timeout: @config.timeout,
555
+ metadata: @config.metadata,
556
+ retry_policy: @config.retry_policy
557
+
558
+ @usage_service_stub.query_reservations request, options do |result, operation|
559
+ yield result, operation if block_given?
560
+ end
561
+ rescue ::Gapic::Rest::Error => e
562
+ raise ::Google::Cloud::Error.from_error(e)
563
+ end
564
+
565
+ ##
566
+ # Exports historical usage data requested by user into either an existing
567
+ # Cloud Storage bucket or a BigQuery table.
568
+ #
569
+ # @overload export_usage_histories(request, options = nil)
570
+ # Pass arguments to `export_usage_histories` via a request object, either of type
571
+ # {::Google::Cloud::CapacityPlanner::V1beta::ExportUsageHistoriesRequest} or an equivalent Hash.
572
+ #
573
+ # @param request [::Google::Cloud::CapacityPlanner::V1beta::ExportUsageHistoriesRequest, ::Hash]
574
+ # A request object representing the call parameters. Required. To specify no
575
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
576
+ # @param options [::Gapic::CallOptions, ::Hash]
577
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
578
+ #
579
+ # @overload export_usage_histories(parent: nil, is_spot: nil, machine_family: nil, machine_shape: nil, disk_type: nil, gpu_type: nil, tpu_type: nil, resource_type: nil, usage_aggregation_method: nil, start_date: nil, end_date: nil, output_config: nil)
580
+ # Pass arguments to `export_usage_histories` via keyword arguments. Note that at
581
+ # least one keyword argument is required. To specify no parameters, or to keep all
582
+ # the default parameter values, pass an empty Hash as a request object (see above).
583
+ #
584
+ # @param parent [::String]
585
+ # Required. The compute engine resource and location for the time series
586
+ # values to return. The format is:
587
+ # projects/\\{project}/locations/\\{location} or
588
+ # organizations/\\{organization}/locations/\\{location} or
589
+ # folders/\\{folder}/locations/\\{location}
590
+ # @param is_spot [::Boolean]
591
+ # Optional. Set true to export usage for spot resources.
592
+ # @param machine_family [::String]
593
+ # Optional. The machine family for the `UsageHistory` values to return.
594
+ # Possible values include "n1", and "n2d". See
595
+ # https://cloud.google.com/compute/docs/machine-types for more examples.
596
+ # @param machine_shape [::Google::Cloud::CapacityPlanner::V1beta::MachineShape, ::Hash]
597
+ # Optional. The machine shape for the time series values to export.
598
+ # @param disk_type [::String]
599
+ # Optional. The disk_type for the `UsageHistory` values to return request
600
+ # with persistent-disk resource_type. Possible values include "pd-ssd",
601
+ # "pd-standard", "pd-balanced", and "pd-extreme".
602
+ # @param gpu_type [::String]
603
+ # Optional. The GPU type for the `UsageHistory` values to return. Sample
604
+ # values are "nvidia-tesla-t4", and "nvidia-tesla-a100". See
605
+ # https://cloud.google.com/compute/docs/gpus for a list. Empty gpu_type
606
+ # will return results matching all GPUs.
607
+ # @param tpu_type [::String]
608
+ # Optional. The TPU type for the `UsageHistory` values to return. Empty
609
+ # tpu_type will return results matching all TPUs.
610
+ # @param resource_type [::String]
611
+ # Required. The resource for the `UsageHistory` values to return. Possible
612
+ # values include "gce-vcpus", "gce-ram", "gce-local-ssd",
613
+ # "gce-persistent-disk", "gce-gpu" and "gce-tpu".
614
+ # @param usage_aggregation_method [::Google::Cloud::CapacityPlanner::V1beta::UsageHistory::AggregationMethod]
615
+ # Optional. The method that should be used to convert sampled usage data to
616
+ # daily usage values. AGGREGATION_METHOD_UNSPECIFIED will return results
617
+ # matching all the aggregation methods.
618
+ # @param start_date [::Google::Type::Date, ::Hash]
619
+ # Optional. The start date of usage.
620
+ # @param end_date [::Google::Type::Date, ::Hash]
621
+ # Optional. The end date of usage.
622
+ # @param output_config [::Google::Cloud::CapacityPlanner::V1beta::OutputConfig, ::Hash]
623
+ # Required. Output configuration indicating where the results will be output
624
+ # to.
625
+ # @yield [result, operation] Access the result along with the TransportOperation object
626
+ # @yieldparam result [::Gapic::Operation]
627
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
628
+ #
629
+ # @return [::Gapic::Operation]
630
+ #
631
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
632
+ #
633
+ # @example Basic example
634
+ # require "google/cloud/capacity_planner/v1beta"
635
+ #
636
+ # # Create a client object. The client can be reused for multiple calls.
637
+ # client = Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Client.new
638
+ #
639
+ # # Create a request. To set request fields, pass in keyword arguments.
640
+ # request = Google::Cloud::CapacityPlanner::V1beta::ExportUsageHistoriesRequest.new
641
+ #
642
+ # # Call the export_usage_histories method.
643
+ # result = client.export_usage_histories request
644
+ #
645
+ # # The returned object is of type Gapic::Operation. You can use it to
646
+ # # check the status of an operation, cancel it, or wait for results.
647
+ # # Here is how to wait for a response.
648
+ # result.wait_until_done! timeout: 60
649
+ # if result.response?
650
+ # p result.response
651
+ # else
652
+ # puts "No response received."
653
+ # end
654
+ #
655
+ def export_usage_histories request, options = nil
656
+ raise ::ArgumentError, "request must be provided" if request.nil?
657
+
658
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CapacityPlanner::V1beta::ExportUsageHistoriesRequest
659
+
660
+ # Converts hash and nil to an options object
661
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
662
+
663
+ # Customize the options with defaults
664
+ call_metadata = @config.rpcs.export_usage_histories.metadata.to_h
665
+
666
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
667
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
668
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
669
+ gapic_version: ::Google::Cloud::CapacityPlanner::V1beta::VERSION,
670
+ transports_version_send: [:rest]
671
+
672
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
673
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
674
+
675
+ options.apply_defaults timeout: @config.rpcs.export_usage_histories.timeout,
676
+ metadata: call_metadata,
677
+ retry_policy: @config.rpcs.export_usage_histories.retry_policy
678
+
679
+ options.apply_defaults timeout: @config.timeout,
680
+ metadata: @config.metadata,
681
+ retry_policy: @config.retry_policy
682
+
683
+ @usage_service_stub.export_usage_histories request, options do |result, operation|
684
+ result = ::Gapic::Operation.new result, @operations_client, options: options
685
+ yield result, operation if block_given?
686
+ throw :response, result
687
+ end
688
+ rescue ::Gapic::Rest::Error => e
689
+ raise ::Google::Cloud::Error.from_error(e)
690
+ end
691
+
692
+ ##
693
+ # Exports forecasted usage data requested by user into either an existing
694
+ # Cloud Storage bucket or a BigQuery table.
695
+ #
696
+ # @overload export_forecasts(request, options = nil)
697
+ # Pass arguments to `export_forecasts` via a request object, either of type
698
+ # {::Google::Cloud::CapacityPlanner::V1beta::ExportForecastsRequest} or an equivalent Hash.
699
+ #
700
+ # @param request [::Google::Cloud::CapacityPlanner::V1beta::ExportForecastsRequest, ::Hash]
701
+ # A request object representing the call parameters. Required. To specify no
702
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
703
+ # @param options [::Gapic::CallOptions, ::Hash]
704
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
705
+ #
706
+ # @overload export_forecasts(parent: nil, machine_family: nil, machine_shape: nil, disk_type: nil, gpu_type: nil, tpu_type: nil, resource_type: nil, prediction_interval: nil, aggregation_method: nil, start_date: nil, end_date: nil, output_config: nil)
707
+ # Pass arguments to `export_forecasts` via keyword arguments. Note that at
708
+ # least one keyword argument is required. To specify no parameters, or to keep all
709
+ # the default parameter values, pass an empty Hash as a request object (see above).
710
+ #
711
+ # @param parent [::String]
712
+ # Required. The compute engine resource and location for the time series
713
+ # values to return. The format is:
714
+ # projects/\\{project}/locations/\\{location} or
715
+ # organizations/\\{organization}/locations/\\{location} or
716
+ # folders/\\{folder}/locations/\\{location}
717
+ # @param machine_family [::String]
718
+ # Optional. The machine family to use to select the `Forecast` values to
719
+ # return. Possible values include "n1", and "n2d".
720
+ # @param machine_shape [::Google::Cloud::CapacityPlanner::V1beta::MachineShape, ::Hash]
721
+ # Optional. The machine shape for the time series values to export.
722
+ # @param disk_type [::String]
723
+ # Optional. The disk_type for the `Forecast` values to return with request
724
+ # persistent-disk resource_type.
725
+ # @param gpu_type [::String]
726
+ # Optional. The GPU type for the `Forecast` values to return. Sample values
727
+ # are "nvidia-tesla-t4", and "nvidia-tesla-a100". See
728
+ # https://cloud.google.com/compute/docs/gpus for a list. Empty gpu_type
729
+ # will return results matching all GPUs.
730
+ # @param tpu_type [::String]
731
+ # Optional. The TPU type for the `Forecast` values to return. Empty tpu_type
732
+ # will return results matching all TPUs.
733
+ # @param resource_type [::String]
734
+ # Required. The resource for the `Forecast` values to return. Possible values
735
+ # include "gce-vcpus", "gce-ram", "gce-local-ssd", "gce-persistent-disk",
736
+ # "gce-gpu" and "gce-tpu".
737
+ # @param prediction_interval [::Google::Cloud::CapacityPlanner::V1beta::Forecast::PredictionInterval]
738
+ # Optional. The prediction interval to use to select the `Forecast` values to
739
+ # return. PREDICTION_INTERVAL_UNSPECIFIED will return results matching all
740
+ # prediction intervals.
741
+ # @param aggregation_method [::Google::Cloud::CapacityPlanner::V1beta::UsageHistory::AggregationMethod]
742
+ # Optional. Aggregation Method of the historical usage for which the forecast
743
+ # is generated.
744
+ # @param start_date [::Google::Type::Date, ::Hash]
745
+ # Optional. The start date of forecasts.
746
+ # @param end_date [::Google::Type::Date, ::Hash]
747
+ # Optional. The end date of forecasts.
748
+ # @param output_config [::Google::Cloud::CapacityPlanner::V1beta::OutputConfig, ::Hash]
749
+ # Required. Output configuration indicating where the results will be output
750
+ # to.
751
+ # @yield [result, operation] Access the result along with the TransportOperation object
752
+ # @yieldparam result [::Gapic::Operation]
753
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
754
+ #
755
+ # @return [::Gapic::Operation]
756
+ #
757
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
758
+ #
759
+ # @example Basic example
760
+ # require "google/cloud/capacity_planner/v1beta"
761
+ #
762
+ # # Create a client object. The client can be reused for multiple calls.
763
+ # client = Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Client.new
764
+ #
765
+ # # Create a request. To set request fields, pass in keyword arguments.
766
+ # request = Google::Cloud::CapacityPlanner::V1beta::ExportForecastsRequest.new
767
+ #
768
+ # # Call the export_forecasts method.
769
+ # result = client.export_forecasts request
770
+ #
771
+ # # The returned object is of type Gapic::Operation. You can use it to
772
+ # # check the status of an operation, cancel it, or wait for results.
773
+ # # Here is how to wait for a response.
774
+ # result.wait_until_done! timeout: 60
775
+ # if result.response?
776
+ # p result.response
777
+ # else
778
+ # puts "No response received."
779
+ # end
780
+ #
781
+ def export_forecasts request, options = nil
782
+ raise ::ArgumentError, "request must be provided" if request.nil?
783
+
784
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CapacityPlanner::V1beta::ExportForecastsRequest
785
+
786
+ # Converts hash and nil to an options object
787
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
788
+
789
+ # Customize the options with defaults
790
+ call_metadata = @config.rpcs.export_forecasts.metadata.to_h
791
+
792
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
793
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
794
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
795
+ gapic_version: ::Google::Cloud::CapacityPlanner::V1beta::VERSION,
796
+ transports_version_send: [:rest]
797
+
798
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
799
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
800
+
801
+ options.apply_defaults timeout: @config.rpcs.export_forecasts.timeout,
802
+ metadata: call_metadata,
803
+ retry_policy: @config.rpcs.export_forecasts.retry_policy
804
+
805
+ options.apply_defaults timeout: @config.timeout,
806
+ metadata: @config.metadata,
807
+ retry_policy: @config.retry_policy
808
+
809
+ @usage_service_stub.export_forecasts request, options do |result, operation|
810
+ result = ::Gapic::Operation.new result, @operations_client, options: options
811
+ yield result, operation if block_given?
812
+ throw :response, result
813
+ end
814
+ rescue ::Gapic::Rest::Error => e
815
+ raise ::Google::Cloud::Error.from_error(e)
816
+ end
817
+
818
+ ##
819
+ # Exports reservations usage data requested by user into either an existing
820
+ # Cloud Storage bucket or a new/existing BigQuery table.
821
+ #
822
+ # @overload export_reservations_usage(request, options = nil)
823
+ # Pass arguments to `export_reservations_usage` via a request object, either of type
824
+ # {::Google::Cloud::CapacityPlanner::V1beta::ExportReservationsUsageRequest} or an equivalent Hash.
825
+ #
826
+ # @param request [::Google::Cloud::CapacityPlanner::V1beta::ExportReservationsUsageRequest, ::Hash]
827
+ # A request object representing the call parameters. Required. To specify no
828
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
829
+ # @param options [::Gapic::CallOptions, ::Hash]
830
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
831
+ #
832
+ # @overload export_reservations_usage(machine_family: nil, machine_shape: nil, gpu_type: nil, parent: nil, location_level: nil, cloud_resource_type: nil, usage_aggregation_method: nil, share_type: nil, start_date: nil, end_date: nil, output_config: nil)
833
+ # Pass arguments to `export_reservations_usage` via keyword arguments. Note that at
834
+ # least one keyword argument is required. To specify no parameters, or to keep all
835
+ # the default parameter values, pass an empty Hash as a request object (see above).
836
+ #
837
+ # @param machine_family [::String]
838
+ # Optional. The machine family to query reservations and usage by. For
839
+ # example: n1, n2d.
840
+ #
841
+ # Note: The following parameters are mutually exclusive: `machine_family`, `machine_shape`, `gpu_type`. At most one of these parameters can be set. If more than one is set, only one will be used, and it is not defined which one.
842
+ # @param machine_shape [::Google::Cloud::CapacityPlanner::V1beta::MachineShape, ::Hash]
843
+ # Optional. The machine_shape as a filter to select matching reservations
844
+ # and its usage.
845
+ #
846
+ # Note: The following parameters are mutually exclusive: `machine_shape`, `machine_family`, `gpu_type`. At most one of these parameters can be set. If more than one is set, only one will be used, and it is not defined which one.
847
+ # @param gpu_type [::String]
848
+ # Optional. The GPU type to query reservations and usage by. For example:
849
+ # NVIDIA T4.
850
+ #
851
+ # Note: The following parameters are mutually exclusive: `gpu_type`, `machine_family`, `machine_shape`. At most one of these parameters can be set. If more than one is set, only one will be used, and it is not defined which one.
852
+ # @param parent [::String]
853
+ # Required. The compute engine resource and location of the
854
+ # reservationsusage. The format is:
855
+ # projects/\\{project}/locations/\\{location} or
856
+ # organizations/\\{organization}/locations/\\{location} or
857
+ # folders/\\{folder}/locations/\\{location}
858
+ # @param location_level [::Google::Cloud::CapacityPlanner::V1beta::TimeSeries::LocationType]
859
+ # Optional. The location level of the reservations usage timeseries.
860
+ # @param cloud_resource_type [::String]
861
+ # Required. The resource for the `ReservationsUsage` values to return.
862
+ # Possible values include "gce-vcpus", "gce-ram", "gce-local-ssd", and
863
+ # "gce-gpu".
864
+ # @param usage_aggregation_method [::Google::Cloud::CapacityPlanner::V1beta::UsageHistory::AggregationMethod]
865
+ # Required. The method that should be used to convert sampled reservations
866
+ # data to daily usage values.
867
+ # @param share_type [::Google::Cloud::CapacityPlanner::V1beta::ExportReservationsUsageRequest::ShareType]
868
+ # Optional. Type of share settings to filter reservations in response. If
869
+ # unspecified, all types are included.
870
+ # @param start_date [::Google::Type::Date, ::Hash]
871
+ # Optional. The start date of reservations usage.
872
+ # @param end_date [::Google::Type::Date, ::Hash]
873
+ # Optional. The end date of reservations usage.
874
+ # @param output_config [::Google::Cloud::CapacityPlanner::V1beta::OutputConfig, ::Hash]
875
+ # Required. Output configuration indicating where the results will be output
876
+ # to.
877
+ # @yield [result, operation] Access the result along with the TransportOperation object
878
+ # @yieldparam result [::Gapic::Operation]
879
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
880
+ #
881
+ # @return [::Gapic::Operation]
882
+ #
883
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
884
+ #
885
+ # @example Basic example
886
+ # require "google/cloud/capacity_planner/v1beta"
887
+ #
888
+ # # Create a client object. The client can be reused for multiple calls.
889
+ # client = Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Client.new
890
+ #
891
+ # # Create a request. To set request fields, pass in keyword arguments.
892
+ # request = Google::Cloud::CapacityPlanner::V1beta::ExportReservationsUsageRequest.new
893
+ #
894
+ # # Call the export_reservations_usage method.
895
+ # result = client.export_reservations_usage request
896
+ #
897
+ # # The returned object is of type Gapic::Operation. You can use it to
898
+ # # check the status of an operation, cancel it, or wait for results.
899
+ # # Here is how to wait for a response.
900
+ # result.wait_until_done! timeout: 60
901
+ # if result.response?
902
+ # p result.response
903
+ # else
904
+ # puts "No response received."
905
+ # end
906
+ #
907
+ def export_reservations_usage request, options = nil
908
+ raise ::ArgumentError, "request must be provided" if request.nil?
909
+
910
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CapacityPlanner::V1beta::ExportReservationsUsageRequest
911
+
912
+ # Converts hash and nil to an options object
913
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
914
+
915
+ # Customize the options with defaults
916
+ call_metadata = @config.rpcs.export_reservations_usage.metadata.to_h
917
+
918
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
919
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
920
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
921
+ gapic_version: ::Google::Cloud::CapacityPlanner::V1beta::VERSION,
922
+ transports_version_send: [:rest]
923
+
924
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
925
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
926
+
927
+ options.apply_defaults timeout: @config.rpcs.export_reservations_usage.timeout,
928
+ metadata: call_metadata,
929
+ retry_policy: @config.rpcs.export_reservations_usage.retry_policy
930
+
931
+ options.apply_defaults timeout: @config.timeout,
932
+ metadata: @config.metadata,
933
+ retry_policy: @config.retry_policy
934
+
935
+ @usage_service_stub.export_reservations_usage request, options do |result, operation|
936
+ result = ::Gapic::Operation.new result, @operations_client, options: options
937
+ yield result, operation if block_given?
938
+ throw :response, result
939
+ end
940
+ rescue ::Gapic::Rest::Error => e
941
+ raise ::Google::Cloud::Error.from_error(e)
942
+ end
943
+
944
+ ##
945
+ # Configuration class for the UsageService REST API.
946
+ #
947
+ # This class represents the configuration for UsageService REST,
948
+ # providing control over timeouts, retry behavior, logging, transport
949
+ # parameters, and other low-level controls. Certain parameters can also be
950
+ # applied individually to specific RPCs. See
951
+ # {::Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Client::Configuration::Rpcs}
952
+ # for a list of RPCs that can be configured independently.
953
+ #
954
+ # Configuration can be applied globally to all clients, or to a single client
955
+ # on construction.
956
+ #
957
+ # @example
958
+ #
959
+ # # Modify the global config, setting the timeout for
960
+ # # query_usage_histories to 20 seconds,
961
+ # # and all remaining timeouts to 10 seconds.
962
+ # ::Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Client.configure do |config|
963
+ # config.timeout = 10.0
964
+ # config.rpcs.query_usage_histories.timeout = 20.0
965
+ # end
966
+ #
967
+ # # Apply the above configuration only to a new client.
968
+ # client = ::Google::Cloud::CapacityPlanner::V1beta::UsageService::Rest::Client.new do |config|
969
+ # config.timeout = 10.0
970
+ # config.rpcs.query_usage_histories.timeout = 20.0
971
+ # end
972
+ #
973
+ # @!attribute [rw] endpoint
974
+ # A custom service endpoint, as a hostname or hostname:port. The default is
975
+ # nil, indicating to use the default endpoint in the current universe domain.
976
+ # @return [::String,nil]
977
+ # @!attribute [rw] credentials
978
+ # Credentials to send with calls. You may provide any of the following types:
979
+ # * (`String`) The path to a service account key file in JSON format
980
+ # * (`Hash`) A service account key as a Hash
981
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
982
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
983
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
984
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
985
+ # * (`nil`) indicating no credentials
986
+ #
987
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
988
+ # external source for authentication to Google Cloud, you must validate it before
989
+ # providing it to a Google API client library. Providing an unvalidated credential
990
+ # configuration to Google APIs can compromise the security of your systems and data.
991
+ # For more information, refer to [Validate credential configurations from external
992
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
993
+ # @return [::Object]
994
+ # @!attribute [rw] scope
995
+ # The OAuth scopes
996
+ # @return [::Array<::String>]
997
+ # @!attribute [rw] lib_name
998
+ # The library name as recorded in instrumentation and logging
999
+ # @return [::String]
1000
+ # @!attribute [rw] lib_version
1001
+ # The library version as recorded in instrumentation and logging
1002
+ # @return [::String]
1003
+ # @!attribute [rw] timeout
1004
+ # The call timeout in seconds.
1005
+ # @return [::Numeric]
1006
+ # @!attribute [rw] metadata
1007
+ # Additional headers to be sent with the call.
1008
+ # @return [::Hash{::Symbol=>::String}]
1009
+ # @!attribute [rw] retry_policy
1010
+ # The retry policy. The value is a hash with the following keys:
1011
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1012
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1013
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1014
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1015
+ # trigger a retry.
1016
+ # @return [::Hash]
1017
+ # @!attribute [rw] quota_project
1018
+ # A separate project against which to charge quota.
1019
+ # @return [::String]
1020
+ # @!attribute [rw] universe_domain
1021
+ # The universe domain within which to make requests. This determines the
1022
+ # default endpoint URL. The default value of nil uses the environment
1023
+ # universe (usually the default "googleapis.com" universe).
1024
+ # @return [::String,nil]
1025
+ # @!attribute [rw] logger
1026
+ # A custom logger to use for request/response debug logging, or the value
1027
+ # `:default` (the default) to construct a default logger, or `nil` to
1028
+ # explicitly disable logging.
1029
+ # @return [::Logger,:default,nil]
1030
+ #
1031
+ class Configuration
1032
+ extend ::Gapic::Config
1033
+
1034
+ # @private
1035
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
1036
+ DEFAULT_ENDPOINT = "capacityplanner.googleapis.com"
1037
+
1038
+ config_attr :endpoint, nil, ::String, nil
1039
+ config_attr :credentials, nil do |value|
1040
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil]
1041
+ allowed.any? { |klass| klass === value }
1042
+ end
1043
+ config_attr :scope, nil, ::String, ::Array, nil
1044
+ config_attr :lib_name, nil, ::String, nil
1045
+ config_attr :lib_version, nil, ::String, nil
1046
+ config_attr :timeout, nil, ::Numeric, nil
1047
+ config_attr :metadata, nil, ::Hash, nil
1048
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1049
+ config_attr :quota_project, nil, ::String, nil
1050
+ config_attr :universe_domain, nil, ::String, nil
1051
+ config_attr :logger, :default, ::Logger, nil, :default
1052
+
1053
+ # @private
1054
+ def initialize parent_config = nil
1055
+ @parent_config = parent_config unless parent_config.nil?
1056
+
1057
+ yield self if block_given?
1058
+ end
1059
+
1060
+ ##
1061
+ # Configurations for individual RPCs
1062
+ # @return [Rpcs]
1063
+ #
1064
+ def rpcs
1065
+ @rpcs ||= begin
1066
+ parent_rpcs = nil
1067
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
1068
+ Rpcs.new parent_rpcs
1069
+ end
1070
+ end
1071
+
1072
+ ##
1073
+ # Configuration RPC class for the UsageService API.
1074
+ #
1075
+ # Includes fields providing the configuration for each RPC in this service.
1076
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1077
+ # the following configuration fields:
1078
+ #
1079
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
1080
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
1081
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1082
+ # include the following keys:
1083
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1084
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1085
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1086
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1087
+ # trigger a retry.
1088
+ #
1089
+ class Rpcs
1090
+ ##
1091
+ # RPC-specific configuration for `query_usage_histories`
1092
+ # @return [::Gapic::Config::Method]
1093
+ #
1094
+ attr_reader :query_usage_histories
1095
+ ##
1096
+ # RPC-specific configuration for `query_forecasts`
1097
+ # @return [::Gapic::Config::Method]
1098
+ #
1099
+ attr_reader :query_forecasts
1100
+ ##
1101
+ # RPC-specific configuration for `query_reservations`
1102
+ # @return [::Gapic::Config::Method]
1103
+ #
1104
+ attr_reader :query_reservations
1105
+ ##
1106
+ # RPC-specific configuration for `export_usage_histories`
1107
+ # @return [::Gapic::Config::Method]
1108
+ #
1109
+ attr_reader :export_usage_histories
1110
+ ##
1111
+ # RPC-specific configuration for `export_forecasts`
1112
+ # @return [::Gapic::Config::Method]
1113
+ #
1114
+ attr_reader :export_forecasts
1115
+ ##
1116
+ # RPC-specific configuration for `export_reservations_usage`
1117
+ # @return [::Gapic::Config::Method]
1118
+ #
1119
+ attr_reader :export_reservations_usage
1120
+
1121
+ # @private
1122
+ def initialize parent_rpcs = nil
1123
+ query_usage_histories_config = parent_rpcs.query_usage_histories if parent_rpcs.respond_to? :query_usage_histories
1124
+ @query_usage_histories = ::Gapic::Config::Method.new query_usage_histories_config
1125
+ query_forecasts_config = parent_rpcs.query_forecasts if parent_rpcs.respond_to? :query_forecasts
1126
+ @query_forecasts = ::Gapic::Config::Method.new query_forecasts_config
1127
+ query_reservations_config = parent_rpcs.query_reservations if parent_rpcs.respond_to? :query_reservations
1128
+ @query_reservations = ::Gapic::Config::Method.new query_reservations_config
1129
+ export_usage_histories_config = parent_rpcs.export_usage_histories if parent_rpcs.respond_to? :export_usage_histories
1130
+ @export_usage_histories = ::Gapic::Config::Method.new export_usage_histories_config
1131
+ export_forecasts_config = parent_rpcs.export_forecasts if parent_rpcs.respond_to? :export_forecasts
1132
+ @export_forecasts = ::Gapic::Config::Method.new export_forecasts_config
1133
+ export_reservations_usage_config = parent_rpcs.export_reservations_usage if parent_rpcs.respond_to? :export_reservations_usage
1134
+ @export_reservations_usage = ::Gapic::Config::Method.new export_reservations_usage_config
1135
+
1136
+ yield self if block_given?
1137
+ end
1138
+ end
1139
+ end
1140
+ end
1141
+ end
1142
+ end
1143
+ end
1144
+ end
1145
+ end
1146
+ end