go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/milo/ui/src/proto/google/rpc/status.pb.ts (about) 1 /* eslint-disable */ 2 import _m0 from "protobufjs/minimal"; 3 import { Any } from "../protobuf/any.pb"; 4 5 export const protobufPackage = "google.rpc"; 6 7 /** 8 * The `Status` type defines a logical error model that is suitable for 9 * different programming environments, including REST APIs and RPC APIs. It is 10 * used by [gRPC](https://github.com/grpc). Each `Status` message contains 11 * three pieces of data: error code, error message, and error details. 12 * 13 * You can find out more about this error model and how to work with it in the 14 * [API Design Guide](https://cloud.google.com/apis/design/errors). 15 */ 16 export interface Status { 17 /** 18 * The status code, which should be an enum value of 19 * [google.rpc.Code][google.rpc.Code]. 20 */ 21 readonly code: number; 22 /** 23 * A developer-facing error message, which should be in English. Any 24 * user-facing error message should be localized and sent in the 25 * [google.rpc.Status.details][google.rpc.Status.details] field, or localized 26 * by the client. 27 */ 28 readonly message: string; 29 /** 30 * A list of messages that carry the error details. There is a common set of 31 * message types for APIs to use. 32 */ 33 readonly details: readonly Any[]; 34 } 35 36 function createBaseStatus(): Status { 37 return { code: 0, message: "", details: [] }; 38 } 39 40 export const Status = { 41 encode(message: Status, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 42 if (message.code !== 0) { 43 writer.uint32(8).int32(message.code); 44 } 45 if (message.message !== "") { 46 writer.uint32(18).string(message.message); 47 } 48 for (const v of message.details) { 49 Any.encode(v!, writer.uint32(26).fork()).ldelim(); 50 } 51 return writer; 52 }, 53 54 decode(input: _m0.Reader | Uint8Array, length?: number): Status { 55 const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); 56 let end = length === undefined ? reader.len : reader.pos + length; 57 const message = createBaseStatus() as any; 58 while (reader.pos < end) { 59 const tag = reader.uint32(); 60 switch (tag >>> 3) { 61 case 1: 62 if (tag !== 8) { 63 break; 64 } 65 66 message.code = reader.int32(); 67 continue; 68 case 2: 69 if (tag !== 18) { 70 break; 71 } 72 73 message.message = reader.string(); 74 continue; 75 case 3: 76 if (tag !== 26) { 77 break; 78 } 79 80 message.details.push(Any.decode(reader, reader.uint32())); 81 continue; 82 } 83 if ((tag & 7) === 4 || tag === 0) { 84 break; 85 } 86 reader.skipType(tag & 7); 87 } 88 return message; 89 }, 90 91 fromJSON(object: any): Status { 92 return { 93 code: isSet(object.code) ? globalThis.Number(object.code) : 0, 94 message: isSet(object.message) ? globalThis.String(object.message) : "", 95 details: globalThis.Array.isArray(object?.details) ? object.details.map((e: any) => Any.fromJSON(e)) : [], 96 }; 97 }, 98 99 toJSON(message: Status): unknown { 100 const obj: any = {}; 101 if (message.code !== 0) { 102 obj.code = Math.round(message.code); 103 } 104 if (message.message !== "") { 105 obj.message = message.message; 106 } 107 if (message.details?.length) { 108 obj.details = message.details.map((e) => Any.toJSON(e)); 109 } 110 return obj; 111 }, 112 113 create<I extends Exact<DeepPartial<Status>, I>>(base?: I): Status { 114 return Status.fromPartial(base ?? ({} as any)); 115 }, 116 fromPartial<I extends Exact<DeepPartial<Status>, I>>(object: I): Status { 117 const message = createBaseStatus() as any; 118 message.code = object.code ?? 0; 119 message.message = object.message ?? ""; 120 message.details = object.details?.map((e) => Any.fromPartial(e)) || []; 121 return message; 122 }, 123 }; 124 125 type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 126 127 export type DeepPartial<T> = T extends Builtin ? T 128 : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> 129 : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> 130 : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> } 131 : Partial<T>; 132 133 type KeysOfUnion<T> = T extends T ? keyof T : never; 134 export type Exact<P, I extends P> = P extends Builtin ? P 135 : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never }; 136 137 function isSet(value: any): boolean { 138 return value !== null && value !== undefined; 139 }