@yandex-cloud/nodejs-sdk
Version:
Yandex.Cloud NodeJS SDK
140 lines (139 loc) • 5.39 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Group = exports.protobufPackage = void 0;
/* eslint-disable */
const typeRegistry_1 = require("../../../../typeRegistry");
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const timestamp_1 = require("../../../../google/protobuf/timestamp");
exports.protobufPackage = "yandex.cloud.organizationmanager.v1";
const baseGroup = {
$type: "yandex.cloud.organizationmanager.v1.Group",
id: "",
organizationId: "",
name: "",
description: "",
};
exports.Group = {
$type: "yandex.cloud.organizationmanager.v1.Group",
encode(message, writer = minimal_1.default.Writer.create()) {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
if (message.organizationId !== "") {
writer.uint32(18).string(message.organizationId);
}
if (message.createdAt !== undefined) {
timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(26).fork()).ldelim();
}
if (message.name !== "") {
writer.uint32(34).string(message.name);
}
if (message.description !== "") {
writer.uint32(42).string(message.description);
}
return writer;
},
decode(input, length) {
const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = Object.assign({}, baseGroup);
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.id = reader.string();
break;
case 2:
message.organizationId = reader.string();
break;
case 3:
message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
break;
case 4:
message.name = reader.string();
break;
case 5:
message.description = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(object) {
const message = Object.assign({}, baseGroup);
message.id =
object.id !== undefined && object.id !== null ? String(object.id) : "";
message.organizationId =
object.organizationId !== undefined && object.organizationId !== null
? String(object.organizationId)
: "";
message.createdAt =
object.createdAt !== undefined && object.createdAt !== null
? fromJsonTimestamp(object.createdAt)
: undefined;
message.name =
object.name !== undefined && object.name !== null
? String(object.name)
: "";
message.description =
object.description !== undefined && object.description !== null
? String(object.description)
: "";
return message;
},
toJSON(message) {
const obj = {};
message.id !== undefined && (obj.id = message.id);
message.organizationId !== undefined &&
(obj.organizationId = message.organizationId);
message.createdAt !== undefined &&
(obj.createdAt = message.createdAt.toISOString());
message.name !== undefined && (obj.name = message.name);
message.description !== undefined &&
(obj.description = message.description);
return obj;
},
fromPartial(object) {
var _a, _b, _c, _d, _e;
const message = Object.assign({}, baseGroup);
message.id = (_a = object.id) !== null && _a !== void 0 ? _a : "";
message.organizationId = (_b = object.organizationId) !== null && _b !== void 0 ? _b : "";
message.createdAt = (_c = object.createdAt) !== null && _c !== void 0 ? _c : undefined;
message.name = (_d = object.name) !== null && _d !== void 0 ? _d : "";
message.description = (_e = object.description) !== null && _e !== void 0 ? _e : "";
return message;
},
};
typeRegistry_1.messageTypeRegistry.set(exports.Group.$type, exports.Group);
function toTimestamp(date) {
const seconds = date.getTime() / 1000;
const nanos = (date.getTime() % 1000) * 1000000;
return { $type: "google.protobuf.Timestamp", seconds, nanos };
}
function fromTimestamp(t) {
let millis = t.seconds * 1000;
millis += t.nanos / 1000000;
return new Date(millis);
}
function fromJsonTimestamp(o) {
if (o instanceof Date) {
return o;
}
else if (typeof o === "string") {
return new Date(o);
}
else {
return fromTimestamp(timestamp_1.Timestamp.fromJSON(o));
}
}
if (minimal_1.default.util.Long !== long_1.default) {
minimal_1.default.util.Long = long_1.default;
minimal_1.default.configure();
}