diff --git a/.jsdoc.js b/.jsdoc.js index aabe555..c3c1e3d 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -43,7 +43,7 @@ module.exports = { copyright: 'Copyright 2022 Google LLC', includeDate: false, sourceFiles: false, - systemName: '@google-cloud/migration', + systemName: '@google-cloud/bigquery-migration', theme: 'lumen', default: { outputSourceFiles: false diff --git a/linkinator.config.json b/linkinator.config.json index ec52446..befd23c 100644 --- a/linkinator.config.json +++ b/linkinator.config.json @@ -1,17 +1,16 @@ { - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://cloud.google.com/nodejs/docs/reference/bigquery-migration/latest", - "https://github.com/googleapis/nodejs-bigquery-migration/blob/master/CHANGELOG.md", - "https://github.com/googleapis/nodejs-bigquery-migration/blob/addSamples/CHANGELOG.md" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} \ No newline at end of file + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/protos/google/cloud/bigquery/migration/v2/migration_entities.proto b/protos/google/cloud/bigquery/migration/v2/migration_entities.proto index 79ca05b..7d77bae 100644 --- a/protos/google/cloud/bigquery/migration/v2/migration_entities.proto +++ b/protos/google/cloud/bigquery/migration/v2/migration_entities.proto @@ -135,7 +135,7 @@ message MigrationTask { // Translation_Oracle2BQ, Translation_HiveQL2BQ, Translation_SparkSQL2BQ, // Translation_Snowflake2BQ, Translation_Netezza2BQ, // Translation_AzureSynapse2BQ, Translation_Vertica2BQ, - // Translation_SQLServer2BQ. + // Translation_SQLServer2BQ, Translation_Presto2BQ, Translation_MySQL2BQ. string type = 2; // Output only. The current state of the task. diff --git a/protos/google/cloud/bigquery/migration/v2/translation_config.proto b/protos/google/cloud/bigquery/migration/v2/translation_config.proto index 3ff2902..994140d 100644 --- a/protos/google/cloud/bigquery/migration/v2/translation_config.proto +++ b/protos/google/cloud/bigquery/migration/v2/translation_config.proto @@ -91,6 +91,15 @@ message Dialect { // The SQL Server dialect SQLServerDialect sql_server_dialect = 11; + + // The Postgresql dialect + PostgresqlDialect postgresql_dialect = 12; + + // The Presto dialect + PrestoDialect presto_dialect = 13; + + // The MySQL dialect + MySQLDialect mysql_dialect = 14; } } @@ -142,6 +151,15 @@ message VerticaDialect {} // The dialect definition for SQL Server. message SQLServerDialect {} +// The dialect definition for Postgresql. +message PostgresqlDialect {} + +// The dialect definition for Presto. +message PrestoDialect {} + +// The dialect definition for MySQL. +message MySQLDialect {} + // Represents a map of name mappings using a list of key:value proto messages of // existing name to desired output name. message ObjectNameMappingList { diff --git a/protos/google/cloud/bigquery/migration/v2alpha/migration_service.proto b/protos/google/cloud/bigquery/migration/v2alpha/migration_service.proto index b5e9014..9a184a1 100644 --- a/protos/google/cloud/bigquery/migration/v2alpha/migration_service.proto +++ b/protos/google/cloud/bigquery/migration/v2alpha/migration_service.proto @@ -25,7 +25,6 @@ import "google/cloud/bigquery/migration/v2alpha/migration_error_details.proto"; import "google/cloud/bigquery/migration/v2alpha/migration_metrics.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/field_mask.proto"; -import "google/rpc/error_details.proto"; option csharp_namespace = "Google.Cloud.BigQuery.Migration.V2Alpha"; option go_package = "google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2alpha;migration"; diff --git a/protos/protos.d.ts b/protos/protos.d.ts index f1cd3de..081d911 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -1413,6 +1413,15 @@ export namespace google { /** Dialect sqlServerDialect */ sqlServerDialect?: (google.cloud.bigquery.migration.v2.ISQLServerDialect|null); + + /** Dialect postgresqlDialect */ + postgresqlDialect?: (google.cloud.bigquery.migration.v2.IPostgresqlDialect|null); + + /** Dialect prestoDialect */ + prestoDialect?: (google.cloud.bigquery.migration.v2.IPrestoDialect|null); + + /** Dialect mysqlDialect */ + mysqlDialect?: (google.cloud.bigquery.migration.v2.IMySQLDialect|null); } /** Represents a Dialect. */ @@ -1457,8 +1466,17 @@ export namespace google { /** Dialect sqlServerDialect. */ public sqlServerDialect?: (google.cloud.bigquery.migration.v2.ISQLServerDialect|null); + /** Dialect postgresqlDialect. */ + public postgresqlDialect?: (google.cloud.bigquery.migration.v2.IPostgresqlDialect|null); + + /** Dialect prestoDialect. */ + public prestoDialect?: (google.cloud.bigquery.migration.v2.IPrestoDialect|null); + + /** Dialect mysqlDialect. */ + public mysqlDialect?: (google.cloud.bigquery.migration.v2.IMySQLDialect|null); + /** Dialect dialectValue. */ - public dialectValue?: ("bigqueryDialect"|"hiveqlDialect"|"redshiftDialect"|"teradataDialect"|"oracleDialect"|"sparksqlDialect"|"snowflakeDialect"|"netezzaDialect"|"azureSynapseDialect"|"verticaDialect"|"sqlServerDialect"); + public dialectValue?: ("bigqueryDialect"|"hiveqlDialect"|"redshiftDialect"|"teradataDialect"|"oracleDialect"|"sparksqlDialect"|"snowflakeDialect"|"netezzaDialect"|"azureSynapseDialect"|"verticaDialect"|"sqlServerDialect"|"postgresqlDialect"|"prestoDialect"|"mysqlDialect"); /** * Creates a new Dialect instance using the specified properties. @@ -2555,6 +2573,279 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a PostgresqlDialect. */ + interface IPostgresqlDialect { + } + + /** Represents a PostgresqlDialect. */ + class PostgresqlDialect implements IPostgresqlDialect { + + /** + * Constructs a new PostgresqlDialect. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.bigquery.migration.v2.IPostgresqlDialect); + + /** + * Creates a new PostgresqlDialect instance using the specified properties. + * @param [properties] Properties to set + * @returns PostgresqlDialect instance + */ + public static create(properties?: google.cloud.bigquery.migration.v2.IPostgresqlDialect): google.cloud.bigquery.migration.v2.PostgresqlDialect; + + /** + * Encodes the specified PostgresqlDialect message. Does not implicitly {@link google.cloud.bigquery.migration.v2.PostgresqlDialect.verify|verify} messages. + * @param message PostgresqlDialect message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.bigquery.migration.v2.IPostgresqlDialect, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PostgresqlDialect message, length delimited. Does not implicitly {@link google.cloud.bigquery.migration.v2.PostgresqlDialect.verify|verify} messages. + * @param message PostgresqlDialect message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.bigquery.migration.v2.IPostgresqlDialect, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PostgresqlDialect message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PostgresqlDialect + * @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.cloud.bigquery.migration.v2.PostgresqlDialect; + + /** + * Decodes a PostgresqlDialect message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PostgresqlDialect + * @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.cloud.bigquery.migration.v2.PostgresqlDialect; + + /** + * Verifies a PostgresqlDialect 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 PostgresqlDialect message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PostgresqlDialect + */ + public static fromObject(object: { [k: string]: any }): google.cloud.bigquery.migration.v2.PostgresqlDialect; + + /** + * Creates a plain object from a PostgresqlDialect message. Also converts values to other types if specified. + * @param message PostgresqlDialect + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.bigquery.migration.v2.PostgresqlDialect, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PostgresqlDialect to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PostgresqlDialect + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PrestoDialect. */ + interface IPrestoDialect { + } + + /** Represents a PrestoDialect. */ + class PrestoDialect implements IPrestoDialect { + + /** + * Constructs a new PrestoDialect. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.bigquery.migration.v2.IPrestoDialect); + + /** + * Creates a new PrestoDialect instance using the specified properties. + * @param [properties] Properties to set + * @returns PrestoDialect instance + */ + public static create(properties?: google.cloud.bigquery.migration.v2.IPrestoDialect): google.cloud.bigquery.migration.v2.PrestoDialect; + + /** + * Encodes the specified PrestoDialect message. Does not implicitly {@link google.cloud.bigquery.migration.v2.PrestoDialect.verify|verify} messages. + * @param message PrestoDialect message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.bigquery.migration.v2.IPrestoDialect, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PrestoDialect message, length delimited. Does not implicitly {@link google.cloud.bigquery.migration.v2.PrestoDialect.verify|verify} messages. + * @param message PrestoDialect message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.bigquery.migration.v2.IPrestoDialect, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PrestoDialect message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PrestoDialect + * @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.cloud.bigquery.migration.v2.PrestoDialect; + + /** + * Decodes a PrestoDialect message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PrestoDialect + * @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.cloud.bigquery.migration.v2.PrestoDialect; + + /** + * Verifies a PrestoDialect 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 PrestoDialect message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PrestoDialect + */ + public static fromObject(object: { [k: string]: any }): google.cloud.bigquery.migration.v2.PrestoDialect; + + /** + * Creates a plain object from a PrestoDialect message. Also converts values to other types if specified. + * @param message PrestoDialect + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.bigquery.migration.v2.PrestoDialect, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PrestoDialect to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PrestoDialect + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a MySQLDialect. */ + interface IMySQLDialect { + } + + /** Represents a MySQLDialect. */ + class MySQLDialect implements IMySQLDialect { + + /** + * Constructs a new MySQLDialect. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.bigquery.migration.v2.IMySQLDialect); + + /** + * Creates a new MySQLDialect instance using the specified properties. + * @param [properties] Properties to set + * @returns MySQLDialect instance + */ + public static create(properties?: google.cloud.bigquery.migration.v2.IMySQLDialect): google.cloud.bigquery.migration.v2.MySQLDialect; + + /** + * Encodes the specified MySQLDialect message. Does not implicitly {@link google.cloud.bigquery.migration.v2.MySQLDialect.verify|verify} messages. + * @param message MySQLDialect message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.bigquery.migration.v2.IMySQLDialect, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MySQLDialect message, length delimited. Does not implicitly {@link google.cloud.bigquery.migration.v2.MySQLDialect.verify|verify} messages. + * @param message MySQLDialect message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.bigquery.migration.v2.IMySQLDialect, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MySQLDialect message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MySQLDialect + * @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.cloud.bigquery.migration.v2.MySQLDialect; + + /** + * Decodes a MySQLDialect message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MySQLDialect + * @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.cloud.bigquery.migration.v2.MySQLDialect; + + /** + * Verifies a MySQLDialect 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 MySQLDialect message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MySQLDialect + */ + public static fromObject(object: { [k: string]: any }): google.cloud.bigquery.migration.v2.MySQLDialect; + + /** + * Creates a plain object from a MySQLDialect message. Also converts values to other types if specified. + * @param message MySQLDialect + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.bigquery.migration.v2.MySQLDialect, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MySQLDialect to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MySQLDialect + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of an ObjectNameMappingList. */ interface IObjectNameMappingList { diff --git a/protos/protos.js b/protos/protos.js index cb744b5..6992ecd 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -3794,6 +3794,9 @@ * @property {google.cloud.bigquery.migration.v2.IAzureSynapseDialect|null} [azureSynapseDialect] Dialect azureSynapseDialect * @property {google.cloud.bigquery.migration.v2.IVerticaDialect|null} [verticaDialect] Dialect verticaDialect * @property {google.cloud.bigquery.migration.v2.ISQLServerDialect|null} [sqlServerDialect] Dialect sqlServerDialect + * @property {google.cloud.bigquery.migration.v2.IPostgresqlDialect|null} [postgresqlDialect] Dialect postgresqlDialect + * @property {google.cloud.bigquery.migration.v2.IPrestoDialect|null} [prestoDialect] Dialect prestoDialect + * @property {google.cloud.bigquery.migration.v2.IMySQLDialect|null} [mysqlDialect] Dialect mysqlDialect */ /** @@ -3899,17 +3902,41 @@ */ Dialect.prototype.sqlServerDialect = null; + /** + * Dialect postgresqlDialect. + * @member {google.cloud.bigquery.migration.v2.IPostgresqlDialect|null|undefined} postgresqlDialect + * @memberof google.cloud.bigquery.migration.v2.Dialect + * @instance + */ + Dialect.prototype.postgresqlDialect = null; + + /** + * Dialect prestoDialect. + * @member {google.cloud.bigquery.migration.v2.IPrestoDialect|null|undefined} prestoDialect + * @memberof google.cloud.bigquery.migration.v2.Dialect + * @instance + */ + Dialect.prototype.prestoDialect = null; + + /** + * Dialect mysqlDialect. + * @member {google.cloud.bigquery.migration.v2.IMySQLDialect|null|undefined} mysqlDialect + * @memberof google.cloud.bigquery.migration.v2.Dialect + * @instance + */ + Dialect.prototype.mysqlDialect = null; + // OneOf field names bound to virtual getters and setters var $oneOfFields; /** * Dialect dialectValue. - * @member {"bigqueryDialect"|"hiveqlDialect"|"redshiftDialect"|"teradataDialect"|"oracleDialect"|"sparksqlDialect"|"snowflakeDialect"|"netezzaDialect"|"azureSynapseDialect"|"verticaDialect"|"sqlServerDialect"|undefined} dialectValue + * @member {"bigqueryDialect"|"hiveqlDialect"|"redshiftDialect"|"teradataDialect"|"oracleDialect"|"sparksqlDialect"|"snowflakeDialect"|"netezzaDialect"|"azureSynapseDialect"|"verticaDialect"|"sqlServerDialect"|"postgresqlDialect"|"prestoDialect"|"mysqlDialect"|undefined} dialectValue * @memberof google.cloud.bigquery.migration.v2.Dialect * @instance */ Object.defineProperty(Dialect.prototype, "dialectValue", { - get: $util.oneOfGetter($oneOfFields = ["bigqueryDialect", "hiveqlDialect", "redshiftDialect", "teradataDialect", "oracleDialect", "sparksqlDialect", "snowflakeDialect", "netezzaDialect", "azureSynapseDialect", "verticaDialect", "sqlServerDialect"]), + get: $util.oneOfGetter($oneOfFields = ["bigqueryDialect", "hiveqlDialect", "redshiftDialect", "teradataDialect", "oracleDialect", "sparksqlDialect", "snowflakeDialect", "netezzaDialect", "azureSynapseDialect", "verticaDialect", "sqlServerDialect", "postgresqlDialect", "prestoDialect", "mysqlDialect"]), set: $util.oneOfSetter($oneOfFields) }); @@ -3959,6 +3986,12 @@ $root.google.cloud.bigquery.migration.v2.VerticaDialect.encode(message.verticaDialect, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); if (message.sqlServerDialect != null && Object.hasOwnProperty.call(message, "sqlServerDialect")) $root.google.cloud.bigquery.migration.v2.SQLServerDialect.encode(message.sqlServerDialect, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + if (message.postgresqlDialect != null && Object.hasOwnProperty.call(message, "postgresqlDialect")) + $root.google.cloud.bigquery.migration.v2.PostgresqlDialect.encode(message.postgresqlDialect, writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); + if (message.prestoDialect != null && Object.hasOwnProperty.call(message, "prestoDialect")) + $root.google.cloud.bigquery.migration.v2.PrestoDialect.encode(message.prestoDialect, writer.uint32(/* id 13, wireType 2 =*/106).fork()).ldelim(); + if (message.mysqlDialect != null && Object.hasOwnProperty.call(message, "mysqlDialect")) + $root.google.cloud.bigquery.migration.v2.MySQLDialect.encode(message.mysqlDialect, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); return writer; }; @@ -4037,6 +4070,18 @@ message.sqlServerDialect = $root.google.cloud.bigquery.migration.v2.SQLServerDialect.decode(reader, reader.uint32()); break; } + case 12: { + message.postgresqlDialect = $root.google.cloud.bigquery.migration.v2.PostgresqlDialect.decode(reader, reader.uint32()); + break; + } + case 13: { + message.prestoDialect = $root.google.cloud.bigquery.migration.v2.PrestoDialect.decode(reader, reader.uint32()); + break; + } + case 14: { + message.mysqlDialect = $root.google.cloud.bigquery.migration.v2.MySQLDialect.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -4181,6 +4226,36 @@ return "sqlServerDialect." + error; } } + if (message.postgresqlDialect != null && message.hasOwnProperty("postgresqlDialect")) { + if (properties.dialectValue === 1) + return "dialectValue: multiple values"; + properties.dialectValue = 1; + { + var error = $root.google.cloud.bigquery.migration.v2.PostgresqlDialect.verify(message.postgresqlDialect); + if (error) + return "postgresqlDialect." + error; + } + } + if (message.prestoDialect != null && message.hasOwnProperty("prestoDialect")) { + if (properties.dialectValue === 1) + return "dialectValue: multiple values"; + properties.dialectValue = 1; + { + var error = $root.google.cloud.bigquery.migration.v2.PrestoDialect.verify(message.prestoDialect); + if (error) + return "prestoDialect." + error; + } + } + if (message.mysqlDialect != null && message.hasOwnProperty("mysqlDialect")) { + if (properties.dialectValue === 1) + return "dialectValue: multiple values"; + properties.dialectValue = 1; + { + var error = $root.google.cloud.bigquery.migration.v2.MySQLDialect.verify(message.mysqlDialect); + if (error) + return "mysqlDialect." + error; + } + } return null; }; @@ -4251,6 +4326,21 @@ throw TypeError(".google.cloud.bigquery.migration.v2.Dialect.sqlServerDialect: object expected"); message.sqlServerDialect = $root.google.cloud.bigquery.migration.v2.SQLServerDialect.fromObject(object.sqlServerDialect); } + if (object.postgresqlDialect != null) { + if (typeof object.postgresqlDialect !== "object") + throw TypeError(".google.cloud.bigquery.migration.v2.Dialect.postgresqlDialect: object expected"); + message.postgresqlDialect = $root.google.cloud.bigquery.migration.v2.PostgresqlDialect.fromObject(object.postgresqlDialect); + } + if (object.prestoDialect != null) { + if (typeof object.prestoDialect !== "object") + throw TypeError(".google.cloud.bigquery.migration.v2.Dialect.prestoDialect: object expected"); + message.prestoDialect = $root.google.cloud.bigquery.migration.v2.PrestoDialect.fromObject(object.prestoDialect); + } + if (object.mysqlDialect != null) { + if (typeof object.mysqlDialect !== "object") + throw TypeError(".google.cloud.bigquery.migration.v2.Dialect.mysqlDialect: object expected"); + message.mysqlDialect = $root.google.cloud.bigquery.migration.v2.MySQLDialect.fromObject(object.mysqlDialect); + } return message; }; @@ -4322,6 +4412,21 @@ if (options.oneofs) object.dialectValue = "sqlServerDialect"; } + if (message.postgresqlDialect != null && message.hasOwnProperty("postgresqlDialect")) { + object.postgresqlDialect = $root.google.cloud.bigquery.migration.v2.PostgresqlDialect.toObject(message.postgresqlDialect, options); + if (options.oneofs) + object.dialectValue = "postgresqlDialect"; + } + if (message.prestoDialect != null && message.hasOwnProperty("prestoDialect")) { + object.prestoDialect = $root.google.cloud.bigquery.migration.v2.PrestoDialect.toObject(message.prestoDialect, options); + if (options.oneofs) + object.dialectValue = "prestoDialect"; + } + if (message.mysqlDialect != null && message.hasOwnProperty("mysqlDialect")) { + object.mysqlDialect = $root.google.cloud.bigquery.migration.v2.MySQLDialect.toObject(message.mysqlDialect, options); + if (options.oneofs) + object.dialectValue = "mysqlDialect"; + } return object; }; @@ -6341,6 +6446,531 @@ return SQLServerDialect; })(); + v2.PostgresqlDialect = (function() { + + /** + * Properties of a PostgresqlDialect. + * @memberof google.cloud.bigquery.migration.v2 + * @interface IPostgresqlDialect + */ + + /** + * Constructs a new PostgresqlDialect. + * @memberof google.cloud.bigquery.migration.v2 + * @classdesc Represents a PostgresqlDialect. + * @implements IPostgresqlDialect + * @constructor + * @param {google.cloud.bigquery.migration.v2.IPostgresqlDialect=} [properties] Properties to set + */ + function PostgresqlDialect(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]]; + } + + /** + * Creates a new PostgresqlDialect instance using the specified properties. + * @function create + * @memberof google.cloud.bigquery.migration.v2.PostgresqlDialect + * @static + * @param {google.cloud.bigquery.migration.v2.IPostgresqlDialect=} [properties] Properties to set + * @returns {google.cloud.bigquery.migration.v2.PostgresqlDialect} PostgresqlDialect instance + */ + PostgresqlDialect.create = function create(properties) { + return new PostgresqlDialect(properties); + }; + + /** + * Encodes the specified PostgresqlDialect message. Does not implicitly {@link google.cloud.bigquery.migration.v2.PostgresqlDialect.verify|verify} messages. + * @function encode + * @memberof google.cloud.bigquery.migration.v2.PostgresqlDialect + * @static + * @param {google.cloud.bigquery.migration.v2.IPostgresqlDialect} message PostgresqlDialect message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PostgresqlDialect.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified PostgresqlDialect message, length delimited. Does not implicitly {@link google.cloud.bigquery.migration.v2.PostgresqlDialect.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.bigquery.migration.v2.PostgresqlDialect + * @static + * @param {google.cloud.bigquery.migration.v2.IPostgresqlDialect} message PostgresqlDialect message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PostgresqlDialect.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PostgresqlDialect message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.bigquery.migration.v2.PostgresqlDialect + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.bigquery.migration.v2.PostgresqlDialect} PostgresqlDialect + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PostgresqlDialect.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.cloud.bigquery.migration.v2.PostgresqlDialect(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PostgresqlDialect message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.bigquery.migration.v2.PostgresqlDialect + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.bigquery.migration.v2.PostgresqlDialect} PostgresqlDialect + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PostgresqlDialect.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PostgresqlDialect message. + * @function verify + * @memberof google.cloud.bigquery.migration.v2.PostgresqlDialect + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PostgresqlDialect.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a PostgresqlDialect message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.bigquery.migration.v2.PostgresqlDialect + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.bigquery.migration.v2.PostgresqlDialect} PostgresqlDialect + */ + PostgresqlDialect.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.bigquery.migration.v2.PostgresqlDialect) + return object; + return new $root.google.cloud.bigquery.migration.v2.PostgresqlDialect(); + }; + + /** + * Creates a plain object from a PostgresqlDialect message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.bigquery.migration.v2.PostgresqlDialect + * @static + * @param {google.cloud.bigquery.migration.v2.PostgresqlDialect} message PostgresqlDialect + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PostgresqlDialect.toObject = function toObject() { + return {}; + }; + + /** + * Converts this PostgresqlDialect to JSON. + * @function toJSON + * @memberof google.cloud.bigquery.migration.v2.PostgresqlDialect + * @instance + * @returns {Object.} JSON object + */ + PostgresqlDialect.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PostgresqlDialect + * @function getTypeUrl + * @memberof google.cloud.bigquery.migration.v2.PostgresqlDialect + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PostgresqlDialect.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.bigquery.migration.v2.PostgresqlDialect"; + }; + + return PostgresqlDialect; + })(); + + v2.PrestoDialect = (function() { + + /** + * Properties of a PrestoDialect. + * @memberof google.cloud.bigquery.migration.v2 + * @interface IPrestoDialect + */ + + /** + * Constructs a new PrestoDialect. + * @memberof google.cloud.bigquery.migration.v2 + * @classdesc Represents a PrestoDialect. + * @implements IPrestoDialect + * @constructor + * @param {google.cloud.bigquery.migration.v2.IPrestoDialect=} [properties] Properties to set + */ + function PrestoDialect(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]]; + } + + /** + * Creates a new PrestoDialect instance using the specified properties. + * @function create + * @memberof google.cloud.bigquery.migration.v2.PrestoDialect + * @static + * @param {google.cloud.bigquery.migration.v2.IPrestoDialect=} [properties] Properties to set + * @returns {google.cloud.bigquery.migration.v2.PrestoDialect} PrestoDialect instance + */ + PrestoDialect.create = function create(properties) { + return new PrestoDialect(properties); + }; + + /** + * Encodes the specified PrestoDialect message. Does not implicitly {@link google.cloud.bigquery.migration.v2.PrestoDialect.verify|verify} messages. + * @function encode + * @memberof google.cloud.bigquery.migration.v2.PrestoDialect + * @static + * @param {google.cloud.bigquery.migration.v2.IPrestoDialect} message PrestoDialect message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PrestoDialect.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified PrestoDialect message, length delimited. Does not implicitly {@link google.cloud.bigquery.migration.v2.PrestoDialect.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.bigquery.migration.v2.PrestoDialect + * @static + * @param {google.cloud.bigquery.migration.v2.IPrestoDialect} message PrestoDialect message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PrestoDialect.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PrestoDialect message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.bigquery.migration.v2.PrestoDialect + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.bigquery.migration.v2.PrestoDialect} PrestoDialect + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PrestoDialect.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.cloud.bigquery.migration.v2.PrestoDialect(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PrestoDialect message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.bigquery.migration.v2.PrestoDialect + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.bigquery.migration.v2.PrestoDialect} PrestoDialect + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PrestoDialect.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PrestoDialect message. + * @function verify + * @memberof google.cloud.bigquery.migration.v2.PrestoDialect + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PrestoDialect.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a PrestoDialect message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.bigquery.migration.v2.PrestoDialect + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.bigquery.migration.v2.PrestoDialect} PrestoDialect + */ + PrestoDialect.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.bigquery.migration.v2.PrestoDialect) + return object; + return new $root.google.cloud.bigquery.migration.v2.PrestoDialect(); + }; + + /** + * Creates a plain object from a PrestoDialect message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.bigquery.migration.v2.PrestoDialect + * @static + * @param {google.cloud.bigquery.migration.v2.PrestoDialect} message PrestoDialect + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PrestoDialect.toObject = function toObject() { + return {}; + }; + + /** + * Converts this PrestoDialect to JSON. + * @function toJSON + * @memberof google.cloud.bigquery.migration.v2.PrestoDialect + * @instance + * @returns {Object.} JSON object + */ + PrestoDialect.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PrestoDialect + * @function getTypeUrl + * @memberof google.cloud.bigquery.migration.v2.PrestoDialect + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PrestoDialect.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.bigquery.migration.v2.PrestoDialect"; + }; + + return PrestoDialect; + })(); + + v2.MySQLDialect = (function() { + + /** + * Properties of a MySQLDialect. + * @memberof google.cloud.bigquery.migration.v2 + * @interface IMySQLDialect + */ + + /** + * Constructs a new MySQLDialect. + * @memberof google.cloud.bigquery.migration.v2 + * @classdesc Represents a MySQLDialect. + * @implements IMySQLDialect + * @constructor + * @param {google.cloud.bigquery.migration.v2.IMySQLDialect=} [properties] Properties to set + */ + function MySQLDialect(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]]; + } + + /** + * Creates a new MySQLDialect instance using the specified properties. + * @function create + * @memberof google.cloud.bigquery.migration.v2.MySQLDialect + * @static + * @param {google.cloud.bigquery.migration.v2.IMySQLDialect=} [properties] Properties to set + * @returns {google.cloud.bigquery.migration.v2.MySQLDialect} MySQLDialect instance + */ + MySQLDialect.create = function create(properties) { + return new MySQLDialect(properties); + }; + + /** + * Encodes the specified MySQLDialect message. Does not implicitly {@link google.cloud.bigquery.migration.v2.MySQLDialect.verify|verify} messages. + * @function encode + * @memberof google.cloud.bigquery.migration.v2.MySQLDialect + * @static + * @param {google.cloud.bigquery.migration.v2.IMySQLDialect} message MySQLDialect message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MySQLDialect.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified MySQLDialect message, length delimited. Does not implicitly {@link google.cloud.bigquery.migration.v2.MySQLDialect.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.bigquery.migration.v2.MySQLDialect + * @static + * @param {google.cloud.bigquery.migration.v2.IMySQLDialect} message MySQLDialect message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MySQLDialect.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MySQLDialect message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.bigquery.migration.v2.MySQLDialect + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.bigquery.migration.v2.MySQLDialect} MySQLDialect + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MySQLDialect.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.cloud.bigquery.migration.v2.MySQLDialect(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MySQLDialect message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.bigquery.migration.v2.MySQLDialect + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.bigquery.migration.v2.MySQLDialect} MySQLDialect + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MySQLDialect.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MySQLDialect message. + * @function verify + * @memberof google.cloud.bigquery.migration.v2.MySQLDialect + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MySQLDialect.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a MySQLDialect message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.bigquery.migration.v2.MySQLDialect + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.bigquery.migration.v2.MySQLDialect} MySQLDialect + */ + MySQLDialect.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.bigquery.migration.v2.MySQLDialect) + return object; + return new $root.google.cloud.bigquery.migration.v2.MySQLDialect(); + }; + + /** + * Creates a plain object from a MySQLDialect message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.bigquery.migration.v2.MySQLDialect + * @static + * @param {google.cloud.bigquery.migration.v2.MySQLDialect} message MySQLDialect + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MySQLDialect.toObject = function toObject() { + return {}; + }; + + /** + * Converts this MySQLDialect to JSON. + * @function toJSON + * @memberof google.cloud.bigquery.migration.v2.MySQLDialect + * @instance + * @returns {Object.} JSON object + */ + MySQLDialect.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for MySQLDialect + * @function getTypeUrl + * @memberof google.cloud.bigquery.migration.v2.MySQLDialect + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MySQLDialect.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.bigquery.migration.v2.MySQLDialect"; + }; + + return MySQLDialect; + })(); + v2.ObjectNameMappingList = (function() { /** diff --git a/protos/protos.json b/protos/protos.json index bdd4cad..090990d 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -422,7 +422,10 @@ "netezzaDialect", "azureSynapseDialect", "verticaDialect", - "sqlServerDialect" + "sqlServerDialect", + "postgresqlDialect", + "prestoDialect", + "mysqlDialect" ] } }, @@ -470,6 +473,18 @@ "sqlServerDialect": { "type": "SQLServerDialect", "id": 11 + }, + "postgresqlDialect": { + "type": "PostgresqlDialect", + "id": 12 + }, + "prestoDialect": { + "type": "PrestoDialect", + "id": 13 + }, + "mysqlDialect": { + "type": "MySQLDialect", + "id": 14 } } }, @@ -520,6 +535,15 @@ "SQLServerDialect": { "fields": {} }, + "PostgresqlDialect": { + "fields": {} + }, + "PrestoDialect": { + "fields": {} + }, + "MySQLDialect": { + "fields": {} + }, "ObjectNameMappingList": { "fields": { "nameMap": { diff --git a/samples/generated/v2/migration_service.create_migration_workflow.js b/samples/generated/v2/migration_service.create_migration_workflow.js index 9aed895..8301c3a 100644 --- a/samples/generated/v2/migration_service.create_migration_workflow.js +++ b/samples/generated/v2/migration_service.create_migration_workflow.js @@ -23,6 +23,9 @@ function main(parent, migrationWorkflow) { // [START bigquerymigration_v2_generated_MigrationService_CreateMigrationWorkflow_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** @@ -36,7 +39,7 @@ function main(parent, migrationWorkflow) { // const migrationWorkflow = {} // Imports the Migration library - const {MigrationServiceClient} = require('@google-cloud/migration').v2; + const {MigrationServiceClient} = require('@google-cloud/bigquery-migration').v2; // Instantiates a client const migrationClient = new MigrationServiceClient(); diff --git a/samples/generated/v2/migration_service.delete_migration_workflow.js b/samples/generated/v2/migration_service.delete_migration_workflow.js index aeda293..9f0651e 100644 --- a/samples/generated/v2/migration_service.delete_migration_workflow.js +++ b/samples/generated/v2/migration_service.delete_migration_workflow.js @@ -23,6 +23,9 @@ function main(name) { // [START bigquerymigration_v2_generated_MigrationService_DeleteMigrationWorkflow_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** @@ -32,7 +35,7 @@ function main(name) { // const name = 'abc123' // Imports the Migration library - const {MigrationServiceClient} = require('@google-cloud/migration').v2; + const {MigrationServiceClient} = require('@google-cloud/bigquery-migration').v2; // Instantiates a client const migrationClient = new MigrationServiceClient(); diff --git a/samples/generated/v2/migration_service.get_migration_subtask.js b/samples/generated/v2/migration_service.get_migration_subtask.js index df6f7d2..25de9e0 100644 --- a/samples/generated/v2/migration_service.get_migration_subtask.js +++ b/samples/generated/v2/migration_service.get_migration_subtask.js @@ -23,6 +23,9 @@ function main(name) { // [START bigquerymigration_v2_generated_MigrationService_GetMigrationSubtask_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** @@ -36,7 +39,7 @@ function main(name) { // const readMask = {} // Imports the Migration library - const {MigrationServiceClient} = require('@google-cloud/migration').v2; + const {MigrationServiceClient} = require('@google-cloud/bigquery-migration').v2; // Instantiates a client const migrationClient = new MigrationServiceClient(); diff --git a/samples/generated/v2/migration_service.get_migration_workflow.js b/samples/generated/v2/migration_service.get_migration_workflow.js index 72f7565..52ab5cd 100644 --- a/samples/generated/v2/migration_service.get_migration_workflow.js +++ b/samples/generated/v2/migration_service.get_migration_workflow.js @@ -23,6 +23,9 @@ function main(name) { // [START bigquerymigration_v2_generated_MigrationService_GetMigrationWorkflow_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** @@ -36,7 +39,7 @@ function main(name) { // const readMask = {} // Imports the Migration library - const {MigrationServiceClient} = require('@google-cloud/migration').v2; + const {MigrationServiceClient} = require('@google-cloud/bigquery-migration').v2; // Instantiates a client const migrationClient = new MigrationServiceClient(); diff --git a/samples/generated/v2/migration_service.list_migration_subtasks.js b/samples/generated/v2/migration_service.list_migration_subtasks.js index 95e5833..c5c7ed0 100644 --- a/samples/generated/v2/migration_service.list_migration_subtasks.js +++ b/samples/generated/v2/migration_service.list_migration_subtasks.js @@ -23,6 +23,9 @@ function main(parent) { // [START bigquerymigration_v2_generated_MigrationService_ListMigrationSubtasks_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** @@ -54,7 +57,7 @@ function main(parent) { // const filter = 'abc123' // Imports the Migration library - const {MigrationServiceClient} = require('@google-cloud/migration').v2; + const {MigrationServiceClient} = require('@google-cloud/bigquery-migration').v2; // Instantiates a client const migrationClient = new MigrationServiceClient(); diff --git a/samples/generated/v2/migration_service.list_migration_workflows.js b/samples/generated/v2/migration_service.list_migration_workflows.js index 63402d4..ebd2127 100644 --- a/samples/generated/v2/migration_service.list_migration_workflows.js +++ b/samples/generated/v2/migration_service.list_migration_workflows.js @@ -23,6 +23,9 @@ function main(parent) { // [START bigquerymigration_v2_generated_MigrationService_ListMigrationWorkflows_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** @@ -48,7 +51,7 @@ function main(parent) { // const pageToken = 'abc123' // Imports the Migration library - const {MigrationServiceClient} = require('@google-cloud/migration').v2; + const {MigrationServiceClient} = require('@google-cloud/bigquery-migration').v2; // Instantiates a client const migrationClient = new MigrationServiceClient(); diff --git a/samples/generated/v2/migration_service.start_migration_workflow.js b/samples/generated/v2/migration_service.start_migration_workflow.js index 76c614c..7f8257d 100644 --- a/samples/generated/v2/migration_service.start_migration_workflow.js +++ b/samples/generated/v2/migration_service.start_migration_workflow.js @@ -23,6 +23,9 @@ function main(name) { // [START bigquerymigration_v2_generated_MigrationService_StartMigrationWorkflow_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** @@ -32,7 +35,7 @@ function main(name) { // const name = 'abc123' // Imports the Migration library - const {MigrationServiceClient} = require('@google-cloud/migration').v2; + const {MigrationServiceClient} = require('@google-cloud/bigquery-migration').v2; // Instantiates a client const migrationClient = new MigrationServiceClient(); diff --git a/samples/generated/v2/snippet_metadata.google.cloud.bigquery.migration.v2.json b/samples/generated/v2/snippet_metadata.google.cloud.bigquery.migration.v2.json index 9827112..259f84f 100644 --- a/samples/generated/v2/snippet_metadata.google.cloud.bigquery.migration.v2.json +++ b/samples/generated/v2/snippet_metadata.google.cloud.bigquery.migration.v2.json @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 56, + "end": 59, "type": "FULL" } ], @@ -66,7 +66,7 @@ "segments": [ { "start": 25, - "end": 55, + "end": 58, "type": "FULL" } ], @@ -110,7 +110,7 @@ "segments": [ { "start": 25, - "end": 69, + "end": 72, "type": "FULL" } ], @@ -162,7 +162,7 @@ "segments": [ { "start": 25, - "end": 51, + "end": 54, "type": "FULL" } ], @@ -202,7 +202,7 @@ "segments": [ { "start": 25, - "end": 51, + "end": 54, "type": "FULL" } ], @@ -242,7 +242,7 @@ "segments": [ { "start": 25, - "end": 55, + "end": 58, "type": "FULL" } ], @@ -286,7 +286,7 @@ "segments": [ { "start": 25, - "end": 75, + "end": 78, "type": "FULL" } ], diff --git a/samples/generated/v2alpha/migration_service.create_migration_workflow.js b/samples/generated/v2alpha/migration_service.create_migration_workflow.js index 4004520..d8613fe 100644 --- a/samples/generated/v2alpha/migration_service.create_migration_workflow.js +++ b/samples/generated/v2alpha/migration_service.create_migration_workflow.js @@ -23,6 +23,9 @@ function main(parent, migrationWorkflow) { // [START bigquerymigration_v2alpha_generated_MigrationService_CreateMigrationWorkflow_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** @@ -36,7 +39,7 @@ function main(parent, migrationWorkflow) { // const migrationWorkflow = {} // Imports the Migration library - const {MigrationServiceClient} = require('@google-cloud/migration').v2alpha; + const {MigrationServiceClient} = require('@google-cloud/bigquery-migration').v2alpha; // Instantiates a client const migrationClient = new MigrationServiceClient(); diff --git a/samples/generated/v2alpha/migration_service.delete_migration_workflow.js b/samples/generated/v2alpha/migration_service.delete_migration_workflow.js index 04adf0d..e17c7ee 100644 --- a/samples/generated/v2alpha/migration_service.delete_migration_workflow.js +++ b/samples/generated/v2alpha/migration_service.delete_migration_workflow.js @@ -23,6 +23,9 @@ function main(name) { // [START bigquerymigration_v2alpha_generated_MigrationService_DeleteMigrationWorkflow_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** @@ -32,7 +35,7 @@ function main(name) { // const name = 'abc123' // Imports the Migration library - const {MigrationServiceClient} = require('@google-cloud/migration').v2alpha; + const {MigrationServiceClient} = require('@google-cloud/bigquery-migration').v2alpha; // Instantiates a client const migrationClient = new MigrationServiceClient(); diff --git a/samples/generated/v2alpha/migration_service.get_migration_subtask.js b/samples/generated/v2alpha/migration_service.get_migration_subtask.js index 8bf28e2..a17add1 100644 --- a/samples/generated/v2alpha/migration_service.get_migration_subtask.js +++ b/samples/generated/v2alpha/migration_service.get_migration_subtask.js @@ -23,6 +23,9 @@ function main(name) { // [START bigquerymigration_v2alpha_generated_MigrationService_GetMigrationSubtask_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** @@ -36,7 +39,7 @@ function main(name) { // const readMask = {} // Imports the Migration library - const {MigrationServiceClient} = require('@google-cloud/migration').v2alpha; + const {MigrationServiceClient} = require('@google-cloud/bigquery-migration').v2alpha; // Instantiates a client const migrationClient = new MigrationServiceClient(); diff --git a/samples/generated/v2alpha/migration_service.get_migration_workflow.js b/samples/generated/v2alpha/migration_service.get_migration_workflow.js index bbc9e68..1519196 100644 --- a/samples/generated/v2alpha/migration_service.get_migration_workflow.js +++ b/samples/generated/v2alpha/migration_service.get_migration_workflow.js @@ -23,6 +23,9 @@ function main(name) { // [START bigquerymigration_v2alpha_generated_MigrationService_GetMigrationWorkflow_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** @@ -36,7 +39,7 @@ function main(name) { // const readMask = {} // Imports the Migration library - const {MigrationServiceClient} = require('@google-cloud/migration').v2alpha; + const {MigrationServiceClient} = require('@google-cloud/bigquery-migration').v2alpha; // Instantiates a client const migrationClient = new MigrationServiceClient(); diff --git a/samples/generated/v2alpha/migration_service.list_migration_subtasks.js b/samples/generated/v2alpha/migration_service.list_migration_subtasks.js index 61a50a0..99419dd 100644 --- a/samples/generated/v2alpha/migration_service.list_migration_subtasks.js +++ b/samples/generated/v2alpha/migration_service.list_migration_subtasks.js @@ -23,6 +23,9 @@ function main(parent) { // [START bigquerymigration_v2alpha_generated_MigrationService_ListMigrationSubtasks_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** @@ -54,7 +57,7 @@ function main(parent) { // const filter = 'abc123' // Imports the Migration library - const {MigrationServiceClient} = require('@google-cloud/migration').v2alpha; + const {MigrationServiceClient} = require('@google-cloud/bigquery-migration').v2alpha; // Instantiates a client const migrationClient = new MigrationServiceClient(); diff --git a/samples/generated/v2alpha/migration_service.list_migration_workflows.js b/samples/generated/v2alpha/migration_service.list_migration_workflows.js index 41d06f8..31c0263 100644 --- a/samples/generated/v2alpha/migration_service.list_migration_workflows.js +++ b/samples/generated/v2alpha/migration_service.list_migration_workflows.js @@ -23,6 +23,9 @@ function main(parent) { // [START bigquerymigration_v2alpha_generated_MigrationService_ListMigrationWorkflows_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** @@ -48,7 +51,7 @@ function main(parent) { // const pageToken = 'abc123' // Imports the Migration library - const {MigrationServiceClient} = require('@google-cloud/migration').v2alpha; + const {MigrationServiceClient} = require('@google-cloud/bigquery-migration').v2alpha; // Instantiates a client const migrationClient = new MigrationServiceClient(); diff --git a/samples/generated/v2alpha/migration_service.start_migration_workflow.js b/samples/generated/v2alpha/migration_service.start_migration_workflow.js index 236300c..85288c6 100644 --- a/samples/generated/v2alpha/migration_service.start_migration_workflow.js +++ b/samples/generated/v2alpha/migration_service.start_migration_workflow.js @@ -23,6 +23,9 @@ function main(name) { // [START bigquerymigration_v2alpha_generated_MigrationService_StartMigrationWorkflow_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** @@ -32,7 +35,7 @@ function main(name) { // const name = 'abc123' // Imports the Migration library - const {MigrationServiceClient} = require('@google-cloud/migration').v2alpha; + const {MigrationServiceClient} = require('@google-cloud/bigquery-migration').v2alpha; // Instantiates a client const migrationClient = new MigrationServiceClient(); diff --git a/samples/generated/v2alpha/snippet_metadata.google.cloud.bigquery.migration.v2alpha.json b/samples/generated/v2alpha/snippet_metadata.google.cloud.bigquery.migration.v2alpha.json index 5b87250..3929d87 100644 --- a/samples/generated/v2alpha/snippet_metadata.google.cloud.bigquery.migration.v2alpha.json +++ b/samples/generated/v2alpha/snippet_metadata.google.cloud.bigquery.migration.v2alpha.json @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 56, + "end": 59, "type": "FULL" } ], @@ -66,7 +66,7 @@ "segments": [ { "start": 25, - "end": 55, + "end": 58, "type": "FULL" } ], @@ -110,7 +110,7 @@ "segments": [ { "start": 25, - "end": 69, + "end": 72, "type": "FULL" } ], @@ -162,7 +162,7 @@ "segments": [ { "start": 25, - "end": 51, + "end": 54, "type": "FULL" } ], @@ -202,7 +202,7 @@ "segments": [ { "start": 25, - "end": 51, + "end": 54, "type": "FULL" } ], @@ -242,7 +242,7 @@ "segments": [ { "start": 25, - "end": 55, + "end": 58, "type": "FULL" } ], @@ -286,7 +286,7 @@ "segments": [ { "start": 25, - "end": 75, + "end": 78, "type": "FULL" } ], diff --git a/src/v2/gapic_metadata.json b/src/v2/gapic_metadata.json index e0aa12f..1b6a33c 100644 --- a/src/v2/gapic_metadata.json +++ b/src/v2/gapic_metadata.json @@ -3,7 +3,7 @@ "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", "language": "typescript", "protoPackage": "google.cloud.bigquery.migration.v2", - "libraryPackage": "@google-cloud/migration", + "libraryPackage": "@google-cloud/bigquery-migration", "services": { "MigrationService": { "clients": { diff --git a/src/v2/migration_service_client.ts b/src/v2/migration_service_client.ts index 7827dd6..c43d8fe 100644 --- a/src/v2/migration_service_client.ts +++ b/src/v2/migration_service_client.ts @@ -17,8 +17,8 @@ // ** All changes to this file may be overwritten. ** /* global window */ -import * as gax from 'google-gax'; -import { +import type * as gax from 'google-gax'; +import type { Callback, CallOptions, Descriptors, @@ -26,9 +26,7 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; - import {Transform} from 'stream'; -import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -37,7 +35,6 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './migration_service_client_config.json'; - const version = require('../../../package.json').version; /** @@ -97,8 +94,18 @@ export class MigrationServiceClient { * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new MigrationServiceClient({fallback: 'rest'}, gax); + * ``` */ - constructor(opts?: ClientOptions) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof MigrationServiceClient; const servicePath = @@ -118,8 +125,13 @@ export class MigrationServiceClient { opts['scopes'] = staticMembers.scopes; } + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); @@ -204,7 +216,7 @@ export class MigrationServiceClient { this.innerApiCalls = {}; // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; + this.warn = this._gaxModule.warn; } /** @@ -268,7 +280,8 @@ export class MigrationServiceClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -424,7 +437,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); this.initialize(); @@ -528,7 +541,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ name: request.name || '', }); this.initialize(); @@ -626,7 +639,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ name: request.name || '', }); this.initialize(); @@ -731,7 +744,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ name: request.name || '', }); this.initialize(); @@ -835,7 +848,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ name: request.name || '', }); this.initialize(); @@ -942,7 +955,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); this.initialize(); @@ -992,14 +1005,14 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); const defaultCallSettings = this._defaults['listMigrationWorkflows']; const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listMigrationWorkflows.createStream( - this.innerApiCalls.listMigrationWorkflows as gax.GaxCall, + this.innerApiCalls.listMigrationWorkflows as GaxCall, request, callSettings ); @@ -1047,7 +1060,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); const defaultCallSettings = this._defaults['listMigrationWorkflows']; @@ -1055,7 +1068,7 @@ export class MigrationServiceClient { this.initialize(); return this.descriptors.page.listMigrationWorkflows.asyncIterate( this.innerApiCalls['listMigrationWorkflows'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } @@ -1163,7 +1176,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); this.initialize(); @@ -1213,14 +1226,14 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); const defaultCallSettings = this._defaults['listMigrationSubtasks']; const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listMigrationSubtasks.createStream( - this.innerApiCalls.listMigrationSubtasks as gax.GaxCall, + this.innerApiCalls.listMigrationSubtasks as GaxCall, request, callSettings ); @@ -1272,7 +1285,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); const defaultCallSettings = this._defaults['listMigrationSubtasks']; @@ -1280,7 +1293,7 @@ export class MigrationServiceClient { this.initialize(); return this.descriptors.page.listMigrationSubtasks.asyncIterate( this.innerApiCalls['listMigrationSubtasks'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } diff --git a/src/v2alpha/gapic_metadata.json b/src/v2alpha/gapic_metadata.json index f751ba9..adf8d06 100644 --- a/src/v2alpha/gapic_metadata.json +++ b/src/v2alpha/gapic_metadata.json @@ -3,7 +3,7 @@ "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", "language": "typescript", "protoPackage": "google.cloud.bigquery.migration.v2alpha", - "libraryPackage": "@google-cloud/migration", + "libraryPackage": "@google-cloud/bigquery-migration", "services": { "MigrationService": { "clients": { diff --git a/src/v2alpha/migration_service_client.ts b/src/v2alpha/migration_service_client.ts index a201987..86e252d 100644 --- a/src/v2alpha/migration_service_client.ts +++ b/src/v2alpha/migration_service_client.ts @@ -17,8 +17,8 @@ // ** All changes to this file may be overwritten. ** /* global window */ -import * as gax from 'google-gax'; -import { +import type * as gax from 'google-gax'; +import type { Callback, CallOptions, Descriptors, @@ -26,9 +26,7 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; - import {Transform} from 'stream'; -import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -37,7 +35,6 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './migration_service_client_config.json'; - const version = require('../../../package.json').version; /** @@ -97,8 +94,18 @@ export class MigrationServiceClient { * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new MigrationServiceClient({fallback: 'rest'}, gax); + * ``` */ - constructor(opts?: ClientOptions) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof MigrationServiceClient; const servicePath = @@ -118,8 +125,13 @@ export class MigrationServiceClient { opts['scopes'] = staticMembers.scopes; } + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); @@ -204,7 +216,7 @@ export class MigrationServiceClient { this.innerApiCalls = {}; // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; + this.warn = this._gaxModule.warn; } /** @@ -268,7 +280,8 @@ export class MigrationServiceClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -424,7 +437,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); this.initialize(); @@ -528,7 +541,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ name: request.name || '', }); this.initialize(); @@ -626,7 +639,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ name: request.name || '', }); this.initialize(); @@ -731,7 +744,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ name: request.name || '', }); this.initialize(); @@ -835,7 +848,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ name: request.name || '', }); this.initialize(); @@ -942,7 +955,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); this.initialize(); @@ -992,14 +1005,14 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); const defaultCallSettings = this._defaults['listMigrationWorkflows']; const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listMigrationWorkflows.createStream( - this.innerApiCalls.listMigrationWorkflows as gax.GaxCall, + this.innerApiCalls.listMigrationWorkflows as GaxCall, request, callSettings ); @@ -1047,7 +1060,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); const defaultCallSettings = this._defaults['listMigrationWorkflows']; @@ -1055,7 +1068,7 @@ export class MigrationServiceClient { this.initialize(); return this.descriptors.page.listMigrationWorkflows.asyncIterate( this.innerApiCalls['listMigrationWorkflows'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } @@ -1163,7 +1176,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); this.initialize(); @@ -1213,14 +1226,14 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); const defaultCallSettings = this._defaults['listMigrationSubtasks']; const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listMigrationSubtasks.createStream( - this.innerApiCalls.listMigrationSubtasks as gax.GaxCall, + this.innerApiCalls.listMigrationSubtasks as GaxCall, request, callSettings ); @@ -1272,7 +1285,7 @@ export class MigrationServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); const defaultCallSettings = this._defaults['listMigrationSubtasks']; @@ -1280,7 +1293,7 @@ export class MigrationServiceClient { this.initialize(); return this.descriptors.page.listMigrationSubtasks.asyncIterate( this.innerApiCalls['listMigrationSubtasks'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } diff --git a/test/gapic_migration_service_v2.ts b/test/gapic_migration_service_v2.ts index f29b4b0..6b034cf 100644 --- a/test/gapic_migration_service_v2.ts +++ b/test/gapic_migration_service_v2.ts @@ -113,101 +113,103 @@ function stubAsyncIterationCall( } describe('v2.MigrationServiceClient', () => { - it('has servicePath', () => { - const servicePath = - migrationserviceModule.v2.MigrationServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = - migrationserviceModule.v2.MigrationServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = migrationserviceModule.v2.MigrationServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new migrationserviceModule.v2.MigrationServiceClient(); - assert(client); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + migrationserviceModule.v2.MigrationServiceClient.servicePath; + assert(servicePath); + }); - it('should create a client with gRPC fallback', () => { - const client = new migrationserviceModule.v2.MigrationServiceClient({ - fallback: true, + it('has apiEndpoint', () => { + const apiEndpoint = + migrationserviceModule.v2.MigrationServiceClient.apiEndpoint; + assert(apiEndpoint); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new migrationserviceModule.v2.MigrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has port', () => { + const port = migrationserviceModule.v2.MigrationServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert.strictEqual(client.migrationServiceStub, undefined); - await client.initialize(); - assert(client.migrationServiceStub); - }); - it('has close method for the initialized client', done => { - const client = new migrationserviceModule.v2.MigrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = new migrationserviceModule.v2.MigrationServiceClient(); + assert(client); }); - client.initialize(); - assert(client.migrationServiceStub); - client.close().then(() => { - done(); + + it('should create a client with gRPC fallback', () => { + const client = new migrationserviceModule.v2.MigrationServiceClient({ + fallback: true, + }); + assert(client); }); - }); - it('has close method for the non-initialized client', done => { - const client = new migrationserviceModule.v2.MigrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has initialize method and supports deferred initialization', async () => { + const client = new migrationserviceModule.v2.MigrationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.migrationServiceStub, undefined); + await client.initialize(); + assert(client.migrationServiceStub); }); - assert.strictEqual(client.migrationServiceStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the initialized client', done => { + const client = new migrationserviceModule.v2.MigrationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.migrationServiceStub); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new migrationserviceModule.v2.MigrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the non-initialized client', done => { + const client = new migrationserviceModule.v2.MigrationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.migrationServiceStub, undefined); + client.close().then(() => { + done(); + }); }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new migrationserviceModule.v2.MigrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new migrationserviceModule.v2.MigrationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new migrationserviceModule.v2.MigrationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('createMigrationWorkflow', () => { diff --git a/test/gapic_migration_service_v2alpha.ts b/test/gapic_migration_service_v2alpha.ts index 8c621eb..0fdc0f1 100644 --- a/test/gapic_migration_service_v2alpha.ts +++ b/test/gapic_migration_service_v2alpha.ts @@ -113,101 +113,104 @@ function stubAsyncIterationCall( } describe('v2alpha.MigrationServiceClient', () => { - it('has servicePath', () => { - const servicePath = - migrationserviceModule.v2alpha.MigrationServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = - migrationserviceModule.v2alpha.MigrationServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = migrationserviceModule.v2alpha.MigrationServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new migrationserviceModule.v2alpha.MigrationServiceClient(); - assert(client); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + migrationserviceModule.v2alpha.MigrationServiceClient.servicePath; + assert(servicePath); + }); - it('should create a client with gRPC fallback', () => { - const client = new migrationserviceModule.v2alpha.MigrationServiceClient({ - fallback: true, + it('has apiEndpoint', () => { + const apiEndpoint = + migrationserviceModule.v2alpha.MigrationServiceClient.apiEndpoint; + assert(apiEndpoint); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new migrationserviceModule.v2alpha.MigrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has port', () => { + const port = migrationserviceModule.v2alpha.MigrationServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert.strictEqual(client.migrationServiceStub, undefined); - await client.initialize(); - assert(client.migrationServiceStub); - }); - it('has close method for the initialized client', done => { - const client = new migrationserviceModule.v2alpha.MigrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = + new migrationserviceModule.v2alpha.MigrationServiceClient(); + assert(client); }); - client.initialize(); - assert(client.migrationServiceStub); - client.close().then(() => { - done(); + + it('should create a client with gRPC fallback', () => { + const client = new migrationserviceModule.v2alpha.MigrationServiceClient({ + fallback: true, + }); + assert(client); }); - }); - it('has close method for the non-initialized client', done => { - const client = new migrationserviceModule.v2alpha.MigrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has initialize method and supports deferred initialization', async () => { + const client = new migrationserviceModule.v2alpha.MigrationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.migrationServiceStub, undefined); + await client.initialize(); + assert(client.migrationServiceStub); }); - assert.strictEqual(client.migrationServiceStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the initialized client', done => { + const client = new migrationserviceModule.v2alpha.MigrationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.migrationServiceStub); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new migrationserviceModule.v2alpha.MigrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the non-initialized client', done => { + const client = new migrationserviceModule.v2alpha.MigrationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.migrationServiceStub, undefined); + client.close().then(() => { + done(); + }); }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new migrationserviceModule.v2alpha.MigrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new migrationserviceModule.v2alpha.MigrationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new migrationserviceModule.v2alpha.MigrationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('createMigrationWorkflow', () => {