简体   繁体   English

.NET 中的 Google.Cloud.AppEngine.V1 客户端库和流量拆分

[英]Google.Cloud.AppEngine.V1 client libraries and traffic splitting in .NET

I am trying to use the Client Libraries provided by Google to move traffic from one version of an app in AppEngine to another.我正在尝试使用 Google 提供的客户端库将流量从 AppEngine 中的一个应用程序版本转移到另一个版本。 However, the documentation for doing this just talks about using the rest API and not the client libraries.但是,执行此操作的文档仅讨论使用 rest API 而不是客户端库。

Here is some example code:这是一些示例代码:

var servicesClient = Google.Cloud.AppEngine.V1.ServicesClient.Create();
var updateServiceRequest = new UpdateServiceRequest();
updateServiceRequest.Name = "apps/myProject/services/myService";
var updateMask = new Google.Protobuf.WellKnownTypes.FieldMask();
updateServiceRequest.UpdateMask = updateMask;

// See below for what should go here...

var updateResponse = servicesClient.UpdateService(updateServiceRequest);

My question is what format do I use for the update mask?我的问题是更新掩码使用什么格式? According to the documentation I should put in: split {"split": { "allocations": { "newVersion": 1 } } } But when I try: updateMask.Paths.Add(@"split { ""split"": { ""allocations"": { ""myNewVersion"": 1 } } }");根据我应该输入的文档: split {"split": { "allocations": { "newVersion": 1 } } }但是当我尝试时: updateMask.Paths.Add(@"split { ""split"": { ""allocations"": { ""myNewVersion"": 1 } } }");

... I get the exception: ...我得到例外:

"This operation is only supported on the following field(s): [labels, migration_config,.network_settings, split, tag_to_target_map], but got field(s): [split { "split": { "allocations": { "myNewVersion": 1 } } }] from the update request.

Any ideas where I should put the details of the split in the field mask object?有什么想法我应该把拆分的细节放在字段掩码 object 中吗? The property Paths just seems to be a collection of strings.属性 Paths 似乎只是字符串的集合。

The examples for these libraries in Google's doco is pretty poor:-( Google 的 doco 中这些库的示例非常糟糕:-(

I raised a support ticket with Google and despite them suggesting a solution which didn't work exactly (due to trying to assign a string to the UpdateMask which needs a FieldMask object), I managed to use it to find the correct solution.我向 Google 提出了支持票,尽管他们提出了一个不完全有效的解决方案(由于试图将字符串分配给需要 FieldMask 对象的 UpdateMask),但我设法使用它找到了正确的解决方案。

The code should be:代码应该是:

// appService is a previously retrieved Service object from the ListServices method
var updateServiceRequest = new UpdateServiceRequest();
updateServiceRequest.Name = appService.Name;
updateServiceRequest.UpdateMask = new Google.Protobuf.WellKnownTypes.FieldMask();
updateServiceRequest.UpdateMask.Paths.Add("split");
appService.Split.Allocations.Clear();
appService.Split.Allocations["newServiceVerison"] = 1;
updateServiceRequest.Service = appService;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Cloud - 错误报告客户端库 - Google Cloud - Error Reporting Client Libraries OAuth2 可以在 Google Cloud 客户端库中使用吗? - Can OAuth2 be used in Google Cloud Client Libraries? google.cloud.firestore_v1.client.Client 过期 - google.cloud.firestore_v1.client.Client expires 使用 dev_appserver.py 和 google.golang.org/appengine@v1.6.6 连接到谷歌云数据存储 - Connect to Google Cloud Datastore using dev_appserver.py & google.golang.org/appengine@v1.6.6 如何从 google.cloud.logging_v2 package 正确导入 MetricsServiceV2Client 属性? - How to properly import the MetricsServiceV2Client attribute from google.cloud.logging_v2 package? 谷歌云防火墙:是否有过滤外部谷歌流量的选项 - Google Cloud Firewall: is there an option to filter outside Google traffic 将 EAR 应用程序从 AppEngine 迁移到 Google Cloud SDK - Migrating an EAR application from AppEngine to Google Cloud SDK Google AppEngine 部署错误(云错误报告) - Google AppEngine Deploy Error (cloud-error-reporting) 将 Java Google AppEngine 本地标准服务器连接到云数据库 | appengine-api-1.0-sdk-1.9.84.jar | IntelliJ 和云代码 - Connect Java Google AppEngine Local Standard Server to Cloud DB | appengine-api-1.0-sdk-1.9.84.jar | IntelliJ & Cloud Code 允许来自特定机器的流量 - Google Cloud Armor - Allow traffic from certain machines - Google Cloud Armor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM