PHP Google_Service_Dataflow 未在存储桶中找到文件

PHP Google_Service_Dataflow not finding file in bucket

我在使用 googleapis/google-api-php-client 库时遇到了一个问题,特别是我无法解决的数据流服务。

当我尝试使用库时,我会像这样设置请求:

$this->client = new \Google_Client();
$this->client->setAuthConfig(config_path('google-service-account.json'));
$this->client->setIncludeGrantedScopes(true);
$this->client->addScope(\Google_Service_Dataflow::CLOUD_PLATFORM);

$body = [
    "gcsPath" => "gs://{$this->bucket}/{$this->template}",
    "location" => "us-central1",
];

$parameters = new \Google_Service_Dataflow_LaunchTemplateParameters;
$parameters->setJobName($this->jobname);
$parameters->setParameters($body);

$service = new \Google_Service_Dataflow($this->client);
$request = $service->projects_templates->launch($this->project, $parameters);

我收到以下错误:

{
  "error": {
    "code": 400,
    "message": "(11f8b78933fc59c3): Bad file name: , expected 
    'gs://\u003cbucket\u003e/\u003cpath\u003e'",
    "errors": [
      {
        "message": "(11f8b78933fc59c3): Bad file name: , expected 
        'gs://\u003cbucket\u003e/\u003cpath\u003e'",
        "domain": "global",
        "reason": "badRequest"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}

路径似乎在途中被破坏了,我已经检查过并且在 Guzzle 对象被实例化以在库内发送请求之前一切正常。

我现在很迷茫,所以欢迎任何建议或线索。

提前谢谢你。

SDK构造请求的query参数中没有gcsPath

这是因为 gcsPath 设置为 Google_Service_Dataflow_LaunchTemplateParameters 的一个选项。

记录了请求查询参数作为可选参数给出 (参见 https://github.com/googleapis/google-api-php-client-services/blob/v0.81/src/Google/Service/Dataflow/Resource/ProjectsTemplates.php#L73。)

$opt_params = [
    "gcsPath" => "gs://{$this->bucket}/{$this->template}",
    "location" => "us-central1",
];

$template_params = [
   // Keep template params here.
];

$launch_params = new \Google_Service_Dataflow_LaunchTemplateParameters;
$launch_params->setJobName($this->jobname);
$parameters->setParameters($template_params);

$service = new \Google_Service_Dataflow($this->client);
$request = $service->projects_templates->launch($this->project, $parameters, $opt_params);