diff --git a/protos/google/storagetransfer/v1/transfer.proto b/protos/google/storagetransfer/v1/transfer.proto index 5ee7211..802cc10 100644 --- a/protos/google/storagetransfer/v1/transfer.proto +++ b/protos/google/storagetransfer/v1/transfer.proto @@ -120,6 +120,14 @@ service StorageTransferService { }; } + // Deletes a transfer job. Deleting a transfer job sets its status to + // [DELETED][google.storagetransfer.v1.TransferJob.Status.DELETED]. + rpc DeleteTransferJob(DeleteTransferJobRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{job_name=transferJobs/**}" + }; + } + // Creates an agent pool resource. rpc CreateAgentPool(CreateAgentPoolRequest) returns (AgentPool) { option (google.api.http) = { @@ -194,7 +202,7 @@ message UpdateTransferJobRequest { // other fields are rejected with the error // [INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. Updating a job status // to [DELETED][google.storagetransfer.v1.TransferJob.Status.DELETED] requires - // `storagetransfer.jobs.delete` permissions. + // `storagetransfer.jobs.delete` permission. TransferJob transfer_job = 3 [(google.api.field_behavior) = REQUIRED]; // The field mask of the fields in `transferJob` that are to be updated in @@ -220,6 +228,16 @@ message GetTransferJobRequest { string project_id = 2 [(google.api.field_behavior) = REQUIRED]; } +// Request passed to DeleteTransferJob. +message DeleteTransferJobRequest { + // Required. The job to delete. + string job_name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID of the Google Cloud project that owns the + // job. + string project_id = 2 [(google.api.field_behavior) = REQUIRED]; +} + // `projectId`, `jobNames`, and `jobStatuses` are query parameters that can // be specified when listing transfer jobs. message ListTransferJobsRequest { diff --git a/protos/google/storagetransfer/v1/transfer_types.proto b/protos/google/storagetransfer/v1/transfer_types.proto index cfb87a6..4e1a3b5 100644 --- a/protos/google/storagetransfer/v1/transfer_types.proto +++ b/protos/google/storagetransfer/v1/transfer_types.proto @@ -319,6 +319,108 @@ message PosixFilesystem { string root_directory = 1; } +// An AwsS3CompatibleData resource. +message AwsS3CompatibleData { + // Required. Specifies the name of the bucket. + string bucket_name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Specifies the root path to transfer objects. + // + // Must be an empty string or full path name that ends with a '/'. This + // field is treated as an object prefix. As such, it should generally not + // begin with a '/'. + string path = 2; + + // Required. Specifies the endpoint of the storage service. + string endpoint = 3 [(google.api.field_behavior) = REQUIRED]; + + // Specifies the region to sign requests with. This can be left blank if + // requests should be signed with an empty region. + string region = 5; + + // Specifies the metadata of the S3 compatible data provider. Each provider + // may contain some attributes that do not apply to all S3-compatible data + // providers. When not specified, S3CompatibleMetadata is used by default. + oneof data_provider { + // A S3 compatible metadata. + S3CompatibleMetadata s3_metadata = 4; + } +} + +// S3CompatibleMetadata contains the metadata fields that apply to the basic +// types of S3-compatible data providers. +message S3CompatibleMetadata { + // The authentication and authorization method used by the storage service. + enum AuthMethod { + // AuthMethod is not specified. + AUTH_METHOD_UNSPECIFIED = 0; + + // Auth requests with AWS SigV4. + AUTH_METHOD_AWS_SIGNATURE_V4 = 1; + + // Auth requests with AWS SigV2. + AUTH_METHOD_AWS_SIGNATURE_V2 = 2; + } + + // The request model of the API. + enum RequestModel { + // RequestModel is not specified. + REQUEST_MODEL_UNSPECIFIED = 0; + + // Perform requests using Virtual Hosted Style. + // Example: https://bucket-name.s3.region.amazonaws.com/key-name + REQUEST_MODEL_VIRTUAL_HOSTED_STYLE = 1; + + // Perform requests using Path Style. + // Example: https://s3.region.amazonaws.com/bucket-name/key-name + REQUEST_MODEL_PATH_STYLE = 2; + } + + // The agent network protocol to access the storage service. + enum NetworkProtocol { + // NetworkProtocol is not specified. + NETWORK_PROTOCOL_UNSPECIFIED = 0; + + // Perform requests using HTTPS. + NETWORK_PROTOCOL_HTTPS = 1; + + // Not recommended: This sends data in clear-text. This is only + // appropriate within a closed network or for publicly available data. + // Perform requests using HTTP. + NETWORK_PROTOCOL_HTTP = 2; + } + + // The Listing API to use for discovering objects. + enum ListApi { + // ListApi is not specified. + LIST_API_UNSPECIFIED = 0; + + // Perform listing using ListObjectsV2 API. + LIST_OBJECTS_V2 = 1; + + // Legacy ListObjects API. + LIST_OBJECTS = 2; + } + + // Specifies the authentication and authorization method used by the storage + // service. When not specified, Transfer Service will attempt to determine + // right auth method to use. + AuthMethod auth_method = 1; + + // Specifies the API request model used to call the storage service. When not + // specified, the default value of RequestModel + // REQUEST_MODEL_VIRTUAL_HOSTED_STYLE is used. + RequestModel request_model = 2; + + // Specifies the network protocol of the agent. When not specified, the + // default value of NetworkProtocol NETWORK_PROTOCOL_HTTPS is used. + NetworkProtocol protocol = 3; + + // The Listing API to use for discovering objects. When not specified, + // Transfer Service will attempt to determine the right API to use. + ListApi list_api = 4; +} + // Represents an On-Premises Agent pool. message AgentPool { option (google.api.resource) = { @@ -372,17 +474,19 @@ message TransferOptions { // Specifies when to overwrite an object in the sink when an object with // matching name is found in the source. enum OverwriteWhen { - // Indicate the option is not set. + // Overwrite behavior is unspecified. OVERWRITE_WHEN_UNSPECIFIED = 0; - // Overwrite destination object with source if the two objects are - // different. + // Overwrites destination objects with the source objects, only if the + // objects have the same name but different HTTP ETags or checksum values. DIFFERENT = 1; - // Never overwrite destination object. + // Never overwrites a destination object if a source object has the + // same name. In this case, the source object is not transferred. NEVER = 2; - // Always overwrite destination object. + // Always overwrite the destination object with the source object, even if + // the HTTP Etags or checksum values are the same. ALWAYS = 3; } @@ -405,13 +509,12 @@ message TransferOptions { // exclusive. bool delete_objects_from_source_after_transfer = 3; - // When to overwrite objects that already exist in the sink. If not set + // When to overwrite objects that already exist in the sink. If not set, // overwrite behavior is determined by // [overwrite_objects_already_existing_in_sink][google.storagetransfer.v1.TransferOptions.overwrite_objects_already_existing_in_sink]. OverwriteWhen overwrite_when = 4; - // Represents the selected metadata options for a transfer job. This feature - // is in Preview. + // Represents the selected metadata options for a transfer job. MetadataOptions metadata_options = 5; } @@ -442,6 +545,9 @@ message TransferSpec { // An Azure Blob Storage data source. AzureBlobStorageData azure_blob_storage_data_source = 8; + + // An AWS S3 compatible data source. + AwsS3CompatibleData aws_s3_compatible_data_source = 19; } // Represents a supported data container type which is required for transfer diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 0611e57..e7a2250 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -155,6 +155,20 @@ export namespace google { */ public runTransferJob(request: google.storagetransfer.v1.IRunTransferJobRequest): Promise; + /** + * Calls DeleteTransferJob. + * @param request DeleteTransferJobRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteTransferJob(request: google.storagetransfer.v1.IDeleteTransferJobRequest, callback: google.storagetransfer.v1.StorageTransferService.DeleteTransferJobCallback): void; + + /** + * Calls DeleteTransferJob. + * @param request DeleteTransferJobRequest message or plain object + * @returns Promise + */ + public deleteTransferJob(request: google.storagetransfer.v1.IDeleteTransferJobRequest): Promise; + /** * Calls CreateAgentPool. * @param request CreateAgentPoolRequest message or plain object @@ -284,6 +298,13 @@ export namespace google { */ type RunTransferJobCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + /** + * Callback as used by {@link google.storagetransfer.v1.StorageTransferService|deleteTransferJob}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteTransferJobCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + /** * Callback as used by {@link google.storagetransfer.v1.StorageTransferService|createAgentPool}. * @param error Error, if any @@ -732,6 +753,109 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a DeleteTransferJobRequest. */ + interface IDeleteTransferJobRequest { + + /** DeleteTransferJobRequest jobName */ + jobName?: (string|null); + + /** DeleteTransferJobRequest projectId */ + projectId?: (string|null); + } + + /** Represents a DeleteTransferJobRequest. */ + class DeleteTransferJobRequest implements IDeleteTransferJobRequest { + + /** + * Constructs a new DeleteTransferJobRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.storagetransfer.v1.IDeleteTransferJobRequest); + + /** DeleteTransferJobRequest jobName. */ + public jobName: string; + + /** DeleteTransferJobRequest projectId. */ + public projectId: string; + + /** + * Creates a new DeleteTransferJobRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteTransferJobRequest instance + */ + public static create(properties?: google.storagetransfer.v1.IDeleteTransferJobRequest): google.storagetransfer.v1.DeleteTransferJobRequest; + + /** + * Encodes the specified DeleteTransferJobRequest message. Does not implicitly {@link google.storagetransfer.v1.DeleteTransferJobRequest.verify|verify} messages. + * @param message DeleteTransferJobRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.storagetransfer.v1.IDeleteTransferJobRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteTransferJobRequest message, length delimited. Does not implicitly {@link google.storagetransfer.v1.DeleteTransferJobRequest.verify|verify} messages. + * @param message DeleteTransferJobRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.storagetransfer.v1.IDeleteTransferJobRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteTransferJobRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteTransferJobRequest + * @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.storagetransfer.v1.DeleteTransferJobRequest; + + /** + * Decodes a DeleteTransferJobRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteTransferJobRequest + * @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.storagetransfer.v1.DeleteTransferJobRequest; + + /** + * Verifies a DeleteTransferJobRequest 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 DeleteTransferJobRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteTransferJobRequest + */ + public static fromObject(object: { [k: string]: any }): google.storagetransfer.v1.DeleteTransferJobRequest; + + /** + * Creates a plain object from a DeleteTransferJobRequest message. Also converts values to other types if specified. + * @param message DeleteTransferJobRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.storagetransfer.v1.DeleteTransferJobRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteTransferJobRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteTransferJobRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a ListTransferJobsRequest. */ interface IListTransferJobsRequest { @@ -2822,6 +2946,276 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of an AwsS3CompatibleData. */ + interface IAwsS3CompatibleData { + + /** AwsS3CompatibleData bucketName */ + bucketName?: (string|null); + + /** AwsS3CompatibleData path */ + path?: (string|null); + + /** AwsS3CompatibleData endpoint */ + endpoint?: (string|null); + + /** AwsS3CompatibleData region */ + region?: (string|null); + + /** AwsS3CompatibleData s3Metadata */ + s3Metadata?: (google.storagetransfer.v1.IS3CompatibleMetadata|null); + } + + /** Represents an AwsS3CompatibleData. */ + class AwsS3CompatibleData implements IAwsS3CompatibleData { + + /** + * Constructs a new AwsS3CompatibleData. + * @param [properties] Properties to set + */ + constructor(properties?: google.storagetransfer.v1.IAwsS3CompatibleData); + + /** AwsS3CompatibleData bucketName. */ + public bucketName: string; + + /** AwsS3CompatibleData path. */ + public path: string; + + /** AwsS3CompatibleData endpoint. */ + public endpoint: string; + + /** AwsS3CompatibleData region. */ + public region: string; + + /** AwsS3CompatibleData s3Metadata. */ + public s3Metadata?: (google.storagetransfer.v1.IS3CompatibleMetadata|null); + + /** AwsS3CompatibleData dataProvider. */ + public dataProvider?: "s3Metadata"; + + /** + * Creates a new AwsS3CompatibleData instance using the specified properties. + * @param [properties] Properties to set + * @returns AwsS3CompatibleData instance + */ + public static create(properties?: google.storagetransfer.v1.IAwsS3CompatibleData): google.storagetransfer.v1.AwsS3CompatibleData; + + /** + * Encodes the specified AwsS3CompatibleData message. Does not implicitly {@link google.storagetransfer.v1.AwsS3CompatibleData.verify|verify} messages. + * @param message AwsS3CompatibleData message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.storagetransfer.v1.IAwsS3CompatibleData, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AwsS3CompatibleData message, length delimited. Does not implicitly {@link google.storagetransfer.v1.AwsS3CompatibleData.verify|verify} messages. + * @param message AwsS3CompatibleData message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.storagetransfer.v1.IAwsS3CompatibleData, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AwsS3CompatibleData message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AwsS3CompatibleData + * @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.storagetransfer.v1.AwsS3CompatibleData; + + /** + * Decodes an AwsS3CompatibleData message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AwsS3CompatibleData + * @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.storagetransfer.v1.AwsS3CompatibleData; + + /** + * Verifies an AwsS3CompatibleData 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 an AwsS3CompatibleData message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AwsS3CompatibleData + */ + public static fromObject(object: { [k: string]: any }): google.storagetransfer.v1.AwsS3CompatibleData; + + /** + * Creates a plain object from an AwsS3CompatibleData message. Also converts values to other types if specified. + * @param message AwsS3CompatibleData + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.storagetransfer.v1.AwsS3CompatibleData, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AwsS3CompatibleData to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AwsS3CompatibleData + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a S3CompatibleMetadata. */ + interface IS3CompatibleMetadata { + + /** S3CompatibleMetadata authMethod */ + authMethod?: (google.storagetransfer.v1.S3CompatibleMetadata.AuthMethod|keyof typeof google.storagetransfer.v1.S3CompatibleMetadata.AuthMethod|null); + + /** S3CompatibleMetadata requestModel */ + requestModel?: (google.storagetransfer.v1.S3CompatibleMetadata.RequestModel|keyof typeof google.storagetransfer.v1.S3CompatibleMetadata.RequestModel|null); + + /** S3CompatibleMetadata protocol */ + protocol?: (google.storagetransfer.v1.S3CompatibleMetadata.NetworkProtocol|keyof typeof google.storagetransfer.v1.S3CompatibleMetadata.NetworkProtocol|null); + + /** S3CompatibleMetadata listApi */ + listApi?: (google.storagetransfer.v1.S3CompatibleMetadata.ListApi|keyof typeof google.storagetransfer.v1.S3CompatibleMetadata.ListApi|null); + } + + /** Represents a S3CompatibleMetadata. */ + class S3CompatibleMetadata implements IS3CompatibleMetadata { + + /** + * Constructs a new S3CompatibleMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.storagetransfer.v1.IS3CompatibleMetadata); + + /** S3CompatibleMetadata authMethod. */ + public authMethod: (google.storagetransfer.v1.S3CompatibleMetadata.AuthMethod|keyof typeof google.storagetransfer.v1.S3CompatibleMetadata.AuthMethod); + + /** S3CompatibleMetadata requestModel. */ + public requestModel: (google.storagetransfer.v1.S3CompatibleMetadata.RequestModel|keyof typeof google.storagetransfer.v1.S3CompatibleMetadata.RequestModel); + + /** S3CompatibleMetadata protocol. */ + public protocol: (google.storagetransfer.v1.S3CompatibleMetadata.NetworkProtocol|keyof typeof google.storagetransfer.v1.S3CompatibleMetadata.NetworkProtocol); + + /** S3CompatibleMetadata listApi. */ + public listApi: (google.storagetransfer.v1.S3CompatibleMetadata.ListApi|keyof typeof google.storagetransfer.v1.S3CompatibleMetadata.ListApi); + + /** + * Creates a new S3CompatibleMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns S3CompatibleMetadata instance + */ + public static create(properties?: google.storagetransfer.v1.IS3CompatibleMetadata): google.storagetransfer.v1.S3CompatibleMetadata; + + /** + * Encodes the specified S3CompatibleMetadata message. Does not implicitly {@link google.storagetransfer.v1.S3CompatibleMetadata.verify|verify} messages. + * @param message S3CompatibleMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.storagetransfer.v1.IS3CompatibleMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified S3CompatibleMetadata message, length delimited. Does not implicitly {@link google.storagetransfer.v1.S3CompatibleMetadata.verify|verify} messages. + * @param message S3CompatibleMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.storagetransfer.v1.IS3CompatibleMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a S3CompatibleMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns S3CompatibleMetadata + * @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.storagetransfer.v1.S3CompatibleMetadata; + + /** + * Decodes a S3CompatibleMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns S3CompatibleMetadata + * @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.storagetransfer.v1.S3CompatibleMetadata; + + /** + * Verifies a S3CompatibleMetadata 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 S3CompatibleMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns S3CompatibleMetadata + */ + public static fromObject(object: { [k: string]: any }): google.storagetransfer.v1.S3CompatibleMetadata; + + /** + * Creates a plain object from a S3CompatibleMetadata message. Also converts values to other types if specified. + * @param message S3CompatibleMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.storagetransfer.v1.S3CompatibleMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this S3CompatibleMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for S3CompatibleMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace S3CompatibleMetadata { + + /** AuthMethod enum. */ + enum AuthMethod { + AUTH_METHOD_UNSPECIFIED = 0, + AUTH_METHOD_AWS_SIGNATURE_V4 = 1, + AUTH_METHOD_AWS_SIGNATURE_V2 = 2 + } + + /** RequestModel enum. */ + enum RequestModel { + REQUEST_MODEL_UNSPECIFIED = 0, + REQUEST_MODEL_VIRTUAL_HOSTED_STYLE = 1, + REQUEST_MODEL_PATH_STYLE = 2 + } + + /** NetworkProtocol enum. */ + enum NetworkProtocol { + NETWORK_PROTOCOL_UNSPECIFIED = 0, + NETWORK_PROTOCOL_HTTPS = 1, + NETWORK_PROTOCOL_HTTP = 2 + } + + /** ListApi enum. */ + enum ListApi { + LIST_API_UNSPECIFIED = 0, + LIST_OBJECTS_V2 = 1, + LIST_OBJECTS = 2 + } + } + /** Properties of an AgentPool. */ interface IAgentPool { @@ -3201,6 +3595,9 @@ export namespace google { /** TransferSpec azureBlobStorageDataSource */ azureBlobStorageDataSource?: (google.storagetransfer.v1.IAzureBlobStorageData|null); + /** TransferSpec awsS3CompatibleDataSource */ + awsS3CompatibleDataSource?: (google.storagetransfer.v1.IAwsS3CompatibleData|null); + /** TransferSpec gcsIntermediateDataLocation */ gcsIntermediateDataLocation?: (google.storagetransfer.v1.IGcsData|null); @@ -3250,6 +3647,9 @@ export namespace google { /** TransferSpec azureBlobStorageDataSource. */ public azureBlobStorageDataSource?: (google.storagetransfer.v1.IAzureBlobStorageData|null); + /** TransferSpec awsS3CompatibleDataSource. */ + public awsS3CompatibleDataSource?: (google.storagetransfer.v1.IAwsS3CompatibleData|null); + /** TransferSpec gcsIntermediateDataLocation. */ public gcsIntermediateDataLocation?: (google.storagetransfer.v1.IGcsData|null); @@ -3272,7 +3672,7 @@ export namespace google { public dataSink?: ("gcsDataSink"|"posixDataSink"); /** TransferSpec dataSource. */ - public dataSource?: ("gcsDataSource"|"awsS3DataSource"|"httpDataSource"|"posixDataSource"|"azureBlobStorageDataSource"); + public dataSource?: ("gcsDataSource"|"awsS3DataSource"|"httpDataSource"|"posixDataSource"|"azureBlobStorageDataSource"|"awsS3CompatibleDataSource"); /** TransferSpec intermediateDataLocation. */ public intermediateDataLocation?: "gcsIntermediateDataLocation"; diff --git a/protos/protos.js b/protos/protos.js index 0d43809..2d24ce1 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -353,6 +353,39 @@ * @variation 2 */ + /** + * Callback as used by {@link google.storagetransfer.v1.StorageTransferService|deleteTransferJob}. + * @memberof google.storagetransfer.v1.StorageTransferService + * @typedef DeleteTransferJobCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteTransferJob. + * @function deleteTransferJob + * @memberof google.storagetransfer.v1.StorageTransferService + * @instance + * @param {google.storagetransfer.v1.IDeleteTransferJobRequest} request DeleteTransferJobRequest message or plain object + * @param {google.storagetransfer.v1.StorageTransferService.DeleteTransferJobCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(StorageTransferService.prototype.deleteTransferJob = function deleteTransferJob(request, callback) { + return this.rpcCall(deleteTransferJob, $root.google.storagetransfer.v1.DeleteTransferJobRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteTransferJob" }); + + /** + * Calls DeleteTransferJob. + * @function deleteTransferJob + * @memberof google.storagetransfer.v1.StorageTransferService + * @instance + * @param {google.storagetransfer.v1.IDeleteTransferJobRequest} request DeleteTransferJobRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link google.storagetransfer.v1.StorageTransferService|createAgentPool}. * @memberof google.storagetransfer.v1.StorageTransferService @@ -1442,6 +1475,233 @@ return GetTransferJobRequest; })(); + v1.DeleteTransferJobRequest = (function() { + + /** + * Properties of a DeleteTransferJobRequest. + * @memberof google.storagetransfer.v1 + * @interface IDeleteTransferJobRequest + * @property {string|null} [jobName] DeleteTransferJobRequest jobName + * @property {string|null} [projectId] DeleteTransferJobRequest projectId + */ + + /** + * Constructs a new DeleteTransferJobRequest. + * @memberof google.storagetransfer.v1 + * @classdesc Represents a DeleteTransferJobRequest. + * @implements IDeleteTransferJobRequest + * @constructor + * @param {google.storagetransfer.v1.IDeleteTransferJobRequest=} [properties] Properties to set + */ + function DeleteTransferJobRequest(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]]; + } + + /** + * DeleteTransferJobRequest jobName. + * @member {string} jobName + * @memberof google.storagetransfer.v1.DeleteTransferJobRequest + * @instance + */ + DeleteTransferJobRequest.prototype.jobName = ""; + + /** + * DeleteTransferJobRequest projectId. + * @member {string} projectId + * @memberof google.storagetransfer.v1.DeleteTransferJobRequest + * @instance + */ + DeleteTransferJobRequest.prototype.projectId = ""; + + /** + * Creates a new DeleteTransferJobRequest instance using the specified properties. + * @function create + * @memberof google.storagetransfer.v1.DeleteTransferJobRequest + * @static + * @param {google.storagetransfer.v1.IDeleteTransferJobRequest=} [properties] Properties to set + * @returns {google.storagetransfer.v1.DeleteTransferJobRequest} DeleteTransferJobRequest instance + */ + DeleteTransferJobRequest.create = function create(properties) { + return new DeleteTransferJobRequest(properties); + }; + + /** + * Encodes the specified DeleteTransferJobRequest message. Does not implicitly {@link google.storagetransfer.v1.DeleteTransferJobRequest.verify|verify} messages. + * @function encode + * @memberof google.storagetransfer.v1.DeleteTransferJobRequest + * @static + * @param {google.storagetransfer.v1.IDeleteTransferJobRequest} message DeleteTransferJobRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteTransferJobRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.jobName != null && Object.hasOwnProperty.call(message, "jobName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.jobName); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.projectId); + return writer; + }; + + /** + * Encodes the specified DeleteTransferJobRequest message, length delimited. Does not implicitly {@link google.storagetransfer.v1.DeleteTransferJobRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.storagetransfer.v1.DeleteTransferJobRequest + * @static + * @param {google.storagetransfer.v1.IDeleteTransferJobRequest} message DeleteTransferJobRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteTransferJobRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteTransferJobRequest message from the specified reader or buffer. + * @function decode + * @memberof google.storagetransfer.v1.DeleteTransferJobRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.storagetransfer.v1.DeleteTransferJobRequest} DeleteTransferJobRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteTransferJobRequest.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.storagetransfer.v1.DeleteTransferJobRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.jobName = reader.string(); + break; + } + case 2: { + message.projectId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteTransferJobRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.storagetransfer.v1.DeleteTransferJobRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.storagetransfer.v1.DeleteTransferJobRequest} DeleteTransferJobRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteTransferJobRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteTransferJobRequest message. + * @function verify + * @memberof google.storagetransfer.v1.DeleteTransferJobRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteTransferJobRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.jobName != null && message.hasOwnProperty("jobName")) + if (!$util.isString(message.jobName)) + return "jobName: string expected"; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + return null; + }; + + /** + * Creates a DeleteTransferJobRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.storagetransfer.v1.DeleteTransferJobRequest + * @static + * @param {Object.} object Plain object + * @returns {google.storagetransfer.v1.DeleteTransferJobRequest} DeleteTransferJobRequest + */ + DeleteTransferJobRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.storagetransfer.v1.DeleteTransferJobRequest) + return object; + var message = new $root.google.storagetransfer.v1.DeleteTransferJobRequest(); + if (object.jobName != null) + message.jobName = String(object.jobName); + if (object.projectId != null) + message.projectId = String(object.projectId); + return message; + }; + + /** + * Creates a plain object from a DeleteTransferJobRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.storagetransfer.v1.DeleteTransferJobRequest + * @static + * @param {google.storagetransfer.v1.DeleteTransferJobRequest} message DeleteTransferJobRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteTransferJobRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.jobName = ""; + object.projectId = ""; + } + if (message.jobName != null && message.hasOwnProperty("jobName")) + object.jobName = message.jobName; + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + return object; + }; + + /** + * Converts this DeleteTransferJobRequest to JSON. + * @function toJSON + * @memberof google.storagetransfer.v1.DeleteTransferJobRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteTransferJobRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteTransferJobRequest + * @function getTypeUrl + * @memberof google.storagetransfer.v1.DeleteTransferJobRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteTransferJobRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.storagetransfer.v1.DeleteTransferJobRequest"; + }; + + return DeleteTransferJobRequest; + })(); + v1.ListTransferJobsRequest = (function() { /** @@ -6211,27 +6471,28 @@ return PosixFilesystem; })(); - v1.AgentPool = (function() { + v1.AwsS3CompatibleData = (function() { /** - * Properties of an AgentPool. + * Properties of an AwsS3CompatibleData. * @memberof google.storagetransfer.v1 - * @interface IAgentPool - * @property {string|null} [name] AgentPool name - * @property {string|null} [displayName] AgentPool displayName - * @property {google.storagetransfer.v1.AgentPool.State|null} [state] AgentPool state - * @property {google.storagetransfer.v1.AgentPool.IBandwidthLimit|null} [bandwidthLimit] AgentPool bandwidthLimit + * @interface IAwsS3CompatibleData + * @property {string|null} [bucketName] AwsS3CompatibleData bucketName + * @property {string|null} [path] AwsS3CompatibleData path + * @property {string|null} [endpoint] AwsS3CompatibleData endpoint + * @property {string|null} [region] AwsS3CompatibleData region + * @property {google.storagetransfer.v1.IS3CompatibleMetadata|null} [s3Metadata] AwsS3CompatibleData s3Metadata */ /** - * Constructs a new AgentPool. + * Constructs a new AwsS3CompatibleData. * @memberof google.storagetransfer.v1 - * @classdesc Represents an AgentPool. - * @implements IAgentPool + * @classdesc Represents an AwsS3CompatibleData. + * @implements IAwsS3CompatibleData * @constructor - * @param {google.storagetransfer.v1.IAgentPool=} [properties] Properties to set + * @param {google.storagetransfer.v1.IAwsS3CompatibleData=} [properties] Properties to set */ - function AgentPool(properties) { + function AwsS3CompatibleData(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -6239,82 +6500,811 @@ } /** - * AgentPool name. - * @member {string} name - * @memberof google.storagetransfer.v1.AgentPool + * AwsS3CompatibleData bucketName. + * @member {string} bucketName + * @memberof google.storagetransfer.v1.AwsS3CompatibleData * @instance */ - AgentPool.prototype.name = ""; + AwsS3CompatibleData.prototype.bucketName = ""; /** - * AgentPool displayName. - * @member {string} displayName - * @memberof google.storagetransfer.v1.AgentPool + * AwsS3CompatibleData path. + * @member {string} path + * @memberof google.storagetransfer.v1.AwsS3CompatibleData * @instance */ - AgentPool.prototype.displayName = ""; + AwsS3CompatibleData.prototype.path = ""; /** - * AgentPool state. - * @member {google.storagetransfer.v1.AgentPool.State} state - * @memberof google.storagetransfer.v1.AgentPool + * AwsS3CompatibleData endpoint. + * @member {string} endpoint + * @memberof google.storagetransfer.v1.AwsS3CompatibleData * @instance */ - AgentPool.prototype.state = 0; + AwsS3CompatibleData.prototype.endpoint = ""; /** - * AgentPool bandwidthLimit. - * @member {google.storagetransfer.v1.AgentPool.IBandwidthLimit|null|undefined} bandwidthLimit - * @memberof google.storagetransfer.v1.AgentPool + * AwsS3CompatibleData region. + * @member {string} region + * @memberof google.storagetransfer.v1.AwsS3CompatibleData * @instance */ - AgentPool.prototype.bandwidthLimit = null; + AwsS3CompatibleData.prototype.region = ""; /** - * Creates a new AgentPool instance using the specified properties. + * AwsS3CompatibleData s3Metadata. + * @member {google.storagetransfer.v1.IS3CompatibleMetadata|null|undefined} s3Metadata + * @memberof google.storagetransfer.v1.AwsS3CompatibleData + * @instance + */ + AwsS3CompatibleData.prototype.s3Metadata = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * AwsS3CompatibleData dataProvider. + * @member {"s3Metadata"|undefined} dataProvider + * @memberof google.storagetransfer.v1.AwsS3CompatibleData + * @instance + */ + Object.defineProperty(AwsS3CompatibleData.prototype, "dataProvider", { + get: $util.oneOfGetter($oneOfFields = ["s3Metadata"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new AwsS3CompatibleData instance using the specified properties. * @function create - * @memberof google.storagetransfer.v1.AgentPool + * @memberof google.storagetransfer.v1.AwsS3CompatibleData * @static - * @param {google.storagetransfer.v1.IAgentPool=} [properties] Properties to set - * @returns {google.storagetransfer.v1.AgentPool} AgentPool instance + * @param {google.storagetransfer.v1.IAwsS3CompatibleData=} [properties] Properties to set + * @returns {google.storagetransfer.v1.AwsS3CompatibleData} AwsS3CompatibleData instance */ - AgentPool.create = function create(properties) { - return new AgentPool(properties); + AwsS3CompatibleData.create = function create(properties) { + return new AwsS3CompatibleData(properties); }; /** - * Encodes the specified AgentPool message. Does not implicitly {@link google.storagetransfer.v1.AgentPool.verify|verify} messages. + * Encodes the specified AwsS3CompatibleData message. Does not implicitly {@link google.storagetransfer.v1.AwsS3CompatibleData.verify|verify} messages. * @function encode - * @memberof google.storagetransfer.v1.AgentPool + * @memberof google.storagetransfer.v1.AwsS3CompatibleData * @static - * @param {google.storagetransfer.v1.IAgentPool} message AgentPool message or plain object to encode + * @param {google.storagetransfer.v1.IAwsS3CompatibleData} message AwsS3CompatibleData message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - AgentPool.encode = function encode(message, writer) { + AwsS3CompatibleData.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && Object.hasOwnProperty.call(message, "name")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.name); - if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) - writer.uint32(/* id 3, wireType 2 =*/26).string(message.displayName); - if (message.state != null && Object.hasOwnProperty.call(message, "state")) - writer.uint32(/* id 4, wireType 0 =*/32).int32(message.state); - if (message.bandwidthLimit != null && Object.hasOwnProperty.call(message, "bandwidthLimit")) - $root.google.storagetransfer.v1.AgentPool.BandwidthLimit.encode(message.bandwidthLimit, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.bucketName != null && Object.hasOwnProperty.call(message, "bucketName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.bucketName); + if (message.path != null && Object.hasOwnProperty.call(message, "path")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.path); + if (message.endpoint != null && Object.hasOwnProperty.call(message, "endpoint")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.endpoint); + if (message.s3Metadata != null && Object.hasOwnProperty.call(message, "s3Metadata")) + $root.google.storagetransfer.v1.S3CompatibleMetadata.encode(message.s3Metadata, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.region != null && Object.hasOwnProperty.call(message, "region")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.region); return writer; }; /** - * Encodes the specified AgentPool message, length delimited. Does not implicitly {@link google.storagetransfer.v1.AgentPool.verify|verify} messages. + * Encodes the specified AwsS3CompatibleData message, length delimited. Does not implicitly {@link google.storagetransfer.v1.AwsS3CompatibleData.verify|verify} messages. * @function encodeDelimited - * @memberof google.storagetransfer.v1.AgentPool + * @memberof google.storagetransfer.v1.AwsS3CompatibleData * @static - * @param {google.storagetransfer.v1.IAgentPool} message AgentPool message or plain object to encode + * @param {google.storagetransfer.v1.IAwsS3CompatibleData} message AwsS3CompatibleData message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - AgentPool.encodeDelimited = function encodeDelimited(message, writer) { + AwsS3CompatibleData.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AwsS3CompatibleData message from the specified reader or buffer. + * @function decode + * @memberof google.storagetransfer.v1.AwsS3CompatibleData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.storagetransfer.v1.AwsS3CompatibleData} AwsS3CompatibleData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AwsS3CompatibleData.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.storagetransfer.v1.AwsS3CompatibleData(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.bucketName = reader.string(); + break; + } + case 2: { + message.path = reader.string(); + break; + } + case 3: { + message.endpoint = reader.string(); + break; + } + case 5: { + message.region = reader.string(); + break; + } + case 4: { + message.s3Metadata = $root.google.storagetransfer.v1.S3CompatibleMetadata.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AwsS3CompatibleData message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.storagetransfer.v1.AwsS3CompatibleData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.storagetransfer.v1.AwsS3CompatibleData} AwsS3CompatibleData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AwsS3CompatibleData.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AwsS3CompatibleData message. + * @function verify + * @memberof google.storagetransfer.v1.AwsS3CompatibleData + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AwsS3CompatibleData.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.bucketName != null && message.hasOwnProperty("bucketName")) + if (!$util.isString(message.bucketName)) + return "bucketName: string expected"; + if (message.path != null && message.hasOwnProperty("path")) + if (!$util.isString(message.path)) + return "path: string expected"; + if (message.endpoint != null && message.hasOwnProperty("endpoint")) + if (!$util.isString(message.endpoint)) + return "endpoint: string expected"; + if (message.region != null && message.hasOwnProperty("region")) + if (!$util.isString(message.region)) + return "region: string expected"; + if (message.s3Metadata != null && message.hasOwnProperty("s3Metadata")) { + properties.dataProvider = 1; + { + var error = $root.google.storagetransfer.v1.S3CompatibleMetadata.verify(message.s3Metadata); + if (error) + return "s3Metadata." + error; + } + } + return null; + }; + + /** + * Creates an AwsS3CompatibleData message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.storagetransfer.v1.AwsS3CompatibleData + * @static + * @param {Object.} object Plain object + * @returns {google.storagetransfer.v1.AwsS3CompatibleData} AwsS3CompatibleData + */ + AwsS3CompatibleData.fromObject = function fromObject(object) { + if (object instanceof $root.google.storagetransfer.v1.AwsS3CompatibleData) + return object; + var message = new $root.google.storagetransfer.v1.AwsS3CompatibleData(); + if (object.bucketName != null) + message.bucketName = String(object.bucketName); + if (object.path != null) + message.path = String(object.path); + if (object.endpoint != null) + message.endpoint = String(object.endpoint); + if (object.region != null) + message.region = String(object.region); + if (object.s3Metadata != null) { + if (typeof object.s3Metadata !== "object") + throw TypeError(".google.storagetransfer.v1.AwsS3CompatibleData.s3Metadata: object expected"); + message.s3Metadata = $root.google.storagetransfer.v1.S3CompatibleMetadata.fromObject(object.s3Metadata); + } + return message; + }; + + /** + * Creates a plain object from an AwsS3CompatibleData message. Also converts values to other types if specified. + * @function toObject + * @memberof google.storagetransfer.v1.AwsS3CompatibleData + * @static + * @param {google.storagetransfer.v1.AwsS3CompatibleData} message AwsS3CompatibleData + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AwsS3CompatibleData.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.bucketName = ""; + object.path = ""; + object.endpoint = ""; + object.region = ""; + } + if (message.bucketName != null && message.hasOwnProperty("bucketName")) + object.bucketName = message.bucketName; + if (message.path != null && message.hasOwnProperty("path")) + object.path = message.path; + if (message.endpoint != null && message.hasOwnProperty("endpoint")) + object.endpoint = message.endpoint; + if (message.s3Metadata != null && message.hasOwnProperty("s3Metadata")) { + object.s3Metadata = $root.google.storagetransfer.v1.S3CompatibleMetadata.toObject(message.s3Metadata, options); + if (options.oneofs) + object.dataProvider = "s3Metadata"; + } + if (message.region != null && message.hasOwnProperty("region")) + object.region = message.region; + return object; + }; + + /** + * Converts this AwsS3CompatibleData to JSON. + * @function toJSON + * @memberof google.storagetransfer.v1.AwsS3CompatibleData + * @instance + * @returns {Object.} JSON object + */ + AwsS3CompatibleData.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AwsS3CompatibleData + * @function getTypeUrl + * @memberof google.storagetransfer.v1.AwsS3CompatibleData + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AwsS3CompatibleData.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.storagetransfer.v1.AwsS3CompatibleData"; + }; + + return AwsS3CompatibleData; + })(); + + v1.S3CompatibleMetadata = (function() { + + /** + * Properties of a S3CompatibleMetadata. + * @memberof google.storagetransfer.v1 + * @interface IS3CompatibleMetadata + * @property {google.storagetransfer.v1.S3CompatibleMetadata.AuthMethod|null} [authMethod] S3CompatibleMetadata authMethod + * @property {google.storagetransfer.v1.S3CompatibleMetadata.RequestModel|null} [requestModel] S3CompatibleMetadata requestModel + * @property {google.storagetransfer.v1.S3CompatibleMetadata.NetworkProtocol|null} [protocol] S3CompatibleMetadata protocol + * @property {google.storagetransfer.v1.S3CompatibleMetadata.ListApi|null} [listApi] S3CompatibleMetadata listApi + */ + + /** + * Constructs a new S3CompatibleMetadata. + * @memberof google.storagetransfer.v1 + * @classdesc Represents a S3CompatibleMetadata. + * @implements IS3CompatibleMetadata + * @constructor + * @param {google.storagetransfer.v1.IS3CompatibleMetadata=} [properties] Properties to set + */ + function S3CompatibleMetadata(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]]; + } + + /** + * S3CompatibleMetadata authMethod. + * @member {google.storagetransfer.v1.S3CompatibleMetadata.AuthMethod} authMethod + * @memberof google.storagetransfer.v1.S3CompatibleMetadata + * @instance + */ + S3CompatibleMetadata.prototype.authMethod = 0; + + /** + * S3CompatibleMetadata requestModel. + * @member {google.storagetransfer.v1.S3CompatibleMetadata.RequestModel} requestModel + * @memberof google.storagetransfer.v1.S3CompatibleMetadata + * @instance + */ + S3CompatibleMetadata.prototype.requestModel = 0; + + /** + * S3CompatibleMetadata protocol. + * @member {google.storagetransfer.v1.S3CompatibleMetadata.NetworkProtocol} protocol + * @memberof google.storagetransfer.v1.S3CompatibleMetadata + * @instance + */ + S3CompatibleMetadata.prototype.protocol = 0; + + /** + * S3CompatibleMetadata listApi. + * @member {google.storagetransfer.v1.S3CompatibleMetadata.ListApi} listApi + * @memberof google.storagetransfer.v1.S3CompatibleMetadata + * @instance + */ + S3CompatibleMetadata.prototype.listApi = 0; + + /** + * Creates a new S3CompatibleMetadata instance using the specified properties. + * @function create + * @memberof google.storagetransfer.v1.S3CompatibleMetadata + * @static + * @param {google.storagetransfer.v1.IS3CompatibleMetadata=} [properties] Properties to set + * @returns {google.storagetransfer.v1.S3CompatibleMetadata} S3CompatibleMetadata instance + */ + S3CompatibleMetadata.create = function create(properties) { + return new S3CompatibleMetadata(properties); + }; + + /** + * Encodes the specified S3CompatibleMetadata message. Does not implicitly {@link google.storagetransfer.v1.S3CompatibleMetadata.verify|verify} messages. + * @function encode + * @memberof google.storagetransfer.v1.S3CompatibleMetadata + * @static + * @param {google.storagetransfer.v1.IS3CompatibleMetadata} message S3CompatibleMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + S3CompatibleMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.authMethod != null && Object.hasOwnProperty.call(message, "authMethod")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.authMethod); + if (message.requestModel != null && Object.hasOwnProperty.call(message, "requestModel")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.requestModel); + if (message.protocol != null && Object.hasOwnProperty.call(message, "protocol")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.protocol); + if (message.listApi != null && Object.hasOwnProperty.call(message, "listApi")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.listApi); + return writer; + }; + + /** + * Encodes the specified S3CompatibleMetadata message, length delimited. Does not implicitly {@link google.storagetransfer.v1.S3CompatibleMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.storagetransfer.v1.S3CompatibleMetadata + * @static + * @param {google.storagetransfer.v1.IS3CompatibleMetadata} message S3CompatibleMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + S3CompatibleMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a S3CompatibleMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.storagetransfer.v1.S3CompatibleMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.storagetransfer.v1.S3CompatibleMetadata} S3CompatibleMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + S3CompatibleMetadata.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.storagetransfer.v1.S3CompatibleMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.authMethod = reader.int32(); + break; + } + case 2: { + message.requestModel = reader.int32(); + break; + } + case 3: { + message.protocol = reader.int32(); + break; + } + case 4: { + message.listApi = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a S3CompatibleMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.storagetransfer.v1.S3CompatibleMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.storagetransfer.v1.S3CompatibleMetadata} S3CompatibleMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + S3CompatibleMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a S3CompatibleMetadata message. + * @function verify + * @memberof google.storagetransfer.v1.S3CompatibleMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + S3CompatibleMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.authMethod != null && message.hasOwnProperty("authMethod")) + switch (message.authMethod) { + default: + return "authMethod: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.requestModel != null && message.hasOwnProperty("requestModel")) + switch (message.requestModel) { + default: + return "requestModel: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.protocol != null && message.hasOwnProperty("protocol")) + switch (message.protocol) { + default: + return "protocol: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.listApi != null && message.hasOwnProperty("listApi")) + switch (message.listApi) { + default: + return "listApi: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a S3CompatibleMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.storagetransfer.v1.S3CompatibleMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.storagetransfer.v1.S3CompatibleMetadata} S3CompatibleMetadata + */ + S3CompatibleMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.storagetransfer.v1.S3CompatibleMetadata) + return object; + var message = new $root.google.storagetransfer.v1.S3CompatibleMetadata(); + switch (object.authMethod) { + case "AUTH_METHOD_UNSPECIFIED": + case 0: + message.authMethod = 0; + break; + case "AUTH_METHOD_AWS_SIGNATURE_V4": + case 1: + message.authMethod = 1; + break; + case "AUTH_METHOD_AWS_SIGNATURE_V2": + case 2: + message.authMethod = 2; + break; + } + switch (object.requestModel) { + case "REQUEST_MODEL_UNSPECIFIED": + case 0: + message.requestModel = 0; + break; + case "REQUEST_MODEL_VIRTUAL_HOSTED_STYLE": + case 1: + message.requestModel = 1; + break; + case "REQUEST_MODEL_PATH_STYLE": + case 2: + message.requestModel = 2; + break; + } + switch (object.protocol) { + case "NETWORK_PROTOCOL_UNSPECIFIED": + case 0: + message.protocol = 0; + break; + case "NETWORK_PROTOCOL_HTTPS": + case 1: + message.protocol = 1; + break; + case "NETWORK_PROTOCOL_HTTP": + case 2: + message.protocol = 2; + break; + } + switch (object.listApi) { + case "LIST_API_UNSPECIFIED": + case 0: + message.listApi = 0; + break; + case "LIST_OBJECTS_V2": + case 1: + message.listApi = 1; + break; + case "LIST_OBJECTS": + case 2: + message.listApi = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a S3CompatibleMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.storagetransfer.v1.S3CompatibleMetadata + * @static + * @param {google.storagetransfer.v1.S3CompatibleMetadata} message S3CompatibleMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + S3CompatibleMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.authMethod = options.enums === String ? "AUTH_METHOD_UNSPECIFIED" : 0; + object.requestModel = options.enums === String ? "REQUEST_MODEL_UNSPECIFIED" : 0; + object.protocol = options.enums === String ? "NETWORK_PROTOCOL_UNSPECIFIED" : 0; + object.listApi = options.enums === String ? "LIST_API_UNSPECIFIED" : 0; + } + if (message.authMethod != null && message.hasOwnProperty("authMethod")) + object.authMethod = options.enums === String ? $root.google.storagetransfer.v1.S3CompatibleMetadata.AuthMethod[message.authMethod] : message.authMethod; + if (message.requestModel != null && message.hasOwnProperty("requestModel")) + object.requestModel = options.enums === String ? $root.google.storagetransfer.v1.S3CompatibleMetadata.RequestModel[message.requestModel] : message.requestModel; + if (message.protocol != null && message.hasOwnProperty("protocol")) + object.protocol = options.enums === String ? $root.google.storagetransfer.v1.S3CompatibleMetadata.NetworkProtocol[message.protocol] : message.protocol; + if (message.listApi != null && message.hasOwnProperty("listApi")) + object.listApi = options.enums === String ? $root.google.storagetransfer.v1.S3CompatibleMetadata.ListApi[message.listApi] : message.listApi; + return object; + }; + + /** + * Converts this S3CompatibleMetadata to JSON. + * @function toJSON + * @memberof google.storagetransfer.v1.S3CompatibleMetadata + * @instance + * @returns {Object.} JSON object + */ + S3CompatibleMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for S3CompatibleMetadata + * @function getTypeUrl + * @memberof google.storagetransfer.v1.S3CompatibleMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + S3CompatibleMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.storagetransfer.v1.S3CompatibleMetadata"; + }; + + /** + * AuthMethod enum. + * @name google.storagetransfer.v1.S3CompatibleMetadata.AuthMethod + * @enum {number} + * @property {number} AUTH_METHOD_UNSPECIFIED=0 AUTH_METHOD_UNSPECIFIED value + * @property {number} AUTH_METHOD_AWS_SIGNATURE_V4=1 AUTH_METHOD_AWS_SIGNATURE_V4 value + * @property {number} AUTH_METHOD_AWS_SIGNATURE_V2=2 AUTH_METHOD_AWS_SIGNATURE_V2 value + */ + S3CompatibleMetadata.AuthMethod = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "AUTH_METHOD_UNSPECIFIED"] = 0; + values[valuesById[1] = "AUTH_METHOD_AWS_SIGNATURE_V4"] = 1; + values[valuesById[2] = "AUTH_METHOD_AWS_SIGNATURE_V2"] = 2; + return values; + })(); + + /** + * RequestModel enum. + * @name google.storagetransfer.v1.S3CompatibleMetadata.RequestModel + * @enum {number} + * @property {number} REQUEST_MODEL_UNSPECIFIED=0 REQUEST_MODEL_UNSPECIFIED value + * @property {number} REQUEST_MODEL_VIRTUAL_HOSTED_STYLE=1 REQUEST_MODEL_VIRTUAL_HOSTED_STYLE value + * @property {number} REQUEST_MODEL_PATH_STYLE=2 REQUEST_MODEL_PATH_STYLE value + */ + S3CompatibleMetadata.RequestModel = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "REQUEST_MODEL_UNSPECIFIED"] = 0; + values[valuesById[1] = "REQUEST_MODEL_VIRTUAL_HOSTED_STYLE"] = 1; + values[valuesById[2] = "REQUEST_MODEL_PATH_STYLE"] = 2; + return values; + })(); + + /** + * NetworkProtocol enum. + * @name google.storagetransfer.v1.S3CompatibleMetadata.NetworkProtocol + * @enum {number} + * @property {number} NETWORK_PROTOCOL_UNSPECIFIED=0 NETWORK_PROTOCOL_UNSPECIFIED value + * @property {number} NETWORK_PROTOCOL_HTTPS=1 NETWORK_PROTOCOL_HTTPS value + * @property {number} NETWORK_PROTOCOL_HTTP=2 NETWORK_PROTOCOL_HTTP value + */ + S3CompatibleMetadata.NetworkProtocol = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NETWORK_PROTOCOL_UNSPECIFIED"] = 0; + values[valuesById[1] = "NETWORK_PROTOCOL_HTTPS"] = 1; + values[valuesById[2] = "NETWORK_PROTOCOL_HTTP"] = 2; + return values; + })(); + + /** + * ListApi enum. + * @name google.storagetransfer.v1.S3CompatibleMetadata.ListApi + * @enum {number} + * @property {number} LIST_API_UNSPECIFIED=0 LIST_API_UNSPECIFIED value + * @property {number} LIST_OBJECTS_V2=1 LIST_OBJECTS_V2 value + * @property {number} LIST_OBJECTS=2 LIST_OBJECTS value + */ + S3CompatibleMetadata.ListApi = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "LIST_API_UNSPECIFIED"] = 0; + values[valuesById[1] = "LIST_OBJECTS_V2"] = 1; + values[valuesById[2] = "LIST_OBJECTS"] = 2; + return values; + })(); + + return S3CompatibleMetadata; + })(); + + v1.AgentPool = (function() { + + /** + * Properties of an AgentPool. + * @memberof google.storagetransfer.v1 + * @interface IAgentPool + * @property {string|null} [name] AgentPool name + * @property {string|null} [displayName] AgentPool displayName + * @property {google.storagetransfer.v1.AgentPool.State|null} [state] AgentPool state + * @property {google.storagetransfer.v1.AgentPool.IBandwidthLimit|null} [bandwidthLimit] AgentPool bandwidthLimit + */ + + /** + * Constructs a new AgentPool. + * @memberof google.storagetransfer.v1 + * @classdesc Represents an AgentPool. + * @implements IAgentPool + * @constructor + * @param {google.storagetransfer.v1.IAgentPool=} [properties] Properties to set + */ + function AgentPool(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]]; + } + + /** + * AgentPool name. + * @member {string} name + * @memberof google.storagetransfer.v1.AgentPool + * @instance + */ + AgentPool.prototype.name = ""; + + /** + * AgentPool displayName. + * @member {string} displayName + * @memberof google.storagetransfer.v1.AgentPool + * @instance + */ + AgentPool.prototype.displayName = ""; + + /** + * AgentPool state. + * @member {google.storagetransfer.v1.AgentPool.State} state + * @memberof google.storagetransfer.v1.AgentPool + * @instance + */ + AgentPool.prototype.state = 0; + + /** + * AgentPool bandwidthLimit. + * @member {google.storagetransfer.v1.AgentPool.IBandwidthLimit|null|undefined} bandwidthLimit + * @memberof google.storagetransfer.v1.AgentPool + * @instance + */ + AgentPool.prototype.bandwidthLimit = null; + + /** + * Creates a new AgentPool instance using the specified properties. + * @function create + * @memberof google.storagetransfer.v1.AgentPool + * @static + * @param {google.storagetransfer.v1.IAgentPool=} [properties] Properties to set + * @returns {google.storagetransfer.v1.AgentPool} AgentPool instance + */ + AgentPool.create = function create(properties) { + return new AgentPool(properties); + }; + + /** + * Encodes the specified AgentPool message. Does not implicitly {@link google.storagetransfer.v1.AgentPool.verify|verify} messages. + * @function encode + * @memberof google.storagetransfer.v1.AgentPool + * @static + * @param {google.storagetransfer.v1.IAgentPool} message AgentPool message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AgentPool.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.name); + if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.displayName); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.state); + if (message.bandwidthLimit != null && Object.hasOwnProperty.call(message, "bandwidthLimit")) + $root.google.storagetransfer.v1.AgentPool.BandwidthLimit.encode(message.bandwidthLimit, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified AgentPool message, length delimited. Does not implicitly {@link google.storagetransfer.v1.AgentPool.verify|verify} messages. + * @function encodeDelimited + * @memberof google.storagetransfer.v1.AgentPool + * @static + * @param {google.storagetransfer.v1.IAgentPool} message AgentPool message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AgentPool.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; @@ -7102,6 +8092,7 @@ * @property {google.storagetransfer.v1.IHttpData|null} [httpDataSource] TransferSpec httpDataSource * @property {google.storagetransfer.v1.IPosixFilesystem|null} [posixDataSource] TransferSpec posixDataSource * @property {google.storagetransfer.v1.IAzureBlobStorageData|null} [azureBlobStorageDataSource] TransferSpec azureBlobStorageDataSource + * @property {google.storagetransfer.v1.IAwsS3CompatibleData|null} [awsS3CompatibleDataSource] TransferSpec awsS3CompatibleDataSource * @property {google.storagetransfer.v1.IGcsData|null} [gcsIntermediateDataLocation] TransferSpec gcsIntermediateDataLocation * @property {google.storagetransfer.v1.IObjectConditions|null} [objectConditions] TransferSpec objectConditions * @property {google.storagetransfer.v1.ITransferOptions|null} [transferOptions] TransferSpec transferOptions @@ -7181,6 +8172,14 @@ */ TransferSpec.prototype.azureBlobStorageDataSource = null; + /** + * TransferSpec awsS3CompatibleDataSource. + * @member {google.storagetransfer.v1.IAwsS3CompatibleData|null|undefined} awsS3CompatibleDataSource + * @memberof google.storagetransfer.v1.TransferSpec + * @instance + */ + TransferSpec.prototype.awsS3CompatibleDataSource = null; + /** * TransferSpec gcsIntermediateDataLocation. * @member {google.storagetransfer.v1.IGcsData|null|undefined} gcsIntermediateDataLocation @@ -7245,12 +8244,12 @@ /** * TransferSpec dataSource. - * @member {"gcsDataSource"|"awsS3DataSource"|"httpDataSource"|"posixDataSource"|"azureBlobStorageDataSource"|undefined} dataSource + * @member {"gcsDataSource"|"awsS3DataSource"|"httpDataSource"|"posixDataSource"|"azureBlobStorageDataSource"|"awsS3CompatibleDataSource"|undefined} dataSource * @memberof google.storagetransfer.v1.TransferSpec * @instance */ Object.defineProperty(TransferSpec.prototype, "dataSource", { - get: $util.oneOfGetter($oneOfFields = ["gcsDataSource", "awsS3DataSource", "httpDataSource", "posixDataSource", "azureBlobStorageDataSource"]), + get: $util.oneOfGetter($oneOfFields = ["gcsDataSource", "awsS3DataSource", "httpDataSource", "posixDataSource", "azureBlobStorageDataSource", "awsS3CompatibleDataSource"]), set: $util.oneOfSetter($oneOfFields) }); @@ -7315,6 +8314,8 @@ writer.uint32(/* id 17, wireType 2 =*/138).string(message.sourceAgentPoolName); if (message.sinkAgentPoolName != null && Object.hasOwnProperty.call(message, "sinkAgentPoolName")) writer.uint32(/* id 18, wireType 2 =*/146).string(message.sinkAgentPoolName); + if (message.awsS3CompatibleDataSource != null && Object.hasOwnProperty.call(message, "awsS3CompatibleDataSource")) + $root.google.storagetransfer.v1.AwsS3CompatibleData.encode(message.awsS3CompatibleDataSource, writer.uint32(/* id 19, wireType 2 =*/154).fork()).ldelim(); return writer; }; @@ -7377,6 +8378,10 @@ message.azureBlobStorageDataSource = $root.google.storagetransfer.v1.AzureBlobStorageData.decode(reader, reader.uint32()); break; } + case 19: { + message.awsS3CompatibleDataSource = $root.google.storagetransfer.v1.AwsS3CompatibleData.decode(reader, reader.uint32()); + break; + } case 16: { message.gcsIntermediateDataLocation = $root.google.storagetransfer.v1.GcsData.decode(reader, reader.uint32()); break; @@ -7503,6 +8508,16 @@ return "azureBlobStorageDataSource." + error; } } + if (message.awsS3CompatibleDataSource != null && message.hasOwnProperty("awsS3CompatibleDataSource")) { + if (properties.dataSource === 1) + return "dataSource: multiple values"; + properties.dataSource = 1; + { + var error = $root.google.storagetransfer.v1.AwsS3CompatibleData.verify(message.awsS3CompatibleDataSource); + if (error) + return "awsS3CompatibleDataSource." + error; + } + } if (message.gcsIntermediateDataLocation != null && message.hasOwnProperty("gcsIntermediateDataLocation")) { properties.intermediateDataLocation = 1; { @@ -7582,6 +8597,11 @@ throw TypeError(".google.storagetransfer.v1.TransferSpec.azureBlobStorageDataSource: object expected"); message.azureBlobStorageDataSource = $root.google.storagetransfer.v1.AzureBlobStorageData.fromObject(object.azureBlobStorageDataSource); } + if (object.awsS3CompatibleDataSource != null) { + if (typeof object.awsS3CompatibleDataSource !== "object") + throw TypeError(".google.storagetransfer.v1.TransferSpec.awsS3CompatibleDataSource: object expected"); + message.awsS3CompatibleDataSource = $root.google.storagetransfer.v1.AwsS3CompatibleData.fromObject(object.awsS3CompatibleDataSource); + } if (object.gcsIntermediateDataLocation != null) { if (typeof object.gcsIntermediateDataLocation !== "object") throw TypeError(".google.storagetransfer.v1.TransferSpec.gcsIntermediateDataLocation: object expected"); @@ -7679,6 +8699,11 @@ object.sourceAgentPoolName = message.sourceAgentPoolName; if (message.sinkAgentPoolName != null && message.hasOwnProperty("sinkAgentPoolName")) object.sinkAgentPoolName = message.sinkAgentPoolName; + if (message.awsS3CompatibleDataSource != null && message.hasOwnProperty("awsS3CompatibleDataSource")) { + object.awsS3CompatibleDataSource = $root.google.storagetransfer.v1.AwsS3CompatibleData.toObject(message.awsS3CompatibleDataSource, options); + if (options.oneofs) + object.dataSource = "awsS3CompatibleDataSource"; + } return object; }; diff --git a/protos/protos.json b/protos/protos.json index 6ab50bf..47e8e61 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -151,6 +151,20 @@ } ] }, + "DeleteTransferJob": { + "requestType": "DeleteTransferJobRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v1/{job_name=transferJobs/**}" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v1/{job_name=transferJobs/**}" + } + } + ] + }, "CreateAgentPool": { "requestType": "CreateAgentPoolRequest", "responseType": "AgentPool", @@ -316,6 +330,24 @@ } } }, + "DeleteTransferJobRequest": { + "fields": { + "jobName": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "projectId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, "ListTransferJobsRequest": { "fields": { "filter": { @@ -646,6 +678,93 @@ } } }, + "AwsS3CompatibleData": { + "oneofs": { + "dataProvider": { + "oneof": [ + "s3Metadata" + ] + } + }, + "fields": { + "bucketName": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "path": { + "type": "string", + "id": 2 + }, + "endpoint": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "region": { + "type": "string", + "id": 5 + }, + "s3Metadata": { + "type": "S3CompatibleMetadata", + "id": 4 + } + } + }, + "S3CompatibleMetadata": { + "fields": { + "authMethod": { + "type": "AuthMethod", + "id": 1 + }, + "requestModel": { + "type": "RequestModel", + "id": 2 + }, + "protocol": { + "type": "NetworkProtocol", + "id": 3 + }, + "listApi": { + "type": "ListApi", + "id": 4 + } + }, + "nested": { + "AuthMethod": { + "values": { + "AUTH_METHOD_UNSPECIFIED": 0, + "AUTH_METHOD_AWS_SIGNATURE_V4": 1, + "AUTH_METHOD_AWS_SIGNATURE_V2": 2 + } + }, + "RequestModel": { + "values": { + "REQUEST_MODEL_UNSPECIFIED": 0, + "REQUEST_MODEL_VIRTUAL_HOSTED_STYLE": 1, + "REQUEST_MODEL_PATH_STYLE": 2 + } + }, + "NetworkProtocol": { + "values": { + "NETWORK_PROTOCOL_UNSPECIFIED": 0, + "NETWORK_PROTOCOL_HTTPS": 1, + "NETWORK_PROTOCOL_HTTP": 2 + } + }, + "ListApi": { + "values": { + "LIST_API_UNSPECIFIED": 0, + "LIST_OBJECTS_V2": 1, + "LIST_OBJECTS": 2 + } + } + } + }, "AgentPool": { "options": { "(google.api.resource).type": "storagetransfer.googleapis.com/agentPools", @@ -742,7 +861,8 @@ "awsS3DataSource", "httpDataSource", "posixDataSource", - "azureBlobStorageDataSource" + "azureBlobStorageDataSource", + "awsS3CompatibleDataSource" ] }, "intermediateDataLocation": { @@ -780,6 +900,10 @@ "type": "AzureBlobStorageData", "id": 8 }, + "awsS3CompatibleDataSource": { + "type": "AwsS3CompatibleData", + "id": 19 + }, "gcsIntermediateDataLocation": { "type": "GcsData", "id": 16 diff --git a/samples/generated/v1/snippet_metadata.google.storagetransfer.v1.json b/samples/generated/v1/snippet_metadata.google.storagetransfer.v1.json index 1c04cc0..162d0ae 100644 --- a/samples/generated/v1/snippet_metadata.google.storagetransfer.v1.json +++ b/samples/generated/v1/snippet_metadata.google.storagetransfer.v1.json @@ -359,6 +359,50 @@ } } }, + { + "regionTag": "storagetransfer_v1_generated_StorageTransferService_DeleteTransferJob_async", + "title": "StorageTransferService deleteTransferJob Sample", + "origin": "API_DEFINITION", + "description": " Deletes a transfer job. Deleting a transfer job sets its status to [DELETED][google.storagetransfer.v1.TransferJob.Status.DELETED].", + "canonical": true, + "file": "storage_transfer_service.delete_transfer_job.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteTransferJob", + "fullName": "google.storagetransfer.v1.StorageTransferService.DeleteTransferJob", + "async": true, + "parameters": [ + { + "name": "job_name", + "type": "TYPE_STRING" + }, + { + "name": "project_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "StorageTransferServiceClient", + "fullName": "google.storagetransfer.v1.StorageTransferServiceClient" + }, + "method": { + "shortName": "DeleteTransferJob", + "fullName": "google.storagetransfer.v1.StorageTransferService.DeleteTransferJob", + "service": { + "shortName": "StorageTransferService", + "fullName": "google.storagetransfer.v1.StorageTransferService" + } + } + } + }, { "regionTag": "storagetransfer_v1_generated_StorageTransferService_CreateAgentPool_async", "title": "StorageTransferService createAgentPool Sample", diff --git a/samples/generated/v1/storage_transfer_service.delete_transfer_job.js b/samples/generated/v1/storage_transfer_service.delete_transfer_job.js new file mode 100644 index 0000000..c70c251 --- /dev/null +++ b/samples/generated/v1/storage_transfer_service.delete_transfer_job.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(jobName, projectId) { + // [START storagetransfer_v1_generated_StorageTransferService_DeleteTransferJob_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. + */ + /** + * Required. The job to delete. + */ + // const jobName = 'abc123' + /** + * Required. The ID of the Google Cloud project that owns the + * job. + */ + // const projectId = 'abc123' + + // Imports the Storagetransfer library + const {StorageTransferServiceClient} = require('@google-cloud/storage-transfer').v1; + + // Instantiates a client + const storagetransferClient = new StorageTransferServiceClient(); + + async function callDeleteTransferJob() { + // Construct request + const request = { + jobName, + projectId, + }; + + // Run request + const response = await storagetransferClient.deleteTransferJob(request); + console.log(response); + } + + callDeleteTransferJob(); + // [END storagetransfer_v1_generated_StorageTransferService_DeleteTransferJob_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/samples/generated/v1/storage_transfer_service.update_transfer_job.js b/samples/generated/v1/storage_transfer_service.update_transfer_job.js index 2ae0d93..7961e98 100644 --- a/samples/generated/v1/storage_transfer_service.update_transfer_job.js +++ b/samples/generated/v1/storage_transfer_service.update_transfer_job.js @@ -47,7 +47,7 @@ function main(jobName, projectId, transferJob) { * other fields are rejected with the error * INVALID_ARGUMENT google.rpc.Code.INVALID_ARGUMENT. Updating a job status * to DELETED google.storagetransfer.v1.TransferJob.Status.DELETED requires - * `storagetransfer.jobs.delete` permissions. + * `storagetransfer.jobs.delete` permission. */ // const transferJob = {} /** diff --git a/src/v1/gapic_metadata.json b/src/v1/gapic_metadata.json index 7f8bdf9..4155aeb 100644 --- a/src/v1/gapic_metadata.json +++ b/src/v1/gapic_metadata.json @@ -40,6 +40,11 @@ "resumeTransferOperation" ] }, + "DeleteTransferJob": { + "methods": [ + "deleteTransferJob" + ] + }, "CreateAgentPool": { "methods": [ "createAgentPool" @@ -114,6 +119,11 @@ "resumeTransferOperation" ] }, + "DeleteTransferJob": { + "methods": [ + "deleteTransferJob" + ] + }, "CreateAgentPool": { "methods": [ "createAgentPool" diff --git a/src/v1/storage_transfer_service_client.ts b/src/v1/storage_transfer_service_client.ts index a80302b..4e4560b 100644 --- a/src/v1/storage_transfer_service_client.ts +++ b/src/v1/storage_transfer_service_client.ts @@ -305,6 +305,7 @@ export class StorageTransferServiceClient { 'pauseTransferOperation', 'resumeTransferOperation', 'runTransferJob', + 'deleteTransferJob', 'createAgentPool', 'updateAgentPool', 'getAgentPool', @@ -496,7 +497,7 @@ export class StorageTransferServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - project_id: request.projectId || '', + project_id: request.projectId ?? '', }); this.initialize(); return this.innerApiCalls.getGoogleServiceAccount( @@ -619,7 +620,7 @@ export class StorageTransferServiceClient { * other fields are rejected with the error * {@link google.rpc.Code.INVALID_ARGUMENT|INVALID_ARGUMENT}. Updating a job status * to {@link google.storagetransfer.v1.TransferJob.Status.DELETED|DELETED} requires - * `storagetransfer.jobs.delete` permissions. + * `storagetransfer.jobs.delete` permission. * @param {google.protobuf.FieldMask} request.updateTransferJobFieldMask * The field mask of the fields in `transferJob` that are to be updated in * this request. Fields in `transferJob` that can be updated are: @@ -710,7 +711,7 @@ export class StorageTransferServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - job_name: request.jobName || '', + job_name: request.jobName ?? '', }); this.initialize(); return this.innerApiCalls.updateTransferJob(request, options, callback); @@ -804,7 +805,7 @@ export class StorageTransferServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - job_name: request.jobName || '', + job_name: request.jobName ?? '', }); this.initialize(); return this.innerApiCalls.getTransferJob(request, options, callback); @@ -901,7 +902,7 @@ export class StorageTransferServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.pauseTransferOperation( @@ -1002,7 +1003,7 @@ export class StorageTransferServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.resumeTransferOperation( @@ -1011,6 +1012,101 @@ export class StorageTransferServiceClient { callback ); } + /** + * Deletes a transfer job. Deleting a transfer job sets its status to + * {@link google.storagetransfer.v1.TransferJob.Status.DELETED|DELETED}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.jobName + * Required. The job to delete. + * @param {string} request.projectId + * Required. The ID of the Google Cloud project that owns the + * job. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/storage_transfer_service.delete_transfer_job.js + * region_tag:storagetransfer_v1_generated_StorageTransferService_DeleteTransferJob_async + */ + deleteTransferJob( + request?: protos.google.storagetransfer.v1.IDeleteTransferJobRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.storagetransfer.v1.IDeleteTransferJobRequest | undefined, + {} | undefined + ] + >; + deleteTransferJob( + request: protos.google.storagetransfer.v1.IDeleteTransferJobRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.storagetransfer.v1.IDeleteTransferJobRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteTransferJob( + request: protos.google.storagetransfer.v1.IDeleteTransferJobRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.storagetransfer.v1.IDeleteTransferJobRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteTransferJob( + request?: protos.google.storagetransfer.v1.IDeleteTransferJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.storagetransfer.v1.IDeleteTransferJobRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.storagetransfer.v1.IDeleteTransferJobRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.storagetransfer.v1.IDeleteTransferJobRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + job_name: request.jobName ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteTransferJob(request, options, callback); + } /** * Creates an agent pool resource. * @@ -1114,7 +1210,7 @@ export class StorageTransferServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - project_id: request.projectId || '', + project_id: request.projectId ?? '', }); this.initialize(); return this.innerApiCalls.createAgentPool(request, options, callback); @@ -1223,7 +1319,7 @@ export class StorageTransferServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'agent_pool.name': request.agentPool!.name || '', + 'agent_pool.name': request.agentPool!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateAgentPool(request, options, callback); @@ -1308,7 +1404,7 @@ export class StorageTransferServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getAgentPool(request, options, callback); @@ -1399,7 +1495,7 @@ export class StorageTransferServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteAgentPool(request, options, callback); @@ -1508,7 +1604,7 @@ export class StorageTransferServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - job_name: request.jobName || '', + job_name: request.jobName ?? '', }); this.initialize(); return this.innerApiCalls.runTransferJob(request, options, callback); @@ -1860,7 +1956,7 @@ export class StorageTransferServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - project_id: request.projectId || '', + project_id: request.projectId ?? '', }); this.initialize(); return this.innerApiCalls.listAgentPools(request, options, callback); @@ -1907,7 +2003,7 @@ export class StorageTransferServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - project_id: request.projectId || '', + project_id: request.projectId ?? '', }); const defaultCallSettings = this._defaults['listAgentPools']; const callSettings = defaultCallSettings.merge(options); @@ -1963,7 +2059,7 @@ export class StorageTransferServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - project_id: request.projectId || '', + project_id: request.projectId ?? '', }); const defaultCallSettings = this._defaults['listAgentPools']; const callSettings = defaultCallSettings.merge(options); @@ -1974,6 +2070,183 @@ export class StorageTransferServiceClient { callSettings ) as AsyncIterable; } + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + // -------------------- // -- Path templates -- // -------------------- diff --git a/src/v1/storage_transfer_service_client_config.json b/src/v1/storage_transfer_service_client_config.json index 6e42410..93b4537 100644 --- a/src/v1/storage_transfer_service_client_config.json +++ b/src/v1/storage_transfer_service_client_config.json @@ -6,6 +6,9 @@ "idempotent": [ "DEADLINE_EXCEEDED", "UNAVAILABLE" + ], + "unavailable": [ + "UNAVAILABLE" ] }, "retry_params": { @@ -17,73 +20,87 @@ "rpc_timeout_multiplier": 1, "max_rpc_timeout_millis": 60000, "total_timeout_millis": 600000 + }, + "264268458a9e88347dbacbd9398202ff5885a40b": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 2, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 } }, "methods": { "GetGoogleServiceAccount": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "264268458a9e88347dbacbd9398202ff5885a40b" }, "CreateTransferJob": { - "timeout_millis": 30000, + "timeout_millis": 60000, "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, "UpdateTransferJob": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "264268458a9e88347dbacbd9398202ff5885a40b" }, "GetTransferJob": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "264268458a9e88347dbacbd9398202ff5885a40b" }, "ListTransferJobs": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "264268458a9e88347dbacbd9398202ff5885a40b" }, "PauseTransferOperation": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "264268458a9e88347dbacbd9398202ff5885a40b" }, "ResumeTransferOperation": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "264268458a9e88347dbacbd9398202ff5885a40b" }, "RunTransferJob": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "264268458a9e88347dbacbd9398202ff5885a40b" + }, + "DeleteTransferJob": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "264268458a9e88347dbacbd9398202ff5885a40b" }, "CreateAgentPool": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "264268458a9e88347dbacbd9398202ff5885a40b" }, "UpdateAgentPool": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "264268458a9e88347dbacbd9398202ff5885a40b" }, "GetAgentPool": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "264268458a9e88347dbacbd9398202ff5885a40b" }, "ListAgentPools": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "264268458a9e88347dbacbd9398202ff5885a40b" }, "DeleteAgentPool": { - "timeout_millis": 30000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "264268458a9e88347dbacbd9398202ff5885a40b" } } } diff --git a/test/gapic_storage_transfer_service_v1.ts b/test/gapic_storage_transfer_service_v1.ts index 433e373..dcda10e 100644 --- a/test/gapic_storage_transfer_service_v1.ts +++ b/test/gapic_storage_transfer_service_v1.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -265,15 +280,12 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.GetGoogleServiceAccountRequest() ); - request.projectId = ''; - const expectedHeaderRequestParams = 'project_id='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetGoogleServiceAccountRequest', + ['projectId'] + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.storagetransfer.v1.GoogleServiceAccount() ); @@ -281,11 +293,14 @@ describe('v1.StorageTransferServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getGoogleServiceAccount(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getGoogleServiceAccount as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getGoogleServiceAccount as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGoogleServiceAccount as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getGoogleServiceAccount without error using callback', async () => { @@ -298,15 +313,12 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.GetGoogleServiceAccountRequest() ); - request.projectId = ''; - const expectedHeaderRequestParams = 'project_id='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetGoogleServiceAccountRequest', + ['projectId'] + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.storagetransfer.v1.GoogleServiceAccount() ); @@ -329,11 +341,14 @@ describe('v1.StorageTransferServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getGoogleServiceAccount as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getGoogleServiceAccount as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGoogleServiceAccount as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getGoogleServiceAccount with error', async () => { @@ -346,15 +361,12 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.GetGoogleServiceAccountRequest() ); - request.projectId = ''; - const expectedHeaderRequestParams = 'project_id='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetGoogleServiceAccountRequest', + ['projectId'] + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getGoogleServiceAccount = stubSimpleCall( undefined, @@ -364,11 +376,14 @@ describe('v1.StorageTransferServiceClient', () => { client.getGoogleServiceAccount(request), expectedError ); - assert( - (client.innerApiCalls.getGoogleServiceAccount as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getGoogleServiceAccount as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getGoogleServiceAccount as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getGoogleServiceAccount with closed client', async () => { @@ -381,7 +396,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.GetGoogleServiceAccountRequest() ); - request.projectId = ''; + const defaultValue1 = getTypeDefaultValue( + 'GetGoogleServiceAccountRequest', + ['projectId'] + ); + request.projectId = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -402,18 +421,12 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.CreateTransferJobRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.storagetransfer.v1.TransferJob() ); client.innerApiCalls.createTransferJob = stubSimpleCall(expectedResponse); const [response] = await client.createTransferJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTransferJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes createTransferJob without error using callback', async () => { @@ -426,7 +439,6 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.CreateTransferJobRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.storagetransfer.v1.TransferJob() ); @@ -449,11 +461,6 @@ describe('v1.StorageTransferServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTransferJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes createTransferJob with error', async () => { @@ -466,18 +473,12 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.CreateTransferJobRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.createTransferJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createTransferJob(request), expectedError); - assert( - (client.innerApiCalls.createTransferJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes createTransferJob with closed client', async () => { @@ -507,26 +508,25 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.UpdateTransferJobRequest() ); - request.jobName = ''; - const expectedHeaderRequestParams = 'job_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UpdateTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; + const expectedHeaderRequestParams = `job_name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.storagetransfer.v1.TransferJob() ); client.innerApiCalls.updateTransferJob = stubSimpleCall(expectedResponse); const [response] = await client.updateTransferJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTransferJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTransferJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTransferJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTransferJob without error using callback', async () => { @@ -539,15 +539,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.UpdateTransferJobRequest() ); - request.jobName = ''; - const expectedHeaderRequestParams = 'job_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UpdateTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; + const expectedHeaderRequestParams = `job_name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.storagetransfer.v1.TransferJob() ); @@ -570,11 +566,14 @@ describe('v1.StorageTransferServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTransferJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateTransferJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTransferJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTransferJob with error', async () => { @@ -587,26 +586,25 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.UpdateTransferJobRequest() ); - request.jobName = ''; - const expectedHeaderRequestParams = 'job_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UpdateTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; + const expectedHeaderRequestParams = `job_name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateTransferJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateTransferJob(request), expectedError); - assert( - (client.innerApiCalls.updateTransferJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTransferJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTransferJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTransferJob with closed client', async () => { @@ -619,7 +617,10 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.UpdateTransferJobRequest() ); - request.jobName = ''; + const defaultValue1 = getTypeDefaultValue('UpdateTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateTransferJob(request), expectedError); @@ -637,26 +638,25 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.GetTransferJobRequest() ); - request.jobName = ''; - const expectedHeaderRequestParams = 'job_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; + const expectedHeaderRequestParams = `job_name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.storagetransfer.v1.TransferJob() ); client.innerApiCalls.getTransferJob = stubSimpleCall(expectedResponse); const [response] = await client.getTransferJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTransferJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTransferJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTransferJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTransferJob without error using callback', async () => { @@ -669,15 +669,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.GetTransferJobRequest() ); - request.jobName = ''; - const expectedHeaderRequestParams = 'job_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; + const expectedHeaderRequestParams = `job_name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.storagetransfer.v1.TransferJob() ); @@ -700,11 +696,14 @@ describe('v1.StorageTransferServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTransferJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getTransferJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTransferJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTransferJob with error', async () => { @@ -717,26 +716,25 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.GetTransferJobRequest() ); - request.jobName = ''; - const expectedHeaderRequestParams = 'job_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; + const expectedHeaderRequestParams = `job_name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getTransferJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getTransferJob(request), expectedError); - assert( - (client.innerApiCalls.getTransferJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTransferJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTransferJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTransferJob with closed client', async () => { @@ -749,7 +747,10 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.GetTransferJobRequest() ); - request.jobName = ''; + const defaultValue1 = getTypeDefaultValue('GetTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getTransferJob(request), expectedError); @@ -767,15 +768,12 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.PauseTransferOperationRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'PauseTransferOperationRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -783,11 +781,14 @@ describe('v1.StorageTransferServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.pauseTransferOperation(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.pauseTransferOperation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.pauseTransferOperation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseTransferOperation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes pauseTransferOperation without error using callback', async () => { @@ -800,15 +801,12 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.PauseTransferOperationRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'PauseTransferOperationRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -831,11 +829,14 @@ describe('v1.StorageTransferServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.pauseTransferOperation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.pauseTransferOperation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseTransferOperation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes pauseTransferOperation with error', async () => { @@ -848,15 +849,12 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.PauseTransferOperationRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'PauseTransferOperationRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.pauseTransferOperation = stubSimpleCall( undefined, @@ -866,11 +864,14 @@ describe('v1.StorageTransferServiceClient', () => { client.pauseTransferOperation(request), expectedError ); - assert( - (client.innerApiCalls.pauseTransferOperation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.pauseTransferOperation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseTransferOperation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes pauseTransferOperation with closed client', async () => { @@ -883,7 +884,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.PauseTransferOperationRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'PauseTransferOperationRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -904,15 +909,12 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.ResumeTransferOperationRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ResumeTransferOperationRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -920,11 +922,14 @@ describe('v1.StorageTransferServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.resumeTransferOperation(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.resumeTransferOperation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.resumeTransferOperation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeTransferOperation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes resumeTransferOperation without error using callback', async () => { @@ -937,15 +942,12 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.ResumeTransferOperationRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ResumeTransferOperationRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -968,11 +970,14 @@ describe('v1.StorageTransferServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.resumeTransferOperation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.resumeTransferOperation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeTransferOperation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes resumeTransferOperation with error', async () => { @@ -985,15 +990,12 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.ResumeTransferOperationRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ResumeTransferOperationRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.resumeTransferOperation = stubSimpleCall( undefined, @@ -1003,11 +1005,14 @@ describe('v1.StorageTransferServiceClient', () => { client.resumeTransferOperation(request), expectedError ); - assert( - (client.innerApiCalls.resumeTransferOperation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.resumeTransferOperation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeTransferOperation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes resumeTransferOperation with closed client', async () => { @@ -1020,7 +1025,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.ResumeTransferOperationRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'ResumeTransferOperationRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1030,6 +1039,136 @@ describe('v1.StorageTransferServiceClient', () => { }); }); + describe('deleteTransferJob', () => { + it('invokes deleteTransferJob without error', async () => { + const client = + new storagetransferserviceModule.v1.StorageTransferServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.storagetransfer.v1.DeleteTransferJobRequest() + ); + const defaultValue1 = getTypeDefaultValue('DeleteTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; + const expectedHeaderRequestParams = `job_name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteTransferJob = stubSimpleCall(expectedResponse); + const [response] = await client.deleteTransferJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTransferJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTransferJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteTransferJob without error using callback', async () => { + const client = + new storagetransferserviceModule.v1.StorageTransferServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.storagetransfer.v1.DeleteTransferJobRequest() + ); + const defaultValue1 = getTypeDefaultValue('DeleteTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; + const expectedHeaderRequestParams = `job_name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteTransferJob = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTransferJob( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTransferJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTransferJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteTransferJob with error', async () => { + const client = + new storagetransferserviceModule.v1.StorageTransferServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.storagetransfer.v1.DeleteTransferJobRequest() + ); + const defaultValue1 = getTypeDefaultValue('DeleteTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; + const expectedHeaderRequestParams = `job_name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTransferJob = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteTransferJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteTransferJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTransferJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteTransferJob with closed client', async () => { + const client = + new storagetransferserviceModule.v1.StorageTransferServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.storagetransfer.v1.DeleteTransferJobRequest() + ); + const defaultValue1 = getTypeDefaultValue('DeleteTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteTransferJob(request), expectedError); + }); + }); + describe('createAgentPool', () => { it('invokes createAgentPool without error', async () => { const client = @@ -1041,26 +1180,25 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.CreateAgentPoolRequest() ); - request.projectId = ''; - const expectedHeaderRequestParams = 'project_id='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateAgentPoolRequest', [ + 'projectId', + ]); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.storagetransfer.v1.AgentPool() ); client.innerApiCalls.createAgentPool = stubSimpleCall(expectedResponse); const [response] = await client.createAgentPool(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createAgentPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createAgentPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createAgentPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createAgentPool without error using callback', async () => { @@ -1073,15 +1211,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.CreateAgentPoolRequest() ); - request.projectId = ''; - const expectedHeaderRequestParams = 'project_id='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateAgentPoolRequest', [ + 'projectId', + ]); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.storagetransfer.v1.AgentPool() ); @@ -1104,11 +1238,14 @@ describe('v1.StorageTransferServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createAgentPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createAgentPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createAgentPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createAgentPool with error', async () => { @@ -1121,26 +1258,25 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.CreateAgentPoolRequest() ); - request.projectId = ''; - const expectedHeaderRequestParams = 'project_id='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateAgentPoolRequest', [ + 'projectId', + ]); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createAgentPool = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createAgentPool(request), expectedError); - assert( - (client.innerApiCalls.createAgentPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createAgentPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createAgentPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createAgentPool with closed client', async () => { @@ -1153,7 +1289,10 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.CreateAgentPoolRequest() ); - request.projectId = ''; + const defaultValue1 = getTypeDefaultValue('CreateAgentPoolRequest', [ + 'projectId', + ]); + request.projectId = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createAgentPool(request), expectedError); @@ -1171,27 +1310,27 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.UpdateAgentPoolRequest() ); - request.agentPool = {}; - request.agentPool.name = ''; - const expectedHeaderRequestParams = 'agent_pool.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.agentPool ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateAgentPoolRequest', [ + 'agentPool', + 'name', + ]); + request.agentPool.name = defaultValue1; + const expectedHeaderRequestParams = `agent_pool.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.storagetransfer.v1.AgentPool() ); client.innerApiCalls.updateAgentPool = stubSimpleCall(expectedResponse); const [response] = await client.updateAgentPool(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateAgentPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateAgentPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAgentPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateAgentPool without error using callback', async () => { @@ -1204,16 +1343,13 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.UpdateAgentPoolRequest() ); - request.agentPool = {}; - request.agentPool.name = ''; - const expectedHeaderRequestParams = 'agent_pool.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.agentPool ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateAgentPoolRequest', [ + 'agentPool', + 'name', + ]); + request.agentPool.name = defaultValue1; + const expectedHeaderRequestParams = `agent_pool.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.storagetransfer.v1.AgentPool() ); @@ -1236,11 +1372,14 @@ describe('v1.StorageTransferServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateAgentPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateAgentPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAgentPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateAgentPool with error', async () => { @@ -1253,27 +1392,27 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.UpdateAgentPoolRequest() ); - request.agentPool = {}; - request.agentPool.name = ''; - const expectedHeaderRequestParams = 'agent_pool.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.agentPool ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateAgentPoolRequest', [ + 'agentPool', + 'name', + ]); + request.agentPool.name = defaultValue1; + const expectedHeaderRequestParams = `agent_pool.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateAgentPool = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateAgentPool(request), expectedError); - assert( - (client.innerApiCalls.updateAgentPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateAgentPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAgentPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateAgentPool with closed client', async () => { @@ -1286,8 +1425,12 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.UpdateAgentPoolRequest() ); - request.agentPool = {}; - request.agentPool.name = ''; + request.agentPool ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateAgentPoolRequest', [ + 'agentPool', + 'name', + ]); + request.agentPool.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateAgentPool(request), expectedError); @@ -1305,26 +1448,25 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.GetAgentPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetAgentPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.storagetransfer.v1.AgentPool() ); client.innerApiCalls.getAgentPool = stubSimpleCall(expectedResponse); const [response] = await client.getAgentPool(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getAgentPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getAgentPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAgentPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getAgentPool without error using callback', async () => { @@ -1337,15 +1479,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.GetAgentPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetAgentPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.storagetransfer.v1.AgentPool() ); @@ -1368,11 +1506,14 @@ describe('v1.StorageTransferServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getAgentPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getAgentPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAgentPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getAgentPool with error', async () => { @@ -1385,26 +1526,25 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.GetAgentPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetAgentPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getAgentPool = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getAgentPool(request), expectedError); - assert( - (client.innerApiCalls.getAgentPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getAgentPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAgentPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getAgentPool with closed client', async () => { @@ -1417,7 +1557,10 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.GetAgentPoolRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetAgentPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getAgentPool(request), expectedError); @@ -1435,26 +1578,25 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.DeleteAgentPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteAgentPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteAgentPool = stubSimpleCall(expectedResponse); const [response] = await client.deleteAgentPool(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteAgentPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteAgentPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAgentPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteAgentPool without error using callback', async () => { @@ -1467,15 +1609,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.DeleteAgentPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteAgentPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1498,11 +1636,14 @@ describe('v1.StorageTransferServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteAgentPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteAgentPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAgentPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteAgentPool with error', async () => { @@ -1515,26 +1656,25 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.DeleteAgentPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteAgentPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteAgentPool = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteAgentPool(request), expectedError); - assert( - (client.innerApiCalls.deleteAgentPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteAgentPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAgentPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteAgentPool with closed client', async () => { @@ -1547,7 +1687,10 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.DeleteAgentPoolRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteAgentPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteAgentPool(request), expectedError); @@ -1565,15 +1708,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.RunTransferJobRequest() ); - request.jobName = ''; - const expectedHeaderRequestParams = 'job_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RunTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; + const expectedHeaderRequestParams = `job_name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1582,11 +1721,14 @@ describe('v1.StorageTransferServiceClient', () => { const [operation] = await client.runTransferJob(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.runTransferJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.runTransferJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runTransferJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes runTransferJob without error using callback', async () => { @@ -1599,15 +1741,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.RunTransferJobRequest() ); - request.jobName = ''; - const expectedHeaderRequestParams = 'job_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RunTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; + const expectedHeaderRequestParams = `job_name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1637,11 +1775,14 @@ describe('v1.StorageTransferServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.runTransferJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.runTransferJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runTransferJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes runTransferJob with call error', async () => { @@ -1654,26 +1795,25 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.RunTransferJobRequest() ); - request.jobName = ''; - const expectedHeaderRequestParams = 'job_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RunTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; + const expectedHeaderRequestParams = `job_name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.runTransferJob = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.runTransferJob(request), expectedError); - assert( - (client.innerApiCalls.runTransferJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.runTransferJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runTransferJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes runTransferJob with LRO error', async () => { @@ -1686,15 +1826,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.RunTransferJobRequest() ); - request.jobName = ''; - const expectedHeaderRequestParams = 'job_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RunTransferJobRequest', [ + 'jobName', + ]); + request.jobName = defaultValue1; + const expectedHeaderRequestParams = `job_name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.runTransferJob = stubLongRunningCall( undefined, @@ -1703,11 +1839,14 @@ describe('v1.StorageTransferServiceClient', () => { ); const [operation] = await client.runTransferJob(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.runTransferJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.runTransferJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runTransferJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkRunTransferJobProgress without error', async () => { @@ -1765,7 +1904,6 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.ListTransferJobsRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = [ generateSampleMessage( new protos.google.storagetransfer.v1.TransferJob() @@ -1780,11 +1918,6 @@ describe('v1.StorageTransferServiceClient', () => { client.innerApiCalls.listTransferJobs = stubSimpleCall(expectedResponse); const [response] = await client.listTransferJobs(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTransferJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes listTransferJobs without error using callback', async () => { @@ -1797,7 +1930,6 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.ListTransferJobsRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = [ generateSampleMessage( new protos.google.storagetransfer.v1.TransferJob() @@ -1828,11 +1960,6 @@ describe('v1.StorageTransferServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTransferJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes listTransferJobs with error', async () => { @@ -1845,18 +1972,12 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.ListTransferJobsRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.listTransferJobs = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listTransferJobs(request), expectedError); - assert( - (client.innerApiCalls.listTransferJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes listTransferJobsStream without error', async () => { @@ -2021,15 +2142,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.ListAgentPoolsRequest() ); - request.projectId = ''; - const expectedHeaderRequestParams = 'project_id='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListAgentPoolsRequest', [ + 'projectId', + ]); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.storagetransfer.v1.AgentPool()), generateSampleMessage(new protos.google.storagetransfer.v1.AgentPool()), @@ -2038,11 +2155,14 @@ describe('v1.StorageTransferServiceClient', () => { client.innerApiCalls.listAgentPools = stubSimpleCall(expectedResponse); const [response] = await client.listAgentPools(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listAgentPools as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listAgentPools as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAgentPools as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listAgentPools without error using callback', async () => { @@ -2055,15 +2175,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.ListAgentPoolsRequest() ); - request.projectId = ''; - const expectedHeaderRequestParams = 'project_id='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListAgentPoolsRequest', [ + 'projectId', + ]); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.storagetransfer.v1.AgentPool()), generateSampleMessage(new protos.google.storagetransfer.v1.AgentPool()), @@ -2088,11 +2204,14 @@ describe('v1.StorageTransferServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listAgentPools as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listAgentPools as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAgentPools as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listAgentPools with error', async () => { @@ -2105,26 +2224,25 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.ListAgentPoolsRequest() ); - request.projectId = ''; - const expectedHeaderRequestParams = 'project_id='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListAgentPoolsRequest', [ + 'projectId', + ]); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listAgentPools = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listAgentPools(request), expectedError); - assert( - (client.innerApiCalls.listAgentPools as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listAgentPools as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAgentPools as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listAgentPoolsStream without error', async () => { @@ -2137,8 +2255,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.ListAgentPoolsRequest() ); - request.projectId = ''; - const expectedHeaderRequestParams = 'project_id='; + const defaultValue1 = getTypeDefaultValue('ListAgentPoolsRequest', [ + 'projectId', + ]); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.storagetransfer.v1.AgentPool()), generateSampleMessage(new protos.google.storagetransfer.v1.AgentPool()), @@ -2169,11 +2290,12 @@ describe('v1.StorageTransferServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listAgentPools, request) ); - assert.strictEqual( - ( - client.descriptors.page.listAgentPools.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listAgentPools.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2187,8 +2309,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.ListAgentPoolsRequest() ); - request.projectId = ''; - const expectedHeaderRequestParams = 'project_id='; + const defaultValue1 = getTypeDefaultValue('ListAgentPoolsRequest', [ + 'projectId', + ]); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listAgentPools.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2214,11 +2339,12 @@ describe('v1.StorageTransferServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listAgentPools, request) ); - assert.strictEqual( - ( - client.descriptors.page.listAgentPools.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listAgentPools.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2232,8 +2358,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.ListAgentPoolsRequest() ); - request.projectId = ''; - const expectedHeaderRequestParams = 'project_id='; + const defaultValue1 = getTypeDefaultValue('ListAgentPoolsRequest', [ + 'projectId', + ]); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.storagetransfer.v1.AgentPool()), generateSampleMessage(new protos.google.storagetransfer.v1.AgentPool()), @@ -2253,11 +2382,12 @@ describe('v1.StorageTransferServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listAgentPools.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listAgentPools.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2271,8 +2401,11 @@ describe('v1.StorageTransferServiceClient', () => { const request = generateSampleMessage( new protos.google.storagetransfer.v1.ListAgentPoolsRequest() ); - request.projectId = ''; - const expectedHeaderRequestParams = 'project_id='; + const defaultValue1 = getTypeDefaultValue('ListAgentPoolsRequest', [ + 'projectId', + ]); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listAgentPools.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2289,11 +2422,328 @@ describe('v1.StorageTransferServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( + (client.descriptors.page.listAgentPools.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new storagetransferserviceModule.v1.StorageTransferServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new storagetransferserviceModule.v1.StorageTransferServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new storagetransferserviceModule.v1.StorageTransferServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new storagetransferserviceModule.v1.StorageTransferServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new storagetransferserviceModule.v1.StorageTransferServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new storagetransferserviceModule.v1.StorageTransferServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new storagetransferserviceModule.v1.StorageTransferServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new storagetransferserviceModule.v1.StorageTransferServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new storagetransferserviceModule.v1.StorageTransferServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new storagetransferserviceModule.v1.StorageTransferServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new storagetransferserviceModule.v1.StorageTransferServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( ( - client.descriptors.page.listAgentPools.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request ); }); });