class Google::Apis::ApikeysV2::ApiKeysServiceService
API Keys API
Manages the API keys associated with developer projects.
@example
require 'google/apis/apikeys_v2' Apikeys = Google::Apis::ApikeysV2 # Alias the module service = Apikeys::ApiKeysServiceService.new
Attributes
@return [String]
API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
@return [String]
Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
Public Class Methods
# File lib/google/apis/apikeys_v2/service.rb, line 45 def initialize super('https://apikeys.googleapis.com/', '', client_name: 'google-apis-apikeys_v2', client_version: Google::Apis::ApikeysV2::GEM_VERSION) @batch_path = 'batch' end
Public Instance Methods
Clones the existing key's restriction and display name to a new API key. The service account must have the `apikeys.keys.get` and `apikeys.keys.create` permissions in the project. NOTE: Key is a global resource; hence the only supported value for location is `global`. @param [String] name
Required. The resource name of the API key to be cloned in the same project.
@param [Google::Apis::ApikeysV2::V2CloneKeyRequest] v2_clone_key_request_object @param [String] fields
Selector specifying which fields to include in a partial response.
@param [String] quota_user
Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
@param [Google::Apis::RequestOptions] options
Request-specific options
@yield [result, err] Result & error if block supplied @yieldparam result [Google::Apis::ApikeysV2::Operation] parsed result object @yieldparam err [StandardError] error object if request failed
@return [Google::Apis::ApikeysV2::Operation]
@raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification @raise [Google::Apis::AuthorizationError] Authorization is required
# File lib/google/apis/apikeys_v2/service.rb, line 140 def clone_project_location_key(name, v2_clone_key_request_object = nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:post, 'v2/{+name}:clone', options) command.request_representation = Google::Apis::ApikeysV2::V2CloneKeyRequest::Representation command.request_object = v2_clone_key_request_object command.response_representation = Google::Apis::ApikeysV2::Operation::Representation command.response_class = Google::Apis::ApikeysV2::Operation command.params['name'] = name unless name.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end
Creates a new API key. NOTE: Key is a global resource; hence the only supported value for location is `global`. @param [String] parent
Required. The project in which the API key is created.
@param [Google::Apis::ApikeysV2::V2Key] v2_key_object @param [String] key_id
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.
@param [String] fields
Selector specifying which fields to include in a partial response.
@param [String] quota_user
Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
@param [Google::Apis::RequestOptions] options
Request-specific options
@yield [result, err] Result & error if block supplied @yieldparam result [Google::Apis::ApikeysV2::Operation] parsed result object @yieldparam err [StandardError] error object if request failed
@return [Google::Apis::ApikeysV2::Operation]
@raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification @raise [Google::Apis::AuthorizationError] Authorization is required
# File lib/google/apis/apikeys_v2/service.rb, line 181 def create_project_location_key(parent, v2_key_object = nil, key_id: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:post, 'v2/{+parent}/keys', options) command.request_representation = Google::Apis::ApikeysV2::V2Key::Representation command.request_object = v2_key_object command.response_representation = Google::Apis::ApikeysV2::Operation::Representation command.response_class = Google::Apis::ApikeysV2::Operation command.params['parent'] = parent unless parent.nil? command.query['keyId'] = key_id unless key_id.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end
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`. @param [String] name
Required. The resource name of the API key to be deleted.
@param [String] etag
Optional. The etag known to the client for the expected state of the key. This is to be used for optimistic concurrency.
@param [String] fields
Selector specifying which fields to include in a partial response.
@param [String] quota_user
Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
@param [Google::Apis::RequestOptions] options
Request-specific options
@yield [result, err] Result & error if block supplied @yieldparam result [Google::Apis::ApikeysV2::Operation] parsed result object @yieldparam err [StandardError] error object if request failed
@return [Google::Apis::ApikeysV2::Operation]
@raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification @raise [Google::Apis::AuthorizationError] Authorization is required
# File lib/google/apis/apikeys_v2/service.rb, line 219 def delete_project_location_key(name, etag: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:delete, 'v2/{+name}', options) command.response_representation = Google::Apis::ApikeysV2::Operation::Representation command.response_class = Google::Apis::ApikeysV2::Operation command.params['name'] = name unless name.nil? command.query['etag'] = etag unless etag.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end
Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. @param [String] name
The name of the operation resource.
@param [String] fields
Selector specifying which fields to include in a partial response.
@param [String] quota_user
Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
@param [Google::Apis::RequestOptions] options
Request-specific options
@yield [result, err] Result & error if block supplied @yieldparam result [Google::Apis::ApikeysV2::Operation] parsed result object @yieldparam err [StandardError] error object if request failed
@return [Google::Apis::ApikeysV2::Operation]
@raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification @raise [Google::Apis::AuthorizationError] Authorization is required
# File lib/google/apis/apikeys_v2/service.rb, line 106 def get_operation(name, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'v2/{+name}', options) command.response_representation = Google::Apis::ApikeysV2::Operation::Representation command.response_class = Google::Apis::ApikeysV2::Operation command.params['name'] = name unless name.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end
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`. @param [String] name
Required. The resource name of the API key to get.
@param [String] fields
Selector specifying which fields to include in a partial response.
@param [String] quota_user
Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
@param [Google::Apis::RequestOptions] options
Request-specific options
@yield [result, err] Result & error if block supplied @yieldparam result [Google::Apis::ApikeysV2::V2Key] parsed result object @yieldparam err [StandardError] error object if request failed
@return [Google::Apis::ApikeysV2::V2Key]
@raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification @raise [Google::Apis::AuthorizationError] Authorization is required
# File lib/google/apis/apikeys_v2/service.rb, line 252 def get_project_location_key(name, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'v2/{+name}', options) command.response_representation = Google::Apis::ApikeysV2::V2Key::Representation command.response_class = Google::Apis::ApikeysV2::V2Key command.params['name'] = name unless name.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end
Get the key string for an API key. NOTE: Key is a global resource; hence the only supported value for location is `global`. @param [String] name
Required. The resource name of the API key to be retrieved.
@param [String] fields
Selector specifying which fields to include in a partial response.
@param [String] quota_user
Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
@param [Google::Apis::RequestOptions] options
Request-specific options
@yield [result, err] Result & error if block supplied @yieldparam result [Google::Apis::ApikeysV2::V2GetKeyStringResponse] parsed result object @yieldparam err [StandardError] error object if request failed
@return [Google::Apis::ApikeysV2::V2GetKeyStringResponse]
@raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification @raise [Google::Apis::AuthorizationError] Authorization is required
# File lib/google/apis/apikeys_v2/service.rb, line 283 def get_project_location_key_key_string(name, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'v2/{+name}/keyString', options) command.response_representation = Google::Apis::ApikeysV2::V2GetKeyStringResponse::Representation command.response_class = Google::Apis::ApikeysV2::V2GetKeyStringResponse command.params['name'] = name unless name.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end
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`. @param [String] parent
Required. Lists all API keys associated with this project.
@param [String] filter
Optional. Only list keys that conform to the specified filter. The allowed filter strings are `state:ACTIVE` and `state:DELETED`. By default, ListKeys returns only active keys.
@param [Fixnum] page_size
Optional. Specifies the maximum number of results to be returned at a time.
@param [String] page_token
Optional. Requests a specific page of results.
@param [String] fields
Selector specifying which fields to include in a partial response.
@param [String] quota_user
Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
@param [Google::Apis::RequestOptions] options
Request-specific options
@yield [result, err] Result & error if block supplied @yieldparam result [Google::Apis::ApikeysV2::V2ListKeysResponse] parsed result object @yieldparam err [StandardError] error object if request failed
@return [Google::Apis::ApikeysV2::V2ListKeysResponse]
@raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification @raise [Google::Apis::AuthorizationError] Authorization is required
# File lib/google/apis/apikeys_v2/service.rb, line 323 def list_project_location_keys(parent, filter: nil, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'v2/{+parent}/keys', options) command.response_representation = Google::Apis::ApikeysV2::V2ListKeysResponse::Representation command.response_class = Google::Apis::ApikeysV2::V2ListKeysResponse command.params['parent'] = parent unless parent.nil? command.query['filter'] = filter unless filter.nil? command.query['pageSize'] = page_size unless page_size.nil? command.query['pageToken'] = page_token unless page_token.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end
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. @param [String] key_string
Required. Finds the project that owns the key string value.
@param [String] fields
Selector specifying which fields to include in a partial response.
@param [String] quota_user
Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
@param [Google::Apis::RequestOptions] options
Request-specific options
@yield [result, err] Result & error if block supplied @yieldparam result [Google::Apis::ApikeysV2::V2LookupKeyResponse] parsed result object @yieldparam err [StandardError] error object if request failed
@return [Google::Apis::ApikeysV2::V2LookupKeyResponse]
@raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification @raise [Google::Apis::AuthorizationError] Authorization is required
# File lib/google/apis/apikeys_v2/service.rb, line 75 def lookup_key_key(key_string: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:get, 'v2/keys:lookupKey', options) command.response_representation = Google::Apis::ApikeysV2::V2LookupKeyResponse::Representation command.response_class = Google::Apis::ApikeysV2::V2LookupKeyResponse command.query['keyString'] = key_string unless key_string.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end
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`. @param [String] name
Output only. The resource name of the key. The `name` has the form: `projects// locations/global/keys/`. For example: `projects/123456867718/locations/global/ keys/b7ff1f9f-8275-410a-94dd-3855ee9b5dd2` NOTE: Key is a global resource; hence the only supported value for location is `global`.
@param [Google::Apis::ApikeysV2::V2Key] v2_key_object @param [String] update_mask
The field mask specifies which fields to be updated as part of this request. All other fields are ignored. Mutable fields are: `display_name` and ` restrictions`. 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.
@param [String] fields
Selector specifying which fields to include in a partial response.
@param [String] quota_user
Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
@param [Google::Apis::RequestOptions] options
Request-specific options
@yield [result, err] Result & error if block supplied @yieldparam result [Google::Apis::ApikeysV2::Operation] parsed result object @yieldparam err [StandardError] error object if request failed
@return [Google::Apis::ApikeysV2::Operation]
@raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification @raise [Google::Apis::AuthorizationError] Authorization is required
# File lib/google/apis/apikeys_v2/service.rb, line 369 def patch_project_location_key(name, v2_key_object = nil, update_mask: nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:patch, 'v2/{+name}', options) command.request_representation = Google::Apis::ApikeysV2::V2Key::Representation command.request_object = v2_key_object command.response_representation = Google::Apis::ApikeysV2::Operation::Representation command.response_class = Google::Apis::ApikeysV2::Operation command.params['name'] = name unless name.nil? command.query['updateMask'] = update_mask unless update_mask.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end
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`. @param [String] name
Required. The resource name of the API key to be undeleted.
@param [Google::Apis::ApikeysV2::V2UndeleteKeyRequest] v2_undelete_key_request_object @param [String] fields
Selector specifying which fields to include in a partial response.
@param [String] quota_user
Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
@param [Google::Apis::RequestOptions] options
Request-specific options
@yield [result, err] Result & error if block supplied @yieldparam result [Google::Apis::ApikeysV2::Operation] parsed result object @yieldparam err [StandardError] error object if request failed
@return [Google::Apis::ApikeysV2::Operation]
@raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification @raise [Google::Apis::AuthorizationError] Authorization is required
# File lib/google/apis/apikeys_v2/service.rb, line 404 def undelete_project_location_key(name, v2_undelete_key_request_object = nil, fields: nil, quota_user: nil, options: nil, &block) command = make_simple_command(:post, 'v2/{+name}:undelete', options) command.request_representation = Google::Apis::ApikeysV2::V2UndeleteKeyRequest::Representation command.request_object = v2_undelete_key_request_object command.response_representation = Google::Apis::ApikeysV2::Operation::Representation command.response_class = Google::Apis::ApikeysV2::Operation command.params['name'] = name unless name.nil? command.query['fields'] = fields unless fields.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? execute_or_queue_command(command, &block) end
Protected Instance Methods
# File lib/google/apis/apikeys_v2/service.rb, line 418 def apply_command_defaults(command) command.query['key'] = key unless key.nil? command.query['quotaUser'] = quota_user unless quota_user.nil? end