@cerbos/http
Version:
Client library for interacting with the Cerbos policy decision point service over HTTP from browser-based applications
189 lines (165 loc) • 4.85 kB
text/typescript
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// source: grpc/health/v1/health.proto
/* eslint-disable */
export const protobufPackage = "grpc.health.v1";
export interface HealthCheckRequest {
service: string;
}
export interface HealthCheckResponse {
status: HealthCheckResponse_ServingStatus;
}
export enum HealthCheckResponse_ServingStatus {
UNKNOWN = 0,
SERVING = 1,
NOT_SERVING = 2,
SERVICE_UNKNOWN = 3,
}
export function healthCheckResponse_ServingStatusFromJSON(
object: any,
): HealthCheckResponse_ServingStatus {
switch (object) {
case 0:
case "UNKNOWN":
return HealthCheckResponse_ServingStatus.UNKNOWN;
case 1:
case "SERVING":
return HealthCheckResponse_ServingStatus.SERVING;
case 2:
case "NOT_SERVING":
return HealthCheckResponse_ServingStatus.NOT_SERVING;
case 3:
case "SERVICE_UNKNOWN":
return HealthCheckResponse_ServingStatus.SERVICE_UNKNOWN;
default:
throw new globalThis.Error(
"Unrecognized enum value " +
object +
" for enum HealthCheckResponse_ServingStatus",
);
}
}
export function healthCheckResponse_ServingStatusToJSON(
object: HealthCheckResponse_ServingStatus,
): string {
switch (object) {
case HealthCheckResponse_ServingStatus.UNKNOWN:
return "UNKNOWN";
case HealthCheckResponse_ServingStatus.SERVING:
return "SERVING";
case HealthCheckResponse_ServingStatus.NOT_SERVING:
return "NOT_SERVING";
case HealthCheckResponse_ServingStatus.SERVICE_UNKNOWN:
return "SERVICE_UNKNOWN";
default:
throw new globalThis.Error(
"Unrecognized enum value " +
object +
" for enum HealthCheckResponse_ServingStatus",
);
}
}
export interface HealthListRequest {}
export interface HealthListResponse {
statuses: { [key: string]: HealthCheckResponse };
}
export interface HealthListResponse_StatusesEntry {
key: string;
value: HealthCheckResponse | undefined;
}
export const HealthCheckRequest: MessageFns<HealthCheckRequest> = {
fromJSON(object: any): HealthCheckRequest {
return {
service: isSet(object.service) ? globalThis.String(object.service) : "",
};
},
toJSON(message: HealthCheckRequest): unknown {
const obj: any = {};
if (message.service !== "") {
obj.service = message.service;
}
return obj;
},
};
export const HealthCheckResponse: MessageFns<HealthCheckResponse> = {
fromJSON(object: any): HealthCheckResponse {
return {
status: isSet(object.status)
? healthCheckResponse_ServingStatusFromJSON(object.status)
: 0,
};
},
toJSON(message: HealthCheckResponse): unknown {
const obj: any = {};
if (message.status !== 0) {
obj.status = healthCheckResponse_ServingStatusToJSON(message.status);
}
return obj;
},
};
export const HealthListRequest: MessageFns<HealthListRequest> = {
fromJSON(_: any): HealthListRequest {
return {};
},
toJSON(_: HealthListRequest): unknown {
const obj: any = {};
return obj;
},
};
export const HealthListResponse: MessageFns<HealthListResponse> = {
fromJSON(object: any): HealthListResponse {
return {
statuses: isObject(object.statuses)
? Object.entries(object.statuses).reduce<{
[key: string]: HealthCheckResponse;
}>((acc, [key, value]) => {
acc[key] = HealthCheckResponse.fromJSON(value);
return acc;
}, {})
: {},
};
},
toJSON(message: HealthListResponse): unknown {
const obj: any = {};
if (message.statuses) {
const entries = Object.entries(message.statuses);
if (entries.length > 0) {
obj.statuses = {};
entries.forEach(([k, v]) => {
obj.statuses[k] = HealthCheckResponse.toJSON(v);
});
}
}
return obj;
},
};
export const HealthListResponse_StatusesEntry: MessageFns<HealthListResponse_StatusesEntry> =
{
fromJSON(object: any): HealthListResponse_StatusesEntry {
return {
key: isSet(object.key) ? globalThis.String(object.key) : "",
value: isSet(object.value)
? HealthCheckResponse.fromJSON(object.value)
: undefined,
};
},
toJSON(message: HealthListResponse_StatusesEntry): unknown {
const obj: any = {};
if (message.key !== "") {
obj.key = message.key;
}
if (message.value !== undefined) {
obj.value = HealthCheckResponse.toJSON(message.value);
}
return obj;
},
};
function isObject(value: any): boolean {
return typeof value === "object" && value !== null;
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
export interface MessageFns<T> {
fromJSON(object: any): T;
toJSON(message: T): unknown;
}