I'm new to grpc/protobuf so please excuse any terminology errors in my question.
I need to take a response from one gRPC request and feed it into the next request. I can't figure out how to populate the "spec" line.
Proto file1:
message UpdateClusterRequest {
string service_name = 3;
ClusterTemplate spec = 4;
string config_revision = 5;
string deploy_strategy = 6;
}
Proto file2:
message ClusterTemplate {
message AppSettings {
string version = 1;
repeated InstanceType instance_layout = 2;
repeated ClientIDTemplate client_ids = 3;
}
AppSettings app = 1;
}
So in my code, the template_response captures the output from the get_template_revisions gRPC API call. I then need to pass the contents to request.spec to the next gRPC API request, which is what I need help with.
template_response=get_template_revisions(client_stub,payload_project_id,metadata_okta_token_and_env)grpc_logger.debug(template_response.revisions[0].template.app)
request=app_pb2.UpdateClusterRequest()
request.spec = ???
response=client_stub.get_grpc_app_stub(grpc_stub_method).UpdateCluster(request=request,metadata=metadata_okta_token_and_env)
This is a heavily nested message mapping and I have tried many permutations without success below and not limited to:
request.spec.extend([template_response.revisions[0].template.app])
request.spec = template_response.revisions[0].template
request.spec.MergeFromString(template_response.revisions[0].template.app)
I've read all the python protobuf documentation and I just can't get it.