diff --git a/samples/generated/v1/autoscaling_policy_service.create_autoscaling_policy.js b/samples/generated/v1/autoscaling_policy_service.create_autoscaling_policy.js index 0d0ad0fc..48edf447 100644 --- a/samples/generated/v1/autoscaling_policy_service.create_autoscaling_policy.js +++ b/samples/generated/v1/autoscaling_policy_service.create_autoscaling_policy.js @@ -23,6 +23,9 @@ function main(parent, policy) { // [START dataproc_v1_generated_AutoscalingPolicyService_CreateAutoscalingPolicy_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. */ /** diff --git a/samples/generated/v1/autoscaling_policy_service.delete_autoscaling_policy.js b/samples/generated/v1/autoscaling_policy_service.delete_autoscaling_policy.js index 86e57f8b..3a3cbe27 100644 --- a/samples/generated/v1/autoscaling_policy_service.delete_autoscaling_policy.js +++ b/samples/generated/v1/autoscaling_policy_service.delete_autoscaling_policy.js @@ -23,6 +23,9 @@ function main(name) { // [START dataproc_v1_generated_AutoscalingPolicyService_DeleteAutoscalingPolicy_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. */ /** diff --git a/samples/generated/v1/autoscaling_policy_service.get_autoscaling_policy.js b/samples/generated/v1/autoscaling_policy_service.get_autoscaling_policy.js index 76a64c9e..a441db5a 100644 --- a/samples/generated/v1/autoscaling_policy_service.get_autoscaling_policy.js +++ b/samples/generated/v1/autoscaling_policy_service.get_autoscaling_policy.js @@ -23,6 +23,9 @@ function main(name) { // [START dataproc_v1_generated_AutoscalingPolicyService_GetAutoscalingPolicy_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. */ /** diff --git a/samples/generated/v1/autoscaling_policy_service.list_autoscaling_policies.js b/samples/generated/v1/autoscaling_policy_service.list_autoscaling_policies.js index 991caee2..95e066e4 100644 --- a/samples/generated/v1/autoscaling_policy_service.list_autoscaling_policies.js +++ b/samples/generated/v1/autoscaling_policy_service.list_autoscaling_policies.js @@ -23,6 +23,9 @@ function main(parent) { // [START dataproc_v1_generated_AutoscalingPolicyService_ListAutoscalingPolicies_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. */ /** diff --git a/samples/generated/v1/autoscaling_policy_service.update_autoscaling_policy.js b/samples/generated/v1/autoscaling_policy_service.update_autoscaling_policy.js index 95b50b8c..fe51b21b 100644 --- a/samples/generated/v1/autoscaling_policy_service.update_autoscaling_policy.js +++ b/samples/generated/v1/autoscaling_policy_service.update_autoscaling_policy.js @@ -23,6 +23,9 @@ function main(policy) { // [START dataproc_v1_generated_AutoscalingPolicyService_UpdateAutoscalingPolicy_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. */ /** diff --git a/samples/generated/v1/batch_controller.create_batch.js b/samples/generated/v1/batch_controller.create_batch.js index 398e78f6..d87aff89 100644 --- a/samples/generated/v1/batch_controller.create_batch.js +++ b/samples/generated/v1/batch_controller.create_batch.js @@ -23,6 +23,9 @@ function main(parent, batch) { // [START dataproc_v1_generated_BatchController_CreateBatch_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. */ /** diff --git a/samples/generated/v1/batch_controller.delete_batch.js b/samples/generated/v1/batch_controller.delete_batch.js index 66c9596e..d2422e49 100644 --- a/samples/generated/v1/batch_controller.delete_batch.js +++ b/samples/generated/v1/batch_controller.delete_batch.js @@ -23,6 +23,9 @@ function main(name) { // [START dataproc_v1_generated_BatchController_DeleteBatch_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. */ /** diff --git a/samples/generated/v1/batch_controller.get_batch.js b/samples/generated/v1/batch_controller.get_batch.js index 2cb9bb34..f8e697e1 100644 --- a/samples/generated/v1/batch_controller.get_batch.js +++ b/samples/generated/v1/batch_controller.get_batch.js @@ -23,6 +23,9 @@ function main(name) { // [START dataproc_v1_generated_BatchController_GetBatch_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. */ /** diff --git a/samples/generated/v1/batch_controller.list_batches.js b/samples/generated/v1/batch_controller.list_batches.js index 4170a038..1255756c 100644 --- a/samples/generated/v1/batch_controller.list_batches.js +++ b/samples/generated/v1/batch_controller.list_batches.js @@ -23,6 +23,9 @@ function main(parent) { // [START dataproc_v1_generated_BatchController_ListBatches_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. */ /** diff --git a/samples/generated/v1/cluster_controller.create_cluster.js b/samples/generated/v1/cluster_controller.create_cluster.js index d0623a49..8a8be5b9 100644 --- a/samples/generated/v1/cluster_controller.create_cluster.js +++ b/samples/generated/v1/cluster_controller.create_cluster.js @@ -23,6 +23,9 @@ function main(projectId, region, cluster) { // [START dataproc_v1_generated_ClusterController_CreateCluster_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. */ /** diff --git a/samples/generated/v1/cluster_controller.delete_cluster.js b/samples/generated/v1/cluster_controller.delete_cluster.js index a832f7d9..ee047da8 100644 --- a/samples/generated/v1/cluster_controller.delete_cluster.js +++ b/samples/generated/v1/cluster_controller.delete_cluster.js @@ -23,6 +23,9 @@ function main(projectId, region, clusterName) { // [START dataproc_v1_generated_ClusterController_DeleteCluster_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. */ /** diff --git a/samples/generated/v1/cluster_controller.diagnose_cluster.js b/samples/generated/v1/cluster_controller.diagnose_cluster.js index 11c39954..4dc33eca 100644 --- a/samples/generated/v1/cluster_controller.diagnose_cluster.js +++ b/samples/generated/v1/cluster_controller.diagnose_cluster.js @@ -23,6 +23,9 @@ function main(projectId, region, clusterName) { // [START dataproc_v1_generated_ClusterController_DiagnoseCluster_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. */ /** diff --git a/samples/generated/v1/cluster_controller.get_cluster.js b/samples/generated/v1/cluster_controller.get_cluster.js index b6886881..d2cb6522 100644 --- a/samples/generated/v1/cluster_controller.get_cluster.js +++ b/samples/generated/v1/cluster_controller.get_cluster.js @@ -23,6 +23,9 @@ function main(projectId, region, clusterName) { // [START dataproc_v1_generated_ClusterController_GetCluster_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. */ /** diff --git a/samples/generated/v1/cluster_controller.list_clusters.js b/samples/generated/v1/cluster_controller.list_clusters.js index 00e7a70a..aaadff9f 100644 --- a/samples/generated/v1/cluster_controller.list_clusters.js +++ b/samples/generated/v1/cluster_controller.list_clusters.js @@ -23,6 +23,9 @@ function main(projectId, region) { // [START dataproc_v1_generated_ClusterController_ListClusters_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. */ /** diff --git a/samples/generated/v1/cluster_controller.start_cluster.js b/samples/generated/v1/cluster_controller.start_cluster.js index 9da8f138..a84afdf0 100644 --- a/samples/generated/v1/cluster_controller.start_cluster.js +++ b/samples/generated/v1/cluster_controller.start_cluster.js @@ -23,6 +23,9 @@ function main(projectId, region, clusterName) { // [START dataproc_v1_generated_ClusterController_StartCluster_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. */ /** diff --git a/samples/generated/v1/cluster_controller.stop_cluster.js b/samples/generated/v1/cluster_controller.stop_cluster.js index 5fe7e713..2322ef9b 100644 --- a/samples/generated/v1/cluster_controller.stop_cluster.js +++ b/samples/generated/v1/cluster_controller.stop_cluster.js @@ -23,6 +23,9 @@ function main(projectId, region, clusterName) { // [START dataproc_v1_generated_ClusterController_StopCluster_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. */ /** diff --git a/samples/generated/v1/cluster_controller.update_cluster.js b/samples/generated/v1/cluster_controller.update_cluster.js index 89efb902..407699f1 100644 --- a/samples/generated/v1/cluster_controller.update_cluster.js +++ b/samples/generated/v1/cluster_controller.update_cluster.js @@ -23,6 +23,9 @@ function main(projectId, region, clusterName, cluster, updateMask) { // [START dataproc_v1_generated_ClusterController_UpdateCluster_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. */ /** diff --git a/samples/generated/v1/job_controller.cancel_job.js b/samples/generated/v1/job_controller.cancel_job.js index a51f789c..3ef3b314 100644 --- a/samples/generated/v1/job_controller.cancel_job.js +++ b/samples/generated/v1/job_controller.cancel_job.js @@ -23,6 +23,9 @@ function main(projectId, region, jobId) { // [START dataproc_v1_generated_JobController_CancelJob_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. */ /** diff --git a/samples/generated/v1/job_controller.delete_job.js b/samples/generated/v1/job_controller.delete_job.js index 4f794f47..a77ccb12 100644 --- a/samples/generated/v1/job_controller.delete_job.js +++ b/samples/generated/v1/job_controller.delete_job.js @@ -23,6 +23,9 @@ function main(projectId, region, jobId) { // [START dataproc_v1_generated_JobController_DeleteJob_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. */ /** diff --git a/samples/generated/v1/job_controller.get_job.js b/samples/generated/v1/job_controller.get_job.js index 20135e2a..4f45a6ee 100644 --- a/samples/generated/v1/job_controller.get_job.js +++ b/samples/generated/v1/job_controller.get_job.js @@ -23,6 +23,9 @@ function main(projectId, region, jobId) { // [START dataproc_v1_generated_JobController_GetJob_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. */ /** diff --git a/samples/generated/v1/job_controller.list_jobs.js b/samples/generated/v1/job_controller.list_jobs.js index fd0ddc7b..7b746d83 100644 --- a/samples/generated/v1/job_controller.list_jobs.js +++ b/samples/generated/v1/job_controller.list_jobs.js @@ -23,6 +23,9 @@ function main(projectId, region) { // [START dataproc_v1_generated_JobController_ListJobs_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. */ /** diff --git a/samples/generated/v1/job_controller.submit_job.js b/samples/generated/v1/job_controller.submit_job.js index bc03f366..10d9ecda 100644 --- a/samples/generated/v1/job_controller.submit_job.js +++ b/samples/generated/v1/job_controller.submit_job.js @@ -23,6 +23,9 @@ function main(projectId, region, job) { // [START dataproc_v1_generated_JobController_SubmitJob_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. */ /** diff --git a/samples/generated/v1/job_controller.submit_job_as_operation.js b/samples/generated/v1/job_controller.submit_job_as_operation.js index 8f613395..9bf24c7d 100644 --- a/samples/generated/v1/job_controller.submit_job_as_operation.js +++ b/samples/generated/v1/job_controller.submit_job_as_operation.js @@ -23,6 +23,9 @@ function main(projectId, region, job) { // [START dataproc_v1_generated_JobController_SubmitJobAsOperation_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. */ /** diff --git a/samples/generated/v1/job_controller.update_job.js b/samples/generated/v1/job_controller.update_job.js index 0ba0c750..6c8a77f8 100644 --- a/samples/generated/v1/job_controller.update_job.js +++ b/samples/generated/v1/job_controller.update_job.js @@ -23,6 +23,9 @@ function main(projectId, region, jobId, job, updateMask) { // [START dataproc_v1_generated_JobController_UpdateJob_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. */ /** diff --git a/samples/generated/v1/snippet_metadata.google.cloud.dataproc.v1.json b/samples/generated/v1/snippet_metadata.google.cloud.dataproc.v1.json index 12901d3d..e9eab8b0 100644 --- a/samples/generated/v1/snippet_metadata.google.cloud.dataproc.v1.json +++ b/samples/generated/v1/snippet_metadata.google.cloud.dataproc.v1.json @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 62, + "end": 65, "type": "FULL" } ], @@ -66,7 +66,7 @@ "segments": [ { "start": 25, - "end": 50, + "end": 53, "type": "FULL" } ], @@ -106,7 +106,7 @@ "segments": [ { "start": 25, - "end": 57, + "end": 60, "type": "FULL" } ], @@ -146,7 +146,7 @@ "segments": [ { "start": 25, - "end": 69, + "end": 72, "type": "FULL" } ], @@ -194,7 +194,7 @@ "segments": [ { "start": 25, - "end": 57, + "end": 60, "type": "FULL" } ], @@ -234,7 +234,7 @@ "segments": [ { "start": 25, - "end": 75, + "end": 78, "type": "FULL" } ], @@ -286,7 +286,7 @@ "segments": [ { "start": 25, - "end": 50, + "end": 53, "type": "FULL" } ], @@ -326,7 +326,7 @@ "segments": [ { "start": 25, - "end": 63, + "end": 66, "type": "FULL" } ], @@ -374,7 +374,7 @@ "segments": [ { "start": 25, - "end": 50, + "end": 53, "type": "FULL" } ], @@ -414,7 +414,7 @@ "segments": [ { "start": 25, - "end": 78, + "end": 81, "type": "FULL" } ], @@ -470,7 +470,7 @@ "segments": [ { "start": 25, - "end": 143, + "end": 146, "type": "FULL" } ], @@ -534,7 +534,7 @@ "segments": [ { "start": 25, - "end": 80, + "end": 83, "type": "FULL" } ], @@ -590,7 +590,7 @@ "segments": [ { "start": 25, - "end": 80, + "end": 83, "type": "FULL" } ], @@ -646,7 +646,7 @@ "segments": [ { "start": 25, - "end": 80, + "end": 83, "type": "FULL" } ], @@ -702,7 +702,7 @@ "segments": [ { "start": 25, - "end": 61, + "end": 64, "type": "FULL" } ], @@ -750,7 +750,7 @@ "segments": [ { "start": 25, - "end": 84, + "end": 87, "type": "FULL" } ], @@ -806,7 +806,7 @@ "segments": [ { "start": 25, - "end": 62, + "end": 65, "type": "FULL" } ], @@ -854,7 +854,7 @@ "segments": [ { "start": 25, - "end": 74, + "end": 77, "type": "FULL" } ], @@ -906,7 +906,7 @@ "segments": [ { "start": 25, - "end": 75, + "end": 78, "type": "FULL" } ], @@ -958,7 +958,7 @@ "segments": [ { "start": 25, - "end": 61, + "end": 64, "type": "FULL" } ], @@ -1006,7 +1006,7 @@ "segments": [ { "start": 25, - "end": 91, + "end": 94, "type": "FULL" } ], @@ -1070,7 +1070,7 @@ "segments": [ { "start": 25, - "end": 76, + "end": 79, "type": "FULL" } ], @@ -1126,7 +1126,7 @@ "segments": [ { "start": 25, - "end": 61, + "end": 64, "type": "FULL" } ], @@ -1174,7 +1174,7 @@ "segments": [ { "start": 25, - "end": 61, + "end": 64, "type": "FULL" } ], @@ -1222,7 +1222,7 @@ "segments": [ { "start": 25, - "end": 62, + "end": 65, "type": "FULL" } ], @@ -1266,7 +1266,7 @@ "segments": [ { "start": 25, - "end": 63, + "end": 66, "type": "FULL" } ], @@ -1310,7 +1310,7 @@ "segments": [ { "start": 25, - "end": 81, + "end": 84, "type": "FULL" } ], @@ -1362,7 +1362,7 @@ "segments": [ { "start": 25, - "end": 73, + "end": 76, "type": "FULL" } ], @@ -1410,7 +1410,7 @@ "segments": [ { "start": 25, - "end": 51, + "end": 54, "type": "FULL" } ], @@ -1450,7 +1450,7 @@ "segments": [ { "start": 25, - "end": 68, + "end": 71, "type": "FULL" } ], @@ -1498,7 +1498,7 @@ "segments": [ { "start": 25, - "end": 63, + "end": 66, "type": "FULL" } ], diff --git a/samples/generated/v1/workflow_template_service.create_workflow_template.js b/samples/generated/v1/workflow_template_service.create_workflow_template.js index facd28fd..7f929bc0 100644 --- a/samples/generated/v1/workflow_template_service.create_workflow_template.js +++ b/samples/generated/v1/workflow_template_service.create_workflow_template.js @@ -23,6 +23,9 @@ function main(parent, template) { // [START dataproc_v1_generated_WorkflowTemplateService_CreateWorkflowTemplate_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. */ /** diff --git a/samples/generated/v1/workflow_template_service.delete_workflow_template.js b/samples/generated/v1/workflow_template_service.delete_workflow_template.js index 9a9dec08..5382da62 100644 --- a/samples/generated/v1/workflow_template_service.delete_workflow_template.js +++ b/samples/generated/v1/workflow_template_service.delete_workflow_template.js @@ -23,6 +23,9 @@ function main(name) { // [START dataproc_v1_generated_WorkflowTemplateService_DeleteWorkflowTemplate_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. */ /** diff --git a/samples/generated/v1/workflow_template_service.get_workflow_template.js b/samples/generated/v1/workflow_template_service.get_workflow_template.js index 0013a450..e1aab5cc 100644 --- a/samples/generated/v1/workflow_template_service.get_workflow_template.js +++ b/samples/generated/v1/workflow_template_service.get_workflow_template.js @@ -23,6 +23,9 @@ function main(name) { // [START dataproc_v1_generated_WorkflowTemplateService_GetWorkflowTemplate_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. */ /** diff --git a/samples/generated/v1/workflow_template_service.instantiate_inline_workflow_template.js b/samples/generated/v1/workflow_template_service.instantiate_inline_workflow_template.js index 6aec41bc..e7d46fa6 100644 --- a/samples/generated/v1/workflow_template_service.instantiate_inline_workflow_template.js +++ b/samples/generated/v1/workflow_template_service.instantiate_inline_workflow_template.js @@ -23,6 +23,9 @@ function main(parent, template) { // [START dataproc_v1_generated_WorkflowTemplateService_InstantiateInlineWorkflowTemplate_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. */ /** diff --git a/samples/generated/v1/workflow_template_service.instantiate_workflow_template.js b/samples/generated/v1/workflow_template_service.instantiate_workflow_template.js index ee97d2a0..cd4efec8 100644 --- a/samples/generated/v1/workflow_template_service.instantiate_workflow_template.js +++ b/samples/generated/v1/workflow_template_service.instantiate_workflow_template.js @@ -23,6 +23,9 @@ function main(name) { // [START dataproc_v1_generated_WorkflowTemplateService_InstantiateWorkflowTemplate_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. */ /** diff --git a/samples/generated/v1/workflow_template_service.list_workflow_templates.js b/samples/generated/v1/workflow_template_service.list_workflow_templates.js index 0facd90a..31c6c24a 100644 --- a/samples/generated/v1/workflow_template_service.list_workflow_templates.js +++ b/samples/generated/v1/workflow_template_service.list_workflow_templates.js @@ -23,6 +23,9 @@ function main(parent) { // [START dataproc_v1_generated_WorkflowTemplateService_ListWorkflowTemplates_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. */ /** diff --git a/samples/generated/v1/workflow_template_service.update_workflow_template.js b/samples/generated/v1/workflow_template_service.update_workflow_template.js index c961fda8..df1ef7ef 100644 --- a/samples/generated/v1/workflow_template_service.update_workflow_template.js +++ b/samples/generated/v1/workflow_template_service.update_workflow_template.js @@ -23,6 +23,9 @@ function main(template) { // [START dataproc_v1_generated_WorkflowTemplateService_UpdateWorkflowTemplate_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. */ /** diff --git a/samples/system-test/quickstart.test.js b/samples/system-test/quickstart.test.js index a8f01d5b..56c1b299 100644 --- a/samples/system-test/quickstart.test.js +++ b/samples/system-test/quickstart.test.js @@ -66,23 +66,27 @@ describe('execute the quickstart', () => { }); afterEach(async () => { - await storage.bucket(bucketName).file(jobFileName).delete(); - await storage.bucket(bucketName).delete(); + try { + await storage.bucket(bucketName).file(jobFileName).delete(); + await storage.bucket(bucketName).delete(); - const [clusters] = await clusterClient.listClusters({ - projectId: projectId, - region: region, - }); + const [clusters] = await clusterClient.listClusters({ + projectId: projectId, + region: region, + }); - for (const cluster of clusters) { - if (cluster.clusterName === clusterName) { - await clusterClient.deleteCluster({ - projectId: projectId, - region: region, - clusterName: clusterName, - }); - break; + for (const cluster of clusters) { + if (cluster.clusterName === clusterName) { + await clusterClient.deleteCluster({ + projectId: projectId, + region: region, + clusterName: clusterName, + }); + break; + } } + } catch (err) { + console.error('Cannot clean up resources:', err); } }); }); diff --git a/src/v1/autoscaling_policy_service_client.ts b/src/v1/autoscaling_policy_service_client.ts index 41dcc2f2..1024baee 100644 --- a/src/v1/autoscaling_policy_service_client.ts +++ b/src/v1/autoscaling_policy_service_client.ts @@ -17,8 +17,8 @@ // ** All changes to this file may be overwritten. ** /* global window */ -import * as gax from 'google-gax'; -import { +import type * as gax from 'google-gax'; +import type { Callback, CallOptions, Descriptors, @@ -26,9 +26,7 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; - import {Transform} from 'stream'; -import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -37,7 +35,6 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './autoscaling_policy_service_client_config.json'; - const version = require('../../../package.json').version; /** @@ -98,8 +95,18 @@ export class AutoscalingPolicyServiceClient { * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new AutoscalingPolicyServiceClient({fallback: 'rest'}, gax); + * ``` */ - constructor(opts?: ClientOptions) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { // Ensure that options include all the required fields. const staticMembers = this .constructor as typeof AutoscalingPolicyServiceClient; @@ -120,8 +127,13 @@ export class AutoscalingPolicyServiceClient { opts['scopes'] = staticMembers.scopes; } + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); @@ -217,7 +229,7 @@ export class AutoscalingPolicyServiceClient { this.innerApiCalls = {}; // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; + this.warn = this._gaxModule.warn; } /** @@ -279,7 +291,8 @@ export class AutoscalingPolicyServiceClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -443,7 +456,7 @@ export class AutoscalingPolicyServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); this.initialize(); @@ -547,7 +560,7 @@ export class AutoscalingPolicyServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ 'policy.name': request.policy!.name || '', }); this.initialize(); @@ -651,7 +664,7 @@ export class AutoscalingPolicyServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ name: request.name || '', }); this.initialize(); @@ -758,7 +771,7 @@ export class AutoscalingPolicyServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ name: request.name || '', }); this.initialize(); @@ -872,7 +885,7 @@ export class AutoscalingPolicyServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); this.initialize(); @@ -925,14 +938,14 @@ export class AutoscalingPolicyServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); const defaultCallSettings = this._defaults['listAutoscalingPolicies']; const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listAutoscalingPolicies.createStream( - this.innerApiCalls.listAutoscalingPolicies as gax.GaxCall, + this.innerApiCalls.listAutoscalingPolicies as GaxCall, request, callSettings ); @@ -983,7 +996,7 @@ export class AutoscalingPolicyServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); const defaultCallSettings = this._defaults['listAutoscalingPolicies']; @@ -991,7 +1004,7 @@ export class AutoscalingPolicyServiceClient { this.initialize(); return this.descriptors.page.listAutoscalingPolicies.asyncIterate( this.innerApiCalls['listAutoscalingPolicies'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } diff --git a/src/v1/batch_controller_client.ts b/src/v1/batch_controller_client.ts index 58fd550a..128497f5 100644 --- a/src/v1/batch_controller_client.ts +++ b/src/v1/batch_controller_client.ts @@ -17,8 +17,8 @@ // ** All changes to this file may be overwritten. ** /* global window */ -import * as gax from 'google-gax'; -import { +import type * as gax from 'google-gax'; +import type { Callback, CallOptions, Descriptors, @@ -28,9 +28,7 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; - import {Transform} from 'stream'; -import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -39,7 +37,6 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './batch_controller_client_config.json'; -import {operationsProtos} from 'google-gax'; const version = require('../../../package.json').version; /** @@ -100,8 +97,18 @@ export class BatchControllerClient { * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new BatchControllerClient({fallback: 'rest'}, gax); + * ``` */ - constructor(opts?: ClientOptions) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof BatchControllerClient; const servicePath = @@ -121,8 +128,13 @@ export class BatchControllerClient { opts['scopes'] = staticMembers.scopes; } + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); @@ -358,7 +370,7 @@ export class BatchControllerClient { this.innerApiCalls = {}; // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; + this.warn = this._gaxModule.warn; } /** @@ -421,7 +433,8 @@ export class BatchControllerClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -560,7 +573,7 @@ export class BatchControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ name: request.name || '', }); this.initialize(); @@ -646,7 +659,7 @@ export class BatchControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ name: request.name || '', }); this.initialize(); @@ -770,7 +783,7 @@ export class BatchControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); this.initialize(); @@ -796,14 +809,15 @@ export class BatchControllerClient { protos.google.cloud.dataproc.v1.BatchOperationMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.createBatch, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.cloud.dataproc.v1.Batch, @@ -899,7 +913,7 @@ export class BatchControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); this.initialize(); @@ -940,14 +954,14 @@ export class BatchControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); const defaultCallSettings = this._defaults['listBatches']; const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listBatches.createStream( - this.innerApiCalls.listBatches as gax.GaxCall, + this.innerApiCalls.listBatches as GaxCall, request, callSettings ); @@ -990,7 +1004,7 @@ export class BatchControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); const defaultCallSettings = this._defaults['listBatches']; @@ -998,7 +1012,7 @@ export class BatchControllerClient { this.initialize(); return this.descriptors.page.listBatches.asyncIterate( this.innerApiCalls['listBatches'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } diff --git a/src/v1/cluster_controller_client.ts b/src/v1/cluster_controller_client.ts index c4ac7922..ea90d4b4 100644 --- a/src/v1/cluster_controller_client.ts +++ b/src/v1/cluster_controller_client.ts @@ -17,8 +17,8 @@ // ** All changes to this file may be overwritten. ** /* global window */ -import * as gax from 'google-gax'; -import { +import type * as gax from 'google-gax'; +import type { Callback, CallOptions, Descriptors, @@ -28,9 +28,7 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; - import {Transform} from 'stream'; -import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -39,7 +37,6 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './cluster_controller_client_config.json'; -import {operationsProtos} from 'google-gax'; const version = require('../../../package.json').version; /** @@ -101,8 +98,18 @@ export class ClusterControllerClient { * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ClusterControllerClient({fallback: 'rest'}, gax); + * ``` */ - constructor(opts?: ClientOptions) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ClusterControllerClient; const servicePath = @@ -122,8 +129,13 @@ export class ClusterControllerClient { opts['scopes'] = staticMembers.scopes; } + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); @@ -411,7 +423,7 @@ export class ClusterControllerClient { this.innerApiCalls = {}; // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; + this.warn = this._gaxModule.warn; } /** @@ -478,7 +490,8 @@ export class ClusterControllerClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -622,7 +635,7 @@ export class ClusterControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', cluster_name: request.clusterName || '', @@ -749,7 +762,7 @@ export class ClusterControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', }); @@ -776,14 +789,15 @@ export class ClusterControllerClient { protos.google.cloud.dataproc.v1.ClusterOperationMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.createCluster, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.cloud.dataproc.v1.Cluster, @@ -973,7 +987,7 @@ export class ClusterControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', cluster_name: request.clusterName || '', @@ -1001,14 +1015,15 @@ export class ClusterControllerClient { protos.google.cloud.dataproc.v1.ClusterOperationMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.updateCluster, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.cloud.dataproc.v1.Cluster, @@ -1133,7 +1148,7 @@ export class ClusterControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', cluster_name: request.clusterName || '', @@ -1161,14 +1176,15 @@ export class ClusterControllerClient { protos.google.cloud.dataproc.v1.ClusterOperationMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.stopCluster, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.cloud.dataproc.v1.Cluster, @@ -1293,7 +1309,7 @@ export class ClusterControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', cluster_name: request.clusterName || '', @@ -1321,14 +1337,15 @@ export class ClusterControllerClient { protos.google.cloud.dataproc.v1.ClusterOperationMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.startCluster, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.cloud.dataproc.v1.Cluster, @@ -1455,7 +1472,7 @@ export class ClusterControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', cluster_name: request.clusterName || '', @@ -1483,14 +1500,15 @@ export class ClusterControllerClient { protos.google.cloud.dataproc.v1.ClusterOperationMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.deleteCluster, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.protobuf.Empty, @@ -1605,7 +1623,7 @@ export class ClusterControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', cluster_name: request.clusterName || '', @@ -1633,14 +1651,15 @@ export class ClusterControllerClient { protos.google.cloud.dataproc.v1.ClusterOperationMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.diagnoseCluster, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.cloud.dataproc.v1.DiagnoseClusterResults, @@ -1756,7 +1775,7 @@ export class ClusterControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', }); @@ -1818,7 +1837,7 @@ export class ClusterControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', }); @@ -1826,7 +1845,7 @@ export class ClusterControllerClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listClusters.createStream( - this.innerApiCalls.listClusters as gax.GaxCall, + this.innerApiCalls.listClusters as GaxCall, request, callSettings ); @@ -1889,7 +1908,7 @@ export class ClusterControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', }); @@ -1898,7 +1917,7 @@ export class ClusterControllerClient { this.initialize(); return this.descriptors.page.listClusters.asyncIterate( this.innerApiCalls['listClusters'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } diff --git a/src/v1/job_controller_client.ts b/src/v1/job_controller_client.ts index 2aa0bf74..a9dd5743 100644 --- a/src/v1/job_controller_client.ts +++ b/src/v1/job_controller_client.ts @@ -17,8 +17,8 @@ // ** All changes to this file may be overwritten. ** /* global window */ -import * as gax from 'google-gax'; -import { +import type * as gax from 'google-gax'; +import type { Callback, CallOptions, Descriptors, @@ -28,9 +28,7 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; - import {Transform} from 'stream'; -import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -39,7 +37,6 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './job_controller_client_config.json'; -import {operationsProtos} from 'google-gax'; const version = require('../../../package.json').version; /** @@ -100,8 +97,18 @@ export class JobControllerClient { * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new JobControllerClient({fallback: 'rest'}, gax); + * ``` */ - constructor(opts?: ClientOptions) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof JobControllerClient; const servicePath = @@ -121,8 +128,13 @@ export class JobControllerClient { opts['scopes'] = staticMembers.scopes; } + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); @@ -352,7 +364,7 @@ export class JobControllerClient { this.innerApiCalls = {}; // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; + this.warn = this._gaxModule.warn; } /** @@ -418,7 +430,8 @@ export class JobControllerClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -575,7 +588,7 @@ export class JobControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', }); @@ -664,7 +677,7 @@ export class JobControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', job_id: request.jobId || '', @@ -763,7 +776,7 @@ export class JobControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', job_id: request.jobId || '', @@ -857,7 +870,7 @@ export class JobControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', job_id: request.jobId || '', @@ -948,7 +961,7 @@ export class JobControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', job_id: request.jobId || '', @@ -1072,7 +1085,7 @@ export class JobControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', }); @@ -1099,14 +1112,15 @@ export class JobControllerClient { protos.google.cloud.dataproc.v1.JobMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.submitJobAsOperation, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.cloud.dataproc.v1.Job, @@ -1224,7 +1238,7 @@ export class JobControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', }); @@ -1290,7 +1304,7 @@ export class JobControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', }); @@ -1298,7 +1312,7 @@ export class JobControllerClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listJobs.createStream( - this.innerApiCalls.listJobs as gax.GaxCall, + this.innerApiCalls.listJobs as GaxCall, request, callSettings ); @@ -1365,7 +1379,7 @@ export class JobControllerClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ project_id: request.projectId || '', region: request.region || '', }); @@ -1374,7 +1388,7 @@ export class JobControllerClient { this.initialize(); return this.descriptors.page.listJobs.asyncIterate( this.innerApiCalls['listJobs'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } diff --git a/src/v1/workflow_template_service_client.ts b/src/v1/workflow_template_service_client.ts index 23f6cca4..b79af6dd 100644 --- a/src/v1/workflow_template_service_client.ts +++ b/src/v1/workflow_template_service_client.ts @@ -17,8 +17,8 @@ // ** All changes to this file may be overwritten. ** /* global window */ -import * as gax from 'google-gax'; -import { +import type * as gax from 'google-gax'; +import type { Callback, CallOptions, Descriptors, @@ -28,9 +28,7 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; - import {Transform} from 'stream'; -import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -39,7 +37,6 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './workflow_template_service_client_config.json'; -import {operationsProtos} from 'google-gax'; const version = require('../../../package.json').version; /** @@ -101,8 +98,18 @@ export class WorkflowTemplateServiceClient { * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new WorkflowTemplateServiceClient({fallback: 'rest'}, gax); + * ``` */ - constructor(opts?: ClientOptions) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { // Ensure that options include all the required fields. const staticMembers = this .constructor as typeof WorkflowTemplateServiceClient; @@ -123,8 +130,13 @@ export class WorkflowTemplateServiceClient { opts['scopes'] = staticMembers.scopes; } + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); @@ -380,7 +392,7 @@ export class WorkflowTemplateServiceClient { this.innerApiCalls = {}; // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; + this.warn = this._gaxModule.warn; } /** @@ -447,7 +459,8 @@ export class WorkflowTemplateServiceClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -611,7 +624,7 @@ export class WorkflowTemplateServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); this.initialize(); @@ -723,7 +736,7 @@ export class WorkflowTemplateServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ name: request.name || '', }); this.initialize(); @@ -823,7 +836,7 @@ export class WorkflowTemplateServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ 'template.name': request.template!.name || '', }); this.initialize(); @@ -937,7 +950,7 @@ export class WorkflowTemplateServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ name: request.name || '', }); this.initialize(); @@ -1093,7 +1106,7 @@ export class WorkflowTemplateServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ name: request.name || '', }); this.initialize(); @@ -1123,14 +1136,15 @@ export class WorkflowTemplateServiceClient { protos.google.cloud.dataproc.v1.WorkflowMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.instantiateWorkflowTemplate, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.protobuf.Empty, @@ -1278,7 +1292,7 @@ export class WorkflowTemplateServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); this.initialize(); @@ -1308,14 +1322,15 @@ export class WorkflowTemplateServiceClient { protos.google.cloud.dataproc.v1.WorkflowMetadata > > { - const request = new operationsProtos.google.longrunning.GetOperationRequest( - {name} - ); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation( + const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.instantiateInlineWorkflowTemplate, - gax.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.protobuf.Empty, @@ -1424,7 +1439,7 @@ export class WorkflowTemplateServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); this.initialize(); @@ -1472,14 +1487,14 @@ export class WorkflowTemplateServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); const defaultCallSettings = this._defaults['listWorkflowTemplates']; const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listWorkflowTemplates.createStream( - this.innerApiCalls.listWorkflowTemplates as gax.GaxCall, + this.innerApiCalls.listWorkflowTemplates as GaxCall, request, callSettings ); @@ -1529,7 +1544,7 @@ export class WorkflowTemplateServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ + this._gaxModule.routingHeader.fromParams({ parent: request.parent || '', }); const defaultCallSettings = this._defaults['listWorkflowTemplates']; @@ -1537,7 +1552,7 @@ export class WorkflowTemplateServiceClient { this.initialize(); return this.descriptors.page.listWorkflowTemplates.asyncIterate( this.innerApiCalls['listWorkflowTemplates'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } diff --git a/test/gapic_autoscaling_policy_service_v1.ts b/test/gapic_autoscaling_policy_service_v1.ts index 5d9d6415..746a32f8 100644 --- a/test/gapic_autoscaling_policy_service_v1.ts +++ b/test/gapic_autoscaling_policy_service_v1.ts @@ -113,111 +113,113 @@ function stubAsyncIterationCall( } describe('v1.AutoscalingPolicyServiceClient', () => { - it('has servicePath', () => { - const servicePath = - autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient - .servicePath; - assert(servicePath); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient + .servicePath; + assert(servicePath); + }); - it('has apiEndpoint', () => { - const apiEndpoint = - autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient - .apiEndpoint; - assert(apiEndpoint); - }); + it('has apiEndpoint', () => { + const apiEndpoint = + autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient + .apiEndpoint; + assert(apiEndpoint); + }); - it('has port', () => { - const port = - autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('has port', () => { + const port = + autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with no option', () => { - const client = - new autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient(); - assert(client); - }); + it('should create a client with no option', () => { + const client = + new autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient(); + assert(client); + }); - it('should create a client with gRPC fallback', () => { - const client = - new autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with gRPC fallback', () => { + const client = + new autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = - new autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.autoscalingPolicyServiceStub, undefined); - await client.initialize(); - assert(client.autoscalingPolicyServiceStub); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = + new autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.autoscalingPolicyServiceStub, undefined); + await client.initialize(); + assert(client.autoscalingPolicyServiceStub); + }); - it('has close method for the initialized client', done => { - const client = - new autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the initialized client', done => { + const client = + new autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.autoscalingPolicyServiceStub); + client.close().then(() => { + done(); }); - client.initialize(); - assert(client.autoscalingPolicyServiceStub); - client.close().then(() => { - done(); }); - }); - it('has close method for the non-initialized client', done => { - const client = - new autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the non-initialized client', done => { + const client = + new autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.autoscalingPolicyServiceStub, undefined); + client.close().then(() => { + done(); }); - assert.strictEqual(client.autoscalingPolicyServiceStub, undefined); - client.close().then(() => { - done(); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = - new autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = - new autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new autoscalingpolicyserviceModule.v1.AutoscalingPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('createAutoscalingPolicy', () => { diff --git a/test/gapic_batch_controller_v1.ts b/test/gapic_batch_controller_v1.ts index b0c01e43..f42db7ce 100644 --- a/test/gapic_batch_controller_v1.ts +++ b/test/gapic_batch_controller_v1.ts @@ -145,101 +145,103 @@ function stubAsyncIterationCall( } describe('v1.BatchControllerClient', () => { - it('has servicePath', () => { - const servicePath = - batchcontrollerModule.v1.BatchControllerClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = - batchcontrollerModule.v1.BatchControllerClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = batchcontrollerModule.v1.BatchControllerClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new batchcontrollerModule.v1.BatchControllerClient(); - assert(client); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + batchcontrollerModule.v1.BatchControllerClient.servicePath; + assert(servicePath); + }); - it('should create a client with gRPC fallback', () => { - const client = new batchcontrollerModule.v1.BatchControllerClient({ - fallback: true, + it('has apiEndpoint', () => { + const apiEndpoint = + batchcontrollerModule.v1.BatchControllerClient.apiEndpoint; + assert(apiEndpoint); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new batchcontrollerModule.v1.BatchControllerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has port', () => { + const port = batchcontrollerModule.v1.BatchControllerClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert.strictEqual(client.batchControllerStub, undefined); - await client.initialize(); - assert(client.batchControllerStub); - }); - it('has close method for the initialized client', done => { - const client = new batchcontrollerModule.v1.BatchControllerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = new batchcontrollerModule.v1.BatchControllerClient(); + assert(client); }); - client.initialize(); - assert(client.batchControllerStub); - client.close().then(() => { - done(); + + it('should create a client with gRPC fallback', () => { + const client = new batchcontrollerModule.v1.BatchControllerClient({ + fallback: true, + }); + assert(client); }); - }); - it('has close method for the non-initialized client', done => { - const client = new batchcontrollerModule.v1.BatchControllerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has initialize method and supports deferred initialization', async () => { + const client = new batchcontrollerModule.v1.BatchControllerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.batchControllerStub, undefined); + await client.initialize(); + assert(client.batchControllerStub); }); - assert.strictEqual(client.batchControllerStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the initialized client', done => { + const client = new batchcontrollerModule.v1.BatchControllerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.batchControllerStub); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new batchcontrollerModule.v1.BatchControllerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the non-initialized client', done => { + const client = new batchcontrollerModule.v1.BatchControllerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.batchControllerStub, undefined); + client.close().then(() => { + done(); + }); }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new batchcontrollerModule.v1.BatchControllerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new batchcontrollerModule.v1.BatchControllerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new batchcontrollerModule.v1.BatchControllerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('getBatch', () => { diff --git a/test/gapic_cluster_controller_v1.ts b/test/gapic_cluster_controller_v1.ts index 8950e4b1..65041098 100644 --- a/test/gapic_cluster_controller_v1.ts +++ b/test/gapic_cluster_controller_v1.ts @@ -145,101 +145,103 @@ function stubAsyncIterationCall( } describe('v1.ClusterControllerClient', () => { - it('has servicePath', () => { - const servicePath = - clustercontrollerModule.v1.ClusterControllerClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = - clustercontrollerModule.v1.ClusterControllerClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = clustercontrollerModule.v1.ClusterControllerClient.port; - assert(port); - assert(typeof port === 'number'); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + clustercontrollerModule.v1.ClusterControllerClient.servicePath; + assert(servicePath); + }); - it('should create a client with no option', () => { - const client = new clustercontrollerModule.v1.ClusterControllerClient(); - assert(client); - }); + it('has apiEndpoint', () => { + const apiEndpoint = + clustercontrollerModule.v1.ClusterControllerClient.apiEndpoint; + assert(apiEndpoint); + }); - it('should create a client with gRPC fallback', () => { - const client = new clustercontrollerModule.v1.ClusterControllerClient({ - fallback: true, + it('has port', () => { + const port = clustercontrollerModule.v1.ClusterControllerClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new clustercontrollerModule.v1.ClusterControllerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = new clustercontrollerModule.v1.ClusterControllerClient(); + assert(client); }); - assert.strictEqual(client.clusterControllerStub, undefined); - await client.initialize(); - assert(client.clusterControllerStub); - }); - it('has close method for the initialized client', done => { - const client = new clustercontrollerModule.v1.ClusterControllerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with gRPC fallback', () => { + const client = new clustercontrollerModule.v1.ClusterControllerClient({ + fallback: true, + }); + assert(client); }); - client.initialize(); - assert(client.clusterControllerStub); - client.close().then(() => { - done(); + + it('has initialize method and supports deferred initialization', async () => { + const client = new clustercontrollerModule.v1.ClusterControllerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.clusterControllerStub, undefined); + await client.initialize(); + assert(client.clusterControllerStub); }); - }); - it('has close method for the non-initialized client', done => { - const client = new clustercontrollerModule.v1.ClusterControllerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the initialized client', done => { + const client = new clustercontrollerModule.v1.ClusterControllerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.clusterControllerStub); + client.close().then(() => { + done(); + }); }); - assert.strictEqual(client.clusterControllerStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the non-initialized client', done => { + const client = new clustercontrollerModule.v1.ClusterControllerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.clusterControllerStub, undefined); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new clustercontrollerModule.v1.ClusterControllerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new clustercontrollerModule.v1.ClusterControllerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new clustercontrollerModule.v1.ClusterControllerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new clustercontrollerModule.v1.ClusterControllerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('getCluster', () => { diff --git a/test/gapic_job_controller_v1.ts b/test/gapic_job_controller_v1.ts index 1ea33e2a..e9f29aec 100644 --- a/test/gapic_job_controller_v1.ts +++ b/test/gapic_job_controller_v1.ts @@ -145,99 +145,103 @@ function stubAsyncIterationCall( } describe('v1.JobControllerClient', () => { - it('has servicePath', () => { - const servicePath = jobcontrollerModule.v1.JobControllerClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = jobcontrollerModule.v1.JobControllerClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = jobcontrollerModule.v1.JobControllerClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new jobcontrollerModule.v1.JobControllerClient(); - assert(client); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + jobcontrollerModule.v1.JobControllerClient.servicePath; + assert(servicePath); + }); - it('should create a client with gRPC fallback', () => { - const client = new jobcontrollerModule.v1.JobControllerClient({ - fallback: true, + it('has apiEndpoint', () => { + const apiEndpoint = + jobcontrollerModule.v1.JobControllerClient.apiEndpoint; + assert(apiEndpoint); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new jobcontrollerModule.v1.JobControllerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has port', () => { + const port = jobcontrollerModule.v1.JobControllerClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert.strictEqual(client.jobControllerStub, undefined); - await client.initialize(); - assert(client.jobControllerStub); - }); - it('has close method for the initialized client', done => { - const client = new jobcontrollerModule.v1.JobControllerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = new jobcontrollerModule.v1.JobControllerClient(); + assert(client); }); - client.initialize(); - assert(client.jobControllerStub); - client.close().then(() => { - done(); + + it('should create a client with gRPC fallback', () => { + const client = new jobcontrollerModule.v1.JobControllerClient({ + fallback: true, + }); + assert(client); }); - }); - it('has close method for the non-initialized client', done => { - const client = new jobcontrollerModule.v1.JobControllerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has initialize method and supports deferred initialization', async () => { + const client = new jobcontrollerModule.v1.JobControllerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.jobControllerStub, undefined); + await client.initialize(); + assert(client.jobControllerStub); }); - assert.strictEqual(client.jobControllerStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the initialized client', done => { + const client = new jobcontrollerModule.v1.JobControllerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.jobControllerStub); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new jobcontrollerModule.v1.JobControllerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the non-initialized client', done => { + const client = new jobcontrollerModule.v1.JobControllerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.jobControllerStub, undefined); + client.close().then(() => { + done(); + }); }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new jobcontrollerModule.v1.JobControllerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new jobcontrollerModule.v1.JobControllerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new jobcontrollerModule.v1.JobControllerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('submitJob', () => { diff --git a/test/gapic_workflow_template_service_v1.ts b/test/gapic_workflow_template_service_v1.ts index d80e2f33..2b0325ff 100644 --- a/test/gapic_workflow_template_service_v1.ts +++ b/test/gapic_workflow_template_service_v1.ts @@ -145,111 +145,113 @@ function stubAsyncIterationCall( } describe('v1.WorkflowTemplateServiceClient', () => { - it('has servicePath', () => { - const servicePath = - workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient - .servicePath; - assert(servicePath); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient + .servicePath; + assert(servicePath); + }); - it('has apiEndpoint', () => { - const apiEndpoint = - workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient - .apiEndpoint; - assert(apiEndpoint); - }); + it('has apiEndpoint', () => { + const apiEndpoint = + workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient + .apiEndpoint; + assert(apiEndpoint); + }); - it('has port', () => { - const port = - workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('has port', () => { + const port = + workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with no option', () => { - const client = - new workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient(); - assert(client); - }); + it('should create a client with no option', () => { + const client = + new workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient(); + assert(client); + }); - it('should create a client with gRPC fallback', () => { - const client = - new workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with gRPC fallback', () => { + const client = + new workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = - new workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.workflowTemplateServiceStub, undefined); - await client.initialize(); - assert(client.workflowTemplateServiceStub); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = + new workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.workflowTemplateServiceStub, undefined); + await client.initialize(); + assert(client.workflowTemplateServiceStub); + }); - it('has close method for the initialized client', done => { - const client = - new workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the initialized client', done => { + const client = + new workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.workflowTemplateServiceStub); + client.close().then(() => { + done(); }); - client.initialize(); - assert(client.workflowTemplateServiceStub); - client.close().then(() => { - done(); }); - }); - it('has close method for the non-initialized client', done => { - const client = - new workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the non-initialized client', done => { + const client = + new workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.workflowTemplateServiceStub, undefined); + client.close().then(() => { + done(); }); - assert.strictEqual(client.workflowTemplateServiceStub, undefined); - client.close().then(() => { - done(); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = - new workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = - new workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new workflowtemplateserviceModule.v1.WorkflowTemplateServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('createWorkflowTemplate', () => {