Closed beccasaurus closed 5 years ago
Request: Priority: P1
Type: Bug
(or Type: Feature Request
if this repo had the label)
#misc
Is there a @googleapis/[team]
I can be added to which gets me rights to this repo?
I'm active and I'd like to be able to label my issues etc ~ /cc @andreamlin 🙏
^--- We have a @googleapis/samplegen team which I'm a member of which could be added to this repo (as a good way to encapsulate the perms)
I guess either @vchudnov-g or @lukesneeringer should have the permission.
If you wanted to go that route, @vchudnov-g, this repo can be added here: https://github.com/orgs/googleapis/teams/samplegen/repositories
Also: ping again on the label update request (or update so I can edit, per above).
Found a solution. Can you try adding the following lines here?
- field_name_patterns:
- topic.name: topic
field_name_patterns
tells the generator which fields (including nested fields) are resource names.
I tried Java after adding this configuration and the generation succeeded. I got:
public static void sampleUpdateTopic() {
// [START update_topic_core]
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
String formattedName =
TopicAdminClient.formatProjectTopicName(
"Your Google Cloud Project ID", "Your Topic Name");
Topic topic = Topic.newBuilder().setName(formattedName).build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateTopicRequest request =
UpdateTopicRequest.newBuilder().setTopic(topic).setUpdateMask(updateMask).build();
ApiFuture<Topic> future = topicAdminClient.updateTopicCallable().futureCall(request);
// Do something
Topic response = future.get();
System.out.println(response);
} catch (Exception exception) {
System.err.println("Failed to create the client due to: " + exception);
}
// [END update_topic_core]
}
I haven't tried running this sample or tried generating samples in other languages though, I'll try later.
The generator only needs to know which top level fields are resource names to generate clients, which is
probably why the nested resource names are never specified under field_name_patterns
.
It's a bit redundant. We need to think about whether we could simplify this configuration once we get there.
Following up on this, @vchudnov-g @hzyi-google @beccasaurus do we have a resolution?
Looks great to me! If I have any issues, I'll re-open. Thanks @hzyi-google!
Solved
In the GAPIC configuration for the specific RPC method, add the following for each
object.name
that you need to map to anentity_name
.For example:
UpdateDataset()
forautoml_v1beta1
requires that you provide the Dataset Name asdataset.name
on the Request object.- field: dataset.name%project
anddataset.name%location
anddataset.name%dataset
UpdateDataset
method configuration in _gapic.yamlCannot generate a request for rpc with resource including
.
e.g.
v1/
pubsub.proto
which has pathtopic.name
(many other APIs also use this pattern)Expected this to work:
Got this:
If you want to reproduce, try out this
pubsub_gapic.yaml
The rpc call for Creating a Topic works (the resource is simply
name
):FYI here are the defined
collections
:The
UpdateTopic
rpc usestopic.name
and the patternprojects/*/topics/*
– which is defined incollections:
and uses variable names{project}
and{topic}
. I couldn't figure out if there's something other thantopic.name
that I should be using? I think I'm doing it right :)=> @hzyi-google /cc @vchudnov-g