Skip to content

Commit 1b4b5e9

Browse files
committed
fix: update docs.
1 parent fbd911f commit 1b4b5e9

3 files changed

Lines changed: 37 additions & 35 deletions

File tree

sdk-platform-java/api-common-java/src/main/java/com/google/api/pathtemplate/PathTemplate.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ public Set<String> vars() {
297297
}
298298

299299
/**
300-
* Returns the set of resource literals. A resource literal is a literal followed by a binding or
301-
* inside a binding.
300+
* Returns the set of resource literals. A resource literal is a literal followed by a binding.
301+
* For example, projects/{project} is a literal/binding pair and projects is a resource literal.
302302
*/
303303
public Set<String> getResourceLiterals() {
304304
Set<String> canonicalSegments = new java.util.LinkedHashSet<>();
@@ -325,14 +325,16 @@ public Set<String> getResourceLiterals() {
325325
}
326326

327327
/**
328-
* Returns the canonical resource name string. A segment is canonical if it is a literal followed
329-
* by a binding or inside a binding. If a literal is not in knownResources, the extraction stops.
328+
* Returns the canonical resource name string. A canonical resource name is extracted from the template by finding the version literal,
329+
* then finding the last binding that is a literal/binding pair or named binding,
330+
* and then extracting the segments between the version literal and the last binding.
331+
* For examplem, projects/{project} is a literal/binding pair. {bar=projects/*/locations/*/bars/*} is a named binding.
330332
*/
331333
public String getCanonicalResourceName(Set<String> knownResources) {
332334
if (knownResources == null) {
333335
return "";
334336
}
335-
337+
336338
int firstBindingIndex = -1;
337339
for (int i = 0; i < segments.size(); i++) {
338340
if (segments.get(i).kind() == SegmentKind.BINDING) {
@@ -371,7 +373,7 @@ public String getCanonicalResourceName(Set<String> knownResources) {
371373
} else if (seg.kind() == SegmentKind.END_BINDING) {
372374
inBinding = false;
373375
boolean isValidPair = false;
374-
376+
375377
if (literalCountInBinding > 1) {
376378
// Named bindings are unconditionally considered pairs
377379
isValidPair = true;
@@ -393,7 +395,7 @@ public String getCanonicalResourceName(Set<String> knownResources) {
393395
}
394396
}
395397
}
396-
398+
397399
if (isValidPair) {
398400
lastValidEndBindingIndex = i;
399401
}

sdk-platform-java/test/integration/goldens/compute/src/com/google/cloud/compute/v1small/AddressesClientTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void aggregatedListTest() throws Exception {
9090
.build();
9191
mockService.addResponse(expectedResponse);
9292

93-
String project = "project-6911";
93+
String project = "project-309310695";
9494

9595
AggregatedListPagedResponse pagedListResponse = client.aggregatedList(project);
9696

@@ -124,7 +124,7 @@ public void aggregatedListExceptionTest() throws Exception {
124124
mockService.addException(exception);
125125

126126
try {
127-
String project = "project-6911";
127+
String project = "project-309310695";
128128
client.aggregatedList(project);
129129
Assert.fail("No exception raised");
130130
} catch (InvalidArgumentException e) {
@@ -162,9 +162,9 @@ public void deleteTest() throws Exception {
162162
.build();
163163
mockService.addResponse(expectedResponse);
164164

165-
String project = "project-6911";
166-
String region = "region-9622";
167-
String address = "address-4954";
165+
String project = "project-309310695";
166+
String region = "region-934795532";
167+
String address = "address-1147692044";
168168

169169
Operation actualResponse = client.deleteAsync(project, region, address).get();
170170
Assert.assertEquals(expectedResponse, actualResponse);
@@ -192,9 +192,9 @@ public void deleteExceptionTest() throws Exception {
192192
mockService.addException(exception);
193193

194194
try {
195-
String project = "project-6911";
196-
String region = "region-9622";
197-
String address = "address-4954";
195+
String project = "project-309310695";
196+
String region = "region-934795532";
197+
String address = "address-1147692044";
198198
client.deleteAsync(project, region, address).get();
199199
Assert.fail("No exception raised");
200200
} catch (ExecutionException e) {
@@ -231,8 +231,8 @@ public void insertTest() throws Exception {
231231
.build();
232232
mockService.addResponse(expectedResponse);
233233

234-
String project = "project-6911";
235-
String region = "region-9622";
234+
String project = "project-309310695";
235+
String region = "region-934795532";
236236
Address addressResource = Address.newBuilder().build();
237237

238238
Operation actualResponse = client.insertAsync(project, region, addressResource).get();
@@ -261,8 +261,8 @@ public void insertExceptionTest() throws Exception {
261261
mockService.addException(exception);
262262

263263
try {
264-
String project = "project-6911";
265-
String region = "region-9622";
264+
String project = "project-309310695";
265+
String region = "region-934795532";
266266
Address addressResource = Address.newBuilder().build();
267267
client.insertAsync(project, region, addressResource).get();
268268
Assert.fail("No exception raised");
@@ -280,8 +280,8 @@ public void listTest() throws Exception {
280280
.build();
281281
mockService.addResponse(expectedResponse);
282282

283-
String project = "project-6911";
284-
String region = "region-9622";
283+
String project = "project-309310695";
284+
String region = "region-934795532";
285285
String orderBy = "orderBy-1207110587";
286286

287287
ListPagedResponse pagedListResponse = client.list(project, region, orderBy);
@@ -314,8 +314,8 @@ public void listExceptionTest() throws Exception {
314314
mockService.addException(exception);
315315

316316
try {
317-
String project = "project-6911";
318-
String region = "region-9622";
317+
String project = "project-309310695";
318+
String region = "region-934795532";
319319
String orderBy = "orderBy-1207110587";
320320
client.list(project, region, orderBy);
321321
Assert.fail("No exception raised");

sdk-platform-java/test/integration/goldens/compute/src/com/google/cloud/compute/v1small/RegionOperationsClientTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ public void getTest() throws Exception {
103103
.build();
104104
mockService.addResponse(expectedResponse);
105105

106-
String project = "project-6911";
107-
String region = "region-9622";
108-
String operation = "operation-3971";
106+
String project = "project-309310695";
107+
String region = "region-934795532";
108+
String operation = "operation1662702951";
109109

110110
Operation actualResponse = client.get(project, region, operation);
111111
Assert.assertEquals(expectedResponse, actualResponse);
@@ -133,9 +133,9 @@ public void getExceptionTest() throws Exception {
133133
mockService.addException(exception);
134134

135135
try {
136-
String project = "project-6911";
137-
String region = "region-9622";
138-
String operation = "operation-3971";
136+
String project = "project-309310695";
137+
String region = "region-934795532";
138+
String operation = "operation1662702951";
139139
client.get(project, region, operation);
140140
Assert.fail("No exception raised");
141141
} catch (InvalidArgumentException e) {
@@ -173,9 +173,9 @@ public void waitTest() throws Exception {
173173
.build();
174174
mockService.addResponse(expectedResponse);
175175

176-
String project = "project-6911";
177-
String region = "region-9622";
178-
String operation = "operation-3971";
176+
String project = "project-309310695";
177+
String region = "region-934795532";
178+
String operation = "operation1662702951";
179179

180180
Operation actualResponse = client.wait(project, region, operation);
181181
Assert.assertEquals(expectedResponse, actualResponse);
@@ -203,9 +203,9 @@ public void waitExceptionTest() throws Exception {
203203
mockService.addException(exception);
204204

205205
try {
206-
String project = "project-6911";
207-
String region = "region-9622";
208-
String operation = "operation-3971";
206+
String project = "project-309310695";
207+
String region = "region-934795532";
208+
String operation = "operation1662702951";
209209
client.wait(project, region, operation);
210210
Assert.fail("No exception raised");
211211
} catch (InvalidArgumentException e) {

0 commit comments

Comments
 (0)