Skip to content

Commit f2c1675

Browse files
authoredMay 6, 2020
feat: check status of long running operation by its name (#724)
For each client method returning a long running operation, a separate method to check its status is added. Added methods: `checkCreateBackupProgress`, `checkCreateClusterProgress`, `checkCreateInstanceProgress`, `checkCreateTableFromSnapshotProgress`, `checkPartialUpdateInstanceProgress`, `checkRestoreTableProgress`, `checkSnapshotTableProgress`, `checkUpdateAppProfileProgress`, `checkUpdateClusterProgress`.
1 parent 998ec84 commit f2c1675

7 files changed

+1231
-643
lines changed
 

‎protos/protos.js

+448-448
Large diffs are not rendered by default.

‎src/v2/bigtable_instance_admin_client.ts

+181-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {Transform} from 'stream';
3232
import {RequestType} from 'google-gax/build/src/apitypes';
3333
import * as protos from '../../protos/protos';
3434
import * as gapicConfig from './bigtable_instance_admin_client_config.json';
35-
35+
import {operationsProtos} from 'google-gax';
3636
const version = require('../../../package.json').version;
3737

3838
/**
@@ -1675,6 +1675,42 @@ export class BigtableInstanceAdminClient {
16751675
this.initialize();
16761676
return this.innerApiCalls.createInstance(request, options, callback);
16771677
}
1678+
/**
1679+
* Check the status of the long running operation returned by the createInstance() method.
1680+
* @param {String} name
1681+
* The operation name that will be passed.
1682+
* @returns {Promise} - The promise which resolves to an object.
1683+
* The decoded operation object has result and metadata field to get information from.
1684+
*
1685+
* @example:
1686+
* const decodedOperation = await checkCreateInstanceProgress(name);
1687+
* console.log(decodedOperation.result);
1688+
* console.log(decodedOperation.done);
1689+
* console.log(decodedOperation.metadata);
1690+
*
1691+
*/
1692+
async checkCreateInstanceProgress(
1693+
name: string
1694+
): Promise<
1695+
LROperation<
1696+
protos.google.bigtable.admin.v2.Instance,
1697+
protos.google.bigtable.admin.v2.CreateInstanceMetadata
1698+
>
1699+
> {
1700+
const request = new operationsProtos.google.longrunning.GetOperationRequest(
1701+
{name}
1702+
);
1703+
const [operation] = await this.operationsClient.getOperation(request);
1704+
const decodeOperation = new gax.Operation(
1705+
operation,
1706+
this.descriptors.longrunning.createInstance,
1707+
gax.createDefaultBackoffSettings()
1708+
);
1709+
return decodeOperation as LROperation<
1710+
protos.google.bigtable.admin.v2.Instance,
1711+
protos.google.bigtable.admin.v2.CreateInstanceMetadata
1712+
>;
1713+
}
16781714
partialUpdateInstance(
16791715
request: protos.google.bigtable.admin.v2.IPartialUpdateInstanceRequest,
16801716
options?: gax.CallOptions
@@ -1777,6 +1813,42 @@ export class BigtableInstanceAdminClient {
17771813
this.initialize();
17781814
return this.innerApiCalls.partialUpdateInstance(request, options, callback);
17791815
}
1816+
/**
1817+
* Check the status of the long running operation returned by the partialUpdateInstance() method.
1818+
* @param {String} name
1819+
* The operation name that will be passed.
1820+
* @returns {Promise} - The promise which resolves to an object.
1821+
* The decoded operation object has result and metadata field to get information from.
1822+
*
1823+
* @example:
1824+
* const decodedOperation = await checkPartialUpdateInstanceProgress(name);
1825+
* console.log(decodedOperation.result);
1826+
* console.log(decodedOperation.done);
1827+
* console.log(decodedOperation.metadata);
1828+
*
1829+
*/
1830+
async checkPartialUpdateInstanceProgress(
1831+
name: string
1832+
): Promise<
1833+
LROperation<
1834+
protos.google.bigtable.admin.v2.Instance,
1835+
protos.google.bigtable.admin.v2.UpdateInstanceMetadata
1836+
>
1837+
> {
1838+
const request = new operationsProtos.google.longrunning.GetOperationRequest(
1839+
{name}
1840+
);
1841+
const [operation] = await this.operationsClient.getOperation(request);
1842+
const decodeOperation = new gax.Operation(
1843+
operation,
1844+
this.descriptors.longrunning.partialUpdateInstance,
1845+
gax.createDefaultBackoffSettings()
1846+
);
1847+
return decodeOperation as LROperation<
1848+
protos.google.bigtable.admin.v2.Instance,
1849+
protos.google.bigtable.admin.v2.UpdateInstanceMetadata
1850+
>;
1851+
}
17801852
createCluster(
17811853
request: protos.google.bigtable.admin.v2.ICreateClusterRequest,
17821854
options?: gax.CallOptions
@@ -1884,6 +1956,42 @@ export class BigtableInstanceAdminClient {
18841956
this.initialize();
18851957
return this.innerApiCalls.createCluster(request, options, callback);
18861958
}
1959+
/**
1960+
* Check the status of the long running operation returned by the createCluster() method.
1961+
* @param {String} name
1962+
* The operation name that will be passed.
1963+
* @returns {Promise} - The promise which resolves to an object.
1964+
* The decoded operation object has result and metadata field to get information from.
1965+
*
1966+
* @example:
1967+
* const decodedOperation = await checkCreateClusterProgress(name);
1968+
* console.log(decodedOperation.result);
1969+
* console.log(decodedOperation.done);
1970+
* console.log(decodedOperation.metadata);
1971+
*
1972+
*/
1973+
async checkCreateClusterProgress(
1974+
name: string
1975+
): Promise<
1976+
LROperation<
1977+
protos.google.bigtable.admin.v2.Cluster,
1978+
protos.google.bigtable.admin.v2.CreateClusterMetadata
1979+
>
1980+
> {
1981+
const request = new operationsProtos.google.longrunning.GetOperationRequest(
1982+
{name}
1983+
);
1984+
const [operation] = await this.operationsClient.getOperation(request);
1985+
const decodeOperation = new gax.Operation(
1986+
operation,
1987+
this.descriptors.longrunning.createCluster,
1988+
gax.createDefaultBackoffSettings()
1989+
);
1990+
return decodeOperation as LROperation<
1991+
protos.google.bigtable.admin.v2.Cluster,
1992+
protos.google.bigtable.admin.v2.CreateClusterMetadata
1993+
>;
1994+
}
18871995
updateCluster(
18881996
request: protos.google.bigtable.admin.v2.ICluster,
18891997
options?: gax.CallOptions
@@ -1998,6 +2106,42 @@ export class BigtableInstanceAdminClient {
19982106
this.initialize();
19992107
return this.innerApiCalls.updateCluster(request, options, callback);
20002108
}
2109+
/**
2110+
* Check the status of the long running operation returned by the updateCluster() method.
2111+
* @param {String} name
2112+
* The operation name that will be passed.
2113+
* @returns {Promise} - The promise which resolves to an object.
2114+
* The decoded operation object has result and metadata field to get information from.
2115+
*
2116+
* @example:
2117+
* const decodedOperation = await checkUpdateClusterProgress(name);
2118+
* console.log(decodedOperation.result);
2119+
* console.log(decodedOperation.done);
2120+
* console.log(decodedOperation.metadata);
2121+
*
2122+
*/
2123+
async checkUpdateClusterProgress(
2124+
name: string
2125+
): Promise<
2126+
LROperation<
2127+
protos.google.bigtable.admin.v2.Cluster,
2128+
protos.google.bigtable.admin.v2.UpdateClusterMetadata
2129+
>
2130+
> {
2131+
const request = new operationsProtos.google.longrunning.GetOperationRequest(
2132+
{name}
2133+
);
2134+
const [operation] = await this.operationsClient.getOperation(request);
2135+
const decodeOperation = new gax.Operation(
2136+
operation,
2137+
this.descriptors.longrunning.updateCluster,
2138+
gax.createDefaultBackoffSettings()
2139+
);
2140+
return decodeOperation as LROperation<
2141+
protos.google.bigtable.admin.v2.Cluster,
2142+
protos.google.bigtable.admin.v2.UpdateClusterMetadata
2143+
>;
2144+
}
20012145
updateAppProfile(
20022146
request: protos.google.bigtable.admin.v2.IUpdateAppProfileRequest,
20032147
options?: gax.CallOptions
@@ -2101,6 +2245,42 @@ export class BigtableInstanceAdminClient {
21012245
this.initialize();
21022246
return this.innerApiCalls.updateAppProfile(request, options, callback);
21032247
}
2248+
/**
2249+
* Check the status of the long running operation returned by the updateAppProfile() method.
2250+
* @param {String} name
2251+
* The operation name that will be passed.
2252+
* @returns {Promise} - The promise which resolves to an object.
2253+
* The decoded operation object has result and metadata field to get information from.
2254+
*
2255+
* @example:
2256+
* const decodedOperation = await checkUpdateAppProfileProgress(name);
2257+
* console.log(decodedOperation.result);
2258+
* console.log(decodedOperation.done);
2259+
* console.log(decodedOperation.metadata);
2260+
*
2261+
*/
2262+
async checkUpdateAppProfileProgress(
2263+
name: string
2264+
): Promise<
2265+
LROperation<
2266+
protos.google.bigtable.admin.v2.AppProfile,
2267+
protos.google.bigtable.admin.v2.UpdateAppProfileMetadata
2268+
>
2269+
> {
2270+
const request = new operationsProtos.google.longrunning.GetOperationRequest(
2271+
{name}
2272+
);
2273+
const [operation] = await this.operationsClient.getOperation(request);
2274+
const decodeOperation = new gax.Operation(
2275+
operation,
2276+
this.descriptors.longrunning.updateAppProfile,
2277+
gax.createDefaultBackoffSettings()
2278+
);
2279+
return decodeOperation as LROperation<
2280+
protos.google.bigtable.admin.v2.AppProfile,
2281+
protos.google.bigtable.admin.v2.UpdateAppProfileMetadata
2282+
>;
2283+
}
21042284
listAppProfiles(
21052285
request: protos.google.bigtable.admin.v2.IListAppProfilesRequest,
21062286
options?: gax.CallOptions

0 commit comments

Comments
 (0)