Class: Google::Cloud::CloudQuotas::V1::CloudQuotas::Client
- Inherits:
-
Object
- Object
- Google::Cloud::CloudQuotas::V1::CloudQuotas::Client
- Includes:
- Paths
- Defined in:
- lib/google/cloud/cloud_quotas/v1/cloud_quotas/client.rb
Overview
Client for the CloudQuotas service.
The Cloud Quotas API is an infrastructure service for Google Cloud that lets service consumers list and manage their resource usage limits.
- List/Get the metadata and current status of the quotas for a service.
- Create/Update quota preferencess that declare the preferred quota values.
- Check the status of a quota preference request.
- List/Get pending and historical quota preference.
Defined Under Namespace
Classes: Configuration
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Client::Configuration
Configure the CloudQuotas Client class.
Instance Method Summary collapse
-
#configure {|config| ... } ⇒ Client::Configuration
Configure the CloudQuotas Client instance.
-
#create_quota_preference(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::CloudQuotas::V1::QuotaPreference
Creates a new QuotaPreference that declares the desired value for a quota.
-
#get_quota_info(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::CloudQuotas::V1::QuotaInfo
Retrieve the QuotaInfo of a quota for a project, folder or organization.
-
#get_quota_preference(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::CloudQuotas::V1::QuotaPreference
Gets details of a single QuotaPreference.
-
#initialize {|config| ... } ⇒ Client
constructor
Create a new CloudQuotas client object.
-
#list_quota_infos(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::CloudQuotas::V1::QuotaInfo>
Lists QuotaInfos of all quotas for a given project, folder or organization.
-
#list_quota_preferences(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::CloudQuotas::V1::QuotaPreference>
Lists QuotaPreferences in a given project, folder or organization.
-
#universe_domain ⇒ String
The effective universe domain.
-
#update_quota_preference(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::CloudQuotas::V1::QuotaPreference
Updates the parameters of a single QuotaPreference.
Methods included from Paths
#location_path, #quota_info_path, #quota_preference_path, #service_path
Constructor Details
#initialize {|config| ... } ⇒ Client
Create a new CloudQuotas client object.
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/google/cloud/cloud_quotas/v1/cloud_quotas/client.rb', line 157 def initialize # These require statements are intentionally placed here to initialize # the gRPC module only when it's required. # See https://github.com/googleapis/toolkit/issues/446 require "gapic/grpc" require "google/api/cloudquotas/v1/cloudquotas_services_pb" # Create the configuration object @config = Configuration.new Client.configure # Yield the configuration if needed yield @config if block_given? # Create credentials credentials = @config.credentials # Use self-signed JWT if the endpoint is unchanged from default, # but only if the default endpoint does not have a region prefix. enable_self_signed_jwt = @config.endpoint.nil? || (@config.endpoint == Configuration::DEFAULT_ENDPOINT && !@config.endpoint.split(".").first.include?("-")) credentials ||= Credentials.default scope: @config.scope, enable_self_signed_jwt: enable_self_signed_jwt if credentials.is_a?(::String) || credentials.is_a?(::Hash) credentials = Credentials.new credentials, scope: @config.scope end @quota_project_id = @config.quota_project @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id @cloud_quotas_stub = ::Gapic::ServiceStub.new( ::Google::Cloud::CloudQuotas::V1::CloudQuotas::Stub, credentials: credentials, endpoint: @config.endpoint, endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, universe_domain: @config.universe_domain, channel_args: @config.channel_args, interceptors: @config.interceptors, channel_pool_config: @config.channel_pool ) end |
Class Method Details
.configure {|config| ... } ⇒ Client::Configuration
Configure the CloudQuotas Client class.
See Configuration for a description of the configuration fields.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/google/cloud/cloud_quotas/v1/cloud_quotas/client.rb', line 65 def self.configure @configure ||= begin namespace = ["Google", "Cloud", "CloudQuotas", "V1"] parent_config = while namespace.any? parent_name = namespace.join "::" parent_const = const_get parent_name break parent_const.configure if parent_const.respond_to? :configure namespace.pop end default_config = Client::Configuration.new parent_config default_config.rpcs.list_quota_infos.timeout = 60.0 default_config.rpcs.list_quota_infos.retry_policy = { initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] } default_config.rpcs.get_quota_info.timeout = 60.0 default_config.rpcs.get_quota_info.retry_policy = { initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] } default_config.rpcs.list_quota_preferences.timeout = 60.0 default_config.rpcs.list_quota_preferences.retry_policy = { initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] } default_config.rpcs.get_quota_preference.timeout = 60.0 default_config.rpcs.get_quota_preference.retry_policy = { initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] } default_config.rpcs.create_quota_preference.timeout = 60.0 default_config.rpcs.create_quota_preference.retry_policy = { initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] } default_config.rpcs.update_quota_preference.timeout = 60.0 default_config.rpcs.update_quota_preference.retry_policy = { initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] } default_config end yield @configure if block_given? @configure end |
Instance Method Details
#configure {|config| ... } ⇒ Client::Configuration
Configure the CloudQuotas Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on configure.
See Configuration for a description of the configuration fields.
127 128 129 130 |
# File 'lib/google/cloud/cloud_quotas/v1/cloud_quotas/client.rb', line 127 def configure yield @config if block_given? @config end |
#create_quota_preference(request, options = nil) ⇒ ::Google::Cloud::CloudQuotas::V1::QuotaPreference #create_quota_preference(parent: nil, quota_preference_id: nil, quota_preference: nil, ignore_safety_checks: nil) ⇒ ::Google::Cloud::CloudQuotas::V1::QuotaPreference
Creates a new QuotaPreference that declares the desired value for a quota.
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 |
# File 'lib/google/cloud/cloud_quotas/v1/cloud_quotas/client.rb', line 652 def create_quota_preference request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CloudQuotas::V1::CreateQuotaPreferenceRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.create_quota_preference..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::CloudQuotas::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.parent header_params["parent"] = request.parent end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.create_quota_preference.timeout, metadata: , retry_policy: @config.rpcs.create_quota_preference.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @cloud_quotas_stub.call_rpc :create_quota_preference, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#get_quota_info(request, options = nil) ⇒ ::Google::Cloud::CloudQuotas::V1::QuotaInfo #get_quota_info(name: nil) ⇒ ::Google::Cloud::CloudQuotas::V1::QuotaInfo
Retrieve the QuotaInfo of a quota for a project, folder or organization.
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
# File 'lib/google/cloud/cloud_quotas/v1/cloud_quotas/client.rb', line 348 def get_quota_info request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CloudQuotas::V1::GetQuotaInfoRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.get_quota_info..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::CloudQuotas::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.name header_params["name"] = request.name end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.get_quota_info.timeout, metadata: , retry_policy: @config.rpcs.get_quota_info.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @cloud_quotas_stub.call_rpc :get_quota_info, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#get_quota_preference(request, options = nil) ⇒ ::Google::Cloud::CloudQuotas::V1::QuotaPreference #get_quota_preference(name: nil) ⇒ ::Google::Cloud::CloudQuotas::V1::QuotaPreference
Gets details of a single QuotaPreference.
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 |
# File 'lib/google/cloud/cloud_quotas/v1/cloud_quotas/client.rb', line 557 def get_quota_preference request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CloudQuotas::V1::GetQuotaPreferenceRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.get_quota_preference..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::CloudQuotas::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.name header_params["name"] = request.name end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.get_quota_preference.timeout, metadata: , retry_policy: @config.rpcs.get_quota_preference.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @cloud_quotas_stub.call_rpc :get_quota_preference, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#list_quota_infos(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::CloudQuotas::V1::QuotaInfo> #list_quota_infos(parent: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::CloudQuotas::V1::QuotaInfo>
Lists QuotaInfos of all quotas for a given project, folder or organization.
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/google/cloud/cloud_quotas/v1/cloud_quotas/client.rb', line 259 def list_quota_infos request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CloudQuotas::V1::ListQuotaInfosRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.list_quota_infos..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::CloudQuotas::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.parent header_params["parent"] = request.parent end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.list_quota_infos.timeout, metadata: , retry_policy: @config.rpcs.list_quota_infos.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @cloud_quotas_stub.call_rpc :list_quota_infos, request, options: do |response, operation| response = ::Gapic::PagedEnumerable.new @cloud_quotas_stub, :list_quota_infos, request, response, operation, yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#list_quota_preferences(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::CloudQuotas::V1::QuotaPreference> #list_quota_preferences(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::CloudQuotas::V1::QuotaPreference>
Lists QuotaPreferences in a given project, folder or organization.
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'lib/google/cloud/cloud_quotas/v1/cloud_quotas/client.rb', line 468 def list_quota_preferences request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CloudQuotas::V1::ListQuotaPreferencesRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.list_quota_preferences..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::CloudQuotas::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.parent header_params["parent"] = request.parent end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.list_quota_preferences.timeout, metadata: , retry_policy: @config.rpcs.list_quota_preferences.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @cloud_quotas_stub.call_rpc :list_quota_preferences, request, options: do |response, operation| response = ::Gapic::PagedEnumerable.new @cloud_quotas_stub, :list_quota_preferences, request, response, operation, yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#universe_domain ⇒ String
The effective universe domain
137 138 139 |
# File 'lib/google/cloud/cloud_quotas/v1/cloud_quotas/client.rb', line 137 def universe_domain @cloud_quotas_stub.universe_domain end |
#update_quota_preference(request, options = nil) ⇒ ::Google::Cloud::CloudQuotas::V1::QuotaPreference #update_quota_preference(update_mask: nil, quota_preference: nil, allow_missing: nil, validate_only: nil, ignore_safety_checks: nil) ⇒ ::Google::Cloud::CloudQuotas::V1::QuotaPreference
Updates the parameters of a single QuotaPreference. It can updates the config in any states, not just the ones pending approval.
753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 |
# File 'lib/google/cloud/cloud_quotas/v1/cloud_quotas/client.rb', line 753 def update_quota_preference request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::CloudQuotas::V1::UpdateQuotaPreferenceRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.update_quota_preference..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::CloudQuotas::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.quota_preference&.name header_params["quota_preference.name"] = request.quota_preference.name end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.update_quota_preference.timeout, metadata: , retry_policy: @config.rpcs.update_quota_preference.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @cloud_quotas_stub.call_rpc :update_quota_preference, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |