From c7b280105d79c69ea01a3e490a712c940a851a32 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 30 Nov 2020 09:07:21 -0800 Subject: [PATCH] feat: add the Tailing API to get a live stream of the tail end of filtered logs (#958) PiperOrigin-RevId: 344435830 Source-Author: Google APIs Source-Date: Thu Nov 26 09:56:05 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: e8857c4c36948e7e0500377cd7fcecbf2459afc8 Source-Link: https://github.com/googleapis/googleapis/commit/e8857c4c36948e7e0500377cd7fcecbf2459afc8 --- protos/google/logging/v2/logging.proto | 99 +++ protos/protos.d.ts | 334 ++++++++ protos/protos.js | 822 +++++++++++++++++++ protos/protos.json | 89 ++ src/v2/logging_service_v2_client.ts | 86 ++ src/v2/logging_service_v2_client_config.json | 5 + synth.metadata | 6 +- test/gapic_logging_service_v2_v2.ts | 102 +++ 8 files changed, 1540 insertions(+), 3 deletions(-) diff --git a/protos/google/logging/v2/logging.proto b/protos/google/logging/v2/logging.proto index 58647b92..f8b01a71 100644 --- a/protos/google/logging/v2/logging.proto +++ b/protos/google/logging/v2/logging.proto @@ -125,6 +125,15 @@ service LoggingServiceV2 { }; option (google.api.method_signature) = "parent"; } + + // Streaming read of log entries as they are ingested. Until the stream is + // terminated, it will continue reading logs. + rpc TailLogEntries(stream TailLogEntriesRequest) returns (stream TailLogEntriesResponse) { + option (google.api.http) = { + post: "/v2/entries:tail" + body: "*" + }; + } } // The parameters to DeleteLog. @@ -254,6 +263,11 @@ message ListLogEntriesRequest { // "billingAccounts/[BILLING_ACCOUNT_ID]" // "folders/[FOLDER_ID]" // + // May alternatively be one or more views + // projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + // organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + // billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + // folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] // // Projects listed in the `project_ids` field are added to this list. repeated string resource_names = 8 [ @@ -363,6 +377,19 @@ message ListLogsRequest { // `nextPageToken` from the previous response. The values of other method // parameters should be identical to those in the previous call. string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The resource name that owns the logs: + // projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + // organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + // billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + // folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + // + // To support legacy queries, it could also be: + // "projects/[PROJECT_ID]" + // "organizations/[ORGANIZATION_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]" + // "folders/[FOLDER_ID]" + repeated string resource_names = 8 [(google.api.field_behavior) = OPTIONAL]; } // Result returned from ListLogs. @@ -377,3 +404,75 @@ message ListLogsResponse { // method again using the value of `nextPageToken` as `pageToken`. string next_page_token = 2; } + +// The parameters to `TailLogEntries`. +message TailLogEntriesRequest { + // Required. Name of a parent resource from which to retrieve log entries: + // + // "projects/[PROJECT_ID]" + // "organizations/[ORGANIZATION_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]" + // "folders/[FOLDER_ID]" + // + // May alternatively be one or more views: + // "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + // "organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + // "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + // "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + repeated string resource_names = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. A filter that chooses which log entries to return. See [Advanced + // Logs Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + // Only log entries that match the filter are returned. An empty filter + // matches all log entries in the resources listed in `resource_names`. + // Referencing a parent resource that is not in `resource_names` will cause + // the filter to return no results. The maximum length of the filter is 20000 + // characters. + string filter = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The amount of time to buffer log entries at the server before + // being returned to prevent out of order results due to late arriving log + // entries. Valid values are between 0-60000 milliseconds. Defaults to 2000 + // milliseconds. + google.protobuf.Duration buffer_window = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Result returned from `TailLogEntries`. +message TailLogEntriesResponse { + // Information about entries that were omitted from the session. + message SuppressionInfo { + // An indicator of why entries were omitted. + enum Reason { + // Unexpected default. + REASON_UNSPECIFIED = 0; + + // Indicates suppression occurred due to relevant entries being + // received in excess of rate limits. For quotas and limits, see + // [Logging API quotas and + // limits](https://cloud.google.com/logging/quotas#api-limits). + RATE_LIMIT = 1; + + // Indicates suppression occurred due to the client not consuming + // responses quickly enough. + NOT_CONSUMED = 2; + } + + // The reason that entries were omitted from the session. + Reason reason = 1; + + // A lower bound on the count of entries omitted due to `reason`. + int32 suppressed_count = 2; + } + + // A list of log entries. Each response in the stream will order entries with + // increasing values of `LogEntry.timestamp`. Ordering is not guaranteed + // between separate responses. + repeated LogEntry entries = 1; + + // If entries that otherwise would have been included in the session were not + // sent back to the client, counts of relevant entries omitted from the + // session with the reason that they were not included. There will be at most + // one of each reason per response. The counts represent the number of + // suppressed entries since the last streamed response. + repeated SuppressionInfo suppression_info = 2; +} diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 8f48ec83..e759458e 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -505,6 +505,20 @@ export namespace google { * @returns Promise */ public listLogs(request: google.logging.v2.IListLogsRequest): Promise; + + /** + * Calls TailLogEntries. + * @param request TailLogEntriesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and TailLogEntriesResponse + */ + public tailLogEntries(request: google.logging.v2.ITailLogEntriesRequest, callback: google.logging.v2.LoggingServiceV2.TailLogEntriesCallback): void; + + /** + * Calls TailLogEntries. + * @param request TailLogEntriesRequest message or plain object + * @returns Promise + */ + public tailLogEntries(request: google.logging.v2.ITailLogEntriesRequest): Promise; } namespace LoggingServiceV2 { @@ -543,6 +557,13 @@ export namespace google { * @param [response] ListLogsResponse */ type ListLogsCallback = (error: (Error|null), response?: google.logging.v2.ListLogsResponse) => void; + + /** + * Callback as used by {@link google.logging.v2.LoggingServiceV2#tailLogEntries}. + * @param error Error, if any + * @param [response] TailLogEntriesResponse + */ + type TailLogEntriesCallback = (error: (Error|null), response?: google.logging.v2.TailLogEntriesResponse) => void; } /** Properties of a DeleteLogRequest. */ @@ -1342,6 +1363,9 @@ export namespace google { /** ListLogsRequest pageToken */ pageToken?: (string|null); + + /** ListLogsRequest resourceNames */ + resourceNames?: (string[]|null); } /** Represents a ListLogsRequest. */ @@ -1362,6 +1386,9 @@ export namespace google { /** ListLogsRequest pageToken. */ public pageToken: string; + /** ListLogsRequest resourceNames. */ + public resourceNames: string[]; + /** * Creates a new ListLogsRequest instance using the specified properties. * @param [properties] Properties to set @@ -1529,6 +1556,313 @@ export namespace google { public toJSON(): { [k: string]: any }; } + /** Properties of a TailLogEntriesRequest. */ + interface ITailLogEntriesRequest { + + /** TailLogEntriesRequest resourceNames */ + resourceNames?: (string[]|null); + + /** TailLogEntriesRequest filter */ + filter?: (string|null); + + /** TailLogEntriesRequest bufferWindow */ + bufferWindow?: (google.protobuf.IDuration|null); + } + + /** Represents a TailLogEntriesRequest. */ + class TailLogEntriesRequest implements ITailLogEntriesRequest { + + /** + * Constructs a new TailLogEntriesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.logging.v2.ITailLogEntriesRequest); + + /** TailLogEntriesRequest resourceNames. */ + public resourceNames: string[]; + + /** TailLogEntriesRequest filter. */ + public filter: string; + + /** TailLogEntriesRequest bufferWindow. */ + public bufferWindow?: (google.protobuf.IDuration|null); + + /** + * Creates a new TailLogEntriesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns TailLogEntriesRequest instance + */ + public static create(properties?: google.logging.v2.ITailLogEntriesRequest): google.logging.v2.TailLogEntriesRequest; + + /** + * Encodes the specified TailLogEntriesRequest message. Does not implicitly {@link google.logging.v2.TailLogEntriesRequest.verify|verify} messages. + * @param message TailLogEntriesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.logging.v2.ITailLogEntriesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TailLogEntriesRequest message, length delimited. Does not implicitly {@link google.logging.v2.TailLogEntriesRequest.verify|verify} messages. + * @param message TailLogEntriesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.logging.v2.ITailLogEntriesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TailLogEntriesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TailLogEntriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.logging.v2.TailLogEntriesRequest; + + /** + * Decodes a TailLogEntriesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TailLogEntriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.logging.v2.TailLogEntriesRequest; + + /** + * Verifies a TailLogEntriesRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a TailLogEntriesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TailLogEntriesRequest + */ + public static fromObject(object: { [k: string]: any }): google.logging.v2.TailLogEntriesRequest; + + /** + * Creates a plain object from a TailLogEntriesRequest message. Also converts values to other types if specified. + * @param message TailLogEntriesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.logging.v2.TailLogEntriesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TailLogEntriesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a TailLogEntriesResponse. */ + interface ITailLogEntriesResponse { + + /** TailLogEntriesResponse entries */ + entries?: (google.logging.v2.ILogEntry[]|null); + + /** TailLogEntriesResponse suppressionInfo */ + suppressionInfo?: (google.logging.v2.TailLogEntriesResponse.ISuppressionInfo[]|null); + } + + /** Represents a TailLogEntriesResponse. */ + class TailLogEntriesResponse implements ITailLogEntriesResponse { + + /** + * Constructs a new TailLogEntriesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.logging.v2.ITailLogEntriesResponse); + + /** TailLogEntriesResponse entries. */ + public entries: google.logging.v2.ILogEntry[]; + + /** TailLogEntriesResponse suppressionInfo. */ + public suppressionInfo: google.logging.v2.TailLogEntriesResponse.ISuppressionInfo[]; + + /** + * Creates a new TailLogEntriesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns TailLogEntriesResponse instance + */ + public static create(properties?: google.logging.v2.ITailLogEntriesResponse): google.logging.v2.TailLogEntriesResponse; + + /** + * Encodes the specified TailLogEntriesResponse message. Does not implicitly {@link google.logging.v2.TailLogEntriesResponse.verify|verify} messages. + * @param message TailLogEntriesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.logging.v2.ITailLogEntriesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TailLogEntriesResponse message, length delimited. Does not implicitly {@link google.logging.v2.TailLogEntriesResponse.verify|verify} messages. + * @param message TailLogEntriesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.logging.v2.ITailLogEntriesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TailLogEntriesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TailLogEntriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.logging.v2.TailLogEntriesResponse; + + /** + * Decodes a TailLogEntriesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TailLogEntriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.logging.v2.TailLogEntriesResponse; + + /** + * Verifies a TailLogEntriesResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a TailLogEntriesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TailLogEntriesResponse + */ + public static fromObject(object: { [k: string]: any }): google.logging.v2.TailLogEntriesResponse; + + /** + * Creates a plain object from a TailLogEntriesResponse message. Also converts values to other types if specified. + * @param message TailLogEntriesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.logging.v2.TailLogEntriesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TailLogEntriesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace TailLogEntriesResponse { + + /** Properties of a SuppressionInfo. */ + interface ISuppressionInfo { + + /** SuppressionInfo reason */ + reason?: (google.logging.v2.TailLogEntriesResponse.SuppressionInfo.Reason|keyof typeof google.logging.v2.TailLogEntriesResponse.SuppressionInfo.Reason|null); + + /** SuppressionInfo suppressedCount */ + suppressedCount?: (number|null); + } + + /** Represents a SuppressionInfo. */ + class SuppressionInfo implements ISuppressionInfo { + + /** + * Constructs a new SuppressionInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.logging.v2.TailLogEntriesResponse.ISuppressionInfo); + + /** SuppressionInfo reason. */ + public reason: (google.logging.v2.TailLogEntriesResponse.SuppressionInfo.Reason|keyof typeof google.logging.v2.TailLogEntriesResponse.SuppressionInfo.Reason); + + /** SuppressionInfo suppressedCount. */ + public suppressedCount: number; + + /** + * Creates a new SuppressionInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns SuppressionInfo instance + */ + public static create(properties?: google.logging.v2.TailLogEntriesResponse.ISuppressionInfo): google.logging.v2.TailLogEntriesResponse.SuppressionInfo; + + /** + * Encodes the specified SuppressionInfo message. Does not implicitly {@link google.logging.v2.TailLogEntriesResponse.SuppressionInfo.verify|verify} messages. + * @param message SuppressionInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.logging.v2.TailLogEntriesResponse.ISuppressionInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SuppressionInfo message, length delimited. Does not implicitly {@link google.logging.v2.TailLogEntriesResponse.SuppressionInfo.verify|verify} messages. + * @param message SuppressionInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.logging.v2.TailLogEntriesResponse.ISuppressionInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SuppressionInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SuppressionInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.logging.v2.TailLogEntriesResponse.SuppressionInfo; + + /** + * Decodes a SuppressionInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SuppressionInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.logging.v2.TailLogEntriesResponse.SuppressionInfo; + + /** + * Verifies a SuppressionInfo message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SuppressionInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SuppressionInfo + */ + public static fromObject(object: { [k: string]: any }): google.logging.v2.TailLogEntriesResponse.SuppressionInfo; + + /** + * Creates a plain object from a SuppressionInfo message. Also converts values to other types if specified. + * @param message SuppressionInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.logging.v2.TailLogEntriesResponse.SuppressionInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SuppressionInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace SuppressionInfo { + + /** Reason enum. */ + enum Reason { + REASON_UNSPECIFIED = 0, + RATE_LIMIT = 1, + NOT_CONSUMED = 2 + } + } + } + /** Represents a ConfigServiceV2 */ class ConfigServiceV2 extends $protobuf.rpc.Service { diff --git a/protos/protos.js b/protos/protos.js index 1152314c..0cdfa140 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -1429,6 +1429,39 @@ * @variation 2 */ + /** + * Callback as used by {@link google.logging.v2.LoggingServiceV2#tailLogEntries}. + * @memberof google.logging.v2.LoggingServiceV2 + * @typedef TailLogEntriesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.TailLogEntriesResponse} [response] TailLogEntriesResponse + */ + + /** + * Calls TailLogEntries. + * @function tailLogEntries + * @memberof google.logging.v2.LoggingServiceV2 + * @instance + * @param {google.logging.v2.ITailLogEntriesRequest} request TailLogEntriesRequest message or plain object + * @param {google.logging.v2.LoggingServiceV2.TailLogEntriesCallback} callback Node-style callback called with the error, if any, and TailLogEntriesResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(LoggingServiceV2.prototype.tailLogEntries = function tailLogEntries(request, callback) { + return this.rpcCall(tailLogEntries, $root.google.logging.v2.TailLogEntriesRequest, $root.google.logging.v2.TailLogEntriesResponse, request, callback); + }, "name", { value: "TailLogEntries" }); + + /** + * Calls TailLogEntries. + * @function tailLogEntries + * @memberof google.logging.v2.LoggingServiceV2 + * @instance + * @param {google.logging.v2.ITailLogEntriesRequest} request TailLogEntriesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + return LoggingServiceV2; })(); @@ -3347,6 +3380,7 @@ * @property {string|null} [parent] ListLogsRequest parent * @property {number|null} [pageSize] ListLogsRequest pageSize * @property {string|null} [pageToken] ListLogsRequest pageToken + * @property {Array.|null} [resourceNames] ListLogsRequest resourceNames */ /** @@ -3358,6 +3392,7 @@ * @param {google.logging.v2.IListLogsRequest=} [properties] Properties to set */ function ListLogsRequest(properties) { + this.resourceNames = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -3388,6 +3423,14 @@ */ ListLogsRequest.prototype.pageToken = ""; + /** + * ListLogsRequest resourceNames. + * @member {Array.} resourceNames + * @memberof google.logging.v2.ListLogsRequest + * @instance + */ + ListLogsRequest.prototype.resourceNames = $util.emptyArray; + /** * Creates a new ListLogsRequest instance using the specified properties. * @function create @@ -3418,6 +3461,9 @@ writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); + if (message.resourceNames != null && message.resourceNames.length) + for (var i = 0; i < message.resourceNames.length; ++i) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.resourceNames[i]); return writer; }; @@ -3461,6 +3507,11 @@ case 3: message.pageToken = reader.string(); break; + case 8: + if (!(message.resourceNames && message.resourceNames.length)) + message.resourceNames = []; + message.resourceNames.push(reader.string()); + break; default: reader.skipType(tag & 7); break; @@ -3505,6 +3556,13 @@ if (message.pageToken != null && message.hasOwnProperty("pageToken")) if (!$util.isString(message.pageToken)) return "pageToken: string expected"; + if (message.resourceNames != null && message.hasOwnProperty("resourceNames")) { + if (!Array.isArray(message.resourceNames)) + return "resourceNames: array expected"; + for (var i = 0; i < message.resourceNames.length; ++i) + if (!$util.isString(message.resourceNames[i])) + return "resourceNames: string[] expected"; + } return null; }; @@ -3526,6 +3584,13 @@ message.pageSize = object.pageSize | 0; if (object.pageToken != null) message.pageToken = String(object.pageToken); + if (object.resourceNames) { + if (!Array.isArray(object.resourceNames)) + throw TypeError(".google.logging.v2.ListLogsRequest.resourceNames: array expected"); + message.resourceNames = []; + for (var i = 0; i < object.resourceNames.length; ++i) + message.resourceNames[i] = String(object.resourceNames[i]); + } return message; }; @@ -3542,6 +3607,8 @@ if (!options) options = {}; var object = {}; + if (options.arrays || options.defaults) + object.resourceNames = []; if (options.defaults) { object.parent = ""; object.pageSize = 0; @@ -3553,6 +3620,11 @@ object.pageSize = message.pageSize; if (message.pageToken != null && message.hasOwnProperty("pageToken")) object.pageToken = message.pageToken; + if (message.resourceNames && message.resourceNames.length) { + object.resourceNames = []; + for (var j = 0; j < message.resourceNames.length; ++j) + object.resourceNames[j] = message.resourceNames[j]; + } return object; }; @@ -3796,6 +3868,756 @@ return ListLogsResponse; })(); + v2.TailLogEntriesRequest = (function() { + + /** + * Properties of a TailLogEntriesRequest. + * @memberof google.logging.v2 + * @interface ITailLogEntriesRequest + * @property {Array.|null} [resourceNames] TailLogEntriesRequest resourceNames + * @property {string|null} [filter] TailLogEntriesRequest filter + * @property {google.protobuf.IDuration|null} [bufferWindow] TailLogEntriesRequest bufferWindow + */ + + /** + * Constructs a new TailLogEntriesRequest. + * @memberof google.logging.v2 + * @classdesc Represents a TailLogEntriesRequest. + * @implements ITailLogEntriesRequest + * @constructor + * @param {google.logging.v2.ITailLogEntriesRequest=} [properties] Properties to set + */ + function TailLogEntriesRequest(properties) { + this.resourceNames = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * TailLogEntriesRequest resourceNames. + * @member {Array.} resourceNames + * @memberof google.logging.v2.TailLogEntriesRequest + * @instance + */ + TailLogEntriesRequest.prototype.resourceNames = $util.emptyArray; + + /** + * TailLogEntriesRequest filter. + * @member {string} filter + * @memberof google.logging.v2.TailLogEntriesRequest + * @instance + */ + TailLogEntriesRequest.prototype.filter = ""; + + /** + * TailLogEntriesRequest bufferWindow. + * @member {google.protobuf.IDuration|null|undefined} bufferWindow + * @memberof google.logging.v2.TailLogEntriesRequest + * @instance + */ + TailLogEntriesRequest.prototype.bufferWindow = null; + + /** + * Creates a new TailLogEntriesRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.TailLogEntriesRequest + * @static + * @param {google.logging.v2.ITailLogEntriesRequest=} [properties] Properties to set + * @returns {google.logging.v2.TailLogEntriesRequest} TailLogEntriesRequest instance + */ + TailLogEntriesRequest.create = function create(properties) { + return new TailLogEntriesRequest(properties); + }; + + /** + * Encodes the specified TailLogEntriesRequest message. Does not implicitly {@link google.logging.v2.TailLogEntriesRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.TailLogEntriesRequest + * @static + * @param {google.logging.v2.ITailLogEntriesRequest} message TailLogEntriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TailLogEntriesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.resourceNames != null && message.resourceNames.length) + for (var i = 0; i < message.resourceNames.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.resourceNames[i]); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.filter); + if (message.bufferWindow != null && Object.hasOwnProperty.call(message, "bufferWindow")) + $root.google.protobuf.Duration.encode(message.bufferWindow, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified TailLogEntriesRequest message, length delimited. Does not implicitly {@link google.logging.v2.TailLogEntriesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.TailLogEntriesRequest + * @static + * @param {google.logging.v2.ITailLogEntriesRequest} message TailLogEntriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TailLogEntriesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TailLogEntriesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.TailLogEntriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.TailLogEntriesRequest} TailLogEntriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TailLogEntriesRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.logging.v2.TailLogEntriesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.resourceNames && message.resourceNames.length)) + message.resourceNames = []; + message.resourceNames.push(reader.string()); + break; + case 2: + message.filter = reader.string(); + break; + case 3: + message.bufferWindow = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TailLogEntriesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.TailLogEntriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.TailLogEntriesRequest} TailLogEntriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TailLogEntriesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TailLogEntriesRequest message. + * @function verify + * @memberof google.logging.v2.TailLogEntriesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TailLogEntriesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.resourceNames != null && message.hasOwnProperty("resourceNames")) { + if (!Array.isArray(message.resourceNames)) + return "resourceNames: array expected"; + for (var i = 0; i < message.resourceNames.length; ++i) + if (!$util.isString(message.resourceNames[i])) + return "resourceNames: string[] expected"; + } + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.bufferWindow != null && message.hasOwnProperty("bufferWindow")) { + var error = $root.google.protobuf.Duration.verify(message.bufferWindow); + if (error) + return "bufferWindow." + error; + } + return null; + }; + + /** + * Creates a TailLogEntriesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.TailLogEntriesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.TailLogEntriesRequest} TailLogEntriesRequest + */ + TailLogEntriesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.logging.v2.TailLogEntriesRequest) + return object; + var message = new $root.google.logging.v2.TailLogEntriesRequest(); + if (object.resourceNames) { + if (!Array.isArray(object.resourceNames)) + throw TypeError(".google.logging.v2.TailLogEntriesRequest.resourceNames: array expected"); + message.resourceNames = []; + for (var i = 0; i < object.resourceNames.length; ++i) + message.resourceNames[i] = String(object.resourceNames[i]); + } + if (object.filter != null) + message.filter = String(object.filter); + if (object.bufferWindow != null) { + if (typeof object.bufferWindow !== "object") + throw TypeError(".google.logging.v2.TailLogEntriesRequest.bufferWindow: object expected"); + message.bufferWindow = $root.google.protobuf.Duration.fromObject(object.bufferWindow); + } + return message; + }; + + /** + * Creates a plain object from a TailLogEntriesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.TailLogEntriesRequest + * @static + * @param {google.logging.v2.TailLogEntriesRequest} message TailLogEntriesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TailLogEntriesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.resourceNames = []; + if (options.defaults) { + object.filter = ""; + object.bufferWindow = null; + } + if (message.resourceNames && message.resourceNames.length) { + object.resourceNames = []; + for (var j = 0; j < message.resourceNames.length; ++j) + object.resourceNames[j] = message.resourceNames[j]; + } + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.bufferWindow != null && message.hasOwnProperty("bufferWindow")) + object.bufferWindow = $root.google.protobuf.Duration.toObject(message.bufferWindow, options); + return object; + }; + + /** + * Converts this TailLogEntriesRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.TailLogEntriesRequest + * @instance + * @returns {Object.} JSON object + */ + TailLogEntriesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return TailLogEntriesRequest; + })(); + + v2.TailLogEntriesResponse = (function() { + + /** + * Properties of a TailLogEntriesResponse. + * @memberof google.logging.v2 + * @interface ITailLogEntriesResponse + * @property {Array.|null} [entries] TailLogEntriesResponse entries + * @property {Array.|null} [suppressionInfo] TailLogEntriesResponse suppressionInfo + */ + + /** + * Constructs a new TailLogEntriesResponse. + * @memberof google.logging.v2 + * @classdesc Represents a TailLogEntriesResponse. + * @implements ITailLogEntriesResponse + * @constructor + * @param {google.logging.v2.ITailLogEntriesResponse=} [properties] Properties to set + */ + function TailLogEntriesResponse(properties) { + this.entries = []; + this.suppressionInfo = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * TailLogEntriesResponse entries. + * @member {Array.} entries + * @memberof google.logging.v2.TailLogEntriesResponse + * @instance + */ + TailLogEntriesResponse.prototype.entries = $util.emptyArray; + + /** + * TailLogEntriesResponse suppressionInfo. + * @member {Array.} suppressionInfo + * @memberof google.logging.v2.TailLogEntriesResponse + * @instance + */ + TailLogEntriesResponse.prototype.suppressionInfo = $util.emptyArray; + + /** + * Creates a new TailLogEntriesResponse instance using the specified properties. + * @function create + * @memberof google.logging.v2.TailLogEntriesResponse + * @static + * @param {google.logging.v2.ITailLogEntriesResponse=} [properties] Properties to set + * @returns {google.logging.v2.TailLogEntriesResponse} TailLogEntriesResponse instance + */ + TailLogEntriesResponse.create = function create(properties) { + return new TailLogEntriesResponse(properties); + }; + + /** + * Encodes the specified TailLogEntriesResponse message. Does not implicitly {@link google.logging.v2.TailLogEntriesResponse.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.TailLogEntriesResponse + * @static + * @param {google.logging.v2.ITailLogEntriesResponse} message TailLogEntriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TailLogEntriesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.entries != null && message.entries.length) + for (var i = 0; i < message.entries.length; ++i) + $root.google.logging.v2.LogEntry.encode(message.entries[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.suppressionInfo != null && message.suppressionInfo.length) + for (var i = 0; i < message.suppressionInfo.length; ++i) + $root.google.logging.v2.TailLogEntriesResponse.SuppressionInfo.encode(message.suppressionInfo[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified TailLogEntriesResponse message, length delimited. Does not implicitly {@link google.logging.v2.TailLogEntriesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.TailLogEntriesResponse + * @static + * @param {google.logging.v2.ITailLogEntriesResponse} message TailLogEntriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TailLogEntriesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TailLogEntriesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.TailLogEntriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.TailLogEntriesResponse} TailLogEntriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TailLogEntriesResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.logging.v2.TailLogEntriesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.entries && message.entries.length)) + message.entries = []; + message.entries.push($root.google.logging.v2.LogEntry.decode(reader, reader.uint32())); + break; + case 2: + if (!(message.suppressionInfo && message.suppressionInfo.length)) + message.suppressionInfo = []; + message.suppressionInfo.push($root.google.logging.v2.TailLogEntriesResponse.SuppressionInfo.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TailLogEntriesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.TailLogEntriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.TailLogEntriesResponse} TailLogEntriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TailLogEntriesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TailLogEntriesResponse message. + * @function verify + * @memberof google.logging.v2.TailLogEntriesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TailLogEntriesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.entries != null && message.hasOwnProperty("entries")) { + if (!Array.isArray(message.entries)) + return "entries: array expected"; + for (var i = 0; i < message.entries.length; ++i) { + var error = $root.google.logging.v2.LogEntry.verify(message.entries[i]); + if (error) + return "entries." + error; + } + } + if (message.suppressionInfo != null && message.hasOwnProperty("suppressionInfo")) { + if (!Array.isArray(message.suppressionInfo)) + return "suppressionInfo: array expected"; + for (var i = 0; i < message.suppressionInfo.length; ++i) { + var error = $root.google.logging.v2.TailLogEntriesResponse.SuppressionInfo.verify(message.suppressionInfo[i]); + if (error) + return "suppressionInfo." + error; + } + } + return null; + }; + + /** + * Creates a TailLogEntriesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.TailLogEntriesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.TailLogEntriesResponse} TailLogEntriesResponse + */ + TailLogEntriesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.logging.v2.TailLogEntriesResponse) + return object; + var message = new $root.google.logging.v2.TailLogEntriesResponse(); + if (object.entries) { + if (!Array.isArray(object.entries)) + throw TypeError(".google.logging.v2.TailLogEntriesResponse.entries: array expected"); + message.entries = []; + for (var i = 0; i < object.entries.length; ++i) { + if (typeof object.entries[i] !== "object") + throw TypeError(".google.logging.v2.TailLogEntriesResponse.entries: object expected"); + message.entries[i] = $root.google.logging.v2.LogEntry.fromObject(object.entries[i]); + } + } + if (object.suppressionInfo) { + if (!Array.isArray(object.suppressionInfo)) + throw TypeError(".google.logging.v2.TailLogEntriesResponse.suppressionInfo: array expected"); + message.suppressionInfo = []; + for (var i = 0; i < object.suppressionInfo.length; ++i) { + if (typeof object.suppressionInfo[i] !== "object") + throw TypeError(".google.logging.v2.TailLogEntriesResponse.suppressionInfo: object expected"); + message.suppressionInfo[i] = $root.google.logging.v2.TailLogEntriesResponse.SuppressionInfo.fromObject(object.suppressionInfo[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a TailLogEntriesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.TailLogEntriesResponse + * @static + * @param {google.logging.v2.TailLogEntriesResponse} message TailLogEntriesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TailLogEntriesResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.entries = []; + object.suppressionInfo = []; + } + if (message.entries && message.entries.length) { + object.entries = []; + for (var j = 0; j < message.entries.length; ++j) + object.entries[j] = $root.google.logging.v2.LogEntry.toObject(message.entries[j], options); + } + if (message.suppressionInfo && message.suppressionInfo.length) { + object.suppressionInfo = []; + for (var j = 0; j < message.suppressionInfo.length; ++j) + object.suppressionInfo[j] = $root.google.logging.v2.TailLogEntriesResponse.SuppressionInfo.toObject(message.suppressionInfo[j], options); + } + return object; + }; + + /** + * Converts this TailLogEntriesResponse to JSON. + * @function toJSON + * @memberof google.logging.v2.TailLogEntriesResponse + * @instance + * @returns {Object.} JSON object + */ + TailLogEntriesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + TailLogEntriesResponse.SuppressionInfo = (function() { + + /** + * Properties of a SuppressionInfo. + * @memberof google.logging.v2.TailLogEntriesResponse + * @interface ISuppressionInfo + * @property {google.logging.v2.TailLogEntriesResponse.SuppressionInfo.Reason|null} [reason] SuppressionInfo reason + * @property {number|null} [suppressedCount] SuppressionInfo suppressedCount + */ + + /** + * Constructs a new SuppressionInfo. + * @memberof google.logging.v2.TailLogEntriesResponse + * @classdesc Represents a SuppressionInfo. + * @implements ISuppressionInfo + * @constructor + * @param {google.logging.v2.TailLogEntriesResponse.ISuppressionInfo=} [properties] Properties to set + */ + function SuppressionInfo(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SuppressionInfo reason. + * @member {google.logging.v2.TailLogEntriesResponse.SuppressionInfo.Reason} reason + * @memberof google.logging.v2.TailLogEntriesResponse.SuppressionInfo + * @instance + */ + SuppressionInfo.prototype.reason = 0; + + /** + * SuppressionInfo suppressedCount. + * @member {number} suppressedCount + * @memberof google.logging.v2.TailLogEntriesResponse.SuppressionInfo + * @instance + */ + SuppressionInfo.prototype.suppressedCount = 0; + + /** + * Creates a new SuppressionInfo instance using the specified properties. + * @function create + * @memberof google.logging.v2.TailLogEntriesResponse.SuppressionInfo + * @static + * @param {google.logging.v2.TailLogEntriesResponse.ISuppressionInfo=} [properties] Properties to set + * @returns {google.logging.v2.TailLogEntriesResponse.SuppressionInfo} SuppressionInfo instance + */ + SuppressionInfo.create = function create(properties) { + return new SuppressionInfo(properties); + }; + + /** + * Encodes the specified SuppressionInfo message. Does not implicitly {@link google.logging.v2.TailLogEntriesResponse.SuppressionInfo.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.TailLogEntriesResponse.SuppressionInfo + * @static + * @param {google.logging.v2.TailLogEntriesResponse.ISuppressionInfo} message SuppressionInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SuppressionInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.reason != null && Object.hasOwnProperty.call(message, "reason")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.reason); + if (message.suppressedCount != null && Object.hasOwnProperty.call(message, "suppressedCount")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.suppressedCount); + return writer; + }; + + /** + * Encodes the specified SuppressionInfo message, length delimited. Does not implicitly {@link google.logging.v2.TailLogEntriesResponse.SuppressionInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.TailLogEntriesResponse.SuppressionInfo + * @static + * @param {google.logging.v2.TailLogEntriesResponse.ISuppressionInfo} message SuppressionInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SuppressionInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SuppressionInfo message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.TailLogEntriesResponse.SuppressionInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.TailLogEntriesResponse.SuppressionInfo} SuppressionInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SuppressionInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.logging.v2.TailLogEntriesResponse.SuppressionInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reason = reader.int32(); + break; + case 2: + message.suppressedCount = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SuppressionInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.TailLogEntriesResponse.SuppressionInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.TailLogEntriesResponse.SuppressionInfo} SuppressionInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SuppressionInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SuppressionInfo message. + * @function verify + * @memberof google.logging.v2.TailLogEntriesResponse.SuppressionInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SuppressionInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.reason != null && message.hasOwnProperty("reason")) + switch (message.reason) { + default: + return "reason: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.suppressedCount != null && message.hasOwnProperty("suppressedCount")) + if (!$util.isInteger(message.suppressedCount)) + return "suppressedCount: integer expected"; + return null; + }; + + /** + * Creates a SuppressionInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.TailLogEntriesResponse.SuppressionInfo + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.TailLogEntriesResponse.SuppressionInfo} SuppressionInfo + */ + SuppressionInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.logging.v2.TailLogEntriesResponse.SuppressionInfo) + return object; + var message = new $root.google.logging.v2.TailLogEntriesResponse.SuppressionInfo(); + switch (object.reason) { + case "REASON_UNSPECIFIED": + case 0: + message.reason = 0; + break; + case "RATE_LIMIT": + case 1: + message.reason = 1; + break; + case "NOT_CONSUMED": + case 2: + message.reason = 2; + break; + } + if (object.suppressedCount != null) + message.suppressedCount = object.suppressedCount | 0; + return message; + }; + + /** + * Creates a plain object from a SuppressionInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.TailLogEntriesResponse.SuppressionInfo + * @static + * @param {google.logging.v2.TailLogEntriesResponse.SuppressionInfo} message SuppressionInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SuppressionInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.reason = options.enums === String ? "REASON_UNSPECIFIED" : 0; + object.suppressedCount = 0; + } + if (message.reason != null && message.hasOwnProperty("reason")) + object.reason = options.enums === String ? $root.google.logging.v2.TailLogEntriesResponse.SuppressionInfo.Reason[message.reason] : message.reason; + if (message.suppressedCount != null && message.hasOwnProperty("suppressedCount")) + object.suppressedCount = message.suppressedCount; + return object; + }; + + /** + * Converts this SuppressionInfo to JSON. + * @function toJSON + * @memberof google.logging.v2.TailLogEntriesResponse.SuppressionInfo + * @instance + * @returns {Object.} JSON object + */ + SuppressionInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Reason enum. + * @name google.logging.v2.TailLogEntriesResponse.SuppressionInfo.Reason + * @enum {number} + * @property {number} REASON_UNSPECIFIED=0 REASON_UNSPECIFIED value + * @property {number} RATE_LIMIT=1 RATE_LIMIT value + * @property {number} NOT_CONSUMED=2 NOT_CONSUMED value + */ + SuppressionInfo.Reason = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "REASON_UNSPECIFIED"] = 0; + values[valuesById[1] = "RATE_LIMIT"] = 1; + values[valuesById[2] = "NOT_CONSUMED"] = 2; + return values; + })(); + + return SuppressionInfo; + })(); + + return TailLogEntriesResponse; + })(); + v2.ConfigServiceV2 = (function() { /** diff --git a/protos/protos.json b/protos/protos.json index e81cee95..1bc64efb 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -322,6 +322,24 @@ "(google.api.method_signature)": "parent" } ] + }, + "TailLogEntries": { + "requestType": "TailLogEntriesRequest", + "requestStream": true, + "responseType": "TailLogEntriesResponse", + "responseStream": true, + "options": { + "(google.api.http).post": "/v2/entries:tail", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/entries:tail", + "body": "*" + } + } + ] } } }, @@ -506,6 +524,14 @@ "options": { "(google.api.field_behavior)": "OPTIONAL" } + }, + "resourceNames": { + "rule": "repeated", + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -522,6 +548,69 @@ } } }, + "TailLogEntriesRequest": { + "fields": { + "resourceNames": { + "rule": "repeated", + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "filter": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "bufferWindow": { + "type": "google.protobuf.Duration", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "TailLogEntriesResponse": { + "fields": { + "entries": { + "rule": "repeated", + "type": "LogEntry", + "id": 1 + }, + "suppressionInfo": { + "rule": "repeated", + "type": "SuppressionInfo", + "id": 2 + } + }, + "nested": { + "SuppressionInfo": { + "fields": { + "reason": { + "type": "Reason", + "id": 1 + }, + "suppressedCount": { + "type": "int32", + "id": 2 + } + }, + "nested": { + "Reason": { + "values": { + "REASON_UNSPECIFIED": 0, + "RATE_LIMIT": 1, + "NOT_CONSUMED": 2 + } + } + } + } + } + }, "ConfigServiceV2": { "options": { "(google.api.default_host)": "logging.googleapis.com", diff --git a/src/v2/logging_service_v2_client.ts b/src/v2/logging_service_v2_client.ts index 8f6919ca..f7c71708 100644 --- a/src/v2/logging_service_v2_client.ts +++ b/src/v2/logging_service_v2_client.ts @@ -267,6 +267,14 @@ export class LoggingServiceV2Client { ), }; + // Some of the methods on this service provide streaming responses. + // Provide descriptors for these. + this.descriptors.stream = { + tailLogEntries: new this._gaxModule.StreamDescriptor( + gax.StreamType.BIDI_STREAMING + ), + }; + // This API contains "long-running operations", which return a // an Operation object that allows for tracking of the operation, // rather than holding a request open. @@ -343,6 +351,7 @@ export class LoggingServiceV2Client { 'listLogEntries', 'listMonitoredResourceDescriptors', 'listLogs', + 'tailLogEntries', ]; for (const methodName of loggingServiceV2StubMethods) { const callPromise = this.loggingServiceV2Stub.then( @@ -360,6 +369,7 @@ export class LoggingServiceV2Client { const descriptor = this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || this.descriptors.batching?.[methodName] || undefined; const apiCall = this._gaxModule.createApiCall( @@ -680,6 +690,31 @@ export class LoggingServiceV2Client { return this.innerApiCalls.writeLogEntries(request, options, callback); } + /** + * Streaming read of log entries as they are ingested. Until the stream is + * terminated, it will continue reading logs. + * + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which is both readable and writable. It accepts objects + * representing [TailLogEntriesRequest]{@link google.logging.v2.TailLogEntriesRequest} for write() method, and + * will emit objects representing [TailLogEntriesResponse]{@link google.logging.v2.TailLogEntriesResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example + * const stream = client.tailLogEntries(); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); + * stream.write(request); + * stream.end(); + */ + tailLogEntries(options?: CallOptions): gax.CancellableStream { + this.initialize(); + return this.innerApiCalls.tailLogEntries(options); + } + listLogEntries( request: protos.google.logging.v2.IListLogEntriesRequest, options?: CallOptions @@ -724,6 +759,11 @@ export class LoggingServiceV2Client { * "billingAccounts/[BILLING_ACCOUNT_ID]" * "folders/[FOLDER_ID]" * + * May alternatively be one or more views + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] * * Projects listed in the `project_ids` field are added to this list. * @param {string} [request.filter] @@ -811,6 +851,11 @@ export class LoggingServiceV2Client { * "billingAccounts/[BILLING_ACCOUNT_ID]" * "folders/[FOLDER_ID]" * + * May alternatively be one or more views + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] * * Projects listed in the `project_ids` field are added to this list. * @param {string} [request.filter] @@ -880,6 +925,11 @@ export class LoggingServiceV2Client { * "billingAccounts/[BILLING_ACCOUNT_ID]" * "folders/[FOLDER_ID]" * + * May alternatively be one or more views + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] * * Projects listed in the `project_ids` field are added to this list. * @param {string} [request.filter] @@ -1173,6 +1223,18 @@ export class LoggingServiceV2Client { * preceding call to this method. `pageToken` must be the value of * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. + * @param {string[]} [request.resourceNames] + * Optional. The resource name that owns the logs: + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * + * To support legacy queries, it could also be: + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -1247,6 +1309,18 @@ export class LoggingServiceV2Client { * preceding call to this method. `pageToken` must be the value of * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. + * @param {string[]} [request.resourceNames] + * Optional. The resource name that owns the logs: + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * + * To support legacy queries, it could also be: + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} @@ -1303,6 +1377,18 @@ export class LoggingServiceV2Client { * preceding call to this method. `pageToken` must be the value of * `nextPageToken` from the previous response. The values of other method * parameters should be identical to those in the previous call. + * @param {string[]} [request.resourceNames] + * Optional. The resource name that owns the logs: + * projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID] + * + * To support legacy queries, it could also be: + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Object} diff --git a/src/v2/logging_service_v2_client_config.json b/src/v2/logging_service_v2_client_config.json index 6ba163db..342e96e9 100644 --- a/src/v2/logging_service_v2_client_config.json +++ b/src/v2/logging_service_v2_client_config.json @@ -55,6 +55,11 @@ "timeout_millis": 60000, "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" + }, + "TailLogEntries": { + "timeout_millis": 3600000, + "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_params_name": "default" } } } diff --git a/synth.metadata b/synth.metadata index 6fe898d5..ff5737be 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-logging.git", - "sha": "763b51c72e0fbfed28b44e77947140460ad7c3ee" + "sha": "ed9dcf8785a5abe72cbe407c38dbb900ffa80bc1" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "2f019bf70bfe06f1e2af1b04011b0a2405190e43", - "internalRef": "343202295" + "sha": "e8857c4c36948e7e0500377cd7fcecbf2459afc8", + "internalRef": "344435830" } }, { diff --git a/test/gapic_logging_service_v2_v2.ts b/test/gapic_logging_service_v2_v2.ts index 9ef4357c..5e421126 100644 --- a/test/gapic_logging_service_v2_v2.ts +++ b/test/gapic_logging_service_v2_v2.ts @@ -52,6 +52,20 @@ function stubSimpleCallWithCallback( : sinon.stub().callsArgWith(2, null, response); } +function stubBidiStreamingCall( + response?: ResponseType, + error?: Error +) { + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + return sinon.stub().returns(mockStream); +} + function stubPageStreamingCall( responses?: ResponseType[], error?: Error @@ -393,6 +407,94 @@ describe('v2.LoggingServiceV2Client', () => { }); }); + describe('tailLogEntries', () => { + it('invokes tailLogEntries without error', async () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.logging.v2.TailLogEntriesRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.logging.v2.TailLogEntriesResponse() + ); + client.innerApiCalls.tailLogEntries = stubBidiStreamingCall( + expectedResponse + ); + const stream = client.tailLogEntries(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.logging.v2.TailLogEntriesResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.tailLogEntries as SinonStub) + .getCall(0) + .calledWithExactly(undefined) + ); + assert.deepStrictEqual( + (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( + 0 + ).args[0], + request + ); + }); + + it('invokes tailLogEntries with error', async () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.logging.v2.TailLogEntriesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.tailLogEntries = stubBidiStreamingCall( + undefined, + expectedError + ); + const stream = client.tailLogEntries(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.logging.v2.TailLogEntriesResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.tailLogEntries as SinonStub) + .getCall(0) + .calledWithExactly(undefined) + ); + assert.deepStrictEqual( + (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( + 0 + ).args[0], + request + ); + }); + }); + describe('listLogEntries', () => { it('invokes listLogEntries without error', async () => { const client = new loggingservicev2Module.v2.LoggingServiceV2Client({