Manages the API keys associated with projects. v2
Package
@google-cloud/apikeysConstructors
(constructor)(opts, gaxInstance)
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
Construct an instance of ApiKeysClient.
Name | Description |
opts |
ClientOptions
|
gaxInstance |
typeof gax | typeof gax.fallback
: loaded instance of |
Properties
apiEndpoint
static get apiEndpoint(): string;
The DNS address for this API service - same as servicePath(), exists for compatibility reasons.
apiKeysStub
apiKeysStub?: Promise<{
[name: string]: Function;
}>;
auth
auth: gax.GoogleAuth;
descriptors
descriptors: Descriptors;
innerApiCalls
innerApiCalls: {
[name: string]: Function;
};
operationsClient
operationsClient: gax.OperationsClient;
pathTemplates
pathTemplates: {
[name: string]: gax.PathTemplate;
};
port
static get port(): number;
The port for this API service.
scopes
static get scopes(): string[];
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
static get servicePath(): string;
The DNS address for this API service.
warn
warn: (code: string, message: string, warnType?: string) => void;
Methods
cancelOperation(request, options, callback)
cancelOperation(request: protos.google.longrunning.CancelOperationRequest, options?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>, callback?: Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>): Promise<protos.google.protobuf.Empty>;
Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED
. Clients can use or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an value with a of 1, corresponding to Code.CANCELLED
.
Name | Description |
request |
protos.google.longrunning.CancelOperationRequest
The request object that will be sent. |
options |
gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See [gax.CallOptions]https://googleapis.github.io/gax-nodejs/global.html#CallOptions for the details. |
callback |
Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>
The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call. |
Type | Description |
Promise<protos.google.protobuf.Empty> |
const client = longrunning.operationsClient();
await client.cancelOperation({name: ''});
checkCreateKeyProgress(name)
checkCreateKeyProgress(name: string): Promise<LROperation<protos.google.api.apikeys.v2.Key, protos.google.protobuf.Empty>>;
Check the status of the long running operation returned by createKey()
.
Name | Description |
name |
string
The operation name that will be passed. |
Type | Description |
Promise<LROperation<protos.google.api.apikeys.v2.Key, protos.google.protobuf.Empty>> | {Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The project in which the API key is created.
*/
// const parent = 'abc123'
/**
* Required. The API key fields to set at creation time.
* You can configure only the `display_name`, `restrictions`, and
* `annotations` fields.
*/
// const key = {}
/**
* 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.
*/
// const keyId = 'abc123'
// Imports the Apikeys library
const {ApiKeysClient} = require('@google-cloud/apikeys').v2;
// Instantiates a client
const apikeysClient = new ApiKeysClient();
async function callCreateKey() {
// Construct request
const request = {
parent,
key,
};
// Run request
const [operation] = await apikeysClient.createKey(request);
const [response] = await operation.promise();
console.log(response);
}
callCreateKey();
checkDeleteKeyProgress(name)
checkDeleteKeyProgress(name: string): Promise<LROperation<protos.google.api.apikeys.v2.Key, protos.google.protobuf.Empty>>;
Check the status of the long running operation returned by deleteKey()
.
Name | Description |
name |
string
The operation name that will be passed. |
Type | Description |
Promise<LROperation<protos.google.api.apikeys.v2.Key, protos.google.protobuf.Empty>> | {Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the API key to be deleted.
*/
// const name = 'abc123'
/**
* Optional. The etag known to the client for the expected state of the key.
* This is to be used for optimistic concurrency.
*/
// const etag = 'abc123'
// Imports the Apikeys library
const {ApiKeysClient} = require('@google-cloud/apikeys').v2;
// Instantiates a client
const apikeysClient = new ApiKeysClient();
async function callDeleteKey() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await apikeysClient.deleteKey(request);
const [response] = await operation.promise();
console.log(response);
}
callDeleteKey();
checkUndeleteKeyProgress(name)
checkUndeleteKeyProgress(name: string): Promise<LROperation<protos.google.api.apikeys.v2.Key, protos.google.protobuf.Empty>>;
Check the status of the long running operation returned by undeleteKey()
.
Name | Description |
name |
string
The operation name that will be passed. |
Type | Description |
Promise<LROperation<protos.google.api.apikeys.v2.Key, protos.google.protobuf.Empty>> | {Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the API key to be undeleted.
*/
// const name = 'abc123'
// Imports the Apikeys library
const {ApiKeysClient} = require('@google-cloud/apikeys').v2;
// Instantiates a client
const apikeysClient = new ApiKeysClient();
async function callUndeleteKey() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await apikeysClient.undeleteKey(request);
const [response] = await operation.promise();
console.log(response);
}
callUndeleteKey();
checkUpdateKeyProgress(name)
checkUpdateKeyProgress(name: string): Promise<LROperation<protos.google.api.apikeys.v2.Key, protos.google.protobuf.Empty>>;
Check the status of the long running operation returned by updateKey()
.
Name | Description |
name |
string
The operation name that will be passed. |
Type | Description |
Promise<LROperation<protos.google.api.apikeys.v2.Key, protos.google.protobuf.Empty>> | {Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Set the `name` field to the resource name of the API key to be
* updated. You can update only the `display_name`, `restrictions`, and
* `annotations` fields.
*/
// const key = {}
/**
* 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`, and `annotations`.
* 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.
*/
// const updateMask = {}
// Imports the Apikeys library
const {ApiKeysClient} = require('@google-cloud/apikeys').v2;
// Instantiates a client
const apikeysClient = new ApiKeysClient();
async function callUpdateKey() {
// Construct request
const request = {
key,
};
// Run request
const [operation] = await apikeysClient.updateKey(request);
const [response] = await operation.promise();
console.log(response);
}
callUpdateKey();
close()
close(): Promise<void>;
Terminate the gRPC channel and close the client.
The client will no longer be usable and all future behavior is undefined.
Type | Description |
Promise<void> | {Promise} A promise that resolves when the client is closed. |
createKey(request, options)
createKey(request?: protos.google.api.apikeys.v2.ICreateKeyRequest, options?: CallOptions): Promise<[
LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
Creates a new API key.
NOTE: Key is a global resource; hence the only supported value for location is global
.
Name | Description |
request |
protos.google.api.apikeys.v2.ICreateKeyRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The project in which the API key is created.
*/
// const parent = 'abc123'
/**
* Required. The API key fields to set at creation time.
* You can configure only the `display_name`, `restrictions`, and
* `annotations` fields.
*/
// const key = {}
/**
* 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.
*/
// const keyId = 'abc123'
// Imports the Apikeys library
const {ApiKeysClient} = require('@google-cloud/apikeys').v2;
// Instantiates a client
const apikeysClient = new ApiKeysClient();
async function callCreateKey() {
// Construct request
const request = {
parent,
key,
};
// Run request
const [operation] = await apikeysClient.createKey(request);
const [response] = await operation.promise();
console.log(response);
}
callCreateKey();
createKey(request, options, callback)
createKey(request: protos.google.api.apikeys.v2.ICreateKeyRequest, options: CallOptions, callback: Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.ICreateKeyRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
createKey(request, callback)
createKey(request: protos.google.api.apikeys.v2.ICreateKeyRequest, callback: Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.ICreateKeyRequest
|
callback |
Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
deleteKey(request, options)
deleteKey(request?: protos.google.api.apikeys.v2.IDeleteKeyRequest, options?: CallOptions): Promise<[
LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
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
.
Name | Description |
request |
protos.google.api.apikeys.v2.IDeleteKeyRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the API key to be deleted.
*/
// const name = 'abc123'
/**
* Optional. The etag known to the client for the expected state of the key.
* This is to be used for optimistic concurrency.
*/
// const etag = 'abc123'
// Imports the Apikeys library
const {ApiKeysClient} = require('@google-cloud/apikeys').v2;
// Instantiates a client
const apikeysClient = new ApiKeysClient();
async function callDeleteKey() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await apikeysClient.deleteKey(request);
const [response] = await operation.promise();
console.log(response);
}
callDeleteKey();
deleteKey(request, options, callback)
deleteKey(request: protos.google.api.apikeys.v2.IDeleteKeyRequest, options: CallOptions, callback: Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.IDeleteKeyRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
deleteKey(request, callback)
deleteKey(request: protos.google.api.apikeys.v2.IDeleteKeyRequest, callback: Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.IDeleteKeyRequest
|
callback |
Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
deleteOperation(request, options, callback)
deleteOperation(request: protos.google.longrunning.DeleteOperationRequest, options?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>): Promise<protos.google.protobuf.Empty>;
Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED
.
Name | Description |
request |
protos.google.longrunning.DeleteOperationRequest
The request object that will be sent. |
options |
gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See [gax.CallOptions]https://googleapis.github.io/gax-nodejs/global.html#CallOptions for the details. |
callback |
Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>
The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call. |
Type | Description |
Promise<protos.google.protobuf.Empty> |
const client = longrunning.operationsClient();
await client.deleteOperation({name: ''});
getKey(request, options)
getKey(request?: protos.google.api.apikeys.v2.IGetKeyRequest, options?: CallOptions): Promise<[
protos.google.api.apikeys.v2.IKey,
protos.google.api.apikeys.v2.IGetKeyRequest | undefined,
{} | undefined
]>;
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
.
Name | Description |
request |
protos.google.api.apikeys.v2.IGetKeyRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ protos.google.api.apikeys.v2.IKey, protos.google.api.apikeys.v2.IGetKeyRequest | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing [Key]. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the API key to get.
*/
// const name = 'abc123'
// Imports the Apikeys library
const {ApiKeysClient} = require('@google-cloud/apikeys').v2;
// Instantiates a client
const apikeysClient = new ApiKeysClient();
async function callGetKey() {
// Construct request
const request = {
name,
};
// Run request
const response = await apikeysClient.getKey(request);
console.log(response);
}
callGetKey();
getKey(request, options, callback)
getKey(request: protos.google.api.apikeys.v2.IGetKeyRequest, options: CallOptions, callback: Callback<protos.google.api.apikeys.v2.IKey, protos.google.api.apikeys.v2.IGetKeyRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.IGetKeyRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.api.apikeys.v2.IKey, protos.google.api.apikeys.v2.IGetKeyRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
getKey(request, callback)
getKey(request: protos.google.api.apikeys.v2.IGetKeyRequest, callback: Callback<protos.google.api.apikeys.v2.IKey, protos.google.api.apikeys.v2.IGetKeyRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.IGetKeyRequest
|
callback |
Callback<protos.google.api.apikeys.v2.IKey, protos.google.api.apikeys.v2.IGetKeyRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
getKeyString(request, options)
getKeyString(request?: protos.google.api.apikeys.v2.IGetKeyStringRequest, options?: CallOptions): Promise<[
protos.google.api.apikeys.v2.IGetKeyStringResponse,
protos.google.api.apikeys.v2.IGetKeyStringRequest | undefined,
{} | undefined
]>;
Get the key string for an API key.
NOTE: Key is a global resource; hence the only supported value for location is global
.
Name | Description |
request |
protos.google.api.apikeys.v2.IGetKeyStringRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ protos.google.api.apikeys.v2.IGetKeyStringResponse, protos.google.api.apikeys.v2.IGetKeyStringRequest | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing [GetKeyStringResponse]. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the API key to be retrieved.
*/
// const name = 'abc123'
// Imports the Apikeys library
const {ApiKeysClient} = require('@google-cloud/apikeys').v2;
// Instantiates a client
const apikeysClient = new ApiKeysClient();
async function callGetKeyString() {
// Construct request
const request = {
name,
};
// Run request
const response = await apikeysClient.getKeyString(request);
console.log(response);
}
callGetKeyString();
getKeyString(request, options, callback)
getKeyString(request: protos.google.api.apikeys.v2.IGetKeyStringRequest, options: CallOptions, callback: Callback<protos.google.api.apikeys.v2.IGetKeyStringResponse, protos.google.api.apikeys.v2.IGetKeyStringRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.IGetKeyStringRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.api.apikeys.v2.IGetKeyStringResponse, protos.google.api.apikeys.v2.IGetKeyStringRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
getKeyString(request, callback)
getKeyString(request: protos.google.api.apikeys.v2.IGetKeyStringRequest, callback: Callback<protos.google.api.apikeys.v2.IGetKeyStringResponse, protos.google.api.apikeys.v2.IGetKeyStringRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.IGetKeyStringRequest
|
callback |
Callback<protos.google.api.apikeys.v2.IGetKeyStringResponse, protos.google.api.apikeys.v2.IGetKeyStringRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
getOperation(request, options, callback)
getOperation(request: protos.google.longrunning.GetOperationRequest, options?: gax.CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>): Promise<[protos.google.longrunning.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.
Name | Description |
request |
protos.google.longrunning.GetOperationRequest
The request object that will be sent. |
options |
gax.CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See [gax.CallOptions]https://googleapis.github.io/gax-nodejs/global.html#CallOptions for the details. |
callback |
Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>
The function which will be called with the result of the API call. The second parameter to the callback is an object representing [google.longrunning.Operation]. {Promise} - The promise which resolves to an array. The first element of the array is an object representing [google.longrunning.Operation]. The promise has a method named "cancel" which cancels the ongoing API call. |
Type | Description |
Promise<[protos.google.longrunning.Operation]> |
const client = longrunning.operationsClient();
const name = '';
const [response] = await client.getOperation({name});
// doThingsWith(response)
getProjectId()
getProjectId(): Promise<string>;
Type | Description |
Promise<string> |
getProjectId(callback)
getProjectId(callback: Callback<string, undefined, undefined>): void;
Name | Description |
callback |
Callback<string, undefined, undefined>
|
Type | Description |
void |
initialize()
initialize(): Promise<{
[name: string]: Function;
}>;
Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.
You can await on this method if you want to make sure the client is initialized.
Type | Description |
Promise<{ [name: string]: Function; }> | {Promise} A promise that resolves to an authenticated service stub. |
keyPath(project, location, key)
keyPath(project: string, location: string, key: string): string;
Return a fully-qualified key resource name string.
Name | Description |
project |
string
|
location |
string
|
key |
string
|
Type | Description |
string | {string} Resource name string. |
listKeys(request, options)
listKeys(request?: protos.google.api.apikeys.v2.IListKeysRequest, options?: CallOptions): Promise<[
protos.google.api.apikeys.v2.IKey[],
protos.google.api.apikeys.v2.IListKeysRequest | null,
protos.google.api.apikeys.v2.IListKeysResponse
]>;
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
.
Name | Description |
request |
protos.google.api.apikeys.v2.IListKeysRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ protos.google.api.apikeys.v2.IKey[], protos.google.api.apikeys.v2.IListKeysRequest | null, protos.google.api.apikeys.v2.IListKeysResponse ]> | {Promise} - The promise which resolves to an array. The first element of the array is Array of [Key]. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using |
listKeys(request, options, callback)
listKeys(request: protos.google.api.apikeys.v2.IListKeysRequest, options: CallOptions, callback: PaginationCallback<protos.google.api.apikeys.v2.IListKeysRequest, protos.google.api.apikeys.v2.IListKeysResponse | null | undefined, protos.google.api.apikeys.v2.IKey>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.IListKeysRequest
|
options |
CallOptions
|
callback |
PaginationCallback<protos.google.api.apikeys.v2.IListKeysRequest, protos.google.api.apikeys.v2.IListKeysResponse | null | undefined, protos.google.api.apikeys.v2.IKey>
|
Type | Description |
void |
listKeys(request, callback)
listKeys(request: protos.google.api.apikeys.v2.IListKeysRequest, callback: PaginationCallback<protos.google.api.apikeys.v2.IListKeysRequest, protos.google.api.apikeys.v2.IListKeysResponse | null | undefined, protos.google.api.apikeys.v2.IKey>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.IListKeysRequest
|
callback |
PaginationCallback<protos.google.api.apikeys.v2.IListKeysRequest, protos.google.api.apikeys.v2.IListKeysResponse | null | undefined, protos.google.api.apikeys.v2.IKey>
|
Type | Description |
void |
listKeysAsync(request, options)
listKeysAsync(request?: protos.google.api.apikeys.v2.IListKeysRequest, options?: CallOptions): AsyncIterable<protos.google.api.apikeys.v2.IKey>;
Equivalent to listKeys
, but returns an iterable object.
for
-await
-of
syntax is used with the iterable to get response elements on-demand.
Name | Description |
request |
protos.google.api.apikeys.v2.IListKeysRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
AsyncIterable<protos.google.api.apikeys.v2.IKey> | {Object} An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). When you iterate the returned iterable, each element will be an object representing [Key]. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Lists all API keys associated with this project.
*/
// const parent = 'abc123'
/**
* Optional. Specifies the maximum number of results to be returned at a time.
*/
// const pageSize = 1234
/**
* Optional. Requests a specific page of results.
*/
// const pageToken = 'abc123'
/**
* Optional. Indicate that keys deleted in the past 30 days should also be
* returned.
*/
// const showDeleted = true
// Imports the Apikeys library
const {ApiKeysClient} = require('@google-cloud/apikeys').v2;
// Instantiates a client
const apikeysClient = new ApiKeysClient();
async function callListKeys() {
// Construct request
const request = {
parent,
};
// Run request
const iterable = await apikeysClient.listKeysAsync(request);
for await (const response of iterable) {
console.log(response);
}
}
callListKeys();
listKeysStream(request, options)
listKeysStream(request?: protos.google.api.apikeys.v2.IListKeysRequest, options?: CallOptions): Transform;
Equivalent to method.name.toCamelCase()
, but returns a NodeJS Stream object.
Name | Description |
request |
protos.google.api.apikeys.v2.IListKeysRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Transform | {Stream} An object stream which emits an object representing [Key] on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using |
listOperationsAsync(request, options)
listOperationsAsync(request: protos.google.longrunning.ListOperationsRequest, options?: gax.CallOptions): AsyncIterable<protos.google.longrunning.ListOperationsResponse>;
Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED
. Returns an iterable object.
For-await-of syntax is used with the iterable to recursively get response element on-demand.
Name | Description |
request |
protos.google.longrunning.ListOperationsRequest
The request object that will be sent. |
options |
gax.CallOptions
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See [gax.CallOptions]https://googleapis.github.io/gax-nodejs/global.html#CallOptions for the details. |
Type | Description |
AsyncIterable<protos.google.longrunning.ListOperationsResponse> | {Object} An iterable Object that conforms to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. |
const client = longrunning.operationsClient();
for await (const response of client.listOperationsAsync(request));
// doThingsWith(response)
locationPath(project, location)
locationPath(project: string, location: string): string;
Return a fully-qualified location resource name string.
Name | Description |
project |
string
|
location |
string
|
Type | Description |
string | {string} Resource name string. |
lookupKey(request, options)
lookupKey(request?: protos.google.api.apikeys.v2.ILookupKeyRequest, options?: CallOptions): Promise<[
protos.google.api.apikeys.v2.ILookupKeyResponse,
protos.google.api.apikeys.v2.ILookupKeyRequest | undefined,
{} | undefined
]>;
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.
Name | Description |
request |
protos.google.api.apikeys.v2.ILookupKeyRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ protos.google.api.apikeys.v2.ILookupKeyResponse, protos.google.api.apikeys.v2.ILookupKeyRequest | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing [LookupKeyResponse]. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Finds the project that owns the key string value.
*/
// const keyString = 'abc123'
// Imports the Apikeys library
const {ApiKeysClient} = require('@google-cloud/apikeys').v2;
// Instantiates a client
const apikeysClient = new ApiKeysClient();
async function callLookupKey() {
// Construct request
const request = {
keyString,
};
// Run request
const response = await apikeysClient.lookupKey(request);
console.log(response);
}
callLookupKey();
lookupKey(request, options, callback)
lookupKey(request: protos.google.api.apikeys.v2.ILookupKeyRequest, options: CallOptions, callback: Callback<protos.google.api.apikeys.v2.ILookupKeyResponse, protos.google.api.apikeys.v2.ILookupKeyRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.ILookupKeyRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.api.apikeys.v2.ILookupKeyResponse, protos.google.api.apikeys.v2.ILookupKeyRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
lookupKey(request, callback)
lookupKey(request: protos.google.api.apikeys.v2.ILookupKeyRequest, callback: Callback<protos.google.api.apikeys.v2.ILookupKeyResponse, protos.google.api.apikeys.v2.ILookupKeyRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.ILookupKeyRequest
|
callback |
Callback<protos.google.api.apikeys.v2.ILookupKeyResponse, protos.google.api.apikeys.v2.ILookupKeyRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
matchKeyFromKeyName(keyName)
matchKeyFromKeyName(keyName: string): string | number;
Parse the key from Key resource.
Name | Description |
keyName |
string
A fully-qualified path representing Key resource. |
Type | Description |
string | number | {string} A string representing the key. |
matchLocationFromKeyName(keyName)
matchLocationFromKeyName(keyName: string): string | number;
Parse the location from Key resource.
Name | Description |
keyName |
string
A fully-qualified path representing Key resource. |
Type | Description |
string | number | {string} A string representing the location. |
matchLocationFromLocationName(locationName)
matchLocationFromLocationName(locationName: string): string | number;
Parse the location from Location resource.
Name | Description |
locationName |
string
A fully-qualified path representing Location resource. |
Type | Description |
string | number | {string} A string representing the location. |
matchProjectFromKeyName(keyName)
matchProjectFromKeyName(keyName: string): string | number;
Parse the project from Key resource.
Name | Description |
keyName |
string
A fully-qualified path representing Key resource. |
Type | Description |
string | number | {string} A string representing the project. |
matchProjectFromLocationName(locationName)
matchProjectFromLocationName(locationName: string): string | number;
Parse the project from Location resource.
Name | Description |
locationName |
string
A fully-qualified path representing Location resource. |
Type | Description |
string | number | {string} A string representing the project. |
matchProjectFromProjectName(projectName)
matchProjectFromProjectName(projectName: string): string | number;
Parse the project from Project resource.
Name | Description |
projectName |
string
A fully-qualified path representing Project resource. |
Type | Description |
string | number | {string} A string representing the project. |
projectPath(project)
projectPath(project: string): string;
Return a fully-qualified project resource name string.
Name | Description |
project |
string
|
Type | Description |
string | {string} Resource name string. |
undeleteKey(request, options)
undeleteKey(request?: protos.google.api.apikeys.v2.IUndeleteKeyRequest, options?: CallOptions): Promise<[
LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
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
.
Name | Description |
request |
protos.google.api.apikeys.v2.IUndeleteKeyRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the API key to be undeleted.
*/
// const name = 'abc123'
// Imports the Apikeys library
const {ApiKeysClient} = require('@google-cloud/apikeys').v2;
// Instantiates a client
const apikeysClient = new ApiKeysClient();
async function callUndeleteKey() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await apikeysClient.undeleteKey(request);
const [response] = await operation.promise();
console.log(response);
}
callUndeleteKey();
undeleteKey(request, options, callback)
undeleteKey(request: protos.google.api.apikeys.v2.IUndeleteKeyRequest, options: CallOptions, callback: Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.IUndeleteKeyRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
undeleteKey(request, callback)
undeleteKey(request: protos.google.api.apikeys.v2.IUndeleteKeyRequest, callback: Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.IUndeleteKeyRequest
|
callback |
Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
updateKey(request, options)
updateKey(request?: protos.google.api.apikeys.v2.IUpdateKeyRequest, options?: CallOptions): Promise<[
LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
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
.
Name | Description |
request |
protos.google.api.apikeys.v2.IUpdateKeyRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Set the `name` field to the resource name of the API key to be
* updated. You can update only the `display_name`, `restrictions`, and
* `annotations` fields.
*/
// const key = {}
/**
* 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`, and `annotations`.
* 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.
*/
// const updateMask = {}
// Imports the Apikeys library
const {ApiKeysClient} = require('@google-cloud/apikeys').v2;
// Instantiates a client
const apikeysClient = new ApiKeysClient();
async function callUpdateKey() {
// Construct request
const request = {
key,
};
// Run request
const [operation] = await apikeysClient.updateKey(request);
const [response] = await operation.promise();
console.log(response);
}
callUpdateKey();
updateKey(request, options, callback)
updateKey(request: protos.google.api.apikeys.v2.IUpdateKeyRequest, options: CallOptions, callback: Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.IUpdateKeyRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
updateKey(request, callback)
updateKey(request: protos.google.api.apikeys.v2.IUpdateKeyRequest, callback: Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.apikeys.v2.IUpdateKeyRequest
|
callback |
Callback<LROperation<protos.google.api.apikeys.v2.IKey, protos.google.protobuf.IEmpty>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |