1 | import { ResetValue } from "../../common/options";
|
2 | import { CloudEvent, CloudFunction } from "../core";
|
3 | import { Expression } from "../../params";
|
4 | import * as options from "../options";
|
5 | import { SecretParam } from "../../params/types";
|
6 | /** Options that can be set on an Eventarc trigger. */
|
7 | export interface EventarcTriggerOptions extends options.EventHandlerOptions {
|
8 | /**
|
9 | * Type of the event to trigger on.
|
10 | */
|
11 | eventType: string;
|
12 | /**
|
13 | * ID of the channel. Can be either:
|
14 | * * fully qualified channel resource name:
|
15 | * `projects/{project}/locations/{location}/channels/{channel-id}`
|
16 | * * partial resource name with location and channel ID, in which case
|
17 | * the runtime project ID of the function will be used:
|
18 | * `locations/{location}/channels/{channel-id}`
|
19 | * * partial channel ID, in which case the runtime project ID of the
|
20 | * function and `us-central1` as location will be used:
|
21 | * `{channel-id}`
|
22 | *
|
23 | * If not specified, the default Firebase channel will be used:
|
24 | * `projects/{project}/locations/us-central1/channels/firebase`
|
25 | */
|
26 | channel?: string;
|
27 | /**
|
28 | * Eventarc event exact match filter.
|
29 | */
|
30 | filters?: Record<string, string>;
|
31 | /**
|
32 | * If true, do not deploy or emulate this function.
|
33 | */
|
34 | omit?: boolean | Expression<boolean>;
|
35 | /**
|
36 | * Region where functions should be deployed.
|
37 | */
|
38 | region?: options.SupportedRegion | string | Expression<string> | ResetValue;
|
39 | /**
|
40 | * Amount of memory to allocate to a function.
|
41 | */
|
42 | memory?: options.MemoryOption | Expression<number> | ResetValue;
|
43 | /**
|
44 | * Timeout for the function in seconds, possible values are 0 to 540.
|
45 | * HTTPS functions can specify a higher timeout.
|
46 | *
|
47 | * @remarks
|
48 | * The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
|
49 | * function depends on the type of function: Event handling functions have a
|
50 | * maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
|
51 | * maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
|
52 | * timeout of 1,800s (30 minutes)
|
53 | */
|
54 | timeoutSeconds?: number | Expression<number> | ResetValue;
|
55 | /**
|
56 | * Min number of actual instances to be running at a given time.
|
57 | *
|
58 | * @remarks
|
59 | * Instances will be billed for memory allocation and 10% of CPU allocation
|
60 | * while idle.
|
61 | */
|
62 | minInstances?: number | Expression<number> | ResetValue;
|
63 | /**
|
64 | * Max number of instances to be running in parallel.
|
65 | */
|
66 | maxInstances?: number | Expression<number> | ResetValue;
|
67 | /**
|
68 | * Number of requests a function can serve at once.
|
69 | *
|
70 | * @remarks
|
71 | * Can only be applied to functions running on Cloud Functions v2.
|
72 | * A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
|
73 | * Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
|
74 | * The maximum value for concurrency is 1,000.
|
75 | */
|
76 | concurrency?: number | Expression<number> | ResetValue;
|
77 | /**
|
78 | * Fractional number of CPUs to allocate to a function.
|
79 | *
|
80 | * @remarks
|
81 | * Defaults to 1 for functions with <= 2GB RAM and increases for larger memory sizes.
|
82 | * This is different from the defaults when using the gcloud utility and is different from
|
83 | * the fixed amount assigned in Google Cloud Functions generation 1.
|
84 | * To revert to the CPU amounts used in gcloud or in Cloud Functions generation 1, set this
|
85 | * to the value "gcf_gen1"
|
86 | */
|
87 | cpu?: number | "gcf_gen1";
|
88 | /**
|
89 | * Connect cloud function to specified VPC connector.
|
90 | */
|
91 | vpcConnector?: string | Expression<string> | ResetValue;
|
92 | /**
|
93 | * Egress settings for VPC connector.
|
94 | */
|
95 | vpcConnectorEgressSettings?: options.VpcEgressSetting | ResetValue;
|
96 | /**
|
97 | * Specific service account for the function to run as.
|
98 | */
|
99 | serviceAccount?: string | Expression<string> | ResetValue;
|
100 | /**
|
101 | * Ingress settings which control where this function can be called from.
|
102 | */
|
103 | ingressSettings?: options.IngressSetting | ResetValue;
|
104 | /**
|
105 | * User labels to set on the function.
|
106 | */
|
107 | labels?: Record<string, string>;
|
108 | secrets?: (string | SecretParam)[];
|
109 | /** Whether failed executions should be delivered again. */
|
110 | retry?: boolean | Expression<boolean> | ResetValue;
|
111 | }
|
112 | /** Handles an Eventarc event published on the default channel.
|
113 | * @param eventType - Type of the event to trigger on.
|
114 | * @param handler - A function to execute when triggered.
|
115 | * @returns A function that you can export and deploy.
|
116 | */
|
117 | export declare function onCustomEventPublished<T = any>(eventType: string, handler: (event: CloudEvent<T>) => any | Promise<any>): CloudFunction<CloudEvent<T>>;
|
118 | /** Handles an Eventarc event.
|
119 | * @param opts - Options to set on this function
|
120 | * @param handler - A function to execute when triggered.
|
121 | * @returns A function that you can export and deploy.
|
122 | */
|
123 | export declare function onCustomEventPublished<T = any>(opts: EventarcTriggerOptions, handler: (event: CloudEvent<T>) => any | Promise<any>): CloudFunction<CloudEvent<T>>;
|