Reference documentation and code samples for the API Keys V2 API class Google::Cloud::ApiKeys::V2::ApiKeys::Client.
Client for the ApiKeys service.
Manages the API keys associated with projects.
Inherits
- Object
Methods
.configure
def self.configure() { |config| ... } -> Client::Configuration
Configure the ApiKeys Client class.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
# Modify the configuration for all ApiKeys clients ::Google::Cloud::ApiKeys::V2::ApiKeys::Client.configure do |config| config.timeout = 10.0 end
#configure
def 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 Client.configure.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
#create_key
def create_key(request, options = nil) -> ::Gapic::Operation
def 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
.
def create_key(request, options = nil) -> ::Gapic::Operation
create_key
via a request object, either of type
CreateKeyRequest or an equivalent Hash.
- request (::Google::Cloud::ApiKeys::V2::CreateKeyRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def create_key(parent: nil, key: nil, key_id: nil) -> ::Gapic::Operation
create_key
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- parent (::String) — Required. The project in which the API key is created.
-
key (::Google::Cloud::ApiKeys::V2::Key, ::Hash) — Required. The API key fields to set at creation time.
You can configure only the
display_name
,restrictions
, andannotations
fields. -
key_id (::String) — User specified key id (optional). If specified, it will become the final
component of the key resource name.
The id must be unique within the project, must conform with RFC-1034, is restricted to lower-cased letters, and has a maximum length of 63 characters. In another word, the id must match the regular expression:
[a-z]([a-z0-9-]{0,61}[a-z0-9])?
.The id must NOT be a UUID-like string.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/api_keys/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::ApiKeys::V2::ApiKeys::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::ApiKeys::V2::CreateKeyRequest.new # Call the create_key method. result = client.create_key request # The returned object is of type Gapic::Operation. You can use it to # check the status of an operation, cancel it, or wait for results. # Here is how to wait for a response. result.wait_until_done! timeout: 60 if result.response? p result.response else puts "No response received." end
#delete_key
def delete_key(request, options = nil) -> ::Gapic::Operation
def 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
.
def delete_key(request, options = nil) -> ::Gapic::Operation
delete_key
via a request object, either of type
DeleteKeyRequest or an equivalent Hash.
- request (::Google::Cloud::ApiKeys::V2::DeleteKeyRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def delete_key(name: nil, etag: nil) -> ::Gapic::Operation
delete_key
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- name (::String) — Required. The resource name of the API key to be deleted.
- etag (::String) — Optional. The etag known to the client for the expected state of the key. This is to be used for optimistic concurrency.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/api_keys/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::ApiKeys::V2::ApiKeys::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::ApiKeys::V2::DeleteKeyRequest.new # Call the delete_key method. result = client.delete_key request # The returned object is of type Gapic::Operation. You can use it to # check the status of an operation, cancel it, or wait for results. # Here is how to wait for a response. result.wait_until_done! timeout: 60 if result.response? p result.response else puts "No response received." end
#get_key
def get_key(request, options = nil) -> ::Google::Cloud::ApiKeys::V2::Key
def 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
.
def get_key(request, options = nil) -> ::Google::Cloud::ApiKeys::V2::Key
get_key
via a request object, either of type
GetKeyRequest or an equivalent Hash.
- request (::Google::Cloud::ApiKeys::V2::GetKeyRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_key(name: nil) -> ::Google::Cloud::ApiKeys::V2::Key
get_key
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- name (::String) — Required. The resource name of the API key to get.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::ApiKeys::V2::Key)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/api_keys/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::ApiKeys::V2::ApiKeys::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::ApiKeys::V2::GetKeyRequest.new # Call the get_key method. result = client.get_key request # The returned object is of type Google::Cloud::ApiKeys::V2::Key. p result
#get_key_string
def get_key_string(request, options = nil) -> ::Google::Cloud::ApiKeys::V2::GetKeyStringResponse
def 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
.
def get_key_string(request, options = nil) -> ::Google::Cloud::ApiKeys::V2::GetKeyStringResponse
get_key_string
via a request object, either of type
GetKeyStringRequest or an equivalent Hash.
- request (::Google::Cloud::ApiKeys::V2::GetKeyStringRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_key_string(name: nil) -> ::Google::Cloud::ApiKeys::V2::GetKeyStringResponse
get_key_string
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- name (::String) — Required. The resource name of the API key to be retrieved.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::ApiKeys::V2::GetKeyStringResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/api_keys/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::ApiKeys::V2::ApiKeys::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::ApiKeys::V2::GetKeyStringRequest.new # Call the get_key_string method. result = client.get_key_string request # The returned object is of type Google::Cloud::ApiKeys::V2::GetKeyStringResponse. p result
#initialize
def initialize() { |config| ... } -> Client
Create a new ApiKeys client object.
- (config) — Configure the ApiKeys client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# Create a client using the default configuration client = ::Google::Cloud::ApiKeys::V2::ApiKeys::Client.new # Create a client using a custom configuration client = ::Google::Cloud::ApiKeys::V2::ApiKeys::Client.new do |config| config.timeout = 10.0 end
#list_keys
def list_keys(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::ApiKeys::V2::Key>
def 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
.
def list_keys(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::ApiKeys::V2::Key>
list_keys
via a request object, either of type
ListKeysRequest or an equivalent Hash.
- request (::Google::Cloud::ApiKeys::V2::ListKeysRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_keys(parent: nil, page_size: nil, page_token: nil, show_deleted: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::ApiKeys::V2::Key>
list_keys
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- parent (::String) — Required. Lists all API keys associated with this project.
- page_size (::Integer) — Optional. Specifies the maximum number of results to be returned at a time.
- page_token (::String) — Optional. Requests a specific page of results.
- show_deleted (::Boolean) — Optional. Indicate that keys deleted in the past 30 days should also be returned.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Cloud::ApiKeys::V2::Key>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Cloud::ApiKeys::V2::Key>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/api_keys/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::ApiKeys::V2::ApiKeys::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::ApiKeys::V2::ListKeysRequest.new # Call the list_keys method. result = client.list_keys request # The returned object is of type Gapic::PagedEnumerable. You can iterate # over elements, and API calls will be issued to fetch pages as needed. result.each do |item| # Each element is of type ::Google::Cloud::ApiKeys::V2::Key. p item end
#logger
def logger() -> Logger
The logger used for request/response debug logging.
- (Logger)
#lookup_key
def lookup_key(request, options = nil) -> ::Google::Cloud::ApiKeys::V2::LookupKeyResponse
def 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.
def lookup_key(request, options = nil) -> ::Google::Cloud::ApiKeys::V2::LookupKeyResponse
lookup_key
via a request object, either of type
LookupKeyRequest or an equivalent Hash.
- request (::Google::Cloud::ApiKeys::V2::LookupKeyRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def lookup_key(key_string: nil) -> ::Google::Cloud::ApiKeys::V2::LookupKeyResponse
lookup_key
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- key_string (::String) — Required. Finds the project that owns the key string value.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::ApiKeys::V2::LookupKeyResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/api_keys/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::ApiKeys::V2::ApiKeys::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::ApiKeys::V2::LookupKeyRequest.new # Call the lookup_key method. result = client.lookup_key request # The returned object is of type Google::Cloud::ApiKeys::V2::LookupKeyResponse. p result
#operations_client
def operations_client() -> ::Google::Cloud::ApiKeys::V2::ApiKeys::Operations
Get the associated client for long-running operations.
#undelete_key
def undelete_key(request, options = nil) -> ::Gapic::Operation
def 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
.
def undelete_key(request, options = nil) -> ::Gapic::Operation
undelete_key
via a request object, either of type
UndeleteKeyRequest or an equivalent Hash.
- request (::Google::Cloud::ApiKeys::V2::UndeleteKeyRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def undelete_key(name: nil) -> ::Gapic::Operation
undelete_key
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- name (::String) — Required. The resource name of the API key to be undeleted.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/api_keys/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::ApiKeys::V2::ApiKeys::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::ApiKeys::V2::UndeleteKeyRequest.new # Call the undelete_key method. result = client.undelete_key request # The returned object is of type Gapic::Operation. You can use it to # check the status of an operation, cancel it, or wait for results. # Here is how to wait for a response. result.wait_until_done! timeout: 60 if result.response? p result.response else puts "No response received." end
#universe_domain
def universe_domain() -> String
The effective universe domain
- (String)
#update_key
def update_key(request, options = nil) -> ::Gapic::Operation
def 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
.
def update_key(request, options = nil) -> ::Gapic::Operation
update_key
via a request object, either of type
UpdateKeyRequest or an equivalent Hash.
- request (::Google::Cloud::ApiKeys::V2::UpdateKeyRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def update_key(key: nil, update_mask: nil) -> ::Gapic::Operation
update_key
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
key (::Google::Cloud::ApiKeys::V2::Key, ::Hash) — Required. Set the
name
field to the resource name of the API key to be updated. You can update only thedisplay_name
,restrictions
, andannotations
fields. -
update_mask (::Google::Protobuf::FieldMask, ::Hash) — The field mask specifies which fields to be updated as part of this
request. All other fields are ignored.
Mutable fields are:
display_name
,restrictions
, andannotations
. If an update mask is not provided, the service treats it as an implied mask equivalent to all allowed fields that are set on the wire. If the field mask has a special value "*", the service treats it equivalent to replace all allowed mutable fields.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::Operation)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/api_keys/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::ApiKeys::V2::ApiKeys::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::ApiKeys::V2::UpdateKeyRequest.new # Call the update_key method. result = client.update_key request # The returned object is of type Gapic::Operation. You can use it to # check the status of an operation, cancel it, or wait for results. # Here is how to wait for a response. result.wait_until_done! timeout: 60 if result.response? p result.response else puts "No response received." end