Class: Google::Cloud::ApiKeys::V2::ApiKeys::Client
- Inherits:
-
Object
- Object
- Google::Cloud::ApiKeys::V2::ApiKeys::Client
- Includes:
- Paths
- Defined in:
- lib/google/cloud/api_keys/v2/api_keys/client.rb
Overview
Client for the ApiKeys service.
Manages the API keys associated with projects.
Defined Under Namespace
Classes: Configuration
Instance Attribute Summary collapse
-
#operations_client ⇒ ::Google::Cloud::ApiKeys::V2::ApiKeys::Operations
readonly
Get the associated client for long-running operations.
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Client::Configuration
Configure the ApiKeys Client class.
Instance Method Summary collapse
-
#configure {|config| ... } ⇒ Client::Configuration
Configure the ApiKeys Client instance.
-
#create_key(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::Operation
Creates a new API key.
-
#delete_key(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::Operation
Deletes an API key.
-
#get_key(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::ApiKeys::V2::Key
Gets the metadata for an API key.
-
#get_key_string(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::ApiKeys::V2::GetKeyStringResponse
Get the key string for an API key.
-
#initialize {|config| ... } ⇒ Client
constructor
Create a new ApiKeys client object.
-
#list_keys(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::ApiKeys::V2::Key>
Lists the API keys owned by a project.
-
#lookup_key(request, options = nil) {|response, operation| ... } ⇒ ::Google::Cloud::ApiKeys::V2::LookupKeyResponse
Find the parent project and resource name of the API key that matches the key string in the request.
-
#undelete_key(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::Operation
Undeletes an API key which was deleted within 30 days.
-
#update_key(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::Operation
Patches the modifiable fields of an API key.
Methods included from Paths
Constructor Details
#initialize {|config| ... } ⇒ Client
Create a new ApiKeys client object.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/google/cloud/api_keys/v2/api_keys/client.rb', line 111 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/apikeys/v2/apikeys_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 == Client.configure.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 @operations_client = Operations.new do |config| config.credentials = credentials config.quota_project = @quota_project_id config.endpoint = @config.endpoint end @api_keys_stub = ::Gapic::ServiceStub.new( ::Google::Cloud::ApiKeys::V2::ApiKeys::Stub, credentials: credentials, endpoint: @config.endpoint, channel_args: @config.channel_args, interceptors: @config.interceptors ) end |
Instance Attribute Details
#operations_client ⇒ ::Google::Cloud::ApiKeys::V2::ApiKeys::Operations (readonly)
Get the associated client for long-running operations.
158 159 160 |
# File 'lib/google/cloud/api_keys/v2/api_keys/client.rb', line 158 def operations_client @operations_client end |
Class Method Details
.configure {|config| ... } ⇒ Client::Configuration
Configure the ApiKeys Client class.
See Configuration for a description of the configuration fields.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/google/cloud/api_keys/v2/api_keys/client.rb', line 56 def self.configure @configure ||= begin namespace = ["Google", "Cloud", "ApiKeys", "V2"] 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.timeout = 10.0 default_config end yield @configure if block_given? @configure end |
Instance Method Details
#configure {|config| ... } ⇒ Client::Configuration
Configure the ApiKeys 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.
90 91 92 93 |
# File 'lib/google/cloud/api_keys/v2/api_keys/client.rb', line 90 def configure yield @config if block_given? @config end |
#create_key(request, options = nil) ⇒ ::Gapic::Operation #create_key(parent: nil, key: nil, key_id: nil) ⇒ ::Gapic::Operation
Creates a new API key.
NOTE: Key is a global resource; hence the only supported value for
location is global
.
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/google/cloud/api_keys/v2/api_keys/client.rb', line 230 def create_key request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::CreateKeyRequest # 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_key..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::ApiKeys::V2::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_key.timeout, metadata: , retry_policy: @config.rpcs.create_key.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @api_keys_stub.call_rpc :create_key, request, options: do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#delete_key(request, options = nil) ⇒ ::Gapic::Operation #delete_key(name: nil, etag: nil) ⇒ ::Gapic::Operation
Deletes an API key. Deleted key can be retrieved within 30 days of deletion. Afterward, key will be purged from the project.
NOTE: Key is a global resource; hence the only supported value for
location is global
.
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 |
# File 'lib/google/cloud/api_keys/v2/api_keys/client.rb', line 717 def delete_key request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::DeleteKeyRequest # 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.delete_key..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::ApiKeys::V2::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.delete_key.timeout, metadata: , retry_policy: @config.rpcs.delete_key.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @api_keys_stub.call_rpc :delete_key, request, options: do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#get_key(request, options = nil) ⇒ ::Google::Cloud::ApiKeys::V2::Key #get_key(name: nil) ⇒ ::Google::Cloud::ApiKeys::V2::Key
Gets the metadata for an API key. The key string of the API key isn't included in the response.
NOTE: Key is a global resource; hence the only supported value for
location is global
.
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 |
# File 'lib/google/cloud/api_keys/v2/api_keys/client.rb', line 423 def get_key request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::GetKeyRequest # 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_key..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::ApiKeys::V2::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_key.timeout, metadata: , retry_policy: @config.rpcs.get_key.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @api_keys_stub.call_rpc :get_key, 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_key_string(request, options = nil) ⇒ ::Google::Cloud::ApiKeys::V2::GetKeyStringResponse #get_key_string(name: nil) ⇒ ::Google::Cloud::ApiKeys::V2::GetKeyStringResponse
Get the key string for an API key.
NOTE: Key is a global resource; hence the only supported value for
location is global
.
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
# File 'lib/google/cloud/api_keys/v2/api_keys/client.rb', line 511 def get_key_string request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::GetKeyStringRequest # 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_key_string..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::ApiKeys::V2::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_key_string.timeout, metadata: , retry_policy: @config.rpcs.get_key_string.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @api_keys_stub.call_rpc :get_key_string, 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_keys(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::ApiKeys::V2::Key> #list_keys(parent: nil, page_size: nil, page_token: nil, show_deleted: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::ApiKeys::V2::Key>
Lists the API keys owned by a project. The key string of the API key isn't included in the response.
NOTE: Key is a global resource; hence the only supported value for
location is global
.
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 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 |
# File 'lib/google/cloud/api_keys/v2/api_keys/client.rb', line 333 def list_keys request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::ListKeysRequest # 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_keys..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::ApiKeys::V2::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_keys.timeout, metadata: , retry_policy: @config.rpcs.list_keys.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @api_keys_stub.call_rpc :list_keys, request, options: do |response, operation| response = ::Gapic::PagedEnumerable.new @api_keys_stub, :list_keys, request, response, operation, yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#lookup_key(request, options = nil) ⇒ ::Google::Cloud::ApiKeys::V2::LookupKeyResponse #lookup_key(key_string: nil) ⇒ ::Google::Cloud::ApiKeys::V2::LookupKeyResponse
Find the parent project and resource name of the API
key that matches the key string in the request. If the API key has been
purged, resource name will not be set.
The service account must have the apikeys.keys.lookup
permission
on the parent project.
903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 |
# File 'lib/google/cloud/api_keys/v2/api_keys/client.rb', line 903 def lookup_key request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::LookupKeyRequest # 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.lookup_key..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::ApiKeys::V2::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.lookup_key.timeout, metadata: , retry_policy: @config.rpcs.lookup_key.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @api_keys_stub.call_rpc :lookup_key, 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 |
#undelete_key(request, options = nil) ⇒ ::Gapic::Operation #undelete_key(name: nil) ⇒ ::Gapic::Operation
Undeletes an API key which was deleted within 30 days.
NOTE: Key is a global resource; hence the only supported value for
location is global
.
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 |
# File 'lib/google/cloud/api_keys/v2/api_keys/client.rb', line 813 def undelete_key request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::UndeleteKeyRequest # 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.undelete_key..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::ApiKeys::V2::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.undelete_key.timeout, metadata: , retry_policy: @config.rpcs.undelete_key.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @api_keys_stub.call_rpc :undelete_key, request, options: do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#update_key(request, options = nil) ⇒ ::Gapic::Operation #update_key(key: nil, update_mask: nil) ⇒ ::Gapic::Operation
Patches the modifiable fields of an API key. The key string of the API key isn't included in the response.
NOTE: Key is a global resource; hence the only supported value for
location is global
.
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 |
# File 'lib/google/cloud/api_keys/v2/api_keys/client.rb', line 617 def update_key request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ApiKeys::V2::UpdateKeyRequest # 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_key..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::ApiKeys::V2::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.key&.name header_params["key.name"] = request.key.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_key.timeout, metadata: , retry_policy: @config.rpcs.update_key.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @api_keys_stub.call_rpc :update_key, request, options: do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |