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