|
12 | 12 | // See the License for the specific language governing permissions and |
13 | 13 | // limitations under the License. |
14 | 14 |
|
| 15 | +import {Bigtable} from '../../../../src'; |
15 | 16 | import * as protos from '../../../protos/protos'; |
16 | 17 |
|
17 | | -type SRKRequest = protos.google.bigtable.v2.ISampleRowKeysRequest; |
18 | | -type SRKResponse = protos.google.bigtable.v2.ISampleRowKeysResponse; |
| 18 | +type ISampleRowKeysRequest = protos.google.bigtable.v2.ISampleRowKeysRequest; |
| 19 | +type ISampleRowKeysResponse = protos.google.bigtable.v2.ISampleRowKeysResponse; |
19 | 20 |
|
20 | 21 | /** |
21 | 22 | * This function will create a request that can be passed into the |
22 | 23 | * handwritten ßsampleRowKeys method and calls the Gapic layer under the hood. |
23 | 24 | * |
24 | | - * @param {any} client Bigtable client |
25 | | - * @param {SRKRequest} request The sampleRowKeys request information |
| 25 | + * @param {Bigtable} client Bigtable client |
| 26 | + * @param {ISampleRowKeysRequest} request The sampleRowKeys request information |
26 | 27 | * that can be sent to the Gapic layer. |
27 | | - * @returns {Promise<SRKResponse>} A reponse that can be passed into the |
| 28 | + * @returns {Promise<ISampleRowKeysResponse>} A reponse that can be passed into the |
28 | 29 | * sampleRowKeys Gapic layer. |
29 | 30 | */ |
30 | 31 | export function getSRKRequest( |
31 | | - // eslint-disable-next-line @typescript-eslint/no-explicit-any |
32 | | - client: any, |
33 | | - request: SRKRequest, |
34 | | -): Promise<SRKResponse> { |
| 32 | + client: Bigtable, |
| 33 | + request: ISampleRowKeysRequest, |
| 34 | +): Promise<ISampleRowKeysResponse> { |
35 | 35 | const {tableName} = request; |
36 | 36 |
|
37 | | - // eslint-disable-next-line @typescript-eslint/no-explicit-any |
38 | | - const getTableInfo = (bigtable: any, tableName: any) => { |
39 | | - const [, , , instanceId, , tableId] = tableName.split('/'); |
40 | | - const instance = bigtable.instance(instanceId); |
41 | | - return instance.table(tableId); |
42 | | - }; |
43 | | - |
44 | | - const table = getTableInfo(client, tableName); |
| 37 | + const [, , , instanceId, , tableId] = tableName!.split('/'); |
| 38 | + const instance = client.instance(instanceId); |
| 39 | + const table = instance.table(tableId); |
45 | 40 | const sampleRowKeysResponse = table.sampleRowKeys(); |
46 | 41 |
|
47 | | - return sampleRowKeysResponse; |
| 42 | + return sampleRowKeysResponse as Promise<ISampleRowKeysResponse>; |
48 | 43 | } |
0 commit comments