The best way to control Claude Code, Codex and more from any computer or phone

main
ts 694 lines 22.5 KB
Raw
1 import * as monitoring from "@distilled.cloud/gcp/monitoring_v3";
2 import { Unowned } from "alchemy/AdoptPolicy";
3 import { createPhysicalName } from "alchemy/PhysicalName";
4 import * as Provider from "alchemy/Provider";
5 import { Resource } from "alchemy/Resource";
6 import { tagRecord } from "alchemy/Tags";
7 import * as Data from "effect/Data";
8 import * as Effect from "effect/Effect";
9 import * as Stream from "effect/Stream";
10 import { GcpEnvironment } from "../Environment.ts";
11 import {
12 createInternalLabels,
13 diffLabels,
14 hasAlchemyLabels,
15 stripInternalLabels,
16 toLabels,
17 } from "../Labels.ts";
18 import type { Providers } from "../Providers.ts";
19
20 const MAX_DISPLAY_NAME_LENGTH = 512;
21 const DEFAULT_TIMEOUT = "10s";
22 const DEFAULT_PERIOD = "600s";
23 const DEFAULT_HOST = "example.com";
24 const DEFAULT_PATH = "/";
25 const DEFAULT_SSL_PORT = 443;
26 const DEFAULT_HTTP_PORT = 80;
27 const DEFAULT_RESOURCE_TYPE = "uptime_url";
28
29 export type BasicAuthentication = {
30 /** Username for HTTP basic auth. */
31 username?: string;
32 /** Password for HTTP basic auth. */
33 password?: string;
34 };
35
36 export type PingConfig = {
37 /** Number of ICMP pings to send with the check (max 3). */
38 pingsCount?: number;
39 };
40
41 export type ResponseStatusCode = {
42 /** Exact HTTP status code to accept. */
43 statusValue?: number;
44 /** HTTP status class to accept (`STATUS_CLASS_2XX`, …). */
45 statusClass?: string;
46 };
47
48 export type HttpCheck = {
49 /**
50 * Request path. Combined with the monitored-resource host.
51 * @default "/"
52 */
53 path?: string;
54 /**
55 * TCP port. Defaults to 443 when `useSsl` is true, otherwise 80.
56 */
57 port?: number;
58 /**
59 * When true, probe over HTTPS.
60 * @default true
61 */
62 useSsl?: boolean;
63 /**
64 * When true, validate the SSL certificate. Only applies when `useSsl`
65 * is true.
66 * @default true
67 */
68 validateSsl?: boolean;
69 /** HTTP method. Defaults to GET. */
70 requestMethod?: string;
71 /** Extra request headers. */
72 headers?: Record<string, string>;
73 /** When true, encrypt stored header values. */
74 maskHeaders?: boolean;
75 /** HTTP basic authentication. */
76 authInfo?: BasicAuthentication;
77 /** Attach an OIDC token from the Monitoring service agent. */
78 serviceAgentAuthentication?: { type?: string };
79 /** Content-Type for POST checks. */
80 contentType?: string;
81 /** Custom Content-Type when `contentType` is `USER_PROVIDED`. */
82 customContentType?: string;
83 /** POST body. Ignored for GET. */
84 body?: string;
85 /** ICMP pings sent alongside the HTTP probe. */
86 pingConfig?: PingConfig;
87 /** Accepted HTTP status codes. Empty means 2xx. */
88 acceptedResponseStatusCodes?: ResponseStatusCode[];
89 };
90
91 export type TcpCheck = {
92 /** TCP port to probe. Required for TCP checks. */
93 port?: number;
94 /** ICMP pings sent alongside the TCP probe. */
95 pingConfig?: PingConfig;
96 };
97
98 export type JsonPathMatcher = {
99 /** JSONPath into the response body. */
100 jsonPath?: string;
101 /** Match type (`EXACT_MATCH` or `REGEX_MATCH`). */
102 jsonMatcher?: string;
103 };
104
105 export type ContentMatcher = {
106 /** String, regex, or JSON value to match. */
107 content?: string;
108 /** Matcher (`CONTAINS_STRING`, `MATCHES_REGEX`, …). */
109 matcher?: string;
110 /** JSONPath matcher, used with `MATCHES_JSON_PATH`. */
111 jsonPathMatcher?: JsonPathMatcher;
112 };
113
114 export type MonitoredResource = {
115 /**
116 * Monitored resource type (`uptime_url`, `gce_instance`, `gae_app`,
117 * `k8s_service`, `cloud_run_revision`, …).
118 */
119 type?: string;
120 /**
121 * Resource labels. For `uptime_url`, set `host` (and optionally
122 * `project_id`).
123 */
124 labels?: Record<string, string>;
125 };
126
127 export type ResourceGroup = {
128 /** Group id (not the full resource name). */
129 groupId?: string;
130 /** Member resource type (`INSTANCE` or `AWS_ELB_LOAD_BALANCER`). */
131 resourceType?: string;
132 };
133
134 export type SyntheticMonitorTarget = {
135 /** Cloud Functions v2 target. */
136 cloudFunctionV2?: { name?: string };
137 };
138
139 export type UptimeCheckConfigProps = {
140 /**
141 * Human-readable display name. If omitted, a unique name is generated
142 * from the stack, stage, and logical id.
143 */
144 displayName?: string;
145 /**
146 * Probe timeout. Must be between 1s and 60s.
147 * @default "10s"
148 */
149 timeout?: string;
150 /**
151 * How often the check runs. Supported values: `60s`, `300s`, `600s`,
152 * `900s`.
153 * @default "600s"
154 */
155 period?: string;
156 /**
157 * HTTP/HTTPS probe. Defaults to HTTPS against `example.com` when no
158 * other target is set.
159 */
160 httpCheck?: HttpCheck;
161 /**
162 * TCP probe. Mutually exclusive with `httpCheck` and
163 * `syntheticMonitor`.
164 */
165 tcpCheck?: TcpCheck;
166 /**
167 * Synthetic monitor (Cloud Functions v2) target.
168 */
169 syntheticMonitor?: SyntheticMonitorTarget;
170 /**
171 * Monitored resource. Defaults to `uptime_url` with host
172 * `example.com` for HTTP/TCP checks.
173 */
174 monitoredResource?: MonitoredResource;
175 /**
176 * Resource group instead of a single monitored resource.
177 */
178 resourceGroup?: ResourceGroup;
179 /**
180 * Content matchers. Only the first entry is used by the API.
181 */
182 contentMatchers?: ContentMatcher[];
183 /**
184 * Regions to probe from. Omitted runs from every available region.
185 * When set, enough regions must be listed to cover at least 3
186 * locations.
187 */
188 selectedRegions?: string[];
189 /**
190 * Checker type (`STATIC_IP_CHECKERS` or `VPC_CHECKERS`).
191 */
192 checkerType?: string;
193 /**
194 * When true, the check exists but does not run.
195 * @default false
196 */
197 disabled?: boolean;
198 /**
199 * When true, failed probes are written to Cloud Logging.
200 * @default false
201 */
202 logCheckFailures?: boolean;
203 /**
204 * User labels. Alchemy ownership labels are merged in automatically.
205 */
206 labels?: Record<string, string>;
207 };
208
209 export type UptimeCheckConfig = Resource<
210 "GCP.Monitoring.UptimeCheckConfig",
211 UptimeCheckConfigProps,
212 {
213 /** Full resource name `projects/{project}/uptimeCheckConfigs/{config}`. */
214 name: string;
215 /** Server-assigned config id (last path segment). */
216 uptimeCheckConfigId: string;
217 /** Project id. */
218 project: string;
219 /** Human-readable display name. */
220 displayName: string | undefined;
221 /** Probe timeout. */
222 timeout: string | undefined;
223 /** Check period. */
224 period: string | undefined;
225 /** HTTP/HTTPS probe, if set. */
226 httpCheck: HttpCheck | undefined;
227 /** TCP probe, if set. */
228 tcpCheck: TcpCheck | undefined;
229 /** Synthetic monitor target, if set. */
230 syntheticMonitor: SyntheticMonitorTarget | undefined;
231 /** Monitored resource, if set. */
232 monitoredResource: MonitoredResource | undefined;
233 /** Resource group, if set. */
234 resourceGroup: ResourceGroup | undefined;
235 /** Content matchers. */
236 contentMatchers: ContentMatcher[];
237 /** Regions the check runs from. */
238 selectedRegions: ReadonlyArray<string>;
239 /** Checker type. */
240 checkerType: string | undefined;
241 /** Whether the check is disabled. */
242 disabled: boolean;
243 /** Whether failed probes are logged. */
244 logCheckFailures: boolean;
245 /** User labels (Alchemy ownership labels stripped). */
246 labels: Record<string, string>;
247 },
248 never,
249 Providers
250 >;
251
252 /**
253 * A Cloud Monitoring uptime check — an HTTP, HTTPS, TCP, or synthetic
254 * probe that measures availability.
255 *
256 * Config ids are assigned by the API. Alchemy stamps ownership into
257 * `userLabels` so `list` / `pnpm nuke:gcp` can find them. Display name,
258 * period, timeout, HTTP/TCP settings, matchers, regions, and labels
259 * update in place.
260 *
261 * ### Creating a Check
262 * **Example:** HTTPS probe of example.com
263 * ```typescript
264 * const check = yield* GCP.Monitoring.UptimeCheckConfig("Homepage", {
265 * httpCheck: { path: "/", useSsl: true, validateSsl: true },
266 * monitoredResource: {
267 * type: "uptime_url",
268 * labels: { host: "example.com" },
269 * },
270 * });
271 * ```
272 *
273 * **Example:** Generated name with labels
274 * ```typescript
275 * const check = yield* GCP.Monitoring.UptimeCheckConfig("Homepage", {
276 * timeout: "10s",
277 * period: "600s",
278 * labels: { env: "prod" },
279 * });
280 * ```
281 *
282 * ### Updating a Check
283 * **Example:** Change path and period
284 * ```typescript
285 * const check = yield* GCP.Monitoring.UptimeCheckConfig("Homepage", {
286 * period: "300s",
287 * httpCheck: { path: "/health", useSsl: true, validateSsl: true },
288 * monitoredResource: {
289 * type: "uptime_url",
290 * labels: { host: "example.com" },
291 * },
292 * });
293 * ```
294 *
295 * @resource
296 * @category Monitoring
297 */
298 export const UptimeCheckConfig = Resource<UptimeCheckConfig>("GCP.Monitoring.UptimeCheckConfig");
299
300 export class UptimeCheckConfigNotResolved extends Data.TaggedError(
301 "GCP.Monitoring.UptimeCheckConfigNotResolved",
302 )<{
303 resourceName: string;
304 }> {}
305
306 const lastSegment = (value: string) => {
307 const trimmed = value.replace(/\/+$/, "");
308 const parts = trimmed.split("/");
309 return parts[parts.length - 1] || trimmed;
310 };
311
312 const parentOf = (project: string) => `projects/${project}`;
313
314 const userFacingLabels = (
315 labels: Record<string, string | undefined> | null | undefined,
316 ): Record<string, string> => stripInternalLabels(tagRecord(labels));
317
318 const jsonEqual = (left: unknown, right: unknown) =>
319 JSON.stringify(canonicalize(left)) === JSON.stringify(canonicalize(right));
320
321 const canonicalize = (value: unknown): unknown => {
322 if (Array.isArray(value)) return value.map(canonicalize);
323 if (value !== null && typeof value === "object") {
324 return Object.fromEntries(
325 Object.entries(value as Record<string, unknown>)
326 .filter(([, item]) => item !== undefined)
327 .sort(([left], [right]) => left.localeCompare(right))
328 .map(([key, item]) => [key, canonicalize(item)]),
329 );
330 }
331 return value;
332 };
333
334 const subsetEqual = (observed: unknown, desired: unknown): boolean => {
335 if (desired === undefined) return true;
336 if (Array.isArray(desired)) {
337 if (!Array.isArray(observed) || observed.length !== desired.length) {
338 return false;
339 }
340 return desired.every((item, index) => subsetEqual(observed[index], item));
341 }
342 if (desired !== null && typeof desired === "object") {
343 if (observed === null || typeof observed !== "object") return false;
344 const current = observed as Record<string, unknown>;
345 return Object.entries(desired as Record<string, unknown>).every(
346 ([key, value]) => value === undefined || subsetEqual(current[key], value),
347 );
348 }
349 return observed === desired;
350 };
351
352 const sorted = (values: readonly string[] | undefined) => [...(values ?? [])].sort();
353
354 const toDisplayName = (id: string, displayName: string | undefined, existing?: string) =>
355 Effect.gen(function* () {
356 return (
357 displayName ??
358 existing ??
359 (yield* createPhysicalName({
360 id,
361 maxLength: MAX_DISPLAY_NAME_LENGTH,
362 lowercase: true,
363 }))
364 );
365 });
366
367 const hasExplicitTarget = (news: UptimeCheckConfigProps) =>
368 news.httpCheck !== undefined ||
369 news.tcpCheck !== undefined ||
370 news.syntheticMonitor !== undefined;
371
372 const defaultHttpCheck = (): HttpCheck => ({
373 path: DEFAULT_PATH,
374 port: DEFAULT_SSL_PORT,
375 useSsl: true,
376 validateSsl: true,
377 });
378
379 const defaultMonitoredResource = (project: string): MonitoredResource => ({
380 type: DEFAULT_RESOURCE_TYPE,
381 labels: { project_id: project, host: DEFAULT_HOST },
382 });
383
384 const desiredHttpCheck = (news: UptimeCheckConfigProps): HttpCheck | undefined => {
385 if (news.tcpCheck !== undefined || news.syntheticMonitor !== undefined) {
386 return news.httpCheck;
387 }
388 const check = news.httpCheck ?? (hasExplicitTarget(news) ? undefined : defaultHttpCheck());
389 if (check === undefined) return undefined;
390 const useSsl = check.useSsl !== false;
391 return {
392 ...check,
393 path: check.path && check.path.length > 0 ? check.path : DEFAULT_PATH,
394 useSsl,
395 validateSsl: useSsl ? check.validateSsl !== false : false,
396 port: check.port ?? (useSsl ? DEFAULT_SSL_PORT : DEFAULT_HTTP_PORT),
397 };
398 };
399
400 const desiredMonitoredResource = (
401 news: UptimeCheckConfigProps,
402 project: string,
403 ): MonitoredResource | undefined => {
404 if (news.syntheticMonitor !== undefined) return news.monitoredResource;
405 if (news.resourceGroup !== undefined) return news.monitoredResource;
406 const resource = news.monitoredResource ?? defaultMonitoredResource(project);
407 const labels = {
408 ...resource.labels,
409 };
410 if (labels.project_id === undefined) labels.project_id = project;
411 if (
412 labels.host === undefined &&
413 (resource.type ?? DEFAULT_RESOURCE_TYPE) === DEFAULT_RESOURCE_TYPE
414 ) {
415 labels.host = DEFAULT_HOST;
416 }
417 return {
418 type: resource.type ?? DEFAULT_RESOURCE_TYPE,
419 labels,
420 };
421 };
422
423 const toHttpCheck = (check: monitoring.HttpCheck | undefined): HttpCheck | undefined => {
424 if (check === undefined) return undefined;
425 const useSsl = check.useSsl !== false;
426 const headers = tagRecord(check.headers);
427 return {
428 path: check.path && check.path.length > 0 ? check.path : DEFAULT_PATH,
429 port: check.port ?? (useSsl ? DEFAULT_SSL_PORT : DEFAULT_HTTP_PORT),
430 useSsl,
431 validateSsl: useSsl ? check.validateSsl !== false : false,
432 requestMethod:
433 check.requestMethod && check.requestMethod !== "METHOD_UNSPECIFIED"
434 ? check.requestMethod
435 : undefined,
436 headers: Object.keys(headers).length > 0 ? headers : undefined,
437 maskHeaders: check.maskHeaders === true ? true : undefined,
438 authInfo: check.authInfo,
439 serviceAgentAuthentication: check.serviceAgentAuthentication,
440 contentType:
441 check.contentType && check.contentType !== "TYPE_UNSPECIFIED" ? check.contentType : undefined,
442 customContentType: check.customContentType,
443 body: check.body,
444 pingConfig: check.pingConfig,
445 acceptedResponseStatusCodes: check.acceptedResponseStatusCodes,
446 };
447 };
448
449 const toMonitoredResource = (
450 resource: monitoring.MonitoredResource | undefined,
451 ): MonitoredResource | undefined => {
452 if (resource === undefined) return undefined;
453 return {
454 type: resource.type,
455 labels: tagRecord(resource.labels),
456 };
457 };
458
459 const toAttrs = (config: monitoring.UptimeCheckConfig, project: string) => {
460 const name = config.name ?? "";
461 return {
462 name,
463 uptimeCheckConfigId: lastSegment(name),
464 project,
465 displayName: config.displayName,
466 timeout: config.timeout,
467 period: config.period,
468 httpCheck: toHttpCheck(config.httpCheck),
469 tcpCheck: config.tcpCheck,
470 syntheticMonitor: config.syntheticMonitor,
471 monitoredResource: toMonitoredResource(config.monitoredResource),
472 resourceGroup: config.resourceGroup,
473 contentMatchers: config.contentMatchers ?? [],
474 selectedRegions: config.selectedRegions ?? [],
475 checkerType: config.checkerType,
476 disabled: config.disabled === true,
477 logCheckFailures: config.logCheckFailures === true,
478 labels: userFacingLabels(config.userLabels),
479 };
480 };
481
482 const getByName = (name: string) =>
483 monitoring
484 .getProjectsUptimeCheckConfigs({ name })
485 .pipe(Effect.catchTag("NotFound", () => Effect.undefined));
486
487 const listOwned = (project: string) =>
488 monitoring.listProjectsUptimeCheckConfigs
489 .pages({
490 parent: parentOf(project),
491 pageSize: 1000,
492 })
493 .pipe(
494 Stream.flatMap((page) => Stream.fromIterable(page.uptimeCheckConfigs ?? [])),
495 Stream.filter((config) =>
496 Object.keys(config.userLabels ?? {}).some((key) => key.startsWith("alchemy-")),
497 ),
498 Stream.map((config) => toAttrs(config, project)),
499 Stream.runCollect,
500 Effect.map((chunk) => Array.from(chunk)),
501 Effect.catchTag("NotFound", () => Effect.succeed([])),
502 );
503
504 const findOwned = (project: string, id: string) =>
505 Effect.gen(function* () {
506 const owned = yield* monitoring.listProjectsUptimeCheckConfigs
507 .pages({
508 parent: parentOf(project),
509 pageSize: 1000,
510 })
511 .pipe(
512 Stream.flatMap((page) => Stream.fromIterable(page.uptimeCheckConfigs ?? [])),
513 Stream.runCollect,
514 Effect.map((chunk) => Array.from(chunk)),
515 Effect.catchTag("NotFound", () => Effect.succeed([])),
516 );
517 for (const config of owned) {
518 if (yield* hasAlchemyLabels(id, tagRecord(config.userLabels))) {
519 return config;
520 }
521 }
522 return undefined;
523 });
524
525 const observe = (project: string, id: string, name: string | undefined) =>
526 Effect.gen(function* () {
527 if (name !== undefined) {
528 const existing = yield* getByName(name);
529 if (existing !== undefined) return existing;
530 }
531 return yield* findOwned(project, id);
532 });
533
534 const toApiHttpCheck = (check: HttpCheck | undefined): monitoring.HttpCheck | undefined => {
535 if (check === undefined) return undefined;
536 return {
537 path: check.path,
538 port: check.port,
539 useSsl: check.useSsl,
540 validateSsl: check.validateSsl,
541 requestMethod: check.requestMethod,
542 headers: check.headers,
543 maskHeaders: check.maskHeaders,
544 authInfo: check.authInfo,
545 serviceAgentAuthentication: check.serviceAgentAuthentication,
546 contentType: check.contentType,
547 customContentType: check.customContentType,
548 body: check.body,
549 pingConfig: check.pingConfig,
550 acceptedResponseStatusCodes: check.acceptedResponseStatusCodes,
551 };
552 };
553
554 const toApiMonitoredResource = (
555 resource: MonitoredResource | undefined,
556 ): monitoring.MonitoredResource | undefined => {
557 if (resource === undefined) return undefined;
558 return {
559 type: resource.type,
560 labels: resource.labels,
561 };
562 };
563
564 export const UptimeCheckConfigProvider = () =>
565 Provider.succeed(UptimeCheckConfig, {
566 stables: ["name", "uptimeCheckConfigId", "project"],
567
568 read: Effect.fn(function* ({ id, output }) {
569 const env = yield* GcpEnvironment.current;
570 const existing = yield* observe(env.project, id, output?.name);
571 if (existing === undefined) return undefined;
572 const attrs = toAttrs(existing, env.project);
573 return (yield* hasAlchemyLabels(id, tagRecord(existing.userLabels))) ? attrs : Unowned(attrs);
574 }),
575
576 list: () =>
577 Effect.gen(function* () {
578 const env = yield* GcpEnvironment.current;
579 return yield* listOwned(env.project);
580 }),
581
582 reconcile: Effect.fn(function* ({ id, news, output }) {
583 const env = yield* GcpEnvironment.current;
584 const displayName = yield* toDisplayName(id, news.displayName, output?.displayName);
585 const desiredLabels = {
586 ...toLabels(news.labels),
587 ...(yield* createInternalLabels(id)),
588 };
589 const timeout = news.timeout ?? DEFAULT_TIMEOUT;
590 const period = news.period ?? DEFAULT_PERIOD;
591 const httpCheck = desiredHttpCheck(news);
592 const monitoredResource = desiredMonitoredResource(news, env.project);
593 const desiredDisabled = news.disabled === true;
594 const desiredLogFailures = news.logCheckFailures === true;
595
596 const body: monitoring.UptimeCheckConfig = {
597 displayName,
598 timeout,
599 period,
600 userLabels: desiredLabels,
601 httpCheck: toApiHttpCheck(httpCheck),
602 tcpCheck: news.tcpCheck,
603 syntheticMonitor: news.syntheticMonitor,
604 monitoredResource: toApiMonitoredResource(monitoredResource),
605 resourceGroup: news.resourceGroup,
606 contentMatchers: news.contentMatchers,
607 selectedRegions: news.selectedRegions,
608 checkerType: news.checkerType,
609 disabled: desiredDisabled ? true : undefined,
610 logCheckFailures: desiredLogFailures ? true : undefined,
611 };
612
613 let current = yield* observe(env.project, id, output?.name);
614
615 if (current === undefined) {
616 const created = yield* monitoring
617 .createProjectsUptimeCheckConfigs({
618 parent: parentOf(env.project),
619 body,
620 })
621 .pipe(Effect.catchTag("Conflict", () => findOwned(env.project, id)));
622 current = created ?? undefined;
623 }
624
625 if (current === undefined) {
626 return yield* new UptimeCheckConfigNotResolved({
627 resourceName: output?.name ?? displayName,
628 });
629 }
630
631 const name = current.name ?? output?.name ?? "";
632 const observedLabels = tagRecord(current.userLabels);
633 const { upsert, removed } = diffLabels(observedLabels, desiredLabels);
634 const labelsChanged = upsert.length > 0 || removed.length > 0;
635 const displayNameChanged = (current.displayName ?? "") !== displayName;
636 const timeoutChanged = (current.timeout ?? "") !== timeout;
637 const periodChanged = (current.period ?? DEFAULT_PERIOD) !== period;
638 const httpChanged =
639 httpCheck !== undefined && !subsetEqual(toHttpCheck(current.httpCheck), httpCheck);
640 const tcpChanged =
641 news.tcpCheck !== undefined && !subsetEqual(current.tcpCheck, news.tcpCheck);
642 const syntheticChanged =
643 news.syntheticMonitor !== undefined &&
644 !subsetEqual(current.syntheticMonitor, news.syntheticMonitor);
645 const resourceChanged =
646 monitoredResource !== undefined &&
647 !subsetEqual(toMonitoredResource(current.monitoredResource), monitoredResource);
648 const groupChanged =
649 news.resourceGroup !== undefined && !jsonEqual(current.resourceGroup, news.resourceGroup);
650 const matchersChanged =
651 news.contentMatchers !== undefined &&
652 !jsonEqual(current.contentMatchers ?? [], news.contentMatchers);
653 const regionsChanged =
654 news.selectedRegions !== undefined &&
655 !jsonEqual(sorted(current.selectedRegions), sorted(news.selectedRegions));
656 const checkerChanged =
657 news.checkerType !== undefined && (current.checkerType ?? "") !== news.checkerType;
658 const disabledChanged = (current.disabled === true) !== desiredDisabled;
659 const logChanged = (current.logCheckFailures === true) !== desiredLogFailures;
660
661 const updateMask = [
662 displayNameChanged ? "display_name" : undefined,
663 timeoutChanged ? "timeout" : undefined,
664 periodChanged ? "period" : undefined,
665 labelsChanged ? "user_labels" : undefined,
666 httpChanged ? "http_check" : undefined,
667 tcpChanged ? "tcp_check" : undefined,
668 syntheticChanged ? "synthetic_monitor" : undefined,
669 resourceChanged ? "monitored_resource" : undefined,
670 groupChanged ? "resource_group" : undefined,
671 matchersChanged ? "content_matchers" : undefined,
672 regionsChanged ? "selected_regions" : undefined,
673 checkerChanged ? "checker_type" : undefined,
674 disabledChanged ? "disabled" : undefined,
675 logChanged ? "log_check_failures" : undefined,
676 ].filter((field): field is string => field !== undefined);
677
678 if (updateMask.length > 0) {
679 current = yield* monitoring.patchProjectsUptimeCheckConfigs({
680 name,
681 updateMask: updateMask.join(","),
682 body: { ...body, name },
683 });
684 }
685
686 return toAttrs(current, env.project);
687 }),
688
689 delete: Effect.fn(function* ({ output }) {
690 yield* monitoring
691 .deleteProjectsUptimeCheckConfigs({ name: output.name })
692 .pipe(Effect.catchTag("NotFound", () => Effect.void));
693 }),
694 });