From 0e24a235af0e84383c6a7f311610c1149051b545 Mon Sep 17 00:00:00 2001 From: Thomas Bouldin Date: Tue, 10 May 2022 13:19:19 -0700 Subject: [PATCH 1/2] Redefine fields in options so they get better docs --- src/common/providers/identity.ts | 3 +- src/v2/options.ts | 1 + src/v2/providers/alerts/alerts.ts | 115 ++++++++++++++++++++- src/v2/providers/alerts/appDistribution.ts | 94 +++++++++++++++++ src/v2/providers/alerts/crashlytics.ts | 94 +++++++++++++++++ src/v2/providers/eventarc.ts | 93 +++++++++++++++++ src/v2/providers/https.ts | 93 +++++++++++++++++ src/v2/providers/identity.ts | 92 ++++++++++++++++- src/v2/providers/pubsub.ts | 93 +++++++++++++++++ src/v2/providers/storage.ts | 93 +++++++++++++++++ src/v2/providers/tasks.ts | 99 +++++++++++++++++- 11 files changed, 866 insertions(+), 4 deletions(-) diff --git a/src/common/providers/identity.ts b/src/common/providers/identity.ts index 031e36f97..08658c48d 100644 --- a/src/common/providers/identity.ts +++ b/src/common/providers/identity.ts @@ -52,7 +52,8 @@ const CLAIMS_MAX_PAYLOAD_SIZE = 1000; /** * Shorthand auth blocking events from GCIP. - * @internal + * @hidden + * @alpha */ export type AuthBlockingEventType = 'beforeCreate' | 'beforeSignIn'; diff --git a/src/v2/options.ts b/src/v2/options.ts index d3155f3c3..a76bfc56c 100644 --- a/src/v2/options.ts +++ b/src/v2/options.ts @@ -212,6 +212,7 @@ export function getGlobalOptions(): GlobalOptions { * Additional fields that can be set on any event-handling Cloud Function. */ export interface EventHandlerOptions extends GlobalOptions { + /** Whether failed executions should be delivered again. */ retry?: boolean; } diff --git a/src/v2/providers/alerts/alerts.ts b/src/v2/providers/alerts/alerts.ts index df800fadb..f821cef5e 100644 --- a/src/v2/providers/alerts/alerts.ts +++ b/src/v2/providers/alerts/alerts.ts @@ -50,15 +50,128 @@ export type AlertType = * Configuration for Firebase Alert functions. */ export interface FirebaseAlertOptions extends options.EventHandlerOptions { + /** The kind of Firebase alert to listen to. */ alertType: AlertType; + + /** An optional app ID to filter events by. */ appId?: string; + + /** + * Region where functions should be deployed. + */ + region?: options.SupportedRegion | string; + + /** + * Amount of memory to allocate to a function. + * A value of null restores the defaults of 256MB. + */ + memory?: options.MemoryOption | null; + + /** + * Timeout for the function in sections, possible values are 0 to 540. + * HTTPS functions can specify a higher timeout. + * A value of null restores the default of 60s + * The minimum timeout for a gen 2 function is 1s. The maximum timeout for a + * function depends on the type of function: Event handling functions have a + * maximum timeout of 540s (9 minutes). HTTPS and callable functions have a + * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum + * timeout of 1,800s (30 minutes) + */ + timeoutSeconds?: number | null; + + /** + * Min number of actual instances to be running at a given time. + * Instances will be billed for memory allocation and 10% of CPU allocation + * while idle. + * A value of null restores the default min instances. + */ + minInstances?: number | null; + + /** + * Max number of instances to be running in parallel. + * A value of null restores the default max instances. + */ + maxInstances?: number | null; + + /** + * Number of requests a function can serve at once. + * Can only be applied to functions running on Cloud Functions v2. + * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise). + * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1. + * The maximum value for concurrency is 1,000. + */ + concurrency?: number | null; + + /** + * Fractional number of CPUs to allocate to a function. + * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes. + * This is different from the defaults when using the gcloud utility and is different from + * the fixed amount assigned in Google Cloud Functions generation 1. + * To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this + * to the value "gcf_gen1" + */ + cpu?: number | 'gcf_gen1'; + + /** + * Connect cloud function to specified VPC connector. + * A value of null removes the VPC connector + */ + vpcConnector?: string | null; + + /** + * Egress settings for VPC connector. + * A value of null turns off VPC connector egress settings + */ + vpcConnectorEgressSettings?: options.VpcEgressSetting | null; + + /** + * Specific service account for the function to run as. + * A value of null restores the default service account. + */ + serviceAccount?: string | null; + + /** + * Ingress settings which control where this function can be called from. + * A value of null turns off ingress settings. + */ + ingressSettings?: options.IngressSetting | null; + + /** + * User labels to set on the function. + */ + labels?: Record; + + /* + * Secrets to bind to a functions. + */ + secrets?: string[]; + + /** Whether failed executions should be delivered again. */ + retry?: boolean; } /** * Declares a function that can handle Firebase Alerts from CloudEvents. - * @param alertTypeOrOpts the alert type or Firebase Alert function configuration. + * @param alertType - the alert type or Firebase Alert function configuration. + * @param handler a function that can handle the Firebase Alert inside a CloudEvent. + * @typeParam T - the type of event.data.payload. + */ +export function onAlertPublished( + alertType: AlertType, + handler: (event: AlertEvent) => any | Promise +): CloudFunction>; + +/** + * Declares a function that can handle Firebase Alerts from CloudEvents. + * @param options - the alert type and other options for this cloud function. * @param handler a function that can handle the Firebase Alert inside a CloudEvent. + * @typeParam T - the type of event.data.payload. */ +export function onAlertPublished( + options: FirebaseAlertOptions, + handler: (event: AlertEvent) => any | Promise +): CloudFunction>; + export function onAlertPublished( alertTypeOrOpts: AlertType | FirebaseAlertOptions, handler: (event: AlertEvent) => any | Promise diff --git a/src/v2/providers/alerts/appDistribution.ts b/src/v2/providers/alerts/appDistribution.ts index e22f847c0..e8328885c 100644 --- a/src/v2/providers/alerts/appDistribution.ts +++ b/src/v2/providers/alerts/appDistribution.ts @@ -36,7 +36,101 @@ export const newTesterIosDeviceAlert = 'appDistribution.newTesterIosDevice'; * Configuration for app distribution functions. */ export interface AppDistributionOptions extends options.EventHandlerOptions { + /** An optional app ID to filter events by. */ appId?: string; + + /** + * Region where functions should be deployed. + */ + region?: options.SupportedRegion | string; + + /** + * Amount of memory to allocate to a function. + * A value of null restores the defaults of 256MB. + */ + memory?: options.MemoryOption | null; + + /** + * Timeout for the function in sections, possible values are 0 to 540. + * HTTPS functions can specify a higher timeout. + * A value of null restores the default of 60s + * The minimum timeout for a gen 2 function is 1s. The maximum timeout for a + * function depends on the type of function: Event handling functions have a + * maximum timeout of 540s (9 minutes). HTTPS and callable functions have a + * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum + * timeout of 1,800s (30 minutes) + */ + timeoutSeconds?: number | null; + + /** + * Min number of actual instances to be running at a given time. + * Instances will be billed for memory allocation and 10% of CPU allocation + * while idle. + * A value of null restores the default min instances. + */ + minInstances?: number | null; + + /** + * Max number of instances to be running in parallel. + * A value of null restores the default max instances. + */ + maxInstances?: number | null; + + /** + * Number of requests a function can serve at once. + * Can only be applied to functions running on Cloud Functions v2. + * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise). + * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1. + * The maximum value for concurrency is 1,000. + */ + concurrency?: number | null; + + /** + * Fractional number of CPUs to allocate to a function. + * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes. + * This is different from the defaults when using the gcloud utility and is different from + * the fixed amount assigned in Google Cloud Functions generation 1. + * To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this + * to the value "gcf_gen1" + */ + cpu?: number | 'gcf_gen1'; + + /** + * Connect cloud function to specified VPC connector. + * A value of null removes the VPC connector + */ + vpcConnector?: string | null; + + /** + * Egress settings for VPC connector. + * A value of null turns off VPC connector egress settings + */ + vpcConnectorEgressSettings?: options.VpcEgressSetting | null; + + /** + * Specific service account for the function to run as. + * A value of null restores the default service account. + */ + serviceAccount?: string | null; + + /** + * Ingress settings which control where this function can be called from. + * A value of null turns off ingress settings. + */ + ingressSettings?: options.IngressSetting | null; + + /** + * User labels to set on the function. + */ + labels?: Record; + + /* + * Secrets to bind to a functions. + */ + secrets?: string[]; + + /** Whether failed executions should be delivered again. */ + retry?: boolean; } /** diff --git a/src/v2/providers/alerts/crashlytics.ts b/src/v2/providers/alerts/crashlytics.ts index 1cbe13760..d72051bc9 100644 --- a/src/v2/providers/alerts/crashlytics.ts +++ b/src/v2/providers/alerts/crashlytics.ts @@ -142,7 +142,101 @@ export const newAnrIssueAlert = 'crashlytics.newAnrIssue'; * Configuration for crashlytics functions. */ export interface CrashlyticsOptions extends options.EventHandlerOptions { + /** An optional app ID to filter events by. */ appId?: string; + + /** + * Region where functions should be deployed. + */ + region?: options.SupportedRegion | string; + + /** + * Amount of memory to allocate to a function. + * A value of null restores the defaults of 256MB. + */ + memory?: options.MemoryOption | null; + + /** + * Timeout for the function in sections, possible values are 0 to 540. + * HTTPS functions can specify a higher timeout. + * A value of null restores the default of 60s + * The minimum timeout for a gen 2 function is 1s. The maximum timeout for a + * function depends on the type of function: Event handling functions have a + * maximum timeout of 540s (9 minutes). HTTPS and callable functions have a + * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum + * timeout of 1,800s (30 minutes) + */ + timeoutSeconds?: number | null; + + /** + * Min number of actual instances to be running at a given time. + * Instances will be billed for memory allocation and 10% of CPU allocation + * while idle. + * A value of null restores the default min instances. + */ + minInstances?: number | null; + + /** + * Max number of instances to be running in parallel. + * A value of null restores the default max instances. + */ + maxInstances?: number | null; + + /** + * Number of requests a function can serve at once. + * Can only be applied to functions running on Cloud Functions v2. + * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise). + * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1. + * The maximum value for concurrency is 1,000. + */ + concurrency?: number | null; + + /** + * Fractional number of CPUs to allocate to a function. + * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes. + * This is different from the defaults when using the gcloud utility and is different from + * the fixed amount assigned in Google Cloud Functions generation 1. + * To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this + * to the value "gcf_gen1" + */ + cpu?: number | 'gcf_gen1'; + + /** + * Connect cloud function to specified VPC connector. + * A value of null removes the VPC connector + */ + vpcConnector?: string | null; + + /** + * Egress settings for VPC connector. + * A value of null turns off VPC connector egress settings + */ + vpcConnectorEgressSettings?: options.VpcEgressSetting | null; + + /** + * Specific service account for the function to run as. + * A value of null restores the default service account. + */ + serviceAccount?: string | null; + + /** + * Ingress settings which control where this function can be called from. + * A value of null turns off ingress settings. + */ + ingressSettings?: options.IngressSetting | null; + + /** + * User labels to set on the function. + */ + labels?: Record; + + /* + * Secrets to bind to a functions. + */ + secrets?: string[]; + + /** Whether failed executions should be delivered again. */ + retry?: boolean; } /** diff --git a/src/v2/providers/eventarc.ts b/src/v2/providers/eventarc.ts index 17750d34a..ed50c4fad 100644 --- a/src/v2/providers/eventarc.ts +++ b/src/v2/providers/eventarc.ts @@ -52,6 +52,99 @@ export interface EventarcTriggerOptions extends options.EventHandlerOptions { * Eventarc event exact match filter. */ filters?: Record; + + /** + * Region where functions should be deployed. + */ + region?: options.SupportedRegion | string; + + /** + * Amount of memory to allocate to a function. + * A value of null restores the defaults of 256MB. + */ + memory?: options.MemoryOption | null; + + /** + * Timeout for the function in sections, possible values are 0 to 540. + * HTTPS functions can specify a higher timeout. + * A value of null restores the default of 60s + * The minimum timeout for a gen 2 function is 1s. The maximum timeout for a + * function depends on the type of function: Event handling functions have a + * maximum timeout of 540s (9 minutes). HTTPS and callable functions have a + * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum + * timeout of 1,800s (30 minutes) + */ + timeoutSeconds?: number | null; + + /** + * Min number of actual instances to be running at a given time. + * Instances will be billed for memory allocation and 10% of CPU allocation + * while idle. + * A value of null restores the default min instances. + */ + minInstances?: number | null; + + /** + * Max number of instances to be running in parallel. + * A value of null restores the default max instances. + */ + maxInstances?: number | null; + + /** + * Number of requests a function can serve at once. + * Can only be applied to functions running on Cloud Functions v2. + * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise). + * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1. + * The maximum value for concurrency is 1,000. + */ + concurrency?: number | null; + + /** + * Fractional number of CPUs to allocate to a function. + * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes. + * This is different from the defaults when using the gcloud utility and is different from + * the fixed amount assigned in Google Cloud Functions generation 1. + * To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this + * to the value "gcf_gen1" + */ + cpu?: number | 'gcf_gen1'; + + /** + * Connect cloud function to specified VPC connector. + * A value of null removes the VPC connector + */ + vpcConnector?: string | null; + + /** + * Egress settings for VPC connector. + * A value of null turns off VPC connector egress settings + */ + vpcConnectorEgressSettings?: options.VpcEgressSetting | null; + + /** + * Specific service account for the function to run as. + * A value of null restores the default service account. + */ + serviceAccount?: string | null; + + /** + * Ingress settings which control where this function can be called from. + * A value of null turns off ingress settings. + */ + ingressSettings?: options.IngressSetting | null; + + /** + * User labels to set on the function. + */ + labels?: Record; + + /* + * Secrets to bind to a functions. + */ + secrets?: string[]; + + /** Whether failed executions should be delivered again. */ + retry?: boolean; } /** diff --git a/src/v2/providers/https.ts b/src/v2/providers/https.ts index d4d3d07c7..eb2155dd6 100644 --- a/src/v2/providers/https.ts +++ b/src/v2/providers/https.ts @@ -49,6 +49,99 @@ export interface HttpsOptions extends Omit { * Defaults to true for {@link https.CallableFunction} and false otherwise. */ cors?: string | boolean | RegExp | Array; + + /** + * Amount of memory to allocate to a function. + * A value of null restores the defaults of 256MB. + */ + memory?: options.MemoryOption | null; + + /** + * Timeout for the function in sections, possible values are 0 to 540. + * HTTPS functions can specify a higher timeout. + * A value of null restores the default of 60s + * The minimum timeout for a gen 2 function is 1s. The maximum timeout for a + * function depends on the type of function: Event handling functions have a + * maximum timeout of 540s (9 minutes). HTTPS and callable functions have a + * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum + * timeout of 1,800s (30 minutes) + */ + timeoutSeconds?: number | null; + + /** + * Min number of actual instances to be running at a given time. + * Instances will be billed for memory allocation and 10% of CPU allocation + * while idle. + * A value of null restores the default min instances. + */ + minInstances?: number | null; + + /** + * Max number of instances to be running in parallel. + * A value of null restores the default max instances. + */ + maxInstances?: number | null; + + /** + * Number of requests a function can serve at once. + * Can only be applied to functions running on Cloud Functions v2. + * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise). + * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1. + * The maximum value for concurrency is 1,000. + */ + concurrency?: number | null; + + /** + * Fractional number of CPUs to allocate to a function. + * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes. + * This is different from the defaults when using the gcloud utility and is different from + * the fixed amount assigned in Google Cloud Functions generation 1. + * To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this + * to the value "gcf_gen1" + */ + cpu?: number | 'gcf_gen1'; + + /** + * Connect cloud function to specified VPC connector. + * A value of null removes the VPC connector + */ + vpcConnector?: string | null; + + /** + * Egress settings for VPC connector. + * A value of null turns off VPC connector egress settings + */ + vpcConnectorEgressSettings?: options.VpcEgressSetting | null; + + /** + * Specific service account for the function to run as. + * A value of null restores the default service account. + */ + serviceAccount?: string | null; + + /** + * Ingress settings which control where this function can be called from. + * A value of null turns off ingress settings. + */ + ingressSettings?: options.IngressSetting | null; + + /** + * User labels to set on the function. + */ + labels?: Record; + + /** + * Invoker to set access control on https functions. + */ + invoker?: 'public' | 'private' | string | string[]; + + /* + * Secrets to bind to a functions. + */ + secrets?: string[]; + + /** Whether failed executions should be delivered again. */ + retry?: boolean; } /** diff --git a/src/v2/providers/identity.ts b/src/v2/providers/identity.ts index e59db6590..3383dc772 100644 --- a/src/v2/providers/identity.ts +++ b/src/v2/providers/identity.ts @@ -22,10 +22,100 @@ interface InternalOptions { /** * All function options plus idToken, accessToken, and refreshToken. */ -export interface BlockingOptions extends options.GlobalOptions { +export interface BlockingOptions { idToken?: boolean; accessToken?: boolean; refreshToken?: boolean; + + /** + * Region where functions should be deployed. + */ + region?: options.SupportedRegion | string; + + /** + * Amount of memory to allocate to a function. + * A value of null restores the defaults of 256MB. + */ + memory?: options.MemoryOption | null; + + /** + * Timeout for the function in sections, possible values are 0 to 540. + * HTTPS functions can specify a higher timeout. + * A value of null restores the default of 60s + * The minimum timeout for a gen 2 function is 1s. The maximum timeout for a + * function depends on the type of function: Event handling functions have a + * maximum timeout of 540s (9 minutes). HTTPS and callable functions have a + * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum + * timeout of 1,800s (30 minutes) + */ + timeoutSeconds?: number | null; + + /** + * Min number of actual instances to be running at a given time. + * Instances will be billed for memory allocation and 10% of CPU allocation + * while idle. + * A value of null restores the default min instances. + */ + minInstances?: number | null; + + /** + * Max number of instances to be running in parallel. + * A value of null restores the default max instances. + */ + maxInstances?: number | null; + + /** + * Number of requests a function can serve at once. + * Can only be applied to functions running on Cloud Functions v2. + * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise). + * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1. + * The maximum value for concurrency is 1,000. + */ + concurrency?: number | null; + + /** + * Fractional number of CPUs to allocate to a function. + * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes. + * This is different from the defaults when using the gcloud utility and is different from + * the fixed amount assigned in Google Cloud Functions generation 1. + * To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this + * to the value "gcf_gen1" + */ + cpu?: number | 'gcf_gen1'; + + /** + * Connect cloud function to specified VPC connector. + * A value of null removes the VPC connector + */ + vpcConnector?: string | null; + + /** + * Egress settings for VPC connector. + * A value of null turns off VPC connector egress settings + */ + vpcConnectorEgressSettings?: options.VpcEgressSetting | null; + + /** + * Specific service account for the function to run as. + * A value of null restores the default service account. + */ + serviceAccount?: string | null; + + /** + * Ingress settings which control where this function can be called from. + * A value of null turns off ingress settings. + */ + ingressSettings?: options.IngressSetting | null; + + /** + * User labels to set on the function. + */ + labels?: Record; + + /* + * Secrets to bind to a functions. + */ + secrets?: string[]; } /** diff --git a/src/v2/providers/pubsub.ts b/src/v2/providers/pubsub.ts index bfcd8c699..8a42c51e8 100644 --- a/src/v2/providers/pubsub.ts +++ b/src/v2/providers/pubsub.ts @@ -118,6 +118,99 @@ export interface MessagePublishedData { export interface PubSubOptions extends options.EventHandlerOptions { /** The Pub/Sub topic to watch for message events */ topic: string; + + /** + * Region where functions should be deployed. + */ + region?: options.SupportedRegion | string; + + /** + * Amount of memory to allocate to a function. + * A value of null restores the defaults of 256MB. + */ + memory?: options.MemoryOption | null; + + /** + * Timeout for the function in sections, possible values are 0 to 540. + * HTTPS functions can specify a higher timeout. + * A value of null restores the default of 60s + * The minimum timeout for a gen 2 function is 1s. The maximum timeout for a + * function depends on the type of function: Event handling functions have a + * maximum timeout of 540s (9 minutes). HTTPS and callable functions have a + * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum + * timeout of 1,800s (30 minutes) + */ + timeoutSeconds?: number | null; + + /** + * Min number of actual instances to be running at a given time. + * Instances will be billed for memory allocation and 10% of CPU allocation + * while idle. + * A value of null restores the default min instances. + */ + minInstances?: number | null; + + /** + * Max number of instances to be running in parallel. + * A value of null restores the default max instances. + */ + maxInstances?: number | null; + + /** + * Number of requests a function can serve at once. + * Can only be applied to functions running on Cloud Functions v2. + * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise). + * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1. + * The maximum value for concurrency is 1,000. + */ + concurrency?: number | null; + + /** + * Fractional number of CPUs to allocate to a function. + * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes. + * This is different from the defaults when using the gcloud utility and is different from + * the fixed amount assigned in Google Cloud Functions generation 1. + * To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this + * to the value "gcf_gen1" + */ + cpu?: number | 'gcf_gen1'; + + /** + * Connect cloud function to specified VPC connector. + * A value of null removes the VPC connector + */ + vpcConnector?: string | null; + + /** + * Egress settings for VPC connector. + * A value of null turns off VPC connector egress settings + */ + vpcConnectorEgressSettings?: options.VpcEgressSetting | null; + + /** + * Specific service account for the function to run as. + * A value of null restores the default service account. + */ + serviceAccount?: string | null; + + /** + * Ingress settings which control where this function can be called from. + * A value of null turns off ingress settings. + */ + ingressSettings?: options.IngressSetting | null; + + /** + * User labels to set on the function. + */ + labels?: Record; + + /* + * Secrets to bind to a functions. + */ + secrets?: string[]; + + /** Whether failed executions should be delivered again. */ + retry?: boolean; } /** diff --git a/src/v2/providers/storage.ts b/src/v2/providers/storage.ts index 27e6d01dc..2ba3f3cde 100644 --- a/src/v2/providers/storage.ts +++ b/src/v2/providers/storage.ts @@ -194,6 +194,99 @@ export const metadataUpdatedEvent = export interface StorageOptions extends options.EventHandlerOptions { /** The name of the bucket containing this object. */ bucket?: string; + + /** + * Region where functions should be deployed. + */ + region?: options.SupportedRegion | string; + + /** + * Amount of memory to allocate to a function. + * A value of null restores the defaults of 256MB. + */ + memory?: options.MemoryOption | null; + + /** + * Timeout for the function in sections, possible values are 0 to 540. + * HTTPS functions can specify a higher timeout. + * A value of null restores the default of 60s + * The minimum timeout for a gen 2 function is 1s. The maximum timeout for a + * function depends on the type of function: Event handling functions have a + * maximum timeout of 540s (9 minutes). HTTPS and callable functions have a + * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum + * timeout of 1,800s (30 minutes) + */ + timeoutSeconds?: number | null; + + /** + * Min number of actual instances to be running at a given time. + * Instances will be billed for memory allocation and 10% of CPU allocation + * while idle. + * A value of null restores the default min instances. + */ + minInstances?: number | null; + + /** + * Max number of instances to be running in parallel. + * A value of null restores the default max instances. + */ + maxInstances?: number | null; + + /** + * Number of requests a function can serve at once. + * Can only be applied to functions running on Cloud Functions v2. + * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise). + * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1. + * The maximum value for concurrency is 1,000. + */ + concurrency?: number | null; + + /** + * Fractional number of CPUs to allocate to a function. + * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes. + * This is different from the defaults when using the gcloud utility and is different from + * the fixed amount assigned in Google Cloud Functions generation 1. + * To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this + * to the value "gcf_gen1" + */ + cpu?: number | 'gcf_gen1'; + + /** + * Connect cloud function to specified VPC connector. + * A value of null removes the VPC connector + */ + vpcConnector?: string | null; + + /** + * Egress settings for VPC connector. + * A value of null turns off VPC connector egress settings + */ + vpcConnectorEgressSettings?: options.VpcEgressSetting | null; + + /** + * Specific service account for the function to run as. + * A value of null restores the default service account. + */ + serviceAccount?: string | null; + + /** + * Ingress settings which control where this function can be called from. + * A value of null turns off ingress settings. + */ + ingressSettings?: options.IngressSetting | null; + + /** + * User labels to set on the function. + */ + labels?: Record; + + /* + * Secrets to bind to a functions. + */ + secrets?: string[]; + + /** Whether failed executions should be delivered again. */ + retry?: boolean; } /** diff --git a/src/v2/providers/tasks.ts b/src/v2/providers/tasks.ts index b45de3361..d3a497676 100644 --- a/src/v2/providers/tasks.ts +++ b/src/v2/providers/tasks.ts @@ -37,9 +37,13 @@ import { HttpsFunction } from './https'; export { AuthData, RateLimits, Request, RetryConfig as RetryPolicy }; -export interface TaskQueueOptions extends options.GlobalOptions { +export interface TaskQueueOptions extends options.EventHandlerOptions { + /** How a task should be retried in the event of a non-2xx return. */ retryConfig?: RetryConfig; + + /** How congestion control should be applied to the function. */ rateLimits?: RateLimits; + /** * Who can enqueue tasks for this function. * If left unspecified, only service accounts which have @@ -47,6 +51,99 @@ export interface TaskQueueOptions extends options.GlobalOptions { * will have permissions. */ invoker?: 'private' | string | string[]; + + /** + * Region where functions should be deployed. + */ + region?: options.SupportedRegion | string; + + /** + * Amount of memory to allocate to a function. + * A value of null restores the defaults of 256MB. + */ + memory?: options.MemoryOption | null; + + /** + * Timeout for the function in sections, possible values are 0 to 540. + * HTTPS functions can specify a higher timeout. + * A value of null restores the default of 60s + * The minimum timeout for a gen 2 function is 1s. The maximum timeout for a + * function depends on the type of function: Event handling functions have a + * maximum timeout of 540s (9 minutes). HTTPS and callable functions have a + * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum + * timeout of 1,800s (30 minutes) + */ + timeoutSeconds?: number | null; + + /** + * Min number of actual instances to be running at a given time. + * Instances will be billed for memory allocation and 10% of CPU allocation + * while idle. + * A value of null restores the default min instances. + */ + minInstances?: number | null; + + /** + * Max number of instances to be running in parallel. + * A value of null restores the default max instances. + */ + maxInstances?: number | null; + + /** + * Number of requests a function can serve at once. + * Can only be applied to functions running on Cloud Functions v2. + * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise). + * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1. + * The maximum value for concurrency is 1,000. + */ + concurrency?: number | null; + + /** + * Fractional number of CPUs to allocate to a function. + * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes. + * This is different from the defaults when using the gcloud utility and is different from + * the fixed amount assigned in Google Cloud Functions generation 1. + * To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this + * to the value "gcf_gen1" + */ + cpu?: number | 'gcf_gen1'; + + /** + * Connect cloud function to specified VPC connector. + * A value of null removes the VPC connector + */ + vpcConnector?: string | null; + + /** + * Egress settings for VPC connector. + * A value of null turns off VPC connector egress settings + */ + vpcConnectorEgressSettings?: options.VpcEgressSetting | null; + + /** + * Specific service account for the function to run as. + * A value of null restores the default service account. + */ + serviceAccount?: string | null; + + /** + * Ingress settings which control where this function can be called from. + * A value of null turns off ingress settings. + */ + ingressSettings?: options.IngressSetting | null; + + /** + * User labels to set on the function. + */ + labels?: Record; + + /* + * Secrets to bind to a functions. + */ + secrets?: string[]; + + /** Whether failed executions should be delivered again. */ + retry?: boolean; } export interface TaskQueueFunction extends HttpsFunction { From c2c8dba57cf6bbd8a63959726dd4f3b8d9c2dfde Mon Sep 17 00:00:00 2001 From: Thomas Bouldin Date: Tue, 10 May 2022 14:22:25 -0700 Subject: [PATCH 2/2] PR feedback --- src/v2/options.ts | 2 +- src/v2/providers/alerts/alerts.ts | 2 +- src/v2/providers/alerts/appDistribution.ts | 2 +- src/v2/providers/alerts/crashlytics.ts | 2 +- src/v2/providers/eventarc.ts | 2 +- src/v2/providers/https.ts | 2 +- src/v2/providers/identity.ts | 2 +- src/v2/providers/pubsub.ts | 2 +- src/v2/providers/storage.ts | 2 +- src/v2/providers/tasks.ts | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/v2/options.ts b/src/v2/options.ts index a76bfc56c..d8beb1341 100644 --- a/src/v2/options.ts +++ b/src/v2/options.ts @@ -181,7 +181,7 @@ export interface GlobalOptions { invoker?: 'public' | 'private' | string | string[]; /* - * Secrets to bind to a functions. + * Secrets to bind to a function. */ secrets?: string[]; } diff --git a/src/v2/providers/alerts/alerts.ts b/src/v2/providers/alerts/alerts.ts index b83da15ee..6d4e09d54 100644 --- a/src/v2/providers/alerts/alerts.ts +++ b/src/v2/providers/alerts/alerts.ts @@ -144,7 +144,7 @@ export interface FirebaseAlertOptions extends options.EventHandlerOptions { labels?: Record; /* - * Secrets to bind to a functions. + * Secrets to bind to a function. */ secrets?: string[]; diff --git a/src/v2/providers/alerts/appDistribution.ts b/src/v2/providers/alerts/appDistribution.ts index 649514b8e..d26f84044 100644 --- a/src/v2/providers/alerts/appDistribution.ts +++ b/src/v2/providers/alerts/appDistribution.ts @@ -126,7 +126,7 @@ export interface AppDistributionOptions extends options.EventHandlerOptions { labels?: Record; /* - * Secrets to bind to a functions. + * Secrets to bind to a function. */ secrets?: string[]; diff --git a/src/v2/providers/alerts/crashlytics.ts b/src/v2/providers/alerts/crashlytics.ts index 198f4eda5..307dda260 100644 --- a/src/v2/providers/alerts/crashlytics.ts +++ b/src/v2/providers/alerts/crashlytics.ts @@ -232,7 +232,7 @@ export interface CrashlyticsOptions extends options.EventHandlerOptions { labels?: Record; /* - * Secrets to bind to a functions. + * Secrets to bind to a function. */ secrets?: string[]; diff --git a/src/v2/providers/eventarc.ts b/src/v2/providers/eventarc.ts index ed50c4fad..289a1a490 100644 --- a/src/v2/providers/eventarc.ts +++ b/src/v2/providers/eventarc.ts @@ -139,7 +139,7 @@ export interface EventarcTriggerOptions extends options.EventHandlerOptions { labels?: Record; /* - * Secrets to bind to a functions. + * Secrets to bind to a function. */ secrets?: string[]; diff --git a/src/v2/providers/https.ts b/src/v2/providers/https.ts index eb2155dd6..847d65631 100644 --- a/src/v2/providers/https.ts +++ b/src/v2/providers/https.ts @@ -136,7 +136,7 @@ export interface HttpsOptions extends Omit { invoker?: 'public' | 'private' | string | string[]; /* - * Secrets to bind to a functions. + * Secrets to bind to a function. */ secrets?: string[]; diff --git a/src/v2/providers/identity.ts b/src/v2/providers/identity.ts index 3383dc772..b101a8194 100644 --- a/src/v2/providers/identity.ts +++ b/src/v2/providers/identity.ts @@ -113,7 +113,7 @@ export interface BlockingOptions { labels?: Record; /* - * Secrets to bind to a functions. + * Secrets to bind to a function. */ secrets?: string[]; } diff --git a/src/v2/providers/pubsub.ts b/src/v2/providers/pubsub.ts index 4401d9261..09c56d59c 100644 --- a/src/v2/providers/pubsub.ts +++ b/src/v2/providers/pubsub.ts @@ -210,7 +210,7 @@ export interface PubSubOptions extends options.EventHandlerOptions { labels?: Record; /* - * Secrets to bind to a functions. + * Secrets to bind to a function. */ secrets?: string[]; diff --git a/src/v2/providers/storage.ts b/src/v2/providers/storage.ts index 2ba3f3cde..ec8068119 100644 --- a/src/v2/providers/storage.ts +++ b/src/v2/providers/storage.ts @@ -281,7 +281,7 @@ export interface StorageOptions extends options.EventHandlerOptions { labels?: Record; /* - * Secrets to bind to a functions. + * Secrets to bind to a function. */ secrets?: string[]; diff --git a/src/v2/providers/tasks.ts b/src/v2/providers/tasks.ts index d3a497676..1c175ead8 100644 --- a/src/v2/providers/tasks.ts +++ b/src/v2/providers/tasks.ts @@ -138,7 +138,7 @@ export interface TaskQueueOptions extends options.EventHandlerOptions { labels?: Record; /* - * Secrets to bind to a functions. + * Secrets to bind to a function. */ secrets?: string[];