Java Code Examples for com.thoughtworks.go.plugin.api.response.GoApiResponse

The following examples show how to use com.thoughtworks.go.plugin.api.response.GoApiResponse. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: kubernetes-elastic-agents   Source File: PluginRequest.java    License: Apache License 2.0 6 votes vote down vote up
public void appendToConsoleLog(JobIdentifier jobIdentifier, String text) throws ServerRequestFailedException {
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("pipelineName", jobIdentifier.getPipelineName());
    requestMap.put("pipelineCounter", String.valueOf(jobIdentifier.getPipelineCounter()));
    requestMap.put("stageName", jobIdentifier.getStageName());
    requestMap.put("stageCounter", jobIdentifier.getStageCounter());
    requestMap.put("jobName", jobIdentifier.getJobName());
    requestMap.put("text", text);

    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_APPEND_TO_CONSOLE_LOG, CONSOLE_LOG_API_VERSION, PLUGIN_IDENTIFIER);
    request.setRequestBody(new GsonBuilder().create().toJson(requestMap));

    GoApiResponse response = accessor.submit(request);

    if (response.responseCode() != 200) {
        LOG.error("Failed to append to console log for " + jobIdentifier.getRepresentation() + " with text: " + text);
    }
}
 
Example 2
@Test
public void shouldContainValidFieldsInResponseMessage() throws UnhandledRequestTypeException {
    GoApiResponse settingsResponse = DefaultGoApiResponse.success("{}");
    when(goAccessor.submit(any(GoApiRequest.class))).thenReturn(settingsResponse);

    GoPluginApiResponse response = parseAndGetResponseForDir(tempDir.getRoot());

    assertThat(response.responseCode(), is(SUCCESS_RESPONSE_CODE));
    final JsonParser parser = new JsonParser();
    JsonElement responseObj = parser.parse(response.responseBody());
    assertTrue(responseObj.isJsonObject());
    JsonObject obj = responseObj.getAsJsonObject();
    assertTrue(obj.has("errors"));
    assertTrue(obj.has("pipelines"));
    assertTrue(obj.has("environments"));
    assertTrue(obj.has("target_version"));
}
 
Example 3
public void appendToConsoleLog(JobIdentifier jobIdentifier, String text) throws ServerRequestFailedException {
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("pipelineName", jobIdentifier.getPipelineName());
    requestMap.put("pipelineCounter", String.valueOf(jobIdentifier.getPipelineCounter()));
    requestMap.put("stageName", jobIdentifier.getStageName());
    requestMap.put("stageCounter", jobIdentifier.getStageCounter());
    requestMap.put("jobName", jobIdentifier.getJobName());
    requestMap.put("text", text);

    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_APPEND_TO_CONSOLE_LOG, CONSOLE_LOG_API_VERSION, PLUGIN_IDENTIFIER);
    request.setRequestBody(new GsonBuilder().create().toJson(requestMap));

    GoApiResponse response = accessor.submit(request);

    if (response.responseCode() != 200) {
        LOG.error("Failed to append to console log for " + jobIdentifier.represent() + " with text: " + text);
    }
}
 
Example 4
@Test
public void testASingleEmailAddressSendsEmail() throws Exception {
    settingsResponseMap.put("receiver_email_id", "[email protected]");

    GoApiResponse settingsResponse = testSettingsResponse();

    when(goApplicationAccessor.submit(any(GoApiRequest.class))).thenReturn(settingsResponse);
    doCallRealMethod().when(mockSession).createMessage(anyString(), anyString(), anyString(), anyString());

    GoPluginApiRequest requestFromServer = testStageChangeRequestFromServer();

    emailNotificationPlugin.handle(requestFromServer);

    verify(mockTransport).sendMessage(any(Message.class), eq(new Address[]{new InternetAddress("[email protected]")}));
    verify(mockTransport, times(1)).connect(eq("test-smtp-host"), eq(25), eq("test-smtp-username"), eq("test-smtp-password"));
    verify(mockTransport, times(1)).close();
    verifyNoMoreInteractions(mockTransport);
}
 
Example 5
@Test
public void testMultipleEmailAddressSendsEmail() throws Exception {
    settingsResponseMap.put("receiver_email_id", "[email protected], [email protected]");

    GoApiResponse settingsResponse = testSettingsResponse();

    when(goApplicationAccessor.submit(any(GoApiRequest.class))).thenReturn(settingsResponse);
    doCallRealMethod().when(mockSession).createMessage(anyString(), anyString(), anyString(), anyString());

    GoPluginApiRequest requestFromServer = testStageChangeRequestFromServer();

    emailNotificationPlugin.handle(requestFromServer);

    verify(mockTransport).sendMessage(any(Message.class), eq(new Address[]{new InternetAddress("[email protected]")}));
    verify(mockTransport).sendMessage(any(Message.class), eq(new Address[]{new InternetAddress("[email protected]")}));
    verify(mockTransport, times(2)).connect(eq("test-smtp-host"), eq(25), eq("test-smtp-username"), eq("test-smtp-password"));
    verify(mockTransport, times(2)).close();
    verifyNoMoreInteractions(mockTransport);
}
 
Example 6
Source Project: go-plugins   Source File: LogNotificationPluginImplTest.java    License: Apache License 2.0 6 votes vote down vote up
private GoApiResponse getGoApiResponse(final String responseBody) {
    return new GoApiResponse() {
        @Override
        public int responseCode() {
            return 0;
        }

        @Override
        public Map<String, String> responseHeaders() {
            return null;
        }

        @Override
        public String responseBody() {
            return responseBody;
        }
    };
}
 
Example 7
Source Project: gocd   Source File: ServerHealthRequestProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldAddDeserializedServerHealthMessages() {
    String requestBody = new Gson().toJson(asList(
            new PluginHealthMessage("warning", "message 1"),
            new PluginHealthMessage("error", "message 2")
    ));

    GoApiResponse response = processor.process(descriptor, createRequest("1.0", requestBody));
    assertThat(response.responseCode()).isEqualTo(SUCCESS_RESPONSE_CODE);

    ArgumentCaptor<ServerHealthState> argumentCaptor = ArgumentCaptor.forClass(ServerHealthState.class);
    InOrder inOrder = inOrder(serverHealthService);
    inOrder.verify(serverHealthService, times(1)).removeByScope(HealthStateScope.fromPlugin(PLUGIN_ID));
    inOrder.verify(serverHealthService, times(2)).update(argumentCaptor.capture());

    assertThat(argumentCaptor.getAllValues().get(0).getDescription()).isEqualTo("message 1");
    assertThat(argumentCaptor.getAllValues().get(1).getDescription()).isEqualTo("message 2");
}
 
Example 8
Source Project: gocd   Source File: ConsoleLogRequestProcessorV1Test.java    License: Apache License 2.0 6 votes vote down vote up
@Test
void shouldRouteMessageToConsoleService() throws IOException, IllegalArtifactLocationException {
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("pipelineName", "p1");
    requestMap.put("pipelineCounter", "1");
    requestMap.put("stageName", "s1");
    requestMap.put("stageCounter", "2");
    requestMap.put("jobName", "j1");
    requestMap.put("text", "message1");

    DefaultGoApiRequest goApiRequest = new DefaultGoApiRequest(APPEND_TO_CONSOLE_LOG, VERSION_1, null);
    goApiRequest.setRequestBody(new GsonBuilder().create().toJson(requestMap));

    final ConsoleLogRequestProcessor processor = new ConsoleLogRequestProcessor(pluginRequestProcessorRegistry, consoleService);
    final GoApiResponse response = processor.process(pluginDescriptor, goApiRequest);

    assertThat(response.responseCode(), is(DefaultGoApiResponse.SUCCESS_RESPONSE_CODE));

    final JobIdentifier jobIdentifier = new JobIdentifier("p1", 1, null, "s1", "2", "j1");
    verify(consoleService).appendToConsoleLog(jobIdentifier, "message1");
}
 
Example 9
Source Project: gocd   Source File: ConsoleLogRequestProcessorV2Test.java    License: Apache License 2.0 6 votes vote down vote up
@Test
void shouldRouteMessageToConsoleService() throws IOException, IllegalArtifactLocationException {
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("pipeline_name", "p1");
    requestMap.put("pipeline_counter", "1");
    requestMap.put("stage_name", "s1");
    requestMap.put("stage_counter", "2");
    requestMap.put("job_name", "j1");
    requestMap.put("text", "message1");

    DefaultGoApiRequest goApiRequest = new DefaultGoApiRequest(APPEND_TO_CONSOLE_LOG, VERSION_2, null);
    goApiRequest.setRequestBody(new GsonBuilder().create().toJson(requestMap));

    final ConsoleLogRequestProcessor processor = new ConsoleLogRequestProcessor(pluginRequestProcessorRegistry, consoleService);
    final GoApiResponse response = processor.process(pluginDescriptor, goApiRequest);

    assertThat(response.responseCode(), is(DefaultGoApiResponse.SUCCESS_RESPONSE_CODE));

    final JobIdentifier jobIdentifier = new JobIdentifier("p1", 1, null, "s1", "2", "j1");
    verify(consoleService).appendToConsoleLog(jobIdentifier, "message1");
}
 
Example 10
Source Project: gocd   Source File: ServerHealthRequestProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public GoApiResponse process(GoPluginDescriptor pluginDescriptor, GoApiRequest goPluginApiRequest) {
    String errorMessageTitle = format("Message from plugin: {0}", pluginDescriptor.id());
    HealthStateScope scope = HealthStateScope.fromPlugin(pluginDescriptor.id());

    try {
        MessageHandlerForServerHealthRequestProcessor messageHandler = versionToMessageHandlerMap.get(goPluginApiRequest.apiVersion());
        List<PluginHealthMessage> pluginHealthMessages = messageHandler.deserializeServerHealthMessages(goPluginApiRequest.requestBody());
        replaceServerHealthMessages(errorMessageTitle, scope, pluginHealthMessages);
    } catch (Exception e) {
        DefaultGoApiResponse response = new DefaultGoApiResponse(DefaultGoApiResponse.INTERNAL_ERROR);
        response.setResponseBody(format("'{' \"message\": \"{0}\" '}'", e.getMessage()));
        LOGGER.warn("Failed to handle message from plugin {}: {}", pluginDescriptor.id(), goPluginApiRequest.requestBody(), e);
        return response;
    }

    return new DefaultGoApiResponse(DefaultGoApiResponse.SUCCESS_RESPONSE_CODE);
}
 
Example 11
Source Project: gocd   Source File: ConsoleLogRequestProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public GoApiResponse process(GoPluginDescriptor pluginDescriptor, GoApiRequest request) {
    try {
        validatePluginRequest(request);

        final MessageHandlerForConsoleLogRequestProcessor handler = versionToMessageHandlerMap.get(request.apiVersion());
        final ConsoleLogAppendRequest logUpdateRequest = handler.deserializeConsoleLogAppendRequest(request.requestBody());
        consoleService.appendToConsoleLog(logUpdateRequest.jobIdentifier(), logUpdateRequest.text());
    } catch (Exception e) {
        DefaultGoApiResponse response = new DefaultGoApiResponse(DefaultGoApiResponse.INTERNAL_ERROR);
        response.setResponseBody(format("'{' \"message\": \"Error: {0}\" '}'", e.getMessage()));
        LOGGER.warn("Failed to handle message from plugin {}: {}", pluginDescriptor.id(), request.requestBody(), e);
        return response;
    }

    return new DefaultGoApiResponse(DefaultGoApiResponse.SUCCESS_RESPONSE_CODE);
}
 
Example 12
Source Project: gocd   Source File: PluginSettingsRequestProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public GoApiResponse process(GoPluginDescriptor pluginDescriptor, GoApiRequest goPluginApiRequest) {
    try {
        MessageHandlerForPluginSettingsRequestProcessor processor = versionToMessageHandlerMap.get(goPluginApiRequest.apiVersion());

        DefaultGoApiResponse response = new DefaultGoApiResponse(200);
        response.setResponseBody(processor.pluginSettingsToJSON(pluginSettingsFor(pluginDescriptor.id())));

        return response;
    } catch (Exception e) {
        LOGGER.error(format("Error processing PluginSettings request from plugin: %s.", pluginDescriptor.id()), e);

        DefaultGoApiResponse errorResponse = new DefaultGoApiResponse(400);
        errorResponse.setResponseBody(format("Error while processing get PluginSettings request - %s", e.getMessage()));

        return errorResponse;
    }
}
 
Example 13
private void sendLog(ConsoleLogMessage consoleLogMessage) {
    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.SEND_CONSOLE_LOG, CONSOLE_LOG_PROCESSOR_API_VERSION, PLUGIN_IDENTIFIER);
    request.setRequestBody(consoleLogMessage.toJSON());

    GoApiResponse response = accessor.submit(request);
    if (response.responseCode() != DefaultGoApiResponse.SUCCESS_RESPONSE_CODE) {
        LOG.error(String.format("Failed to submit console log: %s", response.responseBody()));
    }
}
 
Example 14
Source Project: kubernetes-elastic-agents   Source File: PluginRequest.java    License: Apache License 2.0 5 votes vote down vote up
public ServerInfo getSeverInfo() throws ServerRequestFailedException {
    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_INFO, SERVER_INFO_API_VERSION, PLUGIN_IDENTIFIER);
    GoApiResponse response = accessor.submit(request);

    if (response.responseCode() != 200) {
        throw ServerRequestFailedException.serverInfo(response);
    }

    return ServerInfo.fromJSON(response.responseBody());
}
 
Example 15
Source Project: kubernetes-elastic-agents   Source File: PluginRequest.java    License: Apache License 2.0 5 votes vote down vote up
public Agents listAgents() throws ServerRequestFailedException {
    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_LIST_AGENTS, PROCESSOR_API_VERSION, PLUGIN_IDENTIFIER);
    GoApiResponse response = accessor.submit(request);

    if (response.responseCode() != 200) {
        throw ServerRequestFailedException.listAgents(response);
    }

    return new Agents(Agent.fromJSONArray(response.responseBody()));
}
 
Example 16
Source Project: kubernetes-elastic-agents   Source File: PluginRequest.java    License: Apache License 2.0 5 votes vote down vote up
public void deleteAgents(Collection<Agent> toBeDeleted) throws ServerRequestFailedException {
    LOG.debug(format("[Server Ping] Deleting Agents: {0}", toBeDeleted.toString()));
    if (toBeDeleted.isEmpty()) {
        return;
    }

    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_DELETE_AGENT, PROCESSOR_API_VERSION, PLUGIN_IDENTIFIER);
    request.setRequestBody(Agent.toJSONArray(toBeDeleted));
    GoApiResponse response = accessor.submit(request);

    if (response.responseCode() != 200) {
        throw ServerRequestFailedException.deleteAgents(response);
    }
}
 
Example 17
Source Project: gocd-yaml-config-plugin   Source File: YamlConfigPlugin.java    License: Apache License 2.0 5 votes vote down vote up
private PluginSettings fetchPluginSettings() {
    Map<String, Object> requestMap = new HashMap<String, Object>();
    requestMap.put("plugin-id", PLUGIN_ID);
    GoApiResponse response = goApplicationAccessor.submit(createGoApiRequest(REQ_GET_PLUGIN_SETTINGS, JSONUtils.toJSON(requestMap)));

    if (response.responseBody() == null || response.responseBody().trim().isEmpty()) {
        return new PluginSettings();
    }

    return PluginSettings.fromJson(response.responseBody());
}
 
Example 18
@Before
public void setUp() {
    plugin = new YamlConfigPlugin();
    goAccessor = mock(GoApplicationAccessor.class);
    plugin.initializeGoApplicationAccessor(goAccessor);
    GoApiResponse settingsResponse = DefaultGoApiResponse.success("{}");
    when(goAccessor.submit(any(GoApiRequest.class))).thenReturn(settingsResponse);
    parser = new JsonParser();
}
 
Example 19
@Test
public void shouldRespondSuccessToParseDirectoryRequestWhenPluginHasConfiguration() throws UnhandledRequestTypeException {
    GoApiResponse settingsResponse = DefaultGoApiResponse.success("{}");
    when(goAccessor.submit(any(GoApiRequest.class))).thenReturn(settingsResponse);

    GoPluginApiResponse response = parseAndGetResponseForDir(tempDir.getRoot());

    verify(goAccessor, times(1)).submit(any(GoApiRequest.class));
    assertThat(response.responseCode(), is(SUCCESS_RESPONSE_CODE));
}
 
Example 20
Source Project: gocd   Source File: ArtifactRequestProcessor.java    License: Apache License 2.0 5 votes vote down vote up
private GoApiResponse processConsoleLogRequest(GoPluginDescriptor pluginDescriptor, GoApiRequest request) {
    final ConsoleLogMessage consoleLogMessage = ConsoleLogMessage.fromJSON(request.requestBody());
    final String message = format("[%s] %s", pluginDescriptor.id(), consoleLogMessage.getMessage());
    Optional<String> parsedTag = parseTag(processType, consoleLogMessage.getLogLevel());
    if (parsedTag.isPresent()) {
        safeOutputStreamConsumer.taggedStdOutput(parsedTag.get(), message);
        return DefaultGoApiResponse.success(null);
    }
    return DefaultGoApiResponse.error(format("Unsupported log level `%s`.", consoleLogMessage.getLogLevel()));
}
 
Example 21
public void disableAgents(Collection<Agent> toBeDisabled) throws ServerRequestFailedException {
    if (toBeDisabled.isEmpty()) {
        return;
    }

    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_DISABLE_AGENT, PROCESSOR_API_VERSION, PLUGIN_IDENTIFIER);
    request.setRequestBody(Agent.toJSONArray(toBeDisabled));

    GoApiResponse response = accessor.submit(request);

    if (response.responseCode() != 200) {
        throw ServerRequestFailedException.disableAgents(response);
    }
}
 
Example 22
public void deleteAgents(Collection<Agent> toBeDeleted) throws ServerRequestFailedException {
    if (toBeDeleted.isEmpty()) {
        return;
    }

    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_DELETE_AGENT, PROCESSOR_API_VERSION, PLUGIN_IDENTIFIER);
    request.setRequestBody(Agent.toJSONArray(toBeDeleted));
    GoApiResponse response = accessor.submit(request);

    if (response.responseCode() != 200) {
        throw ServerRequestFailedException.deleteAgents(response);
    }
}
 
Example 23
public Agents listAgents() throws ServerRequestFailedException {
    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_LIST_AGENTS, PROCESSOR_API_VERSION, PLUGIN_IDENTIFIER);
    GoApiResponse response = accessor.submit(request);

    if (response.responseCode() != 200) {
        throw ServerRequestFailedException.listAgents(response);
    }

    return new Agents(Agent.fromJSONArray(response.responseBody()));
}
 
Example 24
public void disableAgents(Collection<Agent> toBeDisabled) throws ServerRequestFailedException {
    if (toBeDisabled.isEmpty()) {
        return;
    }

    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_DISABLE_AGENT, PROCESSOR_API_VERSION, PLUGIN_IDENTIFIER);
    request.setRequestBody(Agent.toJSONArray(toBeDisabled));

    GoApiResponse response = accessor.submit(request);

    if (response.responseCode() != 200) {
        throw ServerRequestFailedException.disableAgents(response);
    }
}
 
Example 25
public void deleteAgents(Collection<Agent> toBeDeleted) throws ServerRequestFailedException {
    if (toBeDeleted.isEmpty()) {
        return;
    }

    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_DELETE_AGENT, PROCESSOR_API_VERSION, PLUGIN_IDENTIFIER);
    request.setRequestBody(Agent.toJSONArray(toBeDeleted));
    GoApiResponse response = accessor.submit(request);

    if (response.responseCode() != 200) {
        throw ServerRequestFailedException.deleteAgents(response);
    }
}
 
Example 26
Source Project: gocd-oauth-login   Source File: OAuthLoginPlugin.java    License: Apache License 2.0 5 votes vote down vote up
public PluginSettings getPluginSettings() {
    Map<String, Object> requestMap = new HashMap<String, Object>();
    requestMap.put("plugin-id", provider.getPluginId());
    GoApiResponse response = goApplicationAccessor.submit(createGoApiRequest(GET_PLUGIN_SETTINGS, JSONUtils.toJSON(requestMap)));
    if (response.responseBody() == null || response.responseBody().trim().isEmpty()) {
        throw new RuntimeException("plugin is not configured. please provide plugin settings.");
    }
    return provider.pluginSettings((Map<String, String>) JSONUtils.fromJSON(response.responseBody()));
}
 
Example 27
Source Project: gocd-oauth-login   Source File: OAuthLoginPlugin.java    License: Apache License 2.0 5 votes vote down vote up
private void  store(SocialAuthManager socialAuthManager) {
    Map<String, Object> requestMap = new HashMap<String, Object>();
    requestMap.put("plugin-id", provider.getPluginId());
    Map<String, Object> sessionData = new HashMap<String, Object>();
    String socialAuthManagerStr = serializeObject(socialAuthManager);
    sessionData.put("social-auth-manager", socialAuthManagerStr);
    requestMap.put("session-data", sessionData);
    GoApiRequest goApiRequest = createGoApiRequest(GO_REQUEST_SESSION_PUT, JSONUtils.toJSON(requestMap));
    GoApiResponse response = goApplicationAccessor.submit(goApiRequest);
    // handle error
}
 
Example 28
Source Project: gocd-oauth-login   Source File: OAuthLoginPlugin.java    License: Apache License 2.0 5 votes vote down vote up
private SocialAuthManager read() {
    Map<String, Object> requestMap = new HashMap<String, Object>();
    requestMap.put("plugin-id", provider.getPluginId());
    GoApiRequest goApiRequest = createGoApiRequest(GO_REQUEST_SESSION_GET, JSONUtils.toJSON(requestMap));
    GoApiResponse response = goApplicationAccessor.submit(goApiRequest);
    // handle error
    String responseBody = response.responseBody();
    Map<String, String> sessionData = (Map<String, String>) JSONUtils.fromJSON(responseBody);
    String socialAuthManagerStr = sessionData.get("social-auth-manager");
    return deserializeObject(socialAuthManagerStr);
}
 
Example 29
Source Project: gocd-oauth-login   Source File: OAuthLoginPlugin.java    License: Apache License 2.0 5 votes vote down vote up
private void delete() {
    Map<String, Object> requestMap = new HashMap<String, Object>();
    requestMap.put("plugin-id", provider.getPluginId());
    GoApiRequest goApiRequest = createGoApiRequest(GO_REQUEST_SESSION_REMOVE, JSONUtils.toJSON(requestMap));
    GoApiResponse response = goApplicationAccessor.submit(goApiRequest);
    // handle error
}
 
Example 30
Source Project: gocd-oauth-login   Source File: OAuthLoginPlugin.java    License: Apache License 2.0 5 votes vote down vote up
private void authenticateUser(User user) {
    final Map<String, Object> userMap = new HashMap<String, Object>();
    userMap.put("user", getUserMap(user));
    GoApiRequest authenticateUserRequest = createGoApiRequest(GO_REQUEST_AUTHENTICATE_USER, JSONUtils.toJSON(userMap));
    GoApiResponse authenticateUserResponse = goApplicationAccessor.submit(authenticateUserRequest);
    // handle error
}