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,639 @@
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/capacity_planning_service_pb"
21
+ require "google/cloud/capacity_planner/v1beta/capacity_planning_service/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module CapacityPlanner
26
+ module V1beta
27
+ module CapacityPlanningService
28
+ module Rest
29
+ ##
30
+ # REST client for the CapacityPlanningService service.
31
+ #
32
+ # This API allows users to plan for GCP capacity associated with their
33
+ # projects. Users can request additional capacity for GCP resources such as
34
+ # VMs, PDs, etc.
35
+ #
36
+ class Client
37
+ # @private
38
+ API_VERSION = ""
39
+
40
+ # @private
41
+ DEFAULT_ENDPOINT_TEMPLATE = "capacityplanner.$UNIVERSE_DOMAIN$"
42
+
43
+ include Paths
44
+
45
+ # @private
46
+ attr_reader :capacity_planning_service_stub
47
+
48
+ ##
49
+ # Configure the CapacityPlanningService Client class.
50
+ #
51
+ # See {::Google::Cloud::CapacityPlanner::V1beta::CapacityPlanningService::Rest::Client::Configuration}
52
+ # for a description of the configuration fields.
53
+ #
54
+ # @example
55
+ #
56
+ # # Modify the configuration for all CapacityPlanningService clients
57
+ # ::Google::Cloud::CapacityPlanner::V1beta::CapacityPlanningService::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", "CapacityPlanner", "V1beta"]
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.rpcs.get_capacity_plan.timeout = 60.0
78
+ default_config.rpcs.get_capacity_plan.retry_policy = {
79
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4, 13]
80
+ }
81
+
82
+ default_config.rpcs.query_capacity_plans.timeout = 60.0
83
+ default_config.rpcs.query_capacity_plans.retry_policy = {
84
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4, 13]
85
+ }
86
+
87
+ default_config.rpcs.query_capacity_plan_insights.timeout = 60.0
88
+ default_config.rpcs.query_capacity_plan_insights.retry_policy = {
89
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4, 13]
90
+ }
91
+
92
+ default_config
93
+ end
94
+ yield @configure if block_given?
95
+ @configure
96
+ end
97
+
98
+ ##
99
+ # Configure the CapacityPlanningService Client instance.
100
+ #
101
+ # The configuration is set to the derived mode, meaning that values can be changed,
102
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
103
+ # should be made on {Client.configure}.
104
+ #
105
+ # See {::Google::Cloud::CapacityPlanner::V1beta::CapacityPlanningService::Rest::Client::Configuration}
106
+ # for a description of the configuration fields.
107
+ #
108
+ # @yield [config] Configure the Client client.
109
+ # @yieldparam config [Client::Configuration]
110
+ #
111
+ # @return [Client::Configuration]
112
+ #
113
+ def configure
114
+ yield @config if block_given?
115
+ @config
116
+ end
117
+
118
+ ##
119
+ # The effective universe domain
120
+ #
121
+ # @return [String]
122
+ #
123
+ def universe_domain
124
+ @capacity_planning_service_stub.universe_domain
125
+ end
126
+
127
+ ##
128
+ # Create a new CapacityPlanningService REST client object.
129
+ #
130
+ # @example
131
+ #
132
+ # # Create a client using the default configuration
133
+ # client = ::Google::Cloud::CapacityPlanner::V1beta::CapacityPlanningService::Rest::Client.new
134
+ #
135
+ # # Create a client using a custom configuration
136
+ # client = ::Google::Cloud::CapacityPlanner::V1beta::CapacityPlanningService::Rest::Client.new do |config|
137
+ # config.timeout = 10.0
138
+ # end
139
+ #
140
+ # @yield [config] Configure the CapacityPlanningService client.
141
+ # @yieldparam config [Client::Configuration]
142
+ #
143
+ def initialize
144
+ # Create the configuration object
145
+ @config = Configuration.new Client.configure
146
+
147
+ # Yield the configuration if needed
148
+ yield @config if block_given?
149
+
150
+ # Create credentials
151
+ credentials = @config.credentials
152
+ # Use self-signed JWT if the endpoint is unchanged from default,
153
+ # but only if the default endpoint does not have a region prefix.
154
+ enable_self_signed_jwt = @config.endpoint.nil? ||
155
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
156
+ !@config.endpoint.split(".").first.include?("-"))
157
+ credentials ||= Credentials.default scope: @config.scope,
158
+ enable_self_signed_jwt: enable_self_signed_jwt
159
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
160
+ credentials = Credentials.new credentials, scope: @config.scope
161
+ end
162
+
163
+ @quota_project_id = @config.quota_project
164
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
165
+
166
+ @capacity_planning_service_stub = ::Google::Cloud::CapacityPlanner::V1beta::CapacityPlanningService::Rest::ServiceStub.new(
167
+ endpoint: @config.endpoint,
168
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
169
+ universe_domain: @config.universe_domain,
170
+ credentials: credentials,
171
+ logger: @config.logger
172
+ )
173
+
174
+ @capacity_planning_service_stub.logger(stub: true)&.info do |entry|
175
+ entry.set_system_name
176
+ entry.set_service
177
+ entry.message = "Created client for #{entry.service}"
178
+ entry.set_credentials_fields credentials
179
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
180
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
181
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
182
+ end
183
+ end
184
+
185
+ ##
186
+ # The logger used for request/response debug logging.
187
+ #
188
+ # @return [Logger]
189
+ #
190
+ def logger
191
+ @capacity_planning_service_stub.logger
192
+ end
193
+
194
+ # Service calls
195
+
196
+ ##
197
+ # Returns information about the capacity plan.
198
+ #
199
+ # @overload get_capacity_plan(request, options = nil)
200
+ # Pass arguments to `get_capacity_plan` via a request object, either of type
201
+ # {::Google::Cloud::CapacityPlanner::V1beta::GetCapacityPlanRequest} or an equivalent Hash.
202
+ #
203
+ # @param request [::Google::Cloud::CapacityPlanner::V1beta::GetCapacityPlanRequest, ::Hash]
204
+ # A request object representing the call parameters. Required. To specify no
205
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
206
+ # @param options [::Gapic::CallOptions, ::Hash]
207
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
208
+ #
209
+ # @overload get_capacity_plan(name: nil)
210
+ # Pass arguments to `get_capacity_plan` via keyword arguments. Note that at
211
+ # least one keyword argument is required. To specify no parameters, or to keep all
212
+ # the default parameter values, pass an empty Hash as a request object (see above).
213
+ #
214
+ # @param name [::String]
215
+ # Required. The name of the capacity plan to retrieve.
216
+ # Format: projects/\\{project}/capacityPlans/\\{capacity_plan}
217
+ # @yield [result, operation] Access the result along with the TransportOperation object
218
+ # @yieldparam result [::Google::Cloud::CapacityPlanner::V1beta::CapacityPlan]
219
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
220
+ #
221
+ # @return [::Google::Cloud::CapacityPlanner::V1beta::CapacityPlan]
222
+ #
223
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
224
+ #
225
+ # @example Basic example
226
+ # require "google/cloud/capacity_planner/v1beta"
227
+ #
228
+ # # Create a client object. The client can be reused for multiple calls.
229
+ # client = Google::Cloud::CapacityPlanner::V1beta::CapacityPlanningService::Rest::Client.new
230
+ #
231
+ # # Create a request. To set request fields, pass in keyword arguments.
232
+ # request = Google::Cloud::CapacityPlanner::V1beta::GetCapacityPlanRequest.new
233
+ #
234
+ # # Call the get_capacity_plan method.
235
+ # result = client.get_capacity_plan request
236
+ #
237
+ # # The returned object is of type Google::Cloud::CapacityPlanner::V1beta::CapacityPlan.
238
+ # p result
239
+ #
240
+ def get_capacity_plan request, options = nil
241
+ raise ::ArgumentError, "request must be provided" if request.nil?
242
+
243
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CapacityPlanner::V1beta::GetCapacityPlanRequest
244
+
245
+ # Converts hash and nil to an options object
246
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
247
+
248
+ # Customize the options with defaults
249
+ call_metadata = @config.rpcs.get_capacity_plan.metadata.to_h
250
+
251
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
252
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
253
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
254
+ gapic_version: ::Google::Cloud::CapacityPlanner::V1beta::VERSION,
255
+ transports_version_send: [:rest]
256
+
257
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
258
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
259
+
260
+ options.apply_defaults timeout: @config.rpcs.get_capacity_plan.timeout,
261
+ metadata: call_metadata,
262
+ retry_policy: @config.rpcs.get_capacity_plan.retry_policy
263
+
264
+ options.apply_defaults timeout: @config.timeout,
265
+ metadata: @config.metadata,
266
+ retry_policy: @config.retry_policy
267
+
268
+ @capacity_planning_service_stub.get_capacity_plan request, options do |result, operation|
269
+ yield result, operation if block_given?
270
+ end
271
+ rescue ::Gapic::Rest::Error => e
272
+ raise ::Google::Cloud::Error.from_error(e)
273
+ end
274
+
275
+ ##
276
+ # Returns a list of the capacity plans that are in the parent parameter and
277
+ # match your specified filters.
278
+ # (The maximum list length is limited by the pageSize parameter.)
279
+ #
280
+ # @overload query_capacity_plans(request, options = nil)
281
+ # Pass arguments to `query_capacity_plans` via a request object, either of type
282
+ # {::Google::Cloud::CapacityPlanner::V1beta::QueryCapacityPlansRequest} or an equivalent Hash.
283
+ #
284
+ # @param request [::Google::Cloud::CapacityPlanner::V1beta::QueryCapacityPlansRequest, ::Hash]
285
+ # A request object representing the call parameters. Required. To specify no
286
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
287
+ # @param options [::Gapic::CallOptions, ::Hash]
288
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
289
+ #
290
+ # @overload query_capacity_plans(parent: nil, page_size: nil, page_token: nil, location: nil)
291
+ # Pass arguments to `query_capacity_plans` via keyword arguments. Note that at
292
+ # least one keyword argument is required. To specify no parameters, or to keep all
293
+ # the default parameter values, pass an empty Hash as a request object (see above).
294
+ #
295
+ # @param parent [::String]
296
+ # Required. The parent resource container.
297
+ # Format:
298
+ # projects/\\{project} or
299
+ # folders/\\{folder} or
300
+ # organizations/\\{organization}
301
+ # @param page_size [::Integer]
302
+ # Optional. The maximum number of plans to return per page. The service may
303
+ # return fewer than this value. If unspecified, the server will use a
304
+ # sensible default. The maximum value is 1000; values above 1000 will be
305
+ # coerced to 1000.
306
+ # @param page_token [::String]
307
+ # Optional. A page token, received from a previous `QueryCapacityPlans` call.
308
+ # Provide this to retrieve the subsequent page.
309
+ # @param location [::String]
310
+ # Optional. The Google Cloud Platform location of capacity plans. If
311
+ # unspecified, all locations will be included.
312
+ # @yield [result, operation] Access the result along with the TransportOperation object
313
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::CapacityPlanner::V1beta::CapacityPlan>]
314
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
315
+ #
316
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::CapacityPlanner::V1beta::CapacityPlan>]
317
+ #
318
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
319
+ #
320
+ # @example Basic example
321
+ # require "google/cloud/capacity_planner/v1beta"
322
+ #
323
+ # # Create a client object. The client can be reused for multiple calls.
324
+ # client = Google::Cloud::CapacityPlanner::V1beta::CapacityPlanningService::Rest::Client.new
325
+ #
326
+ # # Create a request. To set request fields, pass in keyword arguments.
327
+ # request = Google::Cloud::CapacityPlanner::V1beta::QueryCapacityPlansRequest.new
328
+ #
329
+ # # Call the query_capacity_plans method.
330
+ # result = client.query_capacity_plans request
331
+ #
332
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
333
+ # # over elements, and API calls will be issued to fetch pages as needed.
334
+ # result.each do |item|
335
+ # # Each element is of type ::Google::Cloud::CapacityPlanner::V1beta::CapacityPlan.
336
+ # p item
337
+ # end
338
+ #
339
+ def query_capacity_plans request, options = nil
340
+ raise ::ArgumentError, "request must be provided" if request.nil?
341
+
342
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CapacityPlanner::V1beta::QueryCapacityPlansRequest
343
+
344
+ # Converts hash and nil to an options object
345
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
346
+
347
+ # Customize the options with defaults
348
+ call_metadata = @config.rpcs.query_capacity_plans.metadata.to_h
349
+
350
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
351
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
352
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
353
+ gapic_version: ::Google::Cloud::CapacityPlanner::V1beta::VERSION,
354
+ transports_version_send: [:rest]
355
+
356
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
357
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
358
+
359
+ options.apply_defaults timeout: @config.rpcs.query_capacity_plans.timeout,
360
+ metadata: call_metadata,
361
+ retry_policy: @config.rpcs.query_capacity_plans.retry_policy
362
+
363
+ options.apply_defaults timeout: @config.timeout,
364
+ metadata: @config.metadata,
365
+ retry_policy: @config.retry_policy
366
+
367
+ @capacity_planning_service_stub.query_capacity_plans request, options do |result, operation|
368
+ result = ::Gapic::Rest::PagedEnumerable.new @capacity_planning_service_stub, :query_capacity_plans, "capacity_plans", request, result, options
369
+ yield result, operation if block_given?
370
+ throw :response, result
371
+ end
372
+ rescue ::Gapic::Rest::Error => e
373
+ raise ::Google::Cloud::Error.from_error(e)
374
+ end
375
+
376
+ ##
377
+ # Query capacity plan insights that are in the parent parameter and match
378
+ # your specified filters.
379
+ #
380
+ # @overload query_capacity_plan_insights(request, options = nil)
381
+ # Pass arguments to `query_capacity_plan_insights` via a request object, either of type
382
+ # {::Google::Cloud::CapacityPlanner::V1beta::QueryCapacityPlanInsightsRequest} or an equivalent Hash.
383
+ #
384
+ # @param request [::Google::Cloud::CapacityPlanner::V1beta::QueryCapacityPlanInsightsRequest, ::Hash]
385
+ # A request object representing the call parameters. Required. To specify no
386
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
387
+ # @param options [::Gapic::CallOptions, ::Hash]
388
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
389
+ #
390
+ # @overload query_capacity_plan_insights(parent: nil, capacity_plan_filters: nil)
391
+ # Pass arguments to `query_capacity_plan_insights` via keyword arguments. Note that at
392
+ # least one keyword argument is required. To specify no parameters, or to keep all
393
+ # the default parameter values, pass an empty Hash as a request object (see above).
394
+ #
395
+ # @param parent [::String]
396
+ # Required. The parent resource container.
397
+ # Format: projects/\\{project}
398
+ # @param capacity_plan_filters [::Google::Cloud::CapacityPlanner::V1beta::CapacityPlanFilters, ::Hash]
399
+ # Required. The filters to apply to the capacity plan.
400
+ # @yield [result, operation] Access the result along with the TransportOperation object
401
+ # @yieldparam result [::Google::Cloud::CapacityPlanner::V1beta::QueryCapacityPlanInsightsResponse]
402
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
403
+ #
404
+ # @return [::Google::Cloud::CapacityPlanner::V1beta::QueryCapacityPlanInsightsResponse]
405
+ #
406
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
407
+ #
408
+ # @example Basic example
409
+ # require "google/cloud/capacity_planner/v1beta"
410
+ #
411
+ # # Create a client object. The client can be reused for multiple calls.
412
+ # client = Google::Cloud::CapacityPlanner::V1beta::CapacityPlanningService::Rest::Client.new
413
+ #
414
+ # # Create a request. To set request fields, pass in keyword arguments.
415
+ # request = Google::Cloud::CapacityPlanner::V1beta::QueryCapacityPlanInsightsRequest.new
416
+ #
417
+ # # Call the query_capacity_plan_insights method.
418
+ # result = client.query_capacity_plan_insights request
419
+ #
420
+ # # The returned object is of type Google::Cloud::CapacityPlanner::V1beta::QueryCapacityPlanInsightsResponse.
421
+ # p result
422
+ #
423
+ def query_capacity_plan_insights request, options = nil
424
+ raise ::ArgumentError, "request must be provided" if request.nil?
425
+
426
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CapacityPlanner::V1beta::QueryCapacityPlanInsightsRequest
427
+
428
+ # Converts hash and nil to an options object
429
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
430
+
431
+ # Customize the options with defaults
432
+ call_metadata = @config.rpcs.query_capacity_plan_insights.metadata.to_h
433
+
434
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
435
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
436
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
437
+ gapic_version: ::Google::Cloud::CapacityPlanner::V1beta::VERSION,
438
+ transports_version_send: [:rest]
439
+
440
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
441
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
442
+
443
+ options.apply_defaults timeout: @config.rpcs.query_capacity_plan_insights.timeout,
444
+ metadata: call_metadata,
445
+ retry_policy: @config.rpcs.query_capacity_plan_insights.retry_policy
446
+
447
+ options.apply_defaults timeout: @config.timeout,
448
+ metadata: @config.metadata,
449
+ retry_policy: @config.retry_policy
450
+
451
+ @capacity_planning_service_stub.query_capacity_plan_insights request, options do |result, operation|
452
+ yield result, operation if block_given?
453
+ end
454
+ rescue ::Gapic::Rest::Error => e
455
+ raise ::Google::Cloud::Error.from_error(e)
456
+ end
457
+
458
+ ##
459
+ # Configuration class for the CapacityPlanningService REST API.
460
+ #
461
+ # This class represents the configuration for CapacityPlanningService REST,
462
+ # providing control over timeouts, retry behavior, logging, transport
463
+ # parameters, and other low-level controls. Certain parameters can also be
464
+ # applied individually to specific RPCs. See
465
+ # {::Google::Cloud::CapacityPlanner::V1beta::CapacityPlanningService::Rest::Client::Configuration::Rpcs}
466
+ # for a list of RPCs that can be configured independently.
467
+ #
468
+ # Configuration can be applied globally to all clients, or to a single client
469
+ # on construction.
470
+ #
471
+ # @example
472
+ #
473
+ # # Modify the global config, setting the timeout for
474
+ # # get_capacity_plan to 20 seconds,
475
+ # # and all remaining timeouts to 10 seconds.
476
+ # ::Google::Cloud::CapacityPlanner::V1beta::CapacityPlanningService::Rest::Client.configure do |config|
477
+ # config.timeout = 10.0
478
+ # config.rpcs.get_capacity_plan.timeout = 20.0
479
+ # end
480
+ #
481
+ # # Apply the above configuration only to a new client.
482
+ # client = ::Google::Cloud::CapacityPlanner::V1beta::CapacityPlanningService::Rest::Client.new do |config|
483
+ # config.timeout = 10.0
484
+ # config.rpcs.get_capacity_plan.timeout = 20.0
485
+ # end
486
+ #
487
+ # @!attribute [rw] endpoint
488
+ # A custom service endpoint, as a hostname or hostname:port. The default is
489
+ # nil, indicating to use the default endpoint in the current universe domain.
490
+ # @return [::String,nil]
491
+ # @!attribute [rw] credentials
492
+ # Credentials to send with calls. You may provide any of the following types:
493
+ # * (`String`) The path to a service account key file in JSON format
494
+ # * (`Hash`) A service account key as a Hash
495
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
496
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
497
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
498
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
499
+ # * (`nil`) indicating no credentials
500
+ #
501
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
502
+ # external source for authentication to Google Cloud, you must validate it before
503
+ # providing it to a Google API client library. Providing an unvalidated credential
504
+ # configuration to Google APIs can compromise the security of your systems and data.
505
+ # For more information, refer to [Validate credential configurations from external
506
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
507
+ # @return [::Object]
508
+ # @!attribute [rw] scope
509
+ # The OAuth scopes
510
+ # @return [::Array<::String>]
511
+ # @!attribute [rw] lib_name
512
+ # The library name as recorded in instrumentation and logging
513
+ # @return [::String]
514
+ # @!attribute [rw] lib_version
515
+ # The library version as recorded in instrumentation and logging
516
+ # @return [::String]
517
+ # @!attribute [rw] timeout
518
+ # The call timeout in seconds.
519
+ # @return [::Numeric]
520
+ # @!attribute [rw] metadata
521
+ # Additional headers to be sent with the call.
522
+ # @return [::Hash{::Symbol=>::String}]
523
+ # @!attribute [rw] retry_policy
524
+ # The retry policy. The value is a hash with the following keys:
525
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
526
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
527
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
528
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
529
+ # trigger a retry.
530
+ # @return [::Hash]
531
+ # @!attribute [rw] quota_project
532
+ # A separate project against which to charge quota.
533
+ # @return [::String]
534
+ # @!attribute [rw] universe_domain
535
+ # The universe domain within which to make requests. This determines the
536
+ # default endpoint URL. The default value of nil uses the environment
537
+ # universe (usually the default "googleapis.com" universe).
538
+ # @return [::String,nil]
539
+ # @!attribute [rw] logger
540
+ # A custom logger to use for request/response debug logging, or the value
541
+ # `:default` (the default) to construct a default logger, or `nil` to
542
+ # explicitly disable logging.
543
+ # @return [::Logger,:default,nil]
544
+ #
545
+ class Configuration
546
+ extend ::Gapic::Config
547
+
548
+ # @private
549
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
550
+ DEFAULT_ENDPOINT = "capacityplanner.googleapis.com"
551
+
552
+ config_attr :endpoint, nil, ::String, nil
553
+ config_attr :credentials, nil do |value|
554
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil]
555
+ allowed.any? { |klass| klass === value }
556
+ end
557
+ config_attr :scope, nil, ::String, ::Array, nil
558
+ config_attr :lib_name, nil, ::String, nil
559
+ config_attr :lib_version, nil, ::String, nil
560
+ config_attr :timeout, nil, ::Numeric, nil
561
+ config_attr :metadata, nil, ::Hash, nil
562
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
563
+ config_attr :quota_project, nil, ::String, nil
564
+ config_attr :universe_domain, nil, ::String, nil
565
+ config_attr :logger, :default, ::Logger, nil, :default
566
+
567
+ # @private
568
+ def initialize parent_config = nil
569
+ @parent_config = parent_config unless parent_config.nil?
570
+
571
+ yield self if block_given?
572
+ end
573
+
574
+ ##
575
+ # Configurations for individual RPCs
576
+ # @return [Rpcs]
577
+ #
578
+ def rpcs
579
+ @rpcs ||= begin
580
+ parent_rpcs = nil
581
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
582
+ Rpcs.new parent_rpcs
583
+ end
584
+ end
585
+
586
+ ##
587
+ # Configuration RPC class for the CapacityPlanningService API.
588
+ #
589
+ # Includes fields providing the configuration for each RPC in this service.
590
+ # Each configuration object is of type `Gapic::Config::Method` and includes
591
+ # the following configuration fields:
592
+ #
593
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
594
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
595
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
596
+ # include the following keys:
597
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
598
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
599
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
600
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
601
+ # trigger a retry.
602
+ #
603
+ class Rpcs
604
+ ##
605
+ # RPC-specific configuration for `get_capacity_plan`
606
+ # @return [::Gapic::Config::Method]
607
+ #
608
+ attr_reader :get_capacity_plan
609
+ ##
610
+ # RPC-specific configuration for `query_capacity_plans`
611
+ # @return [::Gapic::Config::Method]
612
+ #
613
+ attr_reader :query_capacity_plans
614
+ ##
615
+ # RPC-specific configuration for `query_capacity_plan_insights`
616
+ # @return [::Gapic::Config::Method]
617
+ #
618
+ attr_reader :query_capacity_plan_insights
619
+
620
+ # @private
621
+ def initialize parent_rpcs = nil
622
+ get_capacity_plan_config = parent_rpcs.get_capacity_plan if parent_rpcs.respond_to? :get_capacity_plan
623
+ @get_capacity_plan = ::Gapic::Config::Method.new get_capacity_plan_config
624
+ query_capacity_plans_config = parent_rpcs.query_capacity_plans if parent_rpcs.respond_to? :query_capacity_plans
625
+ @query_capacity_plans = ::Gapic::Config::Method.new query_capacity_plans_config
626
+ query_capacity_plan_insights_config = parent_rpcs.query_capacity_plan_insights if parent_rpcs.respond_to? :query_capacity_plan_insights
627
+ @query_capacity_plan_insights = ::Gapic::Config::Method.new query_capacity_plan_insights_config
628
+
629
+ yield self if block_given?
630
+ end
631
+ end
632
+ end
633
+ end
634
+ end
635
+ end
636
+ end
637
+ end
638
+ end
639
+ end