我在使用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://u003cbucketu003e/u003cpathu003e'",
"errors": [
{
"message": "(11f8b78933fc59c3): Bad file name: , expected
'gs://u003cbucketu003e/u003cpathu003e'",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
路径似乎在一路上被破坏了,我已经检查过了,它一直很好,直到Guzzle对象被实例化以在库中发送请求。
在这一点上我很迷茫,所以任何建议或线索都是受欢迎的。
提前谢谢。
SDK构建的请求的查询参数中没有给出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);