Skip to content

Commit

Permalink
feat: add minimum wrapper for compute LRO method (#618)
Browse files Browse the repository at this point in the history
  • Loading branch information
summer-ji-eng authored Sep 13, 2021
1 parent e0e845c commit ea9a347
Show file tree
Hide file tree
Showing 149 changed files with 10,449 additions and 3,634 deletions.
35 changes: 20 additions & 15 deletions packages/google-cloud-compute/package.json
Original file line number Diff line number Diff line change
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.2"
},
"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: 2 additions & 1 deletion packages/google-cloud-compute/protos/protos.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions packages/google-cloud-compute/protos/protos.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion packages/google-cloud-compute/protos/protos.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/google-cloud-compute/samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"test": "mocha test --timeout 1200000"
},
"dependencies": {
"@google-cloud/compute": "^3.0.0",
"@google-cloud/compute": "^3.0.0-alpha.4",
"@sendgrid/mail": "^7.0.0",
"nodemailer": "^6.0.0",
"nodemailer-smtp-transport": "^2.7.4"
Expand Down
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 packages/google-cloud-compute/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

0 comments on commit ea9a347

Please sign in to comment.