@google-cloud/logging
Version:
Cloud Logging Client Library for Node.js
131 lines (130 loc) • 3.69 kB
TypeScript
/*!
* Copyright 2015 Google Inc. All Rights Reserved.
*
* 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.
*/
export interface ObjectToStructConverterConfig {
removeCircular?: boolean;
stringify?: boolean;
}
export declare function objToStruct(obj: {}, options: ObjectToStructConverterConfig): {
fields: {};
};
export declare class ObjectToStructConverter {
seenObjects: Set<{}>;
removeCircular: boolean;
stringify?: boolean;
/**
* A class that can be used to convert an object to a struct. Optionally this
* class can be used to erase/throw on circular references during conversion.
*
* @private
*
* @param {object=} options - Configuration object.
* @param {boolean} options.removeCircular - Remove circular references in the
* object with a placeholder string. (Default: `false`)
* @param {boolean} options.stringify - Stringify un-recognized types. (Default:
* `false`)
*/
constructor(options?: ObjectToStructConverterConfig);
/**
* Begin the conversion process from a JS object to an encoded gRPC Value
* message.
*
* @param {*} value - The input value.
* @return {object} - The encoded value.
*
* @example
* ```
* ObjectToStructConverter.convert({
* aString: 'Hi'
* });
* // {
* // fields: {
* // aString: {
* // stringValue: 'Hello!'
* // }
* // }
* // }
* ```
*/
convert(obj: any): {
fields: {};
};
/**
* Convert a raw value to a type-denoted protobuf message-friendly object.
*
* @private
*
* @param {*} value - The input value.
* @return {*} - The encoded value.
*
* @example
* ```
* ObjectToStructConverter.encodeValue('Hi');
* // {
* // stringValue: 'Hello!'
* // }
* ```
*/
encodeValue_(value: {} | null): any;
}
/**
* Condense a protobuf Struct into an object of only its values.
*
* @private
*
* @param {object} struct - A protobuf Struct message.
* @return {object} - The simplified object.
*
* @example
* ```
* GrpcService.structToObj_({
* fields: {
* name: {
* kind: 'stringValue',
* stringValue: 'Stephen'
* }
* }
* });
* // {
* // name: 'Stephen'
* // }
* ```
*/
export declare function structToObj(struct: any): any;
/**
* Decode a protobuf Struct's value.
*
* @param {object} value - A Struct's Field message.
* @return {*} - The decoded value.
*/
export declare function decodeValue(value: any): any;
/**
* zuluToDateObj RFC3339 "Zulu" timestamp into a format that can be parsed to
* a JS Date Object.
* @param zuluTime
*/
export declare function zuluToDateObj(zuluTime: string): {
seconds: number;
nanos: number;
};
/**
* Converts Date to nanoseconds format suported by Logging.
* See https://cloud.google.com/logging/docs/agent/logging/configuration#timestamp-processing for more details
* @param date The date to be converted to Logging nanos and seconds format
*/
export declare function toNanosAndSecondsObj(date: Date): {
seconds: number;
nanos: number;
};