Class: Google::Apis::ApikeysV2::ApiKeysServiceService

Inherits:
Core::BaseService
  • Object
show all
Defined in:
lib/google/apis/apikeys_v2/service.rb

Overview

API Keys API

Manages the API keys associated with developer projects.

Examples:

require 'google/apis/apikeys_v2'

Apikeys = Google::Apis::ApikeysV2 # Alias the module
service = Apikeys::ApiKeysServiceService.new

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApiKeysServiceService

Returns a new instance of ApiKeysServiceService.



45
46
47
48
49
50
# 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

Instance Attribute Details

#keyString

Returns 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.

Returns:

  • (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.



38
39
40
# File 'lib/google/apis/apikeys_v2/service.rb', line 38

def key
  @key
end

#quota_userString

Returns 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.

Returns:

  • (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.



43
44
45
# File 'lib/google/apis/apikeys_v2/service.rb', line 43

def quota_user
  @quota_user
end

Instance Method Details

#clone_project_location_key(name, v2_clone_key_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ApikeysV2::Operation

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.

Parameters:

  • name (String)

    Required. The resource name of the API key to be cloned in the same project.

  • v2_clone_key_request_object (Google::Apis::ApikeysV2::V2CloneKeyRequest) (defaults to: nil)
  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



140
141
142
143
144
145
146
147
148
149
150
# 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

#create_project_location_key(parent, v2_key_object = nil, key_id: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ApikeysV2::Operation

Creates a new API key. NOTE: Key is a global resource; hence the only supported value for location is global.

Parameters:

  • parent (String)

    Required. The project in which the API key is created.

  • v2_key_object (Google::Apis::ApikeysV2::V2Key) (defaults to: nil)
  • key_id (String) (defaults to: nil)

    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.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



181
182
183
184
185
186
187
188
189
190
191
192
# 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

#delete_project_location_key(name, etag: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ApikeysV2::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.

Parameters:

  • name (String)

    Required. The resource name of the API key to be deleted.

  • etag (String) (defaults to: nil)

    Optional. The etag known to the client for the expected state of the key. This is to be used for optimistic concurrency.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



219
220
221
222
223
224
225
226
227
228
# 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

#get_operation(name, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ApikeysV2::Operation

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.

Parameters:

  • name (String)

    The name of the operation resource.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



106
107
108
109
110
111
112
113
114
# 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

#get_project_location_key(name, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ApikeysV2::V2Key

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.

Parameters:

  • name (String)

    Required. The resource name of the API key to get.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



252
253
254
255
256
257
258
259
260
# 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_project_location_key_key_string(name, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ApikeysV2::V2GetKeyStringResponse

Get the key string for an API key. NOTE: Key is a global resource; hence the only supported value for location is global.

Parameters:

  • name (String)

    Required. The resource name of the API key to be retrieved.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



283
284
285
286
287
288
289
290
291
# 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

#list_project_location_keys(parent, filter: nil, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ApikeysV2::V2ListKeysResponse

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.

Parameters:

  • parent (String)

    Required. Lists all API keys associated with this project.

  • filter (String) (defaults to: nil)

    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.

  • page_size (Fixnum) (defaults to: nil)

    Optional. Specifies the maximum number of results to be returned at a time.

  • page_token (String) (defaults to: nil)

    Optional. Requests a specific page of results.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



323
324
325
326
327
328
329
330
331
332
333
334
# 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

#lookup_key_key(key_string: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ApikeysV2::V2LookupKeyResponse

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.

Parameters:

  • key_string (String) (defaults to: nil)

    Required. Finds the project that owns the key string value.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



75
76
77
78
79
80
81
82
83
# 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

#patch_project_location_key(name, v2_key_object = nil, update_mask: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ApikeysV2::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.

Parameters:

  • name (String)

    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.

  • v2_key_object (Google::Apis::ApikeysV2::V2Key) (defaults to: nil)
  • update_mask (String) (defaults to: nil)

    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.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



369
370
371
372
373
374
375
376
377
378
379
380
# 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

#undelete_project_location_key(name, v2_undelete_key_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::ApikeysV2::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.

Parameters:

  • name (String)

    Required. The resource name of the API key to be undeleted.

  • v2_undelete_key_request_object (Google::Apis::ApikeysV2::V2UndeleteKeyRequest) (defaults to: nil)
  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



404
405
406
407
408
409
410
411
412
413
414
# 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