Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

feat: add minimum wrapper for compute LRO method #618

Merged
merged 13 commits into from
Sep 13, 2021
37 changes: 21 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@google-cloud/compute",
"description": "Google Compute Engine Client Library for Node.js",
"version": "3.0.0",
"version": "3.0.0-alpha.4",
"license": "Apache-2.0",
"author": "Google LLC",
"engines": {
Expand Down Expand Up @@ -32,13 +32,15 @@
"disks",
"disk types",
"external vpn gateways",
"firewall policies",
"firewalls",
"forwarding rules",
"global addresses",
"global forwarding rules",
"global network endpoint groups",
"global operations",
"global organization operations",
"global public delegated prefixes",
"health checks",
"images",
"instance group managers",
Expand All @@ -58,6 +60,8 @@
"node types",
"packet mirrorings",
"projects",
"public advertised prefixes",
"public delegated prefixes",
"region autoscalers",
"region backend services",
"region commitments",
Expand All @@ -67,6 +71,7 @@
"region health check services",
"region instance group managers",
"region instance groups",
"region instances",
"region network endpoint groups",
"region notification endpoints",
"region operations",
Expand Down Expand Up @@ -115,27 +120,27 @@
"precompile": "gts clean"
},
"dependencies": {
"google-gax": "^2.24.1"
"google-gax": "^2.25.0"
},
"devDependencies": {
"@types/mocha": "^8.2.0",
"@types/node": "^14.14.13",
"@types/sinon": "^10.0.0",
"c8": "^7.3.5",
"@types/mocha": "^9.0.0",
"@types/node": "^14.17.3",
"@types/sinon": "^10.0.2",
"c8": "^7.7.3",
"chai": "^4.3.4",
"gts": "^3.1.0",
"jsdoc": "^3.6.6",
"jsdoc-fresh": "^1.0.2",
"jsdoc-region-tag": "^1.0.6",
"linkinator": "^2.8.0",
"mocha": "^8.2.1",
"jsdoc": "^3.6.7",
"jsdoc-fresh": "^1.1.0",
"jsdoc-region-tag": "^1.1.0",
"linkinator": "^2.13.6",
"mocha": "^9.0.2",
"null-loader": "^4.0.1",
"pack-n-play": "^1.0.0-2",
"sinon": "^11.0.0",
"ts-loader": "^9.0.0",
"typescript": "^4.1.3",
"sinon": "^11.1.1",
"ts-loader": "^9.2.3",
"typescript": "^4.3.4",
"uuid": "^8.0.0",
"webpack": "^5.10.1",
"webpack-cli": "^4.2.0"
"webpack": "^5.39.1",
"webpack-cli": "^4.7.2"
}
}
3 changes: 3 additions & 0 deletions src/v1/accelerator_types_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ export class AcceleratorTypesClient {
// Save the auth object to the client, for use by other methods.
this.auth = this._gaxGrpc.auth as gax.GoogleAuth;

// Set defaultServicePath on the auth object.
this.auth.defaultServicePath = staticMembers.servicePath;

// Set the default scopes in auth client if needed.
if (servicePath === staticMembers.servicePath) {
this.auth.defaultScopes = staticMembers.scopes;
Expand Down
86 changes: 70 additions & 16 deletions src/v1/addresses_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
CallOptions,
Descriptors,
ClientOptions,
LROperation,
PaginationCallback,
GaxCall,
} from 'google-gax';
Expand Down Expand Up @@ -136,6 +137,9 @@ export class AddressesClient {
// Save the auth object to the client, for use by other methods.
this.auth = this._gaxGrpc.auth as gax.GoogleAuth;

// Set defaultServicePath on the auth object.
this.auth.defaultServicePath = staticMembers.servicePath;

// Set the default scopes in auth client if needed.
if (servicePath === staticMembers.servicePath) {
this.auth.defaultScopes = staticMembers.scopes;
Expand Down Expand Up @@ -320,8 +324,8 @@ export class AddressesClient {
options?: CallOptions
): Promise<
[
protos.google.cloud.compute.v1.IOperation,
protos.google.cloud.compute.v1.IDeleteAddressRequest | undefined,
LROperation<protos.google.cloud.compute.v1.IOperation, null>,
protos.google.cloud.compute.v1.IOperation | undefined,
{} | undefined
]
>;
Expand Down Expand Up @@ -362,12 +366,17 @@ export class AddressesClient {
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [Operation]{@link google.cloud.compute.v1.Operation}.
* The first element of the array is an object representing
* a long running operation.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations)
* for more details and examples.
* This method is considered to be in beta. This means while
* stable it is still a work-in-progress and under active development,
* and might get backwards-incompatible changes at any time.
* `.promise()` is not supported yet.
* @example
* const [response] = await client.delete(request);
* const [operation] = await client.delete(request);
*/
delete(
request?: protos.google.cloud.compute.v1.IDeleteAddressRequest,
Expand All @@ -387,8 +396,8 @@ export class AddressesClient {
>
): Promise<
[
protos.google.cloud.compute.v1.IOperation,
protos.google.cloud.compute.v1.IDeleteAddressRequest | undefined,
LROperation<protos.google.cloud.compute.v1.IOperation, null>,
protos.google.cloud.compute.v1.IOperation | undefined,
{} | undefined
]
> | void {
Expand All @@ -408,7 +417,27 @@ export class AddressesClient {
project: request.project || '',
});
this.initialize();
return this.innerApiCalls.delete(request, options, callback);
return this.innerApiCalls
.delete(request, options, callback)
.then(
([response, operation, rawResponse]: [
protos.google.cloud.compute.v1.IOperation,
protos.google.cloud.compute.v1.IOperation,
protos.google.cloud.compute.v1.IOperation
]) => {
return [
{
latestResponse: response,
done: false,
name: response.id,
metadata: null,
result: {},
},
operation,
rawResponse,
];
}
);
}
get(
request?: protos.google.cloud.compute.v1.IGetAddressRequest,
Expand Down Expand Up @@ -502,8 +531,8 @@ export class AddressesClient {
options?: CallOptions
): Promise<
[
protos.google.cloud.compute.v1.IOperation,
protos.google.cloud.compute.v1.IInsertAddressRequest | undefined,
LROperation<protos.google.cloud.compute.v1.IOperation, null>,
protos.google.cloud.compute.v1.IOperation | undefined,
{} | undefined
]
>;
Expand Down Expand Up @@ -544,12 +573,17 @@ export class AddressesClient {
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [Operation]{@link google.cloud.compute.v1.Operation}.
* The first element of the array is an object representing
* a long running operation.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations)
* for more details and examples.
* This method is considered to be in beta. This means while
* stable it is still a work-in-progress and under active development,
* and might get backwards-incompatible changes at any time.
* `.promise()` is not supported yet.
* @example
* const [response] = await client.insert(request);
* const [operation] = await client.insert(request);
*/
insert(
request?: protos.google.cloud.compute.v1.IInsertAddressRequest,
Expand All @@ -569,8 +603,8 @@ export class AddressesClient {
>
): Promise<
[
protos.google.cloud.compute.v1.IOperation,
protos.google.cloud.compute.v1.IInsertAddressRequest | undefined,
LROperation<protos.google.cloud.compute.v1.IOperation, null>,
protos.google.cloud.compute.v1.IOperation | undefined,
{} | undefined
]
> | void {
Expand All @@ -590,7 +624,27 @@ export class AddressesClient {
project: request.project || '',
});
this.initialize();
return this.innerApiCalls.insert(request, options, callback);
return this.innerApiCalls
.insert(request, options, callback)
.then(
([response, operation, rawResponse]: [
protos.google.cloud.compute.v1.IOperation,
protos.google.cloud.compute.v1.IOperation,
protos.google.cloud.compute.v1.IOperation
]) => {
return [
{
latestResponse: response,
done: false,
name: response.id,
metadata: null,
result: {},
},
operation,
rawResponse,
];
}
);
}

/**
Expand Down
Loading