google-ads-api-client
Version:
A friendly and exhaustive client to the google-ads-api, code generated directly from google's published protobuf schema.
447 lines • 23.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.QuotaController = exports.QuotaError = exports.AllocateQuotaResponse = exports.QuotaOperation = exports.AllocateQuotaRequest = exports.QuotaError_Code = exports.QuotaOperation_QuotaMode = void 0;
// @generated by protobuf-ts 2.8.1
// @generated from protobuf file "google/api/servicecontrol/v1/quota_controller.proto" (package "google.api.servicecontrol.v1", syntax proto3)
// tslint:disable
//
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
const runtime_rpc_1 = require("@protobuf-ts/runtime-rpc");
const runtime_1 = require("@protobuf-ts/runtime");
const runtime_2 = require("@protobuf-ts/runtime");
const runtime_3 = require("@protobuf-ts/runtime");
const runtime_4 = require("@protobuf-ts/runtime");
const runtime_5 = require("@protobuf-ts/runtime");
const status_1 = require("../../../rpc/status");
const metric_value_1 = require("./metric_value");
/**
* Supported quota modes.
*
* @generated from protobuf enum google.api.servicecontrol.v1.QuotaOperation.QuotaMode
*/
var QuotaOperation_QuotaMode;
(function (QuotaOperation_QuotaMode) {
/**
* Guard against implicit default. Must not be used.
*
* @generated from protobuf enum value: UNSPECIFIED = 0;
*/
QuotaOperation_QuotaMode[QuotaOperation_QuotaMode["UNSPECIFIED"] = 0] = "UNSPECIFIED";
/**
* For AllocateQuota request, allocates quota for the amount specified in
* the service configuration or specified using the quota metrics. If the
* amount is higher than the available quota, allocation error will be
* returned and no quota will be allocated.
* If multiple quotas are part of the request, and one fails, none of the
* quotas are allocated or released.
*
* @generated from protobuf enum value: NORMAL = 1;
*/
QuotaOperation_QuotaMode[QuotaOperation_QuotaMode["NORMAL"] = 1] = "NORMAL";
/**
* The operation allocates quota for the amount specified in the service
* configuration or specified using the quota metrics. If the amount is
* higher than the available quota, request does not fail but all available
* quota will be allocated.
* For rate quota, BEST_EFFORT will continue to deduct from other groups
* even if one does not have enough quota. For allocation, it will find the
* minimum available amount across all groups and deduct that amount from
* all the affected groups.
*
* @generated from protobuf enum value: BEST_EFFORT = 2;
*/
QuotaOperation_QuotaMode[QuotaOperation_QuotaMode["BEST_EFFORT"] = 2] = "BEST_EFFORT";
/**
* For AllocateQuota request, only checks if there is enough quota
* available and does not change the available quota. No lock is placed on
* the available quota either.
*
* @generated from protobuf enum value: CHECK_ONLY = 3;
*/
QuotaOperation_QuotaMode[QuotaOperation_QuotaMode["CHECK_ONLY"] = 3] = "CHECK_ONLY";
/**
* Unimplemented. When used in AllocateQuotaRequest, this returns the
* effective quota limit(s) in the response, and no quota check will be
* performed. Not supported for other requests, and even for
* AllocateQuotaRequest, this is currently supported only for allowlisted
* services.
*
* @generated from protobuf enum value: QUERY_ONLY = 4;
*/
QuotaOperation_QuotaMode[QuotaOperation_QuotaMode["QUERY_ONLY"] = 4] = "QUERY_ONLY";
/**
* The operation allocates quota for the amount specified in the service
* configuration or specified using the quota metrics. If the requested
* amount is higher than the available quota, request does not fail and
* remaining quota would become negative (going over the limit).
* Not supported for Rate Quota.
*
* @generated from protobuf enum value: ADJUST_ONLY = 5;
*/
QuotaOperation_QuotaMode[QuotaOperation_QuotaMode["ADJUST_ONLY"] = 5] = "ADJUST_ONLY";
})(QuotaOperation_QuotaMode = exports.QuotaOperation_QuotaMode || (exports.QuotaOperation_QuotaMode = {}));
/**
* Error codes related to project config validations are deprecated since the
* quota controller methods do not perform these validations. Instead services
* have to call the Check method, without quota_properties field, to perform
* these validations before calling the quota controller methods. These
* methods check only for project deletion to be wipe out compliant.
*
* @generated from protobuf enum google.api.servicecontrol.v1.QuotaError.Code
*/
var QuotaError_Code;
(function (QuotaError_Code) {
/**
* This is never used.
*
* @generated from protobuf enum value: UNSPECIFIED = 0;
*/
QuotaError_Code[QuotaError_Code["UNSPECIFIED"] = 0] = "UNSPECIFIED";
/**
* Quota allocation failed.
* Same as [google.rpc.Code.RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED].
*
* @generated from protobuf enum value: RESOURCE_EXHAUSTED = 8;
*/
QuotaError_Code[QuotaError_Code["RESOURCE_EXHAUSTED"] = 8] = "RESOURCE_EXHAUSTED";
/**
* Consumer cannot access the service because the service requires active
* billing.
*
* @generated from protobuf enum value: BILLING_NOT_ACTIVE = 107;
*/
QuotaError_Code[QuotaError_Code["BILLING_NOT_ACTIVE"] = 107] = "BILLING_NOT_ACTIVE";
/**
* Consumer's project has been marked as deleted (soft deletion).
*
* @generated from protobuf enum value: PROJECT_DELETED = 108;
*/
QuotaError_Code[QuotaError_Code["PROJECT_DELETED"] = 108] = "PROJECT_DELETED";
/**
* Specified API key is invalid.
*
* @generated from protobuf enum value: API_KEY_INVALID = 105;
*/
QuotaError_Code[QuotaError_Code["API_KEY_INVALID"] = 105] = "API_KEY_INVALID";
/**
* Specified API Key has expired.
*
* @generated from protobuf enum value: API_KEY_EXPIRED = 112;
*/
QuotaError_Code[QuotaError_Code["API_KEY_EXPIRED"] = 112] = "API_KEY_EXPIRED";
})(QuotaError_Code = exports.QuotaError_Code || (exports.QuotaError_Code = {}));
// @generated message type with reflection information, may provide speed optimized methods
class AllocateQuotaRequest$Type extends runtime_5.MessageType {
constructor() {
super("google.api.servicecontrol.v1.AllocateQuotaRequest", [
{ no: 1, name: "service_name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: "allocate_operation", kind: "message", T: () => exports.QuotaOperation },
{ no: 4, name: "service_config_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
]);
}
create(value) {
const message = { serviceName: "", serviceConfigId: "" };
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
(0, runtime_3.reflectionMergePartial)(this, message, value);
return message;
}
internalBinaryRead(reader, length, options, target) {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* string service_name */ 1:
message.serviceName = reader.string();
break;
case /* google.api.servicecontrol.v1.QuotaOperation allocate_operation */ 2:
message.allocateOperation = exports.QuotaOperation.internalBinaryRead(reader, reader.uint32(), options, message.allocateOperation);
break;
case /* string service_config_id */ 4:
message.serviceConfigId = reader.string();
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? runtime_2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message, writer, options) {
/* string service_name = 1; */
if (message.serviceName !== "")
writer.tag(1, runtime_1.WireType.LengthDelimited).string(message.serviceName);
/* google.api.servicecontrol.v1.QuotaOperation allocate_operation = 2; */
if (message.allocateOperation)
exports.QuotaOperation.internalBinaryWrite(message.allocateOperation, writer.tag(2, runtime_1.WireType.LengthDelimited).fork(), options).join();
/* string service_config_id = 4; */
if (message.serviceConfigId !== "")
writer.tag(4, runtime_1.WireType.LengthDelimited).string(message.serviceConfigId);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message google.api.servicecontrol.v1.AllocateQuotaRequest
*/
exports.AllocateQuotaRequest = new AllocateQuotaRequest$Type();
// @generated message type with reflection information, may provide speed optimized methods
class QuotaOperation$Type extends runtime_5.MessageType {
constructor() {
super("google.api.servicecontrol.v1.QuotaOperation", [
{ no: 1, name: "operation_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: "method_name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 3, name: "consumer_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 4, name: "labels", kind: "map", K: 9 /*ScalarType.STRING*/, V: { kind: "scalar", T: 9 /*ScalarType.STRING*/ } },
{ no: 5, name: "quota_metrics", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => metric_value_1.MetricValueSet },
{ no: 6, name: "quota_mode", kind: "enum", T: () => ["google.api.servicecontrol.v1.QuotaOperation.QuotaMode", QuotaOperation_QuotaMode] }
]);
}
create(value) {
const message = { operationId: "", methodName: "", consumerId: "", labels: {}, quotaMetrics: [], quotaMode: 0 };
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
(0, runtime_3.reflectionMergePartial)(this, message, value);
return message;
}
internalBinaryRead(reader, length, options, target) {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* string operation_id */ 1:
message.operationId = reader.string();
break;
case /* string method_name */ 2:
message.methodName = reader.string();
break;
case /* string consumer_id */ 3:
message.consumerId = reader.string();
break;
case /* map<string, string> labels */ 4:
this.binaryReadMap4(message.labels, reader, options);
break;
case /* repeated google.api.servicecontrol.v1.MetricValueSet quota_metrics */ 5:
message.quotaMetrics.push(metric_value_1.MetricValueSet.internalBinaryRead(reader, reader.uint32(), options));
break;
case /* google.api.servicecontrol.v1.QuotaOperation.QuotaMode quota_mode */ 6:
message.quotaMode = reader.int32();
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? runtime_2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
binaryReadMap4(map, reader, options) {
let len = reader.uint32(), end = reader.pos + len, key, val;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case 1:
key = reader.string();
break;
case 2:
val = reader.string();
break;
default: throw new globalThis.Error("unknown map entry field for field google.api.servicecontrol.v1.QuotaOperation.labels");
}
}
map[key ?? ""] = val ?? "";
}
internalBinaryWrite(message, writer, options) {
/* string operation_id = 1; */
if (message.operationId !== "")
writer.tag(1, runtime_1.WireType.LengthDelimited).string(message.operationId);
/* string method_name = 2; */
if (message.methodName !== "")
writer.tag(2, runtime_1.WireType.LengthDelimited).string(message.methodName);
/* string consumer_id = 3; */
if (message.consumerId !== "")
writer.tag(3, runtime_1.WireType.LengthDelimited).string(message.consumerId);
/* map<string, string> labels = 4; */
for (let k of Object.keys(message.labels))
writer.tag(4, runtime_1.WireType.LengthDelimited).fork().tag(1, runtime_1.WireType.LengthDelimited).string(k).tag(2, runtime_1.WireType.LengthDelimited).string(message.labels[k]).join();
/* repeated google.api.servicecontrol.v1.MetricValueSet quota_metrics = 5; */
for (let i = 0; i < message.quotaMetrics.length; i++)
metric_value_1.MetricValueSet.internalBinaryWrite(message.quotaMetrics[i], writer.tag(5, runtime_1.WireType.LengthDelimited).fork(), options).join();
/* google.api.servicecontrol.v1.QuotaOperation.QuotaMode quota_mode = 6; */
if (message.quotaMode !== 0)
writer.tag(6, runtime_1.WireType.Varint).int32(message.quotaMode);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message google.api.servicecontrol.v1.QuotaOperation
*/
exports.QuotaOperation = new QuotaOperation$Type();
// @generated message type with reflection information, may provide speed optimized methods
class AllocateQuotaResponse$Type extends runtime_5.MessageType {
constructor() {
super("google.api.servicecontrol.v1.AllocateQuotaResponse", [
{ no: 1, name: "operation_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: "allocate_errors", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => exports.QuotaError },
{ no: 3, name: "quota_metrics", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => metric_value_1.MetricValueSet },
{ no: 4, name: "service_config_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
]);
}
create(value) {
const message = { operationId: "", allocateErrors: [], quotaMetrics: [], serviceConfigId: "" };
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
(0, runtime_3.reflectionMergePartial)(this, message, value);
return message;
}
internalBinaryRead(reader, length, options, target) {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* string operation_id */ 1:
message.operationId = reader.string();
break;
case /* repeated google.api.servicecontrol.v1.QuotaError allocate_errors */ 2:
message.allocateErrors.push(exports.QuotaError.internalBinaryRead(reader, reader.uint32(), options));
break;
case /* repeated google.api.servicecontrol.v1.MetricValueSet quota_metrics */ 3:
message.quotaMetrics.push(metric_value_1.MetricValueSet.internalBinaryRead(reader, reader.uint32(), options));
break;
case /* string service_config_id */ 4:
message.serviceConfigId = reader.string();
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? runtime_2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message, writer, options) {
/* string operation_id = 1; */
if (message.operationId !== "")
writer.tag(1, runtime_1.WireType.LengthDelimited).string(message.operationId);
/* repeated google.api.servicecontrol.v1.QuotaError allocate_errors = 2; */
for (let i = 0; i < message.allocateErrors.length; i++)
exports.QuotaError.internalBinaryWrite(message.allocateErrors[i], writer.tag(2, runtime_1.WireType.LengthDelimited).fork(), options).join();
/* repeated google.api.servicecontrol.v1.MetricValueSet quota_metrics = 3; */
for (let i = 0; i < message.quotaMetrics.length; i++)
metric_value_1.MetricValueSet.internalBinaryWrite(message.quotaMetrics[i], writer.tag(3, runtime_1.WireType.LengthDelimited).fork(), options).join();
/* string service_config_id = 4; */
if (message.serviceConfigId !== "")
writer.tag(4, runtime_1.WireType.LengthDelimited).string(message.serviceConfigId);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message google.api.servicecontrol.v1.AllocateQuotaResponse
*/
exports.AllocateQuotaResponse = new AllocateQuotaResponse$Type();
// @generated message type with reflection information, may provide speed optimized methods
class QuotaError$Type extends runtime_5.MessageType {
constructor() {
super("google.api.servicecontrol.v1.QuotaError", [
{ no: 1, name: "code", kind: "enum", T: () => ["google.api.servicecontrol.v1.QuotaError.Code", QuotaError_Code] },
{ no: 2, name: "subject", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 3, name: "description", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 4, name: "status", kind: "message", T: () => status_1.Status }
]);
}
create(value) {
const message = { code: 0, subject: "", description: "" };
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
(0, runtime_3.reflectionMergePartial)(this, message, value);
return message;
}
internalBinaryRead(reader, length, options, target) {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* google.api.servicecontrol.v1.QuotaError.Code code */ 1:
message.code = reader.int32();
break;
case /* string subject */ 2:
message.subject = reader.string();
break;
case /* string description */ 3:
message.description = reader.string();
break;
case /* google.rpc.Status status */ 4:
message.status = status_1.Status.internalBinaryRead(reader, reader.uint32(), options, message.status);
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? runtime_2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message, writer, options) {
/* google.api.servicecontrol.v1.QuotaError.Code code = 1; */
if (message.code !== 0)
writer.tag(1, runtime_1.WireType.Varint).int32(message.code);
/* string subject = 2; */
if (message.subject !== "")
writer.tag(2, runtime_1.WireType.LengthDelimited).string(message.subject);
/* string description = 3; */
if (message.description !== "")
writer.tag(3, runtime_1.WireType.LengthDelimited).string(message.description);
/* google.rpc.Status status = 4; */
if (message.status)
status_1.Status.internalBinaryWrite(message.status, writer.tag(4, runtime_1.WireType.LengthDelimited).fork(), options).join();
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message google.api.servicecontrol.v1.QuotaError
*/
exports.QuotaError = new QuotaError$Type();
/**
* @generated ServiceType for protobuf service google.api.servicecontrol.v1.QuotaController
*/
exports.QuotaController = new runtime_rpc_1.ServiceType("google.api.servicecontrol.v1.QuotaController", [
{ name: "AllocateQuota", options: { "google.api.http": { post: "/v1/services/{service_name}:allocateQuota", body: "*" } }, I: exports.AllocateQuotaRequest, O: exports.AllocateQuotaResponse }
], { "google.api.default_host": "servicecontrol.googleapis.com", "google.api.oauth_scopes": "https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/servicecontrol" });
//# sourceMappingURL=quota_controller.js.map