diff --git a/packages/google-privacy-dlp/.eslintrc.json b/packages/google-privacy-dlp/.eslintrc.json index 78215349546..3e8d97ccb39 100644 --- a/packages/google-privacy-dlp/.eslintrc.json +++ b/packages/google-privacy-dlp/.eslintrc.json @@ -1,3 +1,4 @@ { - "extends": "./node_modules/gts" + "extends": "./node_modules/gts", + "root": true } diff --git a/packages/google-privacy-dlp/protos/google/privacy/dlp/v2/dlp.proto b/packages/google-privacy-dlp/protos/google/privacy/dlp/v2/dlp.proto index f19908a0e55..114eaacb40c 100644 --- a/packages/google-privacy-dlp/protos/google/privacy/dlp/v2/dlp.proto +++ b/packages/google-privacy-dlp/protos/google/privacy/dlp/v2/dlp.proto @@ -1384,6 +1384,15 @@ message ContentItem { // Content data to inspect or redact. Replaces `type` and `data`. ByteContentItem byte_item = 5; } + + // User provided metadata for the content. + ContentMetadata content_metadata = 6; +} + +// Metadata on content to be scanned. +message ContentMetadata { + // User provided key-value pairs of content metadata. + repeated KeyValueMetadataProperty properties = 2; } // Structured content to inspect. Up to 50,000 `Value`s per request allowed. See @@ -1403,6 +1412,15 @@ message Table { repeated Row rows = 2; } +// A key-value pair in the Metadata. +message KeyValueMetadataProperty { + // The key of the property. + string key = 1; + + // The value of the property. + string value = 2; +} + // All the findings for a single scanned item. message InspectResult { // List of findings for an item. @@ -7478,6 +7496,9 @@ enum MetadataType { // Metadata extracted from the files. CONTENT_METADATA = 3; + + // Metadata provided by the client. + CLIENT_PROVIDED_METADATA = 4; } // Parts of the APIs which use certain infoTypes. diff --git a/packages/google-privacy-dlp/protos/protos.d.ts b/packages/google-privacy-dlp/protos/protos.d.ts index 7736299155f..4822add63ef 100644 --- a/packages/google-privacy-dlp/protos/protos.d.ts +++ b/packages/google-privacy-dlp/protos/protos.d.ts @@ -2788,6 +2788,9 @@ export namespace google { /** ContentItem byteItem */ byteItem?: (google.privacy.dlp.v2.IByteContentItem|null); + + /** ContentItem contentMetadata */ + contentMetadata?: (google.privacy.dlp.v2.IContentMetadata|null); } /** Represents a ContentItem. */ @@ -2808,6 +2811,9 @@ export namespace google { /** ContentItem byteItem. */ public byteItem?: (google.privacy.dlp.v2.IByteContentItem|null); + /** ContentItem contentMetadata. */ + public contentMetadata?: (google.privacy.dlp.v2.IContentMetadata|null); + /** ContentItem dataItem. */ public dataItem?: ("value"|"table"|"byteItem"); @@ -2889,6 +2895,103 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a ContentMetadata. */ + interface IContentMetadata { + + /** ContentMetadata properties */ + properties?: (google.privacy.dlp.v2.IKeyValueMetadataProperty[]|null); + } + + /** Represents a ContentMetadata. */ + class ContentMetadata implements IContentMetadata { + + /** + * Constructs a new ContentMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.privacy.dlp.v2.IContentMetadata); + + /** ContentMetadata properties. */ + public properties: google.privacy.dlp.v2.IKeyValueMetadataProperty[]; + + /** + * Creates a new ContentMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns ContentMetadata instance + */ + public static create(properties?: google.privacy.dlp.v2.IContentMetadata): google.privacy.dlp.v2.ContentMetadata; + + /** + * Encodes the specified ContentMetadata message. Does not implicitly {@link google.privacy.dlp.v2.ContentMetadata.verify|verify} messages. + * @param message ContentMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.privacy.dlp.v2.IContentMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ContentMetadata message, length delimited. Does not implicitly {@link google.privacy.dlp.v2.ContentMetadata.verify|verify} messages. + * @param message ContentMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.privacy.dlp.v2.IContentMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ContentMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ContentMetadata + * @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.privacy.dlp.v2.ContentMetadata; + + /** + * Decodes a ContentMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ContentMetadata + * @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.privacy.dlp.v2.ContentMetadata; + + /** + * Verifies a ContentMetadata 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 ContentMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ContentMetadata + */ + public static fromObject(object: { [k: string]: any }): google.privacy.dlp.v2.ContentMetadata; + + /** + * Creates a plain object from a ContentMetadata message. Also converts values to other types if specified. + * @param message ContentMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.privacy.dlp.v2.ContentMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ContentMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ContentMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a Table. */ interface ITable { @@ -3092,6 +3195,109 @@ export namespace google { } } + /** Properties of a KeyValueMetadataProperty. */ + interface IKeyValueMetadataProperty { + + /** KeyValueMetadataProperty key */ + key?: (string|null); + + /** KeyValueMetadataProperty value */ + value?: (string|null); + } + + /** Represents a KeyValueMetadataProperty. */ + class KeyValueMetadataProperty implements IKeyValueMetadataProperty { + + /** + * Constructs a new KeyValueMetadataProperty. + * @param [properties] Properties to set + */ + constructor(properties?: google.privacy.dlp.v2.IKeyValueMetadataProperty); + + /** KeyValueMetadataProperty key. */ + public key: string; + + /** KeyValueMetadataProperty value. */ + public value: string; + + /** + * Creates a new KeyValueMetadataProperty instance using the specified properties. + * @param [properties] Properties to set + * @returns KeyValueMetadataProperty instance + */ + public static create(properties?: google.privacy.dlp.v2.IKeyValueMetadataProperty): google.privacy.dlp.v2.KeyValueMetadataProperty; + + /** + * Encodes the specified KeyValueMetadataProperty message. Does not implicitly {@link google.privacy.dlp.v2.KeyValueMetadataProperty.verify|verify} messages. + * @param message KeyValueMetadataProperty message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.privacy.dlp.v2.IKeyValueMetadataProperty, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified KeyValueMetadataProperty message, length delimited. Does not implicitly {@link google.privacy.dlp.v2.KeyValueMetadataProperty.verify|verify} messages. + * @param message KeyValueMetadataProperty message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.privacy.dlp.v2.IKeyValueMetadataProperty, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a KeyValueMetadataProperty message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns KeyValueMetadataProperty + * @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.privacy.dlp.v2.KeyValueMetadataProperty; + + /** + * Decodes a KeyValueMetadataProperty message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns KeyValueMetadataProperty + * @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.privacy.dlp.v2.KeyValueMetadataProperty; + + /** + * Verifies a KeyValueMetadataProperty 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 KeyValueMetadataProperty message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns KeyValueMetadataProperty + */ + public static fromObject(object: { [k: string]: any }): google.privacy.dlp.v2.KeyValueMetadataProperty; + + /** + * Creates a plain object from a KeyValueMetadataProperty message. Also converts values to other types if specified. + * @param message KeyValueMetadataProperty + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.privacy.dlp.v2.KeyValueMetadataProperty, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this KeyValueMetadataProperty to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for KeyValueMetadataProperty + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of an InspectResult. */ interface IInspectResult { @@ -32927,7 +33133,8 @@ export namespace google { enum MetadataType { METADATATYPE_UNSPECIFIED = 0, STORAGE_METADATA = 2, - CONTENT_METADATA = 3 + CONTENT_METADATA = 3, + CLIENT_PROVIDED_METADATA = 4 } /** InfoTypeSupportedBy enum. */ diff --git a/packages/google-privacy-dlp/protos/protos.js b/packages/google-privacy-dlp/protos/protos.js index 92a4a81f664..49b9a698fd7 100644 --- a/packages/google-privacy-dlp/protos/protos.js +++ b/packages/google-privacy-dlp/protos/protos.js @@ -6332,6 +6332,7 @@ * @property {string|null} [value] ContentItem value * @property {google.privacy.dlp.v2.ITable|null} [table] ContentItem table * @property {google.privacy.dlp.v2.IByteContentItem|null} [byteItem] ContentItem byteItem + * @property {google.privacy.dlp.v2.IContentMetadata|null} [contentMetadata] ContentItem contentMetadata */ /** @@ -6373,6 +6374,14 @@ */ ContentItem.prototype.byteItem = null; + /** + * ContentItem contentMetadata. + * @member {google.privacy.dlp.v2.IContentMetadata|null|undefined} contentMetadata + * @memberof google.privacy.dlp.v2.ContentItem + * @instance + */ + ContentItem.prototype.contentMetadata = null; + // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -6417,6 +6426,8 @@ $root.google.privacy.dlp.v2.Table.encode(message.table, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.byteItem != null && Object.hasOwnProperty.call(message, "byteItem")) $root.google.privacy.dlp.v2.ByteContentItem.encode(message.byteItem, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.contentMetadata != null && Object.hasOwnProperty.call(message, "contentMetadata")) + $root.google.privacy.dlp.v2.ContentMetadata.encode(message.contentMetadata, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); return writer; }; @@ -6465,6 +6476,10 @@ message.byteItem = $root.google.privacy.dlp.v2.ByteContentItem.decode(reader, reader.uint32()); break; } + case 6: { + message.contentMetadata = $root.google.privacy.dlp.v2.ContentMetadata.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -6526,6 +6541,11 @@ return "byteItem." + error; } } + if (message.contentMetadata != null && message.hasOwnProperty("contentMetadata")) { + var error = $root.google.privacy.dlp.v2.ContentMetadata.verify(message.contentMetadata); + if (error) + return "contentMetadata." + error; + } return null; }; @@ -6553,6 +6573,11 @@ throw TypeError(".google.privacy.dlp.v2.ContentItem.byteItem: object expected"); message.byteItem = $root.google.privacy.dlp.v2.ByteContentItem.fromObject(object.byteItem); } + if (object.contentMetadata != null) { + if (typeof object.contentMetadata !== "object") + throw TypeError(".google.privacy.dlp.v2.ContentItem.contentMetadata: object expected"); + message.contentMetadata = $root.google.privacy.dlp.v2.ContentMetadata.fromObject(object.contentMetadata); + } return message; }; @@ -6569,6 +6594,8 @@ if (!options) options = {}; var object = {}; + if (options.defaults) + object.contentMetadata = null; if (message.value != null && message.hasOwnProperty("value")) { object.value = message.value; if (options.oneofs) @@ -6584,6 +6611,8 @@ if (options.oneofs) object.dataItem = "byteItem"; } + if (message.contentMetadata != null && message.hasOwnProperty("contentMetadata")) + object.contentMetadata = $root.google.privacy.dlp.v2.ContentMetadata.toObject(message.contentMetadata, options); return object; }; @@ -6616,6 +6645,232 @@ return ContentItem; })(); + v2.ContentMetadata = (function() { + + /** + * Properties of a ContentMetadata. + * @memberof google.privacy.dlp.v2 + * @interface IContentMetadata + * @property {Array.|null} [properties] ContentMetadata properties + */ + + /** + * Constructs a new ContentMetadata. + * @memberof google.privacy.dlp.v2 + * @classdesc Represents a ContentMetadata. + * @implements IContentMetadata + * @constructor + * @param {google.privacy.dlp.v2.IContentMetadata=} [properties] Properties to set + */ + function ContentMetadata(properties) { + this.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]]; + } + + /** + * ContentMetadata properties. + * @member {Array.} properties + * @memberof google.privacy.dlp.v2.ContentMetadata + * @instance + */ + ContentMetadata.prototype.properties = $util.emptyArray; + + /** + * Creates a new ContentMetadata instance using the specified properties. + * @function create + * @memberof google.privacy.dlp.v2.ContentMetadata + * @static + * @param {google.privacy.dlp.v2.IContentMetadata=} [properties] Properties to set + * @returns {google.privacy.dlp.v2.ContentMetadata} ContentMetadata instance + */ + ContentMetadata.create = function create(properties) { + return new ContentMetadata(properties); + }; + + /** + * Encodes the specified ContentMetadata message. Does not implicitly {@link google.privacy.dlp.v2.ContentMetadata.verify|verify} messages. + * @function encode + * @memberof google.privacy.dlp.v2.ContentMetadata + * @static + * @param {google.privacy.dlp.v2.IContentMetadata} message ContentMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContentMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.properties != null && message.properties.length) + for (var i = 0; i < message.properties.length; ++i) + $root.google.privacy.dlp.v2.KeyValueMetadataProperty.encode(message.properties[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ContentMetadata message, length delimited. Does not implicitly {@link google.privacy.dlp.v2.ContentMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.privacy.dlp.v2.ContentMetadata + * @static + * @param {google.privacy.dlp.v2.IContentMetadata} message ContentMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContentMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ContentMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.privacy.dlp.v2.ContentMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.privacy.dlp.v2.ContentMetadata} ContentMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContentMetadata.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.privacy.dlp.v2.ContentMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 2: { + if (!(message.properties && message.properties.length)) + message.properties = []; + message.properties.push($root.google.privacy.dlp.v2.KeyValueMetadataProperty.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ContentMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.privacy.dlp.v2.ContentMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.privacy.dlp.v2.ContentMetadata} ContentMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContentMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ContentMetadata message. + * @function verify + * @memberof google.privacy.dlp.v2.ContentMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ContentMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.properties != null && message.hasOwnProperty("properties")) { + if (!Array.isArray(message.properties)) + return "properties: array expected"; + for (var i = 0; i < message.properties.length; ++i) { + var error = $root.google.privacy.dlp.v2.KeyValueMetadataProperty.verify(message.properties[i]); + if (error) + return "properties." + error; + } + } + return null; + }; + + /** + * Creates a ContentMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.privacy.dlp.v2.ContentMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.privacy.dlp.v2.ContentMetadata} ContentMetadata + */ + ContentMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.privacy.dlp.v2.ContentMetadata) + return object; + var message = new $root.google.privacy.dlp.v2.ContentMetadata(); + if (object.properties) { + if (!Array.isArray(object.properties)) + throw TypeError(".google.privacy.dlp.v2.ContentMetadata.properties: array expected"); + message.properties = []; + for (var i = 0; i < object.properties.length; ++i) { + if (typeof object.properties[i] !== "object") + throw TypeError(".google.privacy.dlp.v2.ContentMetadata.properties: object expected"); + message.properties[i] = $root.google.privacy.dlp.v2.KeyValueMetadataProperty.fromObject(object.properties[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a ContentMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.privacy.dlp.v2.ContentMetadata + * @static + * @param {google.privacy.dlp.v2.ContentMetadata} message ContentMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ContentMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.properties = []; + if (message.properties && message.properties.length) { + object.properties = []; + for (var j = 0; j < message.properties.length; ++j) + object.properties[j] = $root.google.privacy.dlp.v2.KeyValueMetadataProperty.toObject(message.properties[j], options); + } + return object; + }; + + /** + * Converts this ContentMetadata to JSON. + * @function toJSON + * @memberof google.privacy.dlp.v2.ContentMetadata + * @instance + * @returns {Object.} JSON object + */ + ContentMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ContentMetadata + * @function getTypeUrl + * @memberof google.privacy.dlp.v2.ContentMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ContentMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.privacy.dlp.v2.ContentMetadata"; + }; + + return ContentMetadata; + })(); + v2.Table = (function() { /** @@ -7113,6 +7368,235 @@ return Table; })(); + v2.KeyValueMetadataProperty = (function() { + + /** + * Properties of a KeyValueMetadataProperty. + * @memberof google.privacy.dlp.v2 + * @interface IKeyValueMetadataProperty + * @property {string|null} [key] KeyValueMetadataProperty key + * @property {string|null} [value] KeyValueMetadataProperty value + */ + + /** + * Constructs a new KeyValueMetadataProperty. + * @memberof google.privacy.dlp.v2 + * @classdesc Represents a KeyValueMetadataProperty. + * @implements IKeyValueMetadataProperty + * @constructor + * @param {google.privacy.dlp.v2.IKeyValueMetadataProperty=} [properties] Properties to set + */ + function KeyValueMetadataProperty(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]]; + } + + /** + * KeyValueMetadataProperty key. + * @member {string} key + * @memberof google.privacy.dlp.v2.KeyValueMetadataProperty + * @instance + */ + KeyValueMetadataProperty.prototype.key = ""; + + /** + * KeyValueMetadataProperty value. + * @member {string} value + * @memberof google.privacy.dlp.v2.KeyValueMetadataProperty + * @instance + */ + KeyValueMetadataProperty.prototype.value = ""; + + /** + * Creates a new KeyValueMetadataProperty instance using the specified properties. + * @function create + * @memberof google.privacy.dlp.v2.KeyValueMetadataProperty + * @static + * @param {google.privacy.dlp.v2.IKeyValueMetadataProperty=} [properties] Properties to set + * @returns {google.privacy.dlp.v2.KeyValueMetadataProperty} KeyValueMetadataProperty instance + */ + KeyValueMetadataProperty.create = function create(properties) { + return new KeyValueMetadataProperty(properties); + }; + + /** + * Encodes the specified KeyValueMetadataProperty message. Does not implicitly {@link google.privacy.dlp.v2.KeyValueMetadataProperty.verify|verify} messages. + * @function encode + * @memberof google.privacy.dlp.v2.KeyValueMetadataProperty + * @static + * @param {google.privacy.dlp.v2.IKeyValueMetadataProperty} message KeyValueMetadataProperty message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + KeyValueMetadataProperty.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.key); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.value); + return writer; + }; + + /** + * Encodes the specified KeyValueMetadataProperty message, length delimited. Does not implicitly {@link google.privacy.dlp.v2.KeyValueMetadataProperty.verify|verify} messages. + * @function encodeDelimited + * @memberof google.privacy.dlp.v2.KeyValueMetadataProperty + * @static + * @param {google.privacy.dlp.v2.IKeyValueMetadataProperty} message KeyValueMetadataProperty message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + KeyValueMetadataProperty.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a KeyValueMetadataProperty message from the specified reader or buffer. + * @function decode + * @memberof google.privacy.dlp.v2.KeyValueMetadataProperty + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.privacy.dlp.v2.KeyValueMetadataProperty} KeyValueMetadataProperty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + KeyValueMetadataProperty.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.privacy.dlp.v2.KeyValueMetadataProperty(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.key = reader.string(); + break; + } + case 2: { + message.value = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a KeyValueMetadataProperty message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.privacy.dlp.v2.KeyValueMetadataProperty + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.privacy.dlp.v2.KeyValueMetadataProperty} KeyValueMetadataProperty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + KeyValueMetadataProperty.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a KeyValueMetadataProperty message. + * @function verify + * @memberof google.privacy.dlp.v2.KeyValueMetadataProperty + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + KeyValueMetadataProperty.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!$util.isString(message.key)) + return "key: string expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isString(message.value)) + return "value: string expected"; + return null; + }; + + /** + * Creates a KeyValueMetadataProperty message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.privacy.dlp.v2.KeyValueMetadataProperty + * @static + * @param {Object.} object Plain object + * @returns {google.privacy.dlp.v2.KeyValueMetadataProperty} KeyValueMetadataProperty + */ + KeyValueMetadataProperty.fromObject = function fromObject(object) { + if (object instanceof $root.google.privacy.dlp.v2.KeyValueMetadataProperty) + return object; + var message = new $root.google.privacy.dlp.v2.KeyValueMetadataProperty(); + if (object.key != null) + message.key = String(object.key); + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from a KeyValueMetadataProperty message. Also converts values to other types if specified. + * @function toObject + * @memberof google.privacy.dlp.v2.KeyValueMetadataProperty + * @static + * @param {google.privacy.dlp.v2.KeyValueMetadataProperty} message KeyValueMetadataProperty + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + KeyValueMetadataProperty.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.key = ""; + object.value = ""; + } + if (message.key != null && message.hasOwnProperty("key")) + object.key = message.key; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this KeyValueMetadataProperty to JSON. + * @function toJSON + * @memberof google.privacy.dlp.v2.KeyValueMetadataProperty + * @instance + * @returns {Object.} JSON object + */ + KeyValueMetadataProperty.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for KeyValueMetadataProperty + * @function getTypeUrl + * @memberof google.privacy.dlp.v2.KeyValueMetadataProperty + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + KeyValueMetadataProperty.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.privacy.dlp.v2.KeyValueMetadataProperty"; + }; + + return KeyValueMetadataProperty; + })(); + v2.InspectResult = (function() { /** @@ -8852,6 +9336,7 @@ case 0: case 2: case 3: + case 4: break; } if (message.storageLabel != null && message.hasOwnProperty("storageLabel")) { @@ -8906,6 +9391,10 @@ case 3: message.type = 3; break; + case "CLIENT_PROVIDED_METADATA": + case 4: + message.type = 4; + break; } if (object.storageLabel != null) { if (typeof object.storageLabel !== "object") @@ -82506,12 +82995,14 @@ * @property {number} METADATATYPE_UNSPECIFIED=0 METADATATYPE_UNSPECIFIED value * @property {number} STORAGE_METADATA=2 STORAGE_METADATA value * @property {number} CONTENT_METADATA=3 CONTENT_METADATA value + * @property {number} CLIENT_PROVIDED_METADATA=4 CLIENT_PROVIDED_METADATA value */ v2.MetadataType = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "METADATATYPE_UNSPECIFIED"] = 0; values[valuesById[2] = "STORAGE_METADATA"] = 2; values[valuesById[3] = "CONTENT_METADATA"] = 3; + values[valuesById[4] = "CLIENT_PROVIDED_METADATA"] = 4; return values; })(); diff --git a/packages/google-privacy-dlp/protos/protos.json b/packages/google-privacy-dlp/protos/protos.json index 2e6d8783333..bcaba70cf7f 100644 --- a/packages/google-privacy-dlp/protos/protos.json +++ b/packages/google-privacy-dlp/protos/protos.json @@ -1772,6 +1772,19 @@ "byteItem": { "type": "ByteContentItem", "id": 5 + }, + "contentMetadata": { + "type": "ContentMetadata", + "id": 6 + } + } + }, + "ContentMetadata": { + "fields": { + "properties": { + "rule": "repeated", + "type": "KeyValueMetadataProperty", + "id": 2 } } }, @@ -1800,6 +1813,18 @@ } } }, + "KeyValueMetadataProperty": { + "fields": { + "key": { + "type": "string", + "id": 1 + }, + "value": { + "type": "string", + "id": 2 + } + } + }, "InspectResult": { "fields": { "findings": { @@ -7373,7 +7398,8 @@ "values": { "METADATATYPE_UNSPECIFIED": 0, "STORAGE_METADATA": 2, - "CONTENT_METADATA": 3 + "CONTENT_METADATA": 3, + "CLIENT_PROVIDED_METADATA": 4 } }, "InfoTypeSupportedBy": { diff --git a/packages/google-privacy-dlp/system-test/install.ts b/packages/google-privacy-dlp/system-test/install.ts index 394f3362d20..f66069aa394 100644 --- a/packages/google-privacy-dlp/system-test/install.ts +++ b/packages/google-privacy-dlp/system-test/install.ts @@ -40,7 +40,7 @@ describe('📦 pack-n-play test', () => { packageDir: process.cwd(), sample: { description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + cjs: readFileSync('./system-test/fixtures/sample/src/index.js').toString() } }; await packNTest(options);