@miradorlabs/web-grpc 2.20.0 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -247,6 +247,68 @@ export interface SloCorridorStatus {
247
247
  state: SloCorridorState;
248
248
  }
249
249
 
250
+ export interface GetSloTimelineRequest {
251
+ organizationId: string;
252
+ projectId: string;
253
+ sloId: string;
254
+ /** end_time: the timeline's right edge; truncated down to the UTC hour. Unset = now(). */
255
+ endTime:
256
+ | Date
257
+ | undefined;
258
+ /** bucket_count: number of trailing 1-hour buckets (0 = default 168 = 7d; max 2000). */
259
+ bucketCount: number;
260
+ }
261
+
262
+ export interface GetSloTimelineResponse {
263
+ status: ResponseStatus | undefined;
264
+ timeline: SloTimeline | undefined;
265
+ }
266
+
267
+ /**
268
+ * SloTimeline is one SLO's per-hour health over a trailing window of completed UTC
269
+ * hours. Buckets are SPARSE: an hour with no eligible sample is omitted (render it
270
+ * no-data). Each bucket pools all corridors that hour into one aggregate good-ratio,
271
+ * so it is BREACHED when the pooled compliance is below target.
272
+ */
273
+ export interface SloTimeline {
274
+ sloId: string;
275
+ enabled: boolean;
276
+ target: number;
277
+ bucketSeconds: number;
278
+ windowStart: Date | undefined;
279
+ windowEnd: Date | undefined;
280
+ buckets: SloTimelineBucket[];
281
+ }
282
+
283
+ export interface SloTimelineBucket {
284
+ bucketStart:
285
+ | Date
286
+ | undefined;
287
+ /** All corridors pooled for that hour: summed counts and their compliance drive the bar. */
288
+ eligibleCount: number;
289
+ goodCount: number;
290
+ compliance: number;
291
+ state: SloCorridorState;
292
+ }
293
+
294
+ export interface PreviewSloRequest {
295
+ organizationId: string;
296
+ projectId: string;
297
+ /** objective: the unsaved definition to score, updated live as the user edits. */
298
+ objective: SloObjective | undefined;
299
+ evaluationTime:
300
+ | Date
301
+ | undefined;
302
+ /** bucket_count: trailing 1-hour timeline buckets (0 = default 168 = 7d; max 2000). */
303
+ bucketCount: number;
304
+ }
305
+
306
+ export interface PreviewSloResponse {
307
+ status: ResponseStatus | undefined;
308
+ sloStatus: SloStatus | undefined;
309
+ timeline: SloTimeline | undefined;
310
+ }
311
+
250
312
  function createBaseSlo(): Slo {
251
313
  return {
252
314
  id: "",
@@ -2249,64 +2311,867 @@ export const SloCorridorStatus: MessageFns<SloCorridorStatus> = {
2249
2311
  },
2250
2312
  };
2251
2313
 
2252
- /** SloGatewayService provides web client access to SLO definitions. */
2253
- export interface SloGatewayService {
2254
- CreateSlo(request: CreateSloRequest, metadata?: Metadata): Promise<CreateSloResponse>;
2255
- GetSlo(request: GetSloRequest, metadata?: Metadata): Promise<GetSloResponse>;
2256
- ListSlos(request: ListSlosRequest, metadata?: Metadata): Promise<ListSlosResponse>;
2257
- UpdateSlo(request: UpdateSloRequest, metadata?: Metadata): Promise<UpdateSloResponse>;
2258
- DeleteSlo(request: DeleteSloRequest, metadata?: Metadata): Promise<DeleteSloResponse>;
2259
- GetSloStatus(request: GetSloStatusRequest, metadata?: Metadata): Promise<GetSloStatusResponse>;
2314
+ function createBaseGetSloTimelineRequest(): GetSloTimelineRequest {
2315
+ return { organizationId: "", projectId: "", sloId: "", endTime: undefined, bucketCount: 0 };
2260
2316
  }
2261
2317
 
2262
- export const SloGatewayServiceServiceName = "gateway.web.v1.SloGatewayService";
2263
- export class SloGatewayServiceClientImpl implements SloGatewayService {
2264
- private readonly rpc: Rpc;
2265
- private readonly service: string;
2266
- constructor(rpc: Rpc, opts?: { service?: string }) {
2267
- this.service = opts?.service || SloGatewayServiceServiceName;
2268
- this.rpc = rpc;
2269
- this.CreateSlo = this.CreateSlo.bind(this);
2270
- this.GetSlo = this.GetSlo.bind(this);
2271
- this.ListSlos = this.ListSlos.bind(this);
2272
- this.UpdateSlo = this.UpdateSlo.bind(this);
2273
- this.DeleteSlo = this.DeleteSlo.bind(this);
2274
- this.GetSloStatus = this.GetSloStatus.bind(this);
2275
- }
2276
- CreateSlo(request: CreateSloRequest, metadata?: Metadata): Promise<CreateSloResponse> {
2277
- const data = CreateSloRequest.encode(request).finish();
2278
- const promise = this.rpc.request(this.service, "CreateSlo", data, metadata);
2279
- return promise.then((data) => CreateSloResponse.decode(new BinaryReader(data)));
2280
- }
2318
+ export const GetSloTimelineRequest: MessageFns<GetSloTimelineRequest> = {
2319
+ encode(message: GetSloTimelineRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2320
+ if (message.organizationId !== "") {
2321
+ writer.uint32(10).string(message.organizationId);
2322
+ }
2323
+ if (message.projectId !== "") {
2324
+ writer.uint32(18).string(message.projectId);
2325
+ }
2326
+ if (message.sloId !== "") {
2327
+ writer.uint32(26).string(message.sloId);
2328
+ }
2329
+ if (message.endTime !== undefined) {
2330
+ Timestamp.encode(toTimestamp(message.endTime), writer.uint32(34).fork()).join();
2331
+ }
2332
+ if (message.bucketCount !== 0) {
2333
+ writer.uint32(40).uint32(message.bucketCount);
2334
+ }
2335
+ return writer;
2336
+ },
2281
2337
 
2282
- GetSlo(request: GetSloRequest, metadata?: Metadata): Promise<GetSloResponse> {
2283
- const data = GetSloRequest.encode(request).finish();
2284
- const promise = this.rpc.request(this.service, "GetSlo", data, metadata);
2285
- return promise.then((data) => GetSloResponse.decode(new BinaryReader(data)));
2286
- }
2338
+ decode(input: BinaryReader | Uint8Array, length?: number): GetSloTimelineRequest {
2339
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2340
+ const end = length === undefined ? reader.len : reader.pos + length;
2341
+ const message = createBaseGetSloTimelineRequest();
2342
+ while (reader.pos < end) {
2343
+ const tag = reader.uint32();
2344
+ switch (tag >>> 3) {
2345
+ case 1: {
2346
+ if (tag !== 10) {
2347
+ break;
2348
+ }
2287
2349
 
2288
- ListSlos(request: ListSlosRequest, metadata?: Metadata): Promise<ListSlosResponse> {
2289
- const data = ListSlosRequest.encode(request).finish();
2290
- const promise = this.rpc.request(this.service, "ListSlos", data, metadata);
2291
- return promise.then((data) => ListSlosResponse.decode(new BinaryReader(data)));
2292
- }
2350
+ message.organizationId = reader.string();
2351
+ continue;
2352
+ }
2353
+ case 2: {
2354
+ if (tag !== 18) {
2355
+ break;
2356
+ }
2293
2357
 
2294
- UpdateSlo(request: UpdateSloRequest, metadata?: Metadata): Promise<UpdateSloResponse> {
2295
- const data = UpdateSloRequest.encode(request).finish();
2296
- const promise = this.rpc.request(this.service, "UpdateSlo", data, metadata);
2297
- return promise.then((data) => UpdateSloResponse.decode(new BinaryReader(data)));
2298
- }
2358
+ message.projectId = reader.string();
2359
+ continue;
2360
+ }
2361
+ case 3: {
2362
+ if (tag !== 26) {
2363
+ break;
2364
+ }
2299
2365
 
2300
- DeleteSlo(request: DeleteSloRequest, metadata?: Metadata): Promise<DeleteSloResponse> {
2301
- const data = DeleteSloRequest.encode(request).finish();
2302
- const promise = this.rpc.request(this.service, "DeleteSlo", data, metadata);
2303
- return promise.then((data) => DeleteSloResponse.decode(new BinaryReader(data)));
2304
- }
2366
+ message.sloId = reader.string();
2367
+ continue;
2368
+ }
2369
+ case 4: {
2370
+ if (tag !== 34) {
2371
+ break;
2372
+ }
2305
2373
 
2306
- GetSloStatus(request: GetSloStatusRequest, metadata?: Metadata): Promise<GetSloStatusResponse> {
2307
- const data = GetSloStatusRequest.encode(request).finish();
2308
- const promise = this.rpc.request(this.service, "GetSloStatus", data, metadata);
2309
- return promise.then((data) => GetSloStatusResponse.decode(new BinaryReader(data)));
2374
+ message.endTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
2375
+ continue;
2376
+ }
2377
+ case 5: {
2378
+ if (tag !== 40) {
2379
+ break;
2380
+ }
2381
+
2382
+ message.bucketCount = reader.uint32();
2383
+ continue;
2384
+ }
2385
+ }
2386
+ if ((tag & 7) === 4 || tag === 0) {
2387
+ break;
2388
+ }
2389
+ reader.skip(tag & 7);
2390
+ }
2391
+ return message;
2392
+ },
2393
+
2394
+ fromJSON(object: any): GetSloTimelineRequest {
2395
+ return {
2396
+ organizationId: isSet(object.organizationId)
2397
+ ? globalThis.String(object.organizationId)
2398
+ : isSet(object.organization_id)
2399
+ ? globalThis.String(object.organization_id)
2400
+ : "",
2401
+ projectId: isSet(object.projectId)
2402
+ ? globalThis.String(object.projectId)
2403
+ : isSet(object.project_id)
2404
+ ? globalThis.String(object.project_id)
2405
+ : "",
2406
+ sloId: isSet(object.sloId)
2407
+ ? globalThis.String(object.sloId)
2408
+ : isSet(object.slo_id)
2409
+ ? globalThis.String(object.slo_id)
2410
+ : "",
2411
+ endTime: isSet(object.endTime)
2412
+ ? fromJsonTimestamp(object.endTime)
2413
+ : isSet(object.end_time)
2414
+ ? fromJsonTimestamp(object.end_time)
2415
+ : undefined,
2416
+ bucketCount: isSet(object.bucketCount)
2417
+ ? globalThis.Number(object.bucketCount)
2418
+ : isSet(object.bucket_count)
2419
+ ? globalThis.Number(object.bucket_count)
2420
+ : 0,
2421
+ };
2422
+ },
2423
+
2424
+ toJSON(message: GetSloTimelineRequest): unknown {
2425
+ const obj: any = {};
2426
+ if (message.organizationId !== "") {
2427
+ obj.organizationId = message.organizationId;
2428
+ }
2429
+ if (message.projectId !== "") {
2430
+ obj.projectId = message.projectId;
2431
+ }
2432
+ if (message.sloId !== "") {
2433
+ obj.sloId = message.sloId;
2434
+ }
2435
+ if (message.endTime !== undefined) {
2436
+ obj.endTime = message.endTime.toISOString();
2437
+ }
2438
+ if (message.bucketCount !== 0) {
2439
+ obj.bucketCount = Math.round(message.bucketCount);
2440
+ }
2441
+ return obj;
2442
+ },
2443
+
2444
+ create<I extends Exact<DeepPartial<GetSloTimelineRequest>, I>>(base?: I): GetSloTimelineRequest {
2445
+ return GetSloTimelineRequest.fromPartial(base ?? ({} as any));
2446
+ },
2447
+ fromPartial<I extends Exact<DeepPartial<GetSloTimelineRequest>, I>>(object: I): GetSloTimelineRequest {
2448
+ const message = createBaseGetSloTimelineRequest();
2449
+ message.organizationId = object.organizationId ?? "";
2450
+ message.projectId = object.projectId ?? "";
2451
+ message.sloId = object.sloId ?? "";
2452
+ message.endTime = object.endTime ?? undefined;
2453
+ message.bucketCount = object.bucketCount ?? 0;
2454
+ return message;
2455
+ },
2456
+ };
2457
+
2458
+ function createBaseGetSloTimelineResponse(): GetSloTimelineResponse {
2459
+ return { status: undefined, timeline: undefined };
2460
+ }
2461
+
2462
+ export const GetSloTimelineResponse: MessageFns<GetSloTimelineResponse> = {
2463
+ encode(message: GetSloTimelineResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2464
+ if (message.status !== undefined) {
2465
+ ResponseStatus.encode(message.status, writer.uint32(10).fork()).join();
2466
+ }
2467
+ if (message.timeline !== undefined) {
2468
+ SloTimeline.encode(message.timeline, writer.uint32(18).fork()).join();
2469
+ }
2470
+ return writer;
2471
+ },
2472
+
2473
+ decode(input: BinaryReader | Uint8Array, length?: number): GetSloTimelineResponse {
2474
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2475
+ const end = length === undefined ? reader.len : reader.pos + length;
2476
+ const message = createBaseGetSloTimelineResponse();
2477
+ while (reader.pos < end) {
2478
+ const tag = reader.uint32();
2479
+ switch (tag >>> 3) {
2480
+ case 1: {
2481
+ if (tag !== 10) {
2482
+ break;
2483
+ }
2484
+
2485
+ message.status = ResponseStatus.decode(reader, reader.uint32());
2486
+ continue;
2487
+ }
2488
+ case 2: {
2489
+ if (tag !== 18) {
2490
+ break;
2491
+ }
2492
+
2493
+ message.timeline = SloTimeline.decode(reader, reader.uint32());
2494
+ continue;
2495
+ }
2496
+ }
2497
+ if ((tag & 7) === 4 || tag === 0) {
2498
+ break;
2499
+ }
2500
+ reader.skip(tag & 7);
2501
+ }
2502
+ return message;
2503
+ },
2504
+
2505
+ fromJSON(object: any): GetSloTimelineResponse {
2506
+ return {
2507
+ status: isSet(object.status) ? ResponseStatus.fromJSON(object.status) : undefined,
2508
+ timeline: isSet(object.timeline) ? SloTimeline.fromJSON(object.timeline) : undefined,
2509
+ };
2510
+ },
2511
+
2512
+ toJSON(message: GetSloTimelineResponse): unknown {
2513
+ const obj: any = {};
2514
+ if (message.status !== undefined) {
2515
+ obj.status = ResponseStatus.toJSON(message.status);
2516
+ }
2517
+ if (message.timeline !== undefined) {
2518
+ obj.timeline = SloTimeline.toJSON(message.timeline);
2519
+ }
2520
+ return obj;
2521
+ },
2522
+
2523
+ create<I extends Exact<DeepPartial<GetSloTimelineResponse>, I>>(base?: I): GetSloTimelineResponse {
2524
+ return GetSloTimelineResponse.fromPartial(base ?? ({} as any));
2525
+ },
2526
+ fromPartial<I extends Exact<DeepPartial<GetSloTimelineResponse>, I>>(object: I): GetSloTimelineResponse {
2527
+ const message = createBaseGetSloTimelineResponse();
2528
+ message.status = (object.status !== undefined && object.status !== null)
2529
+ ? ResponseStatus.fromPartial(object.status)
2530
+ : undefined;
2531
+ message.timeline = (object.timeline !== undefined && object.timeline !== null)
2532
+ ? SloTimeline.fromPartial(object.timeline)
2533
+ : undefined;
2534
+ return message;
2535
+ },
2536
+ };
2537
+
2538
+ function createBaseSloTimeline(): SloTimeline {
2539
+ return {
2540
+ sloId: "",
2541
+ enabled: false,
2542
+ target: 0,
2543
+ bucketSeconds: 0,
2544
+ windowStart: undefined,
2545
+ windowEnd: undefined,
2546
+ buckets: [],
2547
+ };
2548
+ }
2549
+
2550
+ export const SloTimeline: MessageFns<SloTimeline> = {
2551
+ encode(message: SloTimeline, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2552
+ if (message.sloId !== "") {
2553
+ writer.uint32(10).string(message.sloId);
2554
+ }
2555
+ if (message.enabled !== false) {
2556
+ writer.uint32(16).bool(message.enabled);
2557
+ }
2558
+ if (message.target !== 0) {
2559
+ writer.uint32(25).double(message.target);
2560
+ }
2561
+ if (message.bucketSeconds !== 0) {
2562
+ writer.uint32(32).int64(message.bucketSeconds);
2563
+ }
2564
+ if (message.windowStart !== undefined) {
2565
+ Timestamp.encode(toTimestamp(message.windowStart), writer.uint32(42).fork()).join();
2566
+ }
2567
+ if (message.windowEnd !== undefined) {
2568
+ Timestamp.encode(toTimestamp(message.windowEnd), writer.uint32(50).fork()).join();
2569
+ }
2570
+ for (const v of message.buckets) {
2571
+ SloTimelineBucket.encode(v!, writer.uint32(58).fork()).join();
2572
+ }
2573
+ return writer;
2574
+ },
2575
+
2576
+ decode(input: BinaryReader | Uint8Array, length?: number): SloTimeline {
2577
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2578
+ const end = length === undefined ? reader.len : reader.pos + length;
2579
+ const message = createBaseSloTimeline();
2580
+ while (reader.pos < end) {
2581
+ const tag = reader.uint32();
2582
+ switch (tag >>> 3) {
2583
+ case 1: {
2584
+ if (tag !== 10) {
2585
+ break;
2586
+ }
2587
+
2588
+ message.sloId = reader.string();
2589
+ continue;
2590
+ }
2591
+ case 2: {
2592
+ if (tag !== 16) {
2593
+ break;
2594
+ }
2595
+
2596
+ message.enabled = reader.bool();
2597
+ continue;
2598
+ }
2599
+ case 3: {
2600
+ if (tag !== 25) {
2601
+ break;
2602
+ }
2603
+
2604
+ message.target = reader.double();
2605
+ continue;
2606
+ }
2607
+ case 4: {
2608
+ if (tag !== 32) {
2609
+ break;
2610
+ }
2611
+
2612
+ message.bucketSeconds = longToNumber(reader.int64());
2613
+ continue;
2614
+ }
2615
+ case 5: {
2616
+ if (tag !== 42) {
2617
+ break;
2618
+ }
2619
+
2620
+ message.windowStart = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
2621
+ continue;
2622
+ }
2623
+ case 6: {
2624
+ if (tag !== 50) {
2625
+ break;
2626
+ }
2627
+
2628
+ message.windowEnd = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
2629
+ continue;
2630
+ }
2631
+ case 7: {
2632
+ if (tag !== 58) {
2633
+ break;
2634
+ }
2635
+
2636
+ message.buckets.push(SloTimelineBucket.decode(reader, reader.uint32()));
2637
+ continue;
2638
+ }
2639
+ }
2640
+ if ((tag & 7) === 4 || tag === 0) {
2641
+ break;
2642
+ }
2643
+ reader.skip(tag & 7);
2644
+ }
2645
+ return message;
2646
+ },
2647
+
2648
+ fromJSON(object: any): SloTimeline {
2649
+ return {
2650
+ sloId: isSet(object.sloId)
2651
+ ? globalThis.String(object.sloId)
2652
+ : isSet(object.slo_id)
2653
+ ? globalThis.String(object.slo_id)
2654
+ : "",
2655
+ enabled: isSet(object.enabled) ? globalThis.Boolean(object.enabled) : false,
2656
+ target: isSet(object.target) ? globalThis.Number(object.target) : 0,
2657
+ bucketSeconds: isSet(object.bucketSeconds)
2658
+ ? globalThis.Number(object.bucketSeconds)
2659
+ : isSet(object.bucket_seconds)
2660
+ ? globalThis.Number(object.bucket_seconds)
2661
+ : 0,
2662
+ windowStart: isSet(object.windowStart)
2663
+ ? fromJsonTimestamp(object.windowStart)
2664
+ : isSet(object.window_start)
2665
+ ? fromJsonTimestamp(object.window_start)
2666
+ : undefined,
2667
+ windowEnd: isSet(object.windowEnd)
2668
+ ? fromJsonTimestamp(object.windowEnd)
2669
+ : isSet(object.window_end)
2670
+ ? fromJsonTimestamp(object.window_end)
2671
+ : undefined,
2672
+ buckets: globalThis.Array.isArray(object?.buckets)
2673
+ ? object.buckets.map((e: any) => SloTimelineBucket.fromJSON(e))
2674
+ : [],
2675
+ };
2676
+ },
2677
+
2678
+ toJSON(message: SloTimeline): unknown {
2679
+ const obj: any = {};
2680
+ if (message.sloId !== "") {
2681
+ obj.sloId = message.sloId;
2682
+ }
2683
+ if (message.enabled !== false) {
2684
+ obj.enabled = message.enabled;
2685
+ }
2686
+ if (message.target !== 0) {
2687
+ obj.target = message.target;
2688
+ }
2689
+ if (message.bucketSeconds !== 0) {
2690
+ obj.bucketSeconds = Math.round(message.bucketSeconds);
2691
+ }
2692
+ if (message.windowStart !== undefined) {
2693
+ obj.windowStart = message.windowStart.toISOString();
2694
+ }
2695
+ if (message.windowEnd !== undefined) {
2696
+ obj.windowEnd = message.windowEnd.toISOString();
2697
+ }
2698
+ if (message.buckets?.length) {
2699
+ obj.buckets = message.buckets.map((e) => SloTimelineBucket.toJSON(e));
2700
+ }
2701
+ return obj;
2702
+ },
2703
+
2704
+ create<I extends Exact<DeepPartial<SloTimeline>, I>>(base?: I): SloTimeline {
2705
+ return SloTimeline.fromPartial(base ?? ({} as any));
2706
+ },
2707
+ fromPartial<I extends Exact<DeepPartial<SloTimeline>, I>>(object: I): SloTimeline {
2708
+ const message = createBaseSloTimeline();
2709
+ message.sloId = object.sloId ?? "";
2710
+ message.enabled = object.enabled ?? false;
2711
+ message.target = object.target ?? 0;
2712
+ message.bucketSeconds = object.bucketSeconds ?? 0;
2713
+ message.windowStart = object.windowStart ?? undefined;
2714
+ message.windowEnd = object.windowEnd ?? undefined;
2715
+ message.buckets = object.buckets?.map((e) => SloTimelineBucket.fromPartial(e)) || [];
2716
+ return message;
2717
+ },
2718
+ };
2719
+
2720
+ function createBaseSloTimelineBucket(): SloTimelineBucket {
2721
+ return { bucketStart: undefined, eligibleCount: 0, goodCount: 0, compliance: 0, state: 0 };
2722
+ }
2723
+
2724
+ export const SloTimelineBucket: MessageFns<SloTimelineBucket> = {
2725
+ encode(message: SloTimelineBucket, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2726
+ if (message.bucketStart !== undefined) {
2727
+ Timestamp.encode(toTimestamp(message.bucketStart), writer.uint32(10).fork()).join();
2728
+ }
2729
+ if (message.eligibleCount !== 0) {
2730
+ writer.uint32(16).uint64(message.eligibleCount);
2731
+ }
2732
+ if (message.goodCount !== 0) {
2733
+ writer.uint32(24).uint64(message.goodCount);
2734
+ }
2735
+ if (message.compliance !== 0) {
2736
+ writer.uint32(33).double(message.compliance);
2737
+ }
2738
+ if (message.state !== 0) {
2739
+ writer.uint32(40).int32(message.state);
2740
+ }
2741
+ return writer;
2742
+ },
2743
+
2744
+ decode(input: BinaryReader | Uint8Array, length?: number): SloTimelineBucket {
2745
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2746
+ const end = length === undefined ? reader.len : reader.pos + length;
2747
+ const message = createBaseSloTimelineBucket();
2748
+ while (reader.pos < end) {
2749
+ const tag = reader.uint32();
2750
+ switch (tag >>> 3) {
2751
+ case 1: {
2752
+ if (tag !== 10) {
2753
+ break;
2754
+ }
2755
+
2756
+ message.bucketStart = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
2757
+ continue;
2758
+ }
2759
+ case 2: {
2760
+ if (tag !== 16) {
2761
+ break;
2762
+ }
2763
+
2764
+ message.eligibleCount = longToNumber(reader.uint64());
2765
+ continue;
2766
+ }
2767
+ case 3: {
2768
+ if (tag !== 24) {
2769
+ break;
2770
+ }
2771
+
2772
+ message.goodCount = longToNumber(reader.uint64());
2773
+ continue;
2774
+ }
2775
+ case 4: {
2776
+ if (tag !== 33) {
2777
+ break;
2778
+ }
2779
+
2780
+ message.compliance = reader.double();
2781
+ continue;
2782
+ }
2783
+ case 5: {
2784
+ if (tag !== 40) {
2785
+ break;
2786
+ }
2787
+
2788
+ message.state = reader.int32() as any;
2789
+ continue;
2790
+ }
2791
+ }
2792
+ if ((tag & 7) === 4 || tag === 0) {
2793
+ break;
2794
+ }
2795
+ reader.skip(tag & 7);
2796
+ }
2797
+ return message;
2798
+ },
2799
+
2800
+ fromJSON(object: any): SloTimelineBucket {
2801
+ return {
2802
+ bucketStart: isSet(object.bucketStart)
2803
+ ? fromJsonTimestamp(object.bucketStart)
2804
+ : isSet(object.bucket_start)
2805
+ ? fromJsonTimestamp(object.bucket_start)
2806
+ : undefined,
2807
+ eligibleCount: isSet(object.eligibleCount)
2808
+ ? globalThis.Number(object.eligibleCount)
2809
+ : isSet(object.eligible_count)
2810
+ ? globalThis.Number(object.eligible_count)
2811
+ : 0,
2812
+ goodCount: isSet(object.goodCount)
2813
+ ? globalThis.Number(object.goodCount)
2814
+ : isSet(object.good_count)
2815
+ ? globalThis.Number(object.good_count)
2816
+ : 0,
2817
+ compliance: isSet(object.compliance) ? globalThis.Number(object.compliance) : 0,
2818
+ state: isSet(object.state) ? sloCorridorStateFromJSON(object.state) : 0,
2819
+ };
2820
+ },
2821
+
2822
+ toJSON(message: SloTimelineBucket): unknown {
2823
+ const obj: any = {};
2824
+ if (message.bucketStart !== undefined) {
2825
+ obj.bucketStart = message.bucketStart.toISOString();
2826
+ }
2827
+ if (message.eligibleCount !== 0) {
2828
+ obj.eligibleCount = Math.round(message.eligibleCount);
2829
+ }
2830
+ if (message.goodCount !== 0) {
2831
+ obj.goodCount = Math.round(message.goodCount);
2832
+ }
2833
+ if (message.compliance !== 0) {
2834
+ obj.compliance = message.compliance;
2835
+ }
2836
+ if (message.state !== 0) {
2837
+ obj.state = sloCorridorStateToJSON(message.state);
2838
+ }
2839
+ return obj;
2840
+ },
2841
+
2842
+ create<I extends Exact<DeepPartial<SloTimelineBucket>, I>>(base?: I): SloTimelineBucket {
2843
+ return SloTimelineBucket.fromPartial(base ?? ({} as any));
2844
+ },
2845
+ fromPartial<I extends Exact<DeepPartial<SloTimelineBucket>, I>>(object: I): SloTimelineBucket {
2846
+ const message = createBaseSloTimelineBucket();
2847
+ message.bucketStart = object.bucketStart ?? undefined;
2848
+ message.eligibleCount = object.eligibleCount ?? 0;
2849
+ message.goodCount = object.goodCount ?? 0;
2850
+ message.compliance = object.compliance ?? 0;
2851
+ message.state = object.state ?? 0;
2852
+ return message;
2853
+ },
2854
+ };
2855
+
2856
+ function createBasePreviewSloRequest(): PreviewSloRequest {
2857
+ return { organizationId: "", projectId: "", objective: undefined, evaluationTime: undefined, bucketCount: 0 };
2858
+ }
2859
+
2860
+ export const PreviewSloRequest: MessageFns<PreviewSloRequest> = {
2861
+ encode(message: PreviewSloRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2862
+ if (message.organizationId !== "") {
2863
+ writer.uint32(10).string(message.organizationId);
2864
+ }
2865
+ if (message.projectId !== "") {
2866
+ writer.uint32(18).string(message.projectId);
2867
+ }
2868
+ if (message.objective !== undefined) {
2869
+ SloObjective.encode(message.objective, writer.uint32(26).fork()).join();
2870
+ }
2871
+ if (message.evaluationTime !== undefined) {
2872
+ Timestamp.encode(toTimestamp(message.evaluationTime), writer.uint32(34).fork()).join();
2873
+ }
2874
+ if (message.bucketCount !== 0) {
2875
+ writer.uint32(40).uint32(message.bucketCount);
2876
+ }
2877
+ return writer;
2878
+ },
2879
+
2880
+ decode(input: BinaryReader | Uint8Array, length?: number): PreviewSloRequest {
2881
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2882
+ const end = length === undefined ? reader.len : reader.pos + length;
2883
+ const message = createBasePreviewSloRequest();
2884
+ while (reader.pos < end) {
2885
+ const tag = reader.uint32();
2886
+ switch (tag >>> 3) {
2887
+ case 1: {
2888
+ if (tag !== 10) {
2889
+ break;
2890
+ }
2891
+
2892
+ message.organizationId = reader.string();
2893
+ continue;
2894
+ }
2895
+ case 2: {
2896
+ if (tag !== 18) {
2897
+ break;
2898
+ }
2899
+
2900
+ message.projectId = reader.string();
2901
+ continue;
2902
+ }
2903
+ case 3: {
2904
+ if (tag !== 26) {
2905
+ break;
2906
+ }
2907
+
2908
+ message.objective = SloObjective.decode(reader, reader.uint32());
2909
+ continue;
2910
+ }
2911
+ case 4: {
2912
+ if (tag !== 34) {
2913
+ break;
2914
+ }
2915
+
2916
+ message.evaluationTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
2917
+ continue;
2918
+ }
2919
+ case 5: {
2920
+ if (tag !== 40) {
2921
+ break;
2922
+ }
2923
+
2924
+ message.bucketCount = reader.uint32();
2925
+ continue;
2926
+ }
2927
+ }
2928
+ if ((tag & 7) === 4 || tag === 0) {
2929
+ break;
2930
+ }
2931
+ reader.skip(tag & 7);
2932
+ }
2933
+ return message;
2934
+ },
2935
+
2936
+ fromJSON(object: any): PreviewSloRequest {
2937
+ return {
2938
+ organizationId: isSet(object.organizationId)
2939
+ ? globalThis.String(object.organizationId)
2940
+ : isSet(object.organization_id)
2941
+ ? globalThis.String(object.organization_id)
2942
+ : "",
2943
+ projectId: isSet(object.projectId)
2944
+ ? globalThis.String(object.projectId)
2945
+ : isSet(object.project_id)
2946
+ ? globalThis.String(object.project_id)
2947
+ : "",
2948
+ objective: isSet(object.objective) ? SloObjective.fromJSON(object.objective) : undefined,
2949
+ evaluationTime: isSet(object.evaluationTime)
2950
+ ? fromJsonTimestamp(object.evaluationTime)
2951
+ : isSet(object.evaluation_time)
2952
+ ? fromJsonTimestamp(object.evaluation_time)
2953
+ : undefined,
2954
+ bucketCount: isSet(object.bucketCount)
2955
+ ? globalThis.Number(object.bucketCount)
2956
+ : isSet(object.bucket_count)
2957
+ ? globalThis.Number(object.bucket_count)
2958
+ : 0,
2959
+ };
2960
+ },
2961
+
2962
+ toJSON(message: PreviewSloRequest): unknown {
2963
+ const obj: any = {};
2964
+ if (message.organizationId !== "") {
2965
+ obj.organizationId = message.organizationId;
2966
+ }
2967
+ if (message.projectId !== "") {
2968
+ obj.projectId = message.projectId;
2969
+ }
2970
+ if (message.objective !== undefined) {
2971
+ obj.objective = SloObjective.toJSON(message.objective);
2972
+ }
2973
+ if (message.evaluationTime !== undefined) {
2974
+ obj.evaluationTime = message.evaluationTime.toISOString();
2975
+ }
2976
+ if (message.bucketCount !== 0) {
2977
+ obj.bucketCount = Math.round(message.bucketCount);
2978
+ }
2979
+ return obj;
2980
+ },
2981
+
2982
+ create<I extends Exact<DeepPartial<PreviewSloRequest>, I>>(base?: I): PreviewSloRequest {
2983
+ return PreviewSloRequest.fromPartial(base ?? ({} as any));
2984
+ },
2985
+ fromPartial<I extends Exact<DeepPartial<PreviewSloRequest>, I>>(object: I): PreviewSloRequest {
2986
+ const message = createBasePreviewSloRequest();
2987
+ message.organizationId = object.organizationId ?? "";
2988
+ message.projectId = object.projectId ?? "";
2989
+ message.objective = (object.objective !== undefined && object.objective !== null)
2990
+ ? SloObjective.fromPartial(object.objective)
2991
+ : undefined;
2992
+ message.evaluationTime = object.evaluationTime ?? undefined;
2993
+ message.bucketCount = object.bucketCount ?? 0;
2994
+ return message;
2995
+ },
2996
+ };
2997
+
2998
+ function createBasePreviewSloResponse(): PreviewSloResponse {
2999
+ return { status: undefined, sloStatus: undefined, timeline: undefined };
3000
+ }
3001
+
3002
+ export const PreviewSloResponse: MessageFns<PreviewSloResponse> = {
3003
+ encode(message: PreviewSloResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
3004
+ if (message.status !== undefined) {
3005
+ ResponseStatus.encode(message.status, writer.uint32(10).fork()).join();
3006
+ }
3007
+ if (message.sloStatus !== undefined) {
3008
+ SloStatus.encode(message.sloStatus, writer.uint32(18).fork()).join();
3009
+ }
3010
+ if (message.timeline !== undefined) {
3011
+ SloTimeline.encode(message.timeline, writer.uint32(26).fork()).join();
3012
+ }
3013
+ return writer;
3014
+ },
3015
+
3016
+ decode(input: BinaryReader | Uint8Array, length?: number): PreviewSloResponse {
3017
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
3018
+ const end = length === undefined ? reader.len : reader.pos + length;
3019
+ const message = createBasePreviewSloResponse();
3020
+ while (reader.pos < end) {
3021
+ const tag = reader.uint32();
3022
+ switch (tag >>> 3) {
3023
+ case 1: {
3024
+ if (tag !== 10) {
3025
+ break;
3026
+ }
3027
+
3028
+ message.status = ResponseStatus.decode(reader, reader.uint32());
3029
+ continue;
3030
+ }
3031
+ case 2: {
3032
+ if (tag !== 18) {
3033
+ break;
3034
+ }
3035
+
3036
+ message.sloStatus = SloStatus.decode(reader, reader.uint32());
3037
+ continue;
3038
+ }
3039
+ case 3: {
3040
+ if (tag !== 26) {
3041
+ break;
3042
+ }
3043
+
3044
+ message.timeline = SloTimeline.decode(reader, reader.uint32());
3045
+ continue;
3046
+ }
3047
+ }
3048
+ if ((tag & 7) === 4 || tag === 0) {
3049
+ break;
3050
+ }
3051
+ reader.skip(tag & 7);
3052
+ }
3053
+ return message;
3054
+ },
3055
+
3056
+ fromJSON(object: any): PreviewSloResponse {
3057
+ return {
3058
+ status: isSet(object.status) ? ResponseStatus.fromJSON(object.status) : undefined,
3059
+ sloStatus: isSet(object.sloStatus)
3060
+ ? SloStatus.fromJSON(object.sloStatus)
3061
+ : isSet(object.slo_status)
3062
+ ? SloStatus.fromJSON(object.slo_status)
3063
+ : undefined,
3064
+ timeline: isSet(object.timeline) ? SloTimeline.fromJSON(object.timeline) : undefined,
3065
+ };
3066
+ },
3067
+
3068
+ toJSON(message: PreviewSloResponse): unknown {
3069
+ const obj: any = {};
3070
+ if (message.status !== undefined) {
3071
+ obj.status = ResponseStatus.toJSON(message.status);
3072
+ }
3073
+ if (message.sloStatus !== undefined) {
3074
+ obj.sloStatus = SloStatus.toJSON(message.sloStatus);
3075
+ }
3076
+ if (message.timeline !== undefined) {
3077
+ obj.timeline = SloTimeline.toJSON(message.timeline);
3078
+ }
3079
+ return obj;
3080
+ },
3081
+
3082
+ create<I extends Exact<DeepPartial<PreviewSloResponse>, I>>(base?: I): PreviewSloResponse {
3083
+ return PreviewSloResponse.fromPartial(base ?? ({} as any));
3084
+ },
3085
+ fromPartial<I extends Exact<DeepPartial<PreviewSloResponse>, I>>(object: I): PreviewSloResponse {
3086
+ const message = createBasePreviewSloResponse();
3087
+ message.status = (object.status !== undefined && object.status !== null)
3088
+ ? ResponseStatus.fromPartial(object.status)
3089
+ : undefined;
3090
+ message.sloStatus = (object.sloStatus !== undefined && object.sloStatus !== null)
3091
+ ? SloStatus.fromPartial(object.sloStatus)
3092
+ : undefined;
3093
+ message.timeline = (object.timeline !== undefined && object.timeline !== null)
3094
+ ? SloTimeline.fromPartial(object.timeline)
3095
+ : undefined;
3096
+ return message;
3097
+ },
3098
+ };
3099
+
3100
+ /** SloGatewayService provides web client access to SLO definitions. */
3101
+ export interface SloGatewayService {
3102
+ CreateSlo(request: CreateSloRequest, metadata?: Metadata): Promise<CreateSloResponse>;
3103
+ GetSlo(request: GetSloRequest, metadata?: Metadata): Promise<GetSloResponse>;
3104
+ ListSlos(request: ListSlosRequest, metadata?: Metadata): Promise<ListSlosResponse>;
3105
+ UpdateSlo(request: UpdateSloRequest, metadata?: Metadata): Promise<UpdateSloResponse>;
3106
+ DeleteSlo(request: DeleteSloRequest, metadata?: Metadata): Promise<DeleteSloResponse>;
3107
+ GetSloStatus(request: GetSloStatusRequest, metadata?: Metadata): Promise<GetSloStatusResponse>;
3108
+ GetSloTimeline(request: GetSloTimelineRequest, metadata?: Metadata): Promise<GetSloTimelineResponse>;
3109
+ /** PreviewSlo scores an unsaved objective (status + timeline) for the authoring UI. */
3110
+ PreviewSlo(request: PreviewSloRequest, metadata?: Metadata): Promise<PreviewSloResponse>;
3111
+ }
3112
+
3113
+ export const SloGatewayServiceServiceName = "gateway.web.v1.SloGatewayService";
3114
+ export class SloGatewayServiceClientImpl implements SloGatewayService {
3115
+ private readonly rpc: Rpc;
3116
+ private readonly service: string;
3117
+ constructor(rpc: Rpc, opts?: { service?: string }) {
3118
+ this.service = opts?.service || SloGatewayServiceServiceName;
3119
+ this.rpc = rpc;
3120
+ this.CreateSlo = this.CreateSlo.bind(this);
3121
+ this.GetSlo = this.GetSlo.bind(this);
3122
+ this.ListSlos = this.ListSlos.bind(this);
3123
+ this.UpdateSlo = this.UpdateSlo.bind(this);
3124
+ this.DeleteSlo = this.DeleteSlo.bind(this);
3125
+ this.GetSloStatus = this.GetSloStatus.bind(this);
3126
+ this.GetSloTimeline = this.GetSloTimeline.bind(this);
3127
+ this.PreviewSlo = this.PreviewSlo.bind(this);
3128
+ }
3129
+ CreateSlo(request: CreateSloRequest, metadata?: Metadata): Promise<CreateSloResponse> {
3130
+ const data = CreateSloRequest.encode(request).finish();
3131
+ const promise = this.rpc.request(this.service, "CreateSlo", data, metadata);
3132
+ return promise.then((data) => CreateSloResponse.decode(new BinaryReader(data)));
3133
+ }
3134
+
3135
+ GetSlo(request: GetSloRequest, metadata?: Metadata): Promise<GetSloResponse> {
3136
+ const data = GetSloRequest.encode(request).finish();
3137
+ const promise = this.rpc.request(this.service, "GetSlo", data, metadata);
3138
+ return promise.then((data) => GetSloResponse.decode(new BinaryReader(data)));
3139
+ }
3140
+
3141
+ ListSlos(request: ListSlosRequest, metadata?: Metadata): Promise<ListSlosResponse> {
3142
+ const data = ListSlosRequest.encode(request).finish();
3143
+ const promise = this.rpc.request(this.service, "ListSlos", data, metadata);
3144
+ return promise.then((data) => ListSlosResponse.decode(new BinaryReader(data)));
3145
+ }
3146
+
3147
+ UpdateSlo(request: UpdateSloRequest, metadata?: Metadata): Promise<UpdateSloResponse> {
3148
+ const data = UpdateSloRequest.encode(request).finish();
3149
+ const promise = this.rpc.request(this.service, "UpdateSlo", data, metadata);
3150
+ return promise.then((data) => UpdateSloResponse.decode(new BinaryReader(data)));
3151
+ }
3152
+
3153
+ DeleteSlo(request: DeleteSloRequest, metadata?: Metadata): Promise<DeleteSloResponse> {
3154
+ const data = DeleteSloRequest.encode(request).finish();
3155
+ const promise = this.rpc.request(this.service, "DeleteSlo", data, metadata);
3156
+ return promise.then((data) => DeleteSloResponse.decode(new BinaryReader(data)));
3157
+ }
3158
+
3159
+ GetSloStatus(request: GetSloStatusRequest, metadata?: Metadata): Promise<GetSloStatusResponse> {
3160
+ const data = GetSloStatusRequest.encode(request).finish();
3161
+ const promise = this.rpc.request(this.service, "GetSloStatus", data, metadata);
3162
+ return promise.then((data) => GetSloStatusResponse.decode(new BinaryReader(data)));
3163
+ }
3164
+
3165
+ GetSloTimeline(request: GetSloTimelineRequest, metadata?: Metadata): Promise<GetSloTimelineResponse> {
3166
+ const data = GetSloTimelineRequest.encode(request).finish();
3167
+ const promise = this.rpc.request(this.service, "GetSloTimeline", data, metadata);
3168
+ return promise.then((data) => GetSloTimelineResponse.decode(new BinaryReader(data)));
3169
+ }
3170
+
3171
+ PreviewSlo(request: PreviewSloRequest, metadata?: Metadata): Promise<PreviewSloResponse> {
3172
+ const data = PreviewSloRequest.encode(request).finish();
3173
+ const promise = this.rpc.request(this.service, "PreviewSlo", data, metadata);
3174
+ return promise.then((data) => PreviewSloResponse.decode(new BinaryReader(data)));
2310
3175
  }
2311
3176
  }
2312
3177