Java Code Examples for com.thoughtworks.go.plugin.api.request.GoPluginApiRequest#requestName()

The following examples show how to use com.thoughtworks.go.plugin.api.request.GoPluginApiRequest#requestName() . 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 File: Plugin2.java    From go-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest goPluginApiRequest) throws UnhandledRequestTypeException {

    if ("configuration".equals(goPluginApiRequest.requestName())) {
        HashMap<String, Object> config = new HashMap<>();

        HashMap<String, Object> url = new HashMap<>();
        url.put("display-order", "0");
        url.put("display-name", "Url");
        url.put("required", true);
        config.put("Url", url);
        return DefaultGoPluginApiResponse.success(new GsonBuilder().create().toJson(config));
    } else if ("view".equals(goPluginApiRequest.requestName())) {
        return getViewRequest();
    }
    throw new UnhandledRequestTypeException(goPluginApiRequest.requestName());
}
 
Example 2
Source File: OAuthLoginPlugin.java    From gocd-oauth-login with Apache License 2.0 6 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest goPluginApiRequest) {
    String requestName = goPluginApiRequest.requestName();
    if (requestName.equals(PLUGIN_SETTINGS_GET_CONFIGURATION)) {
        return handleGetPluginSettingsConfiguration();
    } else if (requestName.equals(PLUGIN_SETTINGS_GET_VIEW)) {
        try {
            return handleGetPluginSettingsView();
        } catch (IOException e) {
            return renderJSON(500, String.format("Failed to find template: %s", e.getMessage()));
        }
    } else if (requestName.equals(PLUGIN_SETTINGS_VALIDATE_CONFIGURATION)) {
        return handleValidatePluginSettingsConfiguration(goPluginApiRequest);
    } else if (requestName.equals(PLUGIN_CONFIGURATION)) {
        Map<String, Object> configuration = getPluginConfiguration();
        return renderJSON(SUCCESS_RESPONSE_CODE, configuration);
    } else if (requestName.equals(SEARCH_USER)) {
        return handleSearchUserRequest(goPluginApiRequest);
    } else if (requestName.equals(WEB_REQUEST_INDEX)) {
        return handleSetupLoginWebRequest(goPluginApiRequest);
    } else if (requestName.equals(WEB_REQUEST_AUTHENTICATE)) {
        return handleAuthenticateWebRequest(goPluginApiRequest);
    }
    return renderJSON(NOT_FOUND_ERROR_RESPONSE_CODE, null);
}
 
Example 3
Source File: BaseGoPlugin.java    From gocd-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest request) throws UnhandledRequestTypeException {
    try {
        switch (request.requestName()) {
            case "configuration":
            case "go.plugin-settings.get-configuration":
                return handleGetConfigRequest(request);
            case "validate":
            case "go.plugin-settings.validate-configuration":
                return handleValidation(request);
            case "execute":
                return handleTaskExecution(request);
            case "view":
            case "go.plugin-settings.get-view":
                return handleTaskView(request);
            default:
                return DefaultGoPluginApiResponse.badRequest(String.format("Invalid request name %s", request.requestName()));
        }
    } catch (Throwable e) {
        return DefaultGoPluginApiResponse.error(e.getMessage());
    }
}
 
Example 4
Source File: NessusScanTask.java    From gocd-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest request) throws UnhandledRequestTypeException {
    switch (request.requestName()) {
        case "configuration":
        case "go.plugin-settings.get-configuration":
            return handleGetConfigRequest();
        case "validate":
        case "go.plugin-settings.validate-configuration":
            return handleValidation();
        case "execute":
            return handleTaskExecution(request);
        case "view":
        case "go.plugin-settings.get-view":
            return handleTaskView();
        default:
            throw new UnhandledRequestTypeException(request.requestName());
    }
}
 
Example 5
Source File: SampleAuthenticationPluginImpl.java    From go-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest goPluginApiRequest) {
    String requestName = goPluginApiRequest.requestName();
    if (requestName.equals(PLUGIN_CONFIGURATION)) {
        return handlePluginConfigurationRequest();
    } else if (requestName.equals(SEARCH_USER)) {
        return handleSearchUserRequest(goPluginApiRequest);
    } else if (requestName.equals(AUTHENTICATE_USER)) {
        return handleAuthenticateUserRequest(goPluginApiRequest);
    } else if (requestName.equals(WEB_REQUEST_INDEX)) {
        return handleSetupLoginWebRequest(goPluginApiRequest);
    } else if (requestName.equals(WEB_REQUEST_AUTHENTICATE)) {
        return handleAuthenticateWebRequest(goPluginApiRequest);
    }
    return renderResponse(404, null, null);
}
 
Example 6
Source File: EmailNotificationPluginImpl.java    From email-notifier with Apache License 2.0 6 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest goPluginApiRequest) {
    String requestName = goPluginApiRequest.requestName();
    if (requestName.equals(PLUGIN_SETTINGS_GET_CONFIGURATION)) {
        return handleGetPluginSettingsConfiguration();
    } else if (requestName.equals(PLUGIN_SETTINGS_GET_VIEW)) {
        try {
            return handleGetPluginSettingsView();
        } catch (IOException e) {
            return renderJSON(500, String.format("Failed to find template: %s", e.getMessage()));
        }
    } else if (requestName.equals(PLUGIN_SETTINGS_VALIDATE_CONFIGURATION)) {
        return handleValidatePluginSettingsConfiguration(goPluginApiRequest);
    } else if (requestName.equals(REQUEST_NOTIFICATIONS_INTERESTED_IN)) {
        return handleNotificationsInterestedIn();
    } else if (requestName.equals(REQUEST_STAGE_STATUS)) {
        return handleStageNotification(goPluginApiRequest);
    }
    return renderJSON(NOT_FOUND_RESPONSE_CODE, null);
}
 
Example 7
Source File: BuildStatusNotifierPlugin.java    From gocd-build-status-notifier with Apache License 2.0 6 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest goPluginApiRequest) {
    String requestName = goPluginApiRequest.requestName();
    if (requestName.equals(PLUGIN_SETTINGS_GET_CONFIGURATION)) {
        return handleGetPluginSettingsConfiguration();
    } else if (requestName.equals(PLUGIN_SETTINGS_GET_VIEW)) {
        try {
            return handleGetPluginSettingsView();
        } catch (IOException e) {
            return renderJSON(500, String.format("Failed to find template: %s", e.getMessage()));
        }
    } else if (requestName.equals(PLUGIN_SETTINGS_VALIDATE_CONFIGURATION)) {
        return handleValidatePluginSettingsConfiguration(goPluginApiRequest);
    } else if (requestName.equals(REQUEST_NOTIFICATIONS_INTERESTED_IN)) {
        return handleNotificationsInterestedIn();
    } else if (requestName.equals(REQUEST_STAGE_STATUS)) {
        return handleStageNotification(goPluginApiRequest);
    }
    return renderJSON(NOT_FOUND_RESPONSE_CODE, null);
}
 
Example 8
Source File: ValidSubClassPlugin.java    From go-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest goPluginApiRequest) throws UnhandledRequestTypeException {

    if ("configuration".equals(goPluginApiRequest.requestName())) {
        return new GetTaskPluginConfig().execute();
    } else if ("view".equals(goPluginApiRequest.requestName())) {
        return getViewRequest();
    }
    throw new UnhandledRequestTypeException(goPluginApiRequest.requestName());
}
 
Example 9
Source File: DockerRegistryArtifactPlugin.java    From docker-registry-artifact-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest request) {
    try {
        switch (Request.fromString(request.requestName())) {
            case REQUEST_GET_PLUGIN_ICON:
                return new GetPluginIconExecutor().execute();
            case REQUEST_GET_PLUGIN_CAPABILITIES:
                return new GetCapabilitiesExecutor().execute();
            case REQUEST_STORE_CONFIG_METADATA:
                return new GetArtifactStoreConfigMetadataExecutor().execute();
            case REQUEST_STORE_CONFIG_VIEW:
                return new GetArtifactStoreViewExecutor().execute();
            case REQUEST_STORE_CONFIG_VALIDATE:
                return new ValidateArtifactStoreConfigExecutor(request).execute();
            case REQUEST_PUBLISH_ARTIFACT_METADATA:
                return new GetPublishArtifactConfigMetadataExecutor().execute();
            case REQUEST_PUBLISH_ARTIFACT_VIEW:
                return new GetPublishArtifactViewExecutor().execute();
            case REQUEST_PUBLISH_ARTIFACT_VALIDATE:
                return new ValidatePublishArtifactConfigExecutor(request).execute();
            case REQUEST_FETCH_ARTIFACT_METADATA:
                return new GetFetchArtifactMetadataExecutor().execute();
            case REQUEST_FETCH_ARTIFACT_VIEW:
                return new GetFetchArtifactViewExecutor().execute();
            case REQUEST_FETCH_ARTIFACT_VALIDATE:
                return new ValidateFetchArtifactConfigExecutor(request).execute();
            case REQUEST_PUBLISH_ARTIFACT:
                return new PublishArtifactExecutor(request, consoleLogger).execute();
            case REQUEST_FETCH_ARTIFACT:
                return new FetchArtifactExecutor(request, consoleLogger).execute();
            default:
                throw new UnhandledRequestTypeException(request.requestName());
        }
    } catch (Exception e) {
        LOG.error("Error while executing request " + request.requestName(), e);
        throw new RuntimeException(e);
    }
}
 
Example 10
Source File: ValidInnerClassPlugin.java    From go-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest goPluginApiRequest) throws UnhandledRequestTypeException {

    if ("configuration".equals(goPluginApiRequest.requestName())) {
        return new GetTaskPluginConfig().execute();
    } else if ("view".equals(goPluginApiRequest.requestName())) {
        return getViewRequest();
    }
    throw new UnhandledRequestTypeException(goPluginApiRequest.requestName());
}
 
Example 11
Source File: TestWithSomePluginXmlValues.java    From go-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest goPluginApiRequest) throws UnhandledRequestTypeException {

    if ("configuration".equals(goPluginApiRequest.requestName())) {
        return new GetTaskPluginConfig().execute();
    } else if ("view".equals(goPluginApiRequest.requestName())) {
        return getViewRequest();
    }
    throw new UnhandledRequestTypeException(goPluginApiRequest.requestName());
}
 
Example 12
Source File: FetchTask.java    From gocd-s3-artifacts with Apache License 2.0 5 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest request) throws UnhandledRequestTypeException {
    if ("configuration".equals(request.requestName())) {
        return handleGetConfigRequest();
    } else if ("validate".equals(request.requestName())) {
        return handleValidation(request);
    } else if ("execute".equals(request.requestName())) {
        return handleTaskExecution(request);
    } else if ("view".equals(request.requestName())) {
        return handleTaskView();
    }
    throw new UnhandledRequestTypeException(request.requestName());
}
 
Example 13
Source File: PublishTask.java    From gocd-s3-artifacts with Apache License 2.0 5 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest request) throws UnhandledRequestTypeException {
    if ("configuration".equals(request.requestName())) {
        return handleGetConfigRequest();
    } else if ("validate".equals(request.requestName())) {
        return handleValidation(request);
    } else if ("execute".equals(request.requestName())) {
        return handleTaskExecution(request);
    } else if ("view".equals(request.requestName())) {
        return handleTaskView();
    }
    throw new UnhandledRequestTypeException(request.requestName());
}
 
Example 14
Source File: DoNothingPlugin.java    From go-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest goPluginApiRequest) throws UnhandledRequestTypeException {

    if ("configuration".equals(goPluginApiRequest.requestName())) {
        return new GetTaskPluginConfig().execute();
    } else if ("view".equals(goPluginApiRequest.requestName())) {
        return getViewRequest();
    }
    throw new UnhandledRequestTypeException(goPluginApiRequest.requestName());
}
 
Example 15
Source File: PublishTask.java    From gocd-s3-artifacts with Apache License 2.0 5 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest request) throws UnhandledRequestTypeException {
    if ("configuration".equals(request.requestName())) {
        return handleGetConfigRequest();
    } else if ("validate".equals(request.requestName())) {
        return handleValidation(request);
    } else if ("execute".equals(request.requestName())) {
        return handleTaskExecution(request);
    } else if ("view".equals(request.requestName())) {
        return handleTaskView();
    }
    throw new UnhandledRequestTypeException(request.requestName());
}
 
Example 16
Source File: DockerTask.java    From gocd-docker with Apache License 2.0 5 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest request) throws UnhandledRequestTypeException {
    if ("configuration".equals(request.requestName())) {
        return handleGetConfigRequest();
    } else if ("validate".equals(request.requestName())) {
        return handleValidation(request);
    } else if ("execute".equals(request.requestName())) {
        return handleTaskExecution(request);
    } else if ("view".equals(request.requestName())) {
        return handleTaskView();
    }
    throw new UnhandledRequestTypeException(request.requestName());
}
 
Example 17
Source File: DumbPluginThatRespondsWithClassloaderName.java    From gocd with Apache License 2.0 5 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest goPluginApiRequest) throws UnhandledRequestTypeException {
    switch(goPluginApiRequest.requestName()){
        case "Thread.currentThread.getContextClassLoader":
            return DefaultGoPluginApiResponse.success(Thread.currentThread().getContextClassLoader().getClass().getCanonicalName());
        case "this.getClass.getClassLoader":
            return DefaultGoPluginApiResponse.success(this.getClass().getClassLoader().getClass().getCanonicalName());
        default:
            throw new UnhandledRequestTypeException(goPluginApiRequest.requestName());
    }
}
 
Example 18
Source File: DummyArtifactPlugin.java    From go-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest request) throws UnhandledRequestTypeException {
    final RequestFromServer requestFromServer = RequestFromServer.from(request.requestName());
    try {
        switch (requestFromServer) {
            case REQUEST_GET_CAPABILITIES:
                return DefaultGoPluginApiResponse.success("{}");
            case REQUEST_STORE_CONFIG_METADATA:
                return DefaultGoPluginApiResponse.success(artifactStoreMetadata());
            case REQUEST_STORE_CONFIG_VIEW:
                return DefaultGoPluginApiResponse.success(new View("/artifact-store.template.html").toJSON());
            case REQUEST_STORE_CONFIG_VALIDATE:
                return DefaultGoPluginApiResponse.success(ArtifactStoreConfig.from(request.requestBody()).validate().toJSON());
            case REQUEST_PUBLISH_ARTIFACT_METADATA:
                return DefaultGoPluginApiResponse.success(ArtifactConfig.artifactConfigMetadata());
            case REQUEST_PUBLISH_ARTIFACT_VIEW:
                return DefaultGoPluginApiResponse.success(new View("/publish-artifact.template.html").toJSON());
            case REQUEST_PUBLISH_ARTIFACT_VALIDATE:
                return DefaultGoPluginApiResponse.success(ArtifactConfig.from(request.requestBody()).validate().toJSON());
            case REQUEST_FETCH_ARTIFACT_METADATA:
                return DefaultGoPluginApiResponse.success(FetchArtifact.metadata());
            case REQUEST_FETCH_ARTIFACT_VIEW:
                return DefaultGoPluginApiResponse.success(new View("/fetch-artifact.template.html").toJSON());
            case REQUEST_FETCH_ARTIFACT_VALIDATE:
                return DefaultGoPluginApiResponse.success(FetchArtifact.from(request.requestBody()).validate().toJSON());
            case REQUEST_PUBLISH_ARTIFACT:
                return publishArtifact(PublishArtifactRequest.fromJSON(request.requestBody()));
            case REQUEST_FETCH_ARTIFACT:
                return fetchArtifact(FetchArtifactRequest.fromJSON(request.requestBody()));
            case REQUEST_GET_PLUGIN_ICON:
                JsonObject jsonObject = new JsonObject();
                jsonObject.addProperty("content_type", "image/jpg");
                jsonObject.addProperty("data", Base64.getEncoder().encodeToString(ResourceReader.readBytes("/icon.jpg")));
                return DefaultGoPluginApiResponse.success(jsonObject.toString());
            default:
                throw new RuntimeException("Error while executing request" + request.requestName());
        }
    } catch (Exception e) {
        LOG.error("Error while executing request " + request.requestName(), e);
        throw new RuntimeException(e);
    }
}
 
Example 19
Source File: DockerPlugin.java    From docker-elastic-agents-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest request) {
    ClusterProfileProperties clusterProfileProperties;
    try {
        switch (Request.fromString(request.requestName())) {
            case REQUEST_SHOULD_ASSIGN_WORK:
                ShouldAssignWorkRequest shouldAssignWorkRequest = ShouldAssignWorkRequest.fromJSON(request.requestBody());
                clusterProfileProperties = shouldAssignWorkRequest.getClusterProfileProperties();
                refreshInstancesForCluster(clusterProfileProperties);
                return shouldAssignWorkRequest.executor(getAgentInstancesFor(clusterProfileProperties)).execute();
            case REQUEST_CREATE_AGENT:
                CreateAgentRequest createAgentRequest = CreateAgentRequest.fromJSON(request.requestBody());
                clusterProfileProperties = createAgentRequest.getClusterProfileProperties();
                refreshInstancesForCluster(clusterProfileProperties);
                return createAgentRequest.executor(getAgentInstancesFor(clusterProfileProperties), pluginRequest).execute();
            case REQUEST_SERVER_PING:
                ServerPingRequest serverPingRequest = ServerPingRequest.fromJSON(request.requestBody());
                List<ClusterProfileProperties> listOfClusterProfileProperties = serverPingRequest.allClusterProfileProperties();
                refreshInstancesForAllClusters(listOfClusterProfileProperties);
                return serverPingRequest.executor(clusterSpecificAgentInstances, pluginRequest).execute();
            case REQUEST_GET_ELASTIC_AGENT_PROFILE_METADATA:
                return new GetProfileMetadataExecutor().execute();
            case REQUEST_GET_ELASTIC_AGENT_PROFILE_VIEW:
                return new GetProfileViewExecutor().execute();
            case REQUEST_VALIDATE_ELASTIC_AGENT_PROFILE:
                return ProfileValidateRequest.fromJSON(request.requestBody()).executor().execute();
            case REQUEST_GET_ICON:
                return new GetPluginSettingsIconExecutor().execute();
            case REQUEST_GET_CLUSTER_PROFILE_METADATA:
                return new GetClusterProfileMetadataExecutor().execute();
            case REQUEST_VALIDATE_CLUSTER_PROFILE_CONFIGURATION:
                return ClusterProfileValidateRequest.fromJSON(request.requestBody()).executor().execute();
            case REQUEST_GET_CLUSTER_PROFILE_VIEW:
                return new GetClusterProfileViewRequestExecutor().execute();
            case REQUEST_MIGRATE_CONFIGURATION:
                return MigrateConfigurationRequest.fromJSON(request.requestBody()).executor().execute();
            case REQUEST_AGENT_STATUS_REPORT:
                AgentStatusReportRequest statusReportRequest = AgentStatusReportRequest.fromJSON(request.requestBody());
                ClusterProfileProperties clusterProfile = statusReportRequest.getClusterProfile();
                refreshInstancesForCluster(clusterProfile);
                return statusReportRequest.executor(pluginRequest, clusterSpecificAgentInstances.get(clusterProfile.uuid())).execute();
            case REQUEST_CLUSTER_STATUS_REPORT:
                ClusterStatusReportRequest clusterStatusReportRequest = ClusterStatusReportRequest.fromJSON(request.requestBody());
                clusterProfileProperties = clusterStatusReportRequest.getClusterProfile();
                refreshInstancesForCluster(clusterProfileProperties);
                return clusterStatusReportRequest.executor(clusterSpecificAgentInstances.get(clusterProfileProperties.uuid())).execute();
            case REQUEST_CAPABILITIES:
                return new GetCapabilitiesExecutor().execute();
            case REQUEST_JOB_COMPLETION:
                JobCompletionRequest jobCompletionRequest = JobCompletionRequest.fromJSON(request.requestBody());
                clusterProfileProperties = jobCompletionRequest.getClusterProfileProperties();
                refreshInstancesForCluster(clusterProfileProperties);
                return jobCompletionRequest.executor(getAgentInstancesFor(clusterProfileProperties), pluginRequest).execute();
            default:
                throw new UnhandledRequestTypeException(request.requestName());
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 20
Source File: KubernetesPlugin.java    From kubernetes-elastic-agents with Apache License 2.0 4 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest request) {
    ClusterProfileProperties clusterProfileProperties;
    try {
        switch (Request.fromString(request.requestName())) {
            case REQUEST_GET_CAPABILITIES:
                return new GetCapabilitiesExecutor().execute();
            case PLUGIN_SETTINGS_GET_ICON:
                return new GetPluginSettingsIconExecutor().execute();
            case REQUEST_GET_ELASTIC_AGENT_PROFILE_METADATA:
                return new GetProfileMetadataExecutor().execute();
            case REQUEST_GET_ELASTIC_AGENT_PROFILE_VIEW:
                return new GetProfileViewExecutor().execute();
            case REQUEST_VALIDATE_ELASTIC_AGENT_PROFILE:
                return ProfileValidateRequest.fromJSON(request.requestBody()).executor().execute();
            case REQUEST_GET_CLUSTER_PROFILE_METADATA:
                return new GetClusterProfileMetadataExecutor().execute();
            case REQUEST_GET_CLUSTER_PROFILE_VIEW:
                return new GetClusterProfileViewRequestExecutor().execute();
            case REQUEST_VALIDATE_CLUSTER_PROFILE_CONFIGURATION:
                return ClusterProfileValidateRequest.fromJSON(request.requestBody()).executor(pluginRequest).execute();
            case REQUEST_CREATE_AGENT:
                CreateAgentRequest createAgentRequest = CreateAgentRequest.fromJSON(request.requestBody());
                clusterProfileProperties = createAgentRequest.clusterProfileProperties();
                return createAgentRequest.executor(getAgentInstancesFor(clusterProfileProperties), pluginRequest).execute();
            case REQUEST_SHOULD_ASSIGN_WORK:
                ShouldAssignWorkRequest shouldAssignWorkRequest = ShouldAssignWorkRequest.fromJSON(request.requestBody());
                clusterProfileProperties = shouldAssignWorkRequest.clusterProfileProperties();
                return shouldAssignWorkRequest.executor(getAgentInstancesFor(clusterProfileProperties)).execute();
            case REQUEST_SERVER_PING:
                ServerPingRequest serverPingRequest = ServerPingRequest.fromJSON(request.requestBody());
                List<ClusterProfileProperties> listOfClusterProfileProperties = serverPingRequest.allClusterProfileProperties();
                refreshInstancesForAllClusters(listOfClusterProfileProperties);
                return serverPingRequest.executor(clusterSpecificAgentInstances, pluginRequest).execute();
            case REQUEST_JOB_COMPLETION:
                JobCompletionRequest jobCompletionRequest = JobCompletionRequest.fromJSON(request.requestBody());
                clusterProfileProperties = jobCompletionRequest.clusterProfileProperties();
                return jobCompletionRequest.executor(getAgentInstancesFor(clusterProfileProperties), pluginRequest).execute();
            case REQUEST_CLUSTER_STATUS_REPORT:
                ClusterStatusReportRequest clusterStatusReportRequest = ClusterStatusReportRequest.fromJSON(request.requestBody());
                clusterProfileProperties = clusterStatusReportRequest.clusterProfileProperties();
                KubernetesClientFactory.instance().clearOutExistingClient();
                refreshInstancesForCluster(clusterProfileProperties);
                return clusterStatusReportRequest.executor().execute();
            case REQUEST_ELASTIC_AGENT_STATUS_REPORT:
                AgentStatusReportRequest statusReportRequest = AgentStatusReportRequest.fromJSON(request.requestBody());
                clusterProfileProperties = statusReportRequest.clusterProfileProperties();
                refreshInstancesForCluster(clusterProfileProperties);
                return statusReportRequest.executor().execute();
            case REQUEST_CLUSTER_PROFILE_CHANGED:
                return new DefaultGoPluginApiResponse(200);
            case REQUEST_MIGRATE_CONFIGURATION:
                return MigrateConfigurationRequest.fromJSON(request.requestBody()).executor().execute();
            default:
                throw new UnhandledRequestTypeException(request.requestName());
        }
    } catch (Exception e) {
        LOG.error("Failed to handle request " + request.requestName(), e);
        return DefaultGoPluginApiResponse.error("Failed to handle request " + request.requestName());
    }
}