1
1
import * as clc from "colorette" ;
2
2
3
- import { Client } from "../apiv2" ;
3
+ import { Client , ClientVerbOptions } from "../apiv2" ;
4
4
import { FirebaseError } from "../error" ;
5
5
import { functionsV2Origin } from "../api" ;
6
6
import { logger } from "../logger" ;
@@ -19,7 +19,7 @@ import {
19
19
HASH_LABEL ,
20
20
} from "../functions/constants" ;
21
21
22
- export const API_VERSION = "v2alpha " ;
22
+ export const API_VERSION = "v2 " ;
23
23
24
24
const client = new Client ( {
25
25
urlPrefix : functionsV2Origin ,
@@ -351,7 +351,11 @@ async function listFunctionsInternal(
351
351
let pageToken = "" ;
352
352
while ( true ) {
353
353
const url = `projects/${ projectId } /locations/${ region } /functions` ;
354
- const opts = pageToken === "" ? { } : { queryParams : { pageToken } } ;
354
+ // V2 API returns both V1 and V2 Functions. Add filter condition to return only V2 functions.
355
+ const opts : ClientVerbOptions = { queryParams : { filter : `environment="GEN_2"` } } ;
356
+ if ( pageToken !== "" ) {
357
+ opts . queryParams = { ...opts . queryParams , pageToken } ;
358
+ }
355
359
const res = await client . get < Response > ( url , opts ) ;
356
360
functions . push ( ...( res . body . functions || [ ] ) ) ;
357
361
for ( const region of res . body . unreachable || [ ] ) {
0 commit comments