Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit 11275c4

Browse files
authoredFeb 10, 2020
docs(regen): update sample code to set total timeout, add API client header test
1 parent c051ebd commit 11275c4

File tree

4 files changed

+179
-10
lines changed

4 files changed

+179
-10
lines changed
 

‎google-cloud-irm/src/main/java/com/google/cloud/irm/v1alpha2/IncidentServiceSettings.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,12 @@
111111
* <code>
112112
* IncidentServiceSettings.Builder incidentServiceSettingsBuilder =
113113
* IncidentServiceSettings.newBuilder();
114-
* incidentServiceSettingsBuilder.deleteArtifactSettings().getRetrySettings().toBuilder()
115-
* .setTotalTimeout(Duration.ofSeconds(30));
114+
* incidentServiceSettingsBuilder
115+
* .deleteArtifactSettings()
116+
* .setRetrySettings(
117+
* incidentServiceSettingsBuilder.deleteArtifactSettings().getRetrySettings().toBuilder()
118+
* .setTotalTimeout(Duration.ofSeconds(30))
119+
* .build());
116120
* IncidentServiceSettings incidentServiceSettings = incidentServiceSettingsBuilder.build();
117121
* </code>
118122
* </pre>

‎google-cloud-irm/src/main/java/com/google/cloud/irm/v1alpha2/stub/IncidentServiceStubSettings.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,12 @@
126126
* <code>
127127
* IncidentServiceStubSettings.Builder incidentServiceSettingsBuilder =
128128
* IncidentServiceStubSettings.newBuilder();
129-
* incidentServiceSettingsBuilder.deleteArtifactSettings().getRetrySettings().toBuilder()
130-
* .setTotalTimeout(Duration.ofSeconds(30));
129+
* incidentServiceSettingsBuilder
130+
* .deleteArtifactSettings()
131+
* .setRetrySettings(
132+
* incidentServiceSettingsBuilder.deleteArtifactSettings().getRetrySettings().toBuilder()
133+
* .setTotalTimeout(Duration.ofSeconds(30))
134+
* .build());
131135
* IncidentServiceStubSettings incidentServiceSettings = incidentServiceSettingsBuilder.build();
132136
* </code>
133137
* </pre>

‎google-cloud-irm/src/test/java/com/google/cloud/irm/v1alpha2/IncidentServiceClientTest.java

+161
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
import com.google.irm.service.v1alpha2.api.DeleteIncidentRoleAssignmentRequest;
5050
import com.google.irm.service.v1alpha2.api.DeleteSubscriptionRequest;
5151
import com.google.irm.service.v1alpha2.api.DeleteTagRequest;
52+
import com.google.irm.service.v1alpha2.api.EscalateIncidentRequest;
53+
import com.google.irm.service.v1alpha2.api.EscalateIncidentResponse;
5254
import com.google.irm.service.v1alpha2.api.ForceIncidentRoleHandoverRequest;
5355
import com.google.irm.service.v1alpha2.api.GetIncidentRequest;
5456
import com.google.irm.service.v1alpha2.api.GetSignalRequest;
@@ -66,6 +68,7 @@
6668
import com.google.irm.service.v1alpha2.api.ListSubscriptionsResponse;
6769
import com.google.irm.service.v1alpha2.api.ListTagsRequest;
6870
import com.google.irm.service.v1alpha2.api.ListTagsResponse;
71+
import com.google.irm.service.v1alpha2.api.LookupSignalRequest;
6972
import com.google.irm.service.v1alpha2.api.ProjectName;
7073
import com.google.irm.service.v1alpha2.api.RequestIncidentRoleHandoverRequest;
7174
import com.google.irm.service.v1alpha2.api.SearchIncidentsRequest;
@@ -74,6 +77,8 @@
7477
import com.google.irm.service.v1alpha2.api.SearchSignalsResponse;
7578
import com.google.irm.service.v1alpha2.api.SearchSimilarIncidentsRequest;
7679
import com.google.irm.service.v1alpha2.api.SearchSimilarIncidentsResponse;
80+
import com.google.irm.service.v1alpha2.api.SendShiftHandoffRequest;
81+
import com.google.irm.service.v1alpha2.api.SendShiftHandoffResponse;
7782
import com.google.irm.service.v1alpha2.api.Signal;
7883
import com.google.irm.service.v1alpha2.api.SignalName;
7984
import com.google.irm.service.v1alpha2.api.Subscription;
@@ -91,6 +96,7 @@
9196
import io.grpc.Status;
9297
import io.grpc.StatusRuntimeException;
9398
import java.io.IOException;
99+
import java.util.ArrayList;
94100
import java.util.Arrays;
95101
import java.util.List;
96102
import java.util.UUID;
@@ -903,6 +909,57 @@ public void searchSignalsExceptionTest() throws Exception {
903909
}
904910
}
905911

912+
@Test
913+
@SuppressWarnings("all")
914+
public void lookupSignalTest() {
915+
SignalName name = SignalName.of("[PROJECT]", "[SIGNAL]");
916+
String etag = "etag3123477";
917+
String incident = "incident86983890";
918+
String title = "title110371416";
919+
String contentType = "contentType831846208";
920+
String content = "content951530617";
921+
Signal expectedResponse =
922+
Signal.newBuilder()
923+
.setName(name.toString())
924+
.setEtag(etag)
925+
.setIncident(incident)
926+
.setTitle(title)
927+
.setContentType(contentType)
928+
.setContent(content)
929+
.build();
930+
mockIncidentService.addResponse(expectedResponse);
931+
932+
LookupSignalRequest request = LookupSignalRequest.newBuilder().build();
933+
934+
Signal actualResponse = client.lookupSignal(request);
935+
Assert.assertEquals(expectedResponse, actualResponse);
936+
937+
List<AbstractMessage> actualRequests = mockIncidentService.getRequests();
938+
Assert.assertEquals(1, actualRequests.size());
939+
LookupSignalRequest actualRequest = (LookupSignalRequest) actualRequests.get(0);
940+
941+
Assert.assertTrue(
942+
channelProvider.isHeaderSent(
943+
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
944+
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
945+
}
946+
947+
@Test
948+
@SuppressWarnings("all")
949+
public void lookupSignalExceptionTest() throws Exception {
950+
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
951+
mockIncidentService.addException(exception);
952+
953+
try {
954+
LookupSignalRequest request = LookupSignalRequest.newBuilder().build();
955+
956+
client.lookupSignal(request);
957+
Assert.fail("No exception raised");
958+
} catch (InvalidArgumentException e) {
959+
// Expected exception
960+
}
961+
}
962+
906963
@Test
907964
@SuppressWarnings("all")
908965
public void getSignalTest() {
@@ -1010,6 +1067,48 @@ public void updateSignalExceptionTest() throws Exception {
10101067
}
10111068
}
10121069

1070+
@Test
1071+
@SuppressWarnings("all")
1072+
public void escalateIncidentTest() {
1073+
EscalateIncidentResponse expectedResponse = EscalateIncidentResponse.newBuilder().build();
1074+
mockIncidentService.addResponse(expectedResponse);
1075+
1076+
Incident incident = Incident.newBuilder().build();
1077+
EscalateIncidentRequest request =
1078+
EscalateIncidentRequest.newBuilder().setIncident(incident).build();
1079+
1080+
EscalateIncidentResponse actualResponse = client.escalateIncident(request);
1081+
Assert.assertEquals(expectedResponse, actualResponse);
1082+
1083+
List<AbstractMessage> actualRequests = mockIncidentService.getRequests();
1084+
Assert.assertEquals(1, actualRequests.size());
1085+
EscalateIncidentRequest actualRequest = (EscalateIncidentRequest) actualRequests.get(0);
1086+
1087+
Assert.assertEquals(incident, actualRequest.getIncident());
1088+
Assert.assertTrue(
1089+
channelProvider.isHeaderSent(
1090+
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1091+
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1092+
}
1093+
1094+
@Test
1095+
@SuppressWarnings("all")
1096+
public void escalateIncidentExceptionTest() throws Exception {
1097+
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
1098+
mockIncidentService.addException(exception);
1099+
1100+
try {
1101+
Incident incident = Incident.newBuilder().build();
1102+
EscalateIncidentRequest request =
1103+
EscalateIncidentRequest.newBuilder().setIncident(incident).build();
1104+
1105+
client.escalateIncident(request);
1106+
Assert.fail("No exception raised");
1107+
} catch (InvalidArgumentException e) {
1108+
// Expected exception
1109+
}
1110+
}
1111+
10131112
@Test
10141113
@SuppressWarnings("all")
10151114
public void createArtifactTest() {
@@ -1160,6 +1259,68 @@ public void updateArtifactExceptionTest() throws Exception {
11601259
}
11611260
}
11621261

1262+
@Test
1263+
@SuppressWarnings("all")
1264+
public void sendShiftHandoffTest() {
1265+
String contentType = "contentType831846208";
1266+
String content = "content951530617";
1267+
SendShiftHandoffResponse expectedResponse =
1268+
SendShiftHandoffResponse.newBuilder()
1269+
.setContentType(contentType)
1270+
.setContent(content)
1271+
.build();
1272+
mockIncidentService.addResponse(expectedResponse);
1273+
1274+
ProjectName parent = ProjectName.of("[PROJECT]");
1275+
List<String> recipients = new ArrayList<>();
1276+
String subject = "subject-1867885268";
1277+
SendShiftHandoffRequest request =
1278+
SendShiftHandoffRequest.newBuilder()
1279+
.setParent(parent.toString())
1280+
.addAllRecipients(recipients)
1281+
.setSubject(subject)
1282+
.build();
1283+
1284+
SendShiftHandoffResponse actualResponse = client.sendShiftHandoff(request);
1285+
Assert.assertEquals(expectedResponse, actualResponse);
1286+
1287+
List<AbstractMessage> actualRequests = mockIncidentService.getRequests();
1288+
Assert.assertEquals(1, actualRequests.size());
1289+
SendShiftHandoffRequest actualRequest = (SendShiftHandoffRequest) actualRequests.get(0);
1290+
1291+
Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent()));
1292+
Assert.assertEquals(recipients, actualRequest.getRecipientsList());
1293+
Assert.assertEquals(subject, actualRequest.getSubject());
1294+
Assert.assertTrue(
1295+
channelProvider.isHeaderSent(
1296+
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
1297+
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
1298+
}
1299+
1300+
@Test
1301+
@SuppressWarnings("all")
1302+
public void sendShiftHandoffExceptionTest() throws Exception {
1303+
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
1304+
mockIncidentService.addException(exception);
1305+
1306+
try {
1307+
ProjectName parent = ProjectName.of("[PROJECT]");
1308+
List<String> recipients = new ArrayList<>();
1309+
String subject = "subject-1867885268";
1310+
SendShiftHandoffRequest request =
1311+
SendShiftHandoffRequest.newBuilder()
1312+
.setParent(parent.toString())
1313+
.addAllRecipients(recipients)
1314+
.setSubject(subject)
1315+
.build();
1316+
1317+
client.sendShiftHandoff(request);
1318+
Assert.fail("No exception raised");
1319+
} catch (InvalidArgumentException e) {
1320+
// Expected exception
1321+
}
1322+
}
1323+
11631324
@Test
11641325
@SuppressWarnings("all")
11651326
public void createSubscriptionTest() {

‎synth.metadata

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
2-
"updateTime": "2020-02-06T22:55:13.561734Z",
2+
"updateTime": "2020-02-08T09:55:52.654470Z",
33
"sources": [
44
{
55
"generator": {
66
"name": "artman",
7-
"version": "0.44.4",
8-
"dockerImage": "googleapis/artman@sha256:19e945954fc960a4bdfee6cb34695898ab21a8cf0bac063ee39b91f00a1faec8"
7+
"version": "0.45.0",
8+
"dockerImage": "googleapis/artman@sha256:6aec9c34db0e4be221cdaf6faba27bdc07cfea846808b3d3b964dfce3a9a0f9b"
99
}
1010
},
1111
{
1212
"git": {
1313
"name": "googleapis",
1414
"remote": "https://github.com/googleapis/googleapis.git",
15-
"sha": "2e23b8fbc45f5d9e200572ca662fe1271bcd6760",
16-
"internalRef": "293666452",
17-
"log": "2e23b8fbc45f5d9e200572ca662fe1271bcd6760\nAdd ListEntryGroups method, add http bindings to support entry group tagging, and update some comments.\n\nPiperOrigin-RevId: 293666452\n\n0275e38a4ca03a13d3f47a9613aac8c8b0d3f1f2\nAdd proto_package field to managedidentities API. It is needed for APIs that still depend on artman generation.\n\nPiperOrigin-RevId: 293643323\n\n4cdfe8278cb6f308106580d70648001c9146e759\nRegenerating public protos for Data Catalog to add new Custom Type Entry feature.\n\nPiperOrigin-RevId: 293614782\n\n45d2a569ab526a1fad3720f95eefb1c7330eaada\nEnable client generation for v1 ManagedIdentities API.\n\nPiperOrigin-RevId: 293515675\n\n2c17086b77e6f3bcf04a1f65758dfb0c3da1568f\nAdd the Actions on Google common types (//google/actions/type/*).\n\nPiperOrigin-RevId: 293478245\n\n781aadb932e64a12fb6ead7cd842698d99588433\nDialogflow weekly v2/v2beta1 library update:\n- Documentation updates\nImportant updates are also posted at\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 293443396\n\ne2602608c9138c2fca24162720e67f9307c30b95\nDialogflow weekly v2/v2beta1 library update:\n- Documentation updates\nImportant updates are also posted at\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 293442964\n\nc8aef82028d06b7992278fa9294c18570dc86c3d\nAdd cc_proto_library and cc_grpc_library targets for Bigtable protos.\n\nAlso fix indentation of cc_grpc_library targets in Spanner and IAM protos.\n\nPiperOrigin-RevId: 293440538\n\ne2faab04f4cb7f9755072330866689b1943a16e9\ncloudtasks: v2 replace non-standard retry params in gapic config v2\n\nPiperOrigin-RevId: 293424055\n\ndfb4097ea628a8470292c6590a4313aee0c675bd\nerrorreporting: v1beta1 add legacy artman config for php\n\nPiperOrigin-RevId: 293423790\n\nb18aed55b45bfe5b62476292c72759e6c3e573c6\nasset: v1p1beta1 updated comment for `page_size` limit.\n\nPiperOrigin-RevId: 293421386\n\nc9ef36b7956d9859a2fc86ad35fcaa16958ab44f\nbazel: Refactor CI build scripts\n\nPiperOrigin-RevId: 293387911\n\na8ed9d921fdddc61d8467bfd7c1668f0ad90435c\nfix: set Ruby module name for OrgPolicy\n\nPiperOrigin-RevId: 293257997\n\n6c7d28509bd8315de8af0889688ee20099594269\nredis: v1beta1 add UpgradeInstance and connect_mode field to Instance\n\nPiperOrigin-RevId: 293242878\n\nae0abed4fcb4c21f5cb67a82349a049524c4ef68\nredis: v1 add connect_mode field to Instance\n\nPiperOrigin-RevId: 293241914\n\n3f7a0d29b28ee9365771da2b66edf7fa2b4e9c56\nAdds service config definition for bigqueryreservation v1beta1\n\nPiperOrigin-RevId: 293234418\n\n0c88168d5ed6fe353a8cf8cbdc6bf084f6bb66a5\naddition of BUILD & configuration for accessapproval v1\n\nPiperOrigin-RevId: 293219198\n\n39bedc2e30f4778ce81193f6ba1fec56107bcfc4\naccessapproval: v1 publish protos\n\nPiperOrigin-RevId: 293167048\n\n69d9945330a5721cd679f17331a78850e2618226\nAdd file-level `Session` resource definition\n\nPiperOrigin-RevId: 293080182\n\nf6a1a6b417f39694275ca286110bc3c1ca4db0dc\nAdd file-level `Session` resource definition\n\nPiperOrigin-RevId: 293080178\n\n"
15+
"sha": "e7d8a694f4559201e6913f6610069cb08b39274e",
16+
"internalRef": "293903652",
17+
"log": "e7d8a694f4559201e6913f6610069cb08b39274e\nDepend on the latest gapic-generator and resource names plugin.\n\nThis fixes the very old an very annoying bug: https://github.com/googleapis/gapic-generator/pull/3087\n\nPiperOrigin-RevId: 293903652\n\n806b2854a966d55374ee26bb0cef4e30eda17b58\nfix: correct capitalization of Ruby namespaces in SecurityCenter V1p1beta1\n\nPiperOrigin-RevId: 293903613\n\n1b83c92462b14d67a7644e2980f723112472e03a\nPublish annotations and grpc service config for Logging API.\n\nPiperOrigin-RevId: 293893514\n\ne46f761cd6ec15a9e3d5ed4ff321a4bcba8e8585\nGenerate the Bazel build file for recommendengine public api\n\nPiperOrigin-RevId: 293710856\n\n68477017c4173c98addac0373950c6aa9d7b375f\nMake `language_code` optional for UpdateIntentRequest and BatchUpdateIntentsRequest.\n\nThe comments and proto annotations describe this parameter as optional.\n\nPiperOrigin-RevId: 293703548\n\n16f823f578bca4e845a19b88bb9bc5870ea71ab2\nAdd BUILD.bazel files for managedidentities API\n\nPiperOrigin-RevId: 293698246\n\n2f53fd8178c9a9de4ad10fae8dd17a7ba36133f2\nAdd v1p1beta1 config file\n\nPiperOrigin-RevId: 293696729\n\n052b274138fce2be80f97b6dcb83ab343c7c8812\nAdd source field for user event and add field behavior annotations\n\nPiperOrigin-RevId: 293693115\n\n1e89732b2d69151b1b3418fff3d4cc0434f0dded\ndatacatalog: v1beta1 add three new RPCs to gapic v1beta1 config\n\nPiperOrigin-RevId: 293692823\n\n9c8bd09bbdc7c4160a44f1fbab279b73cd7a2337\nchange the name of AccessApproval service to AccessApprovalAdmin\n\nPiperOrigin-RevId: 293690934\n\n"
1818
}
1919
},
2020
{

0 commit comments

Comments
 (0)
This repository has been archived.