use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class UpdateClusterProfileCommandTest method shouldValidateElasticAgentProfilesAsPartOfUpdateClusterProfile.
@Test
void shouldValidateElasticAgentProfilesAsPartOfUpdateClusterProfile() {
ElasticConfig elasticConfig = new ElasticConfig();
elasticConfig.getClusterProfiles().add(new ClusterProfile("cluster1", "ecs"));
elasticConfig.getProfiles().add(new ElasticProfile("profile1", "cluster1"));
config.setElasticConfig(elasticConfig);
RecordNotFoundException exception = assertThrows(RecordNotFoundException.class, () -> command.isValid(config));
assertThat(exception.getMessage()).isEqualTo("Cluster profile with id 'cluster-id' was not found!");
}
use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class ClusterProfileRepresenter method fromJSON.
public static ClusterProfile fromJSON(JsonReader jsonReader) {
ClusterProfile clusterProfile = new ClusterProfile(jsonReader.getString("id"), jsonReader.getString("plugin_id"));
clusterProfile.addConfigurations(ConfigurationPropertyRepresenter.fromJSONArray(jsonReader, "properties"));
return clusterProfile;
}
use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class ClusterProfilesControllerV1 method getClusterProfile.
public String getClusterProfile(Request request, Response response) throws IOException {
final ClusterProfile clusterProfile = fetchEntityFromConfig(request.params("cluster_id"));
String etag = etagFor(clusterProfile);
if (fresh(request, etag)) {
return notModified(response);
}
setEtagHeader(response, etag);
return writerForTopLevelObject(request, response, jsonWriter(clusterProfile));
}
use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class ElasticProfileControllerV2 method create.
public String create(Request request, Response response) {
final ElasticProfile elasticProfileToCreate = buildEntityFromRequestBody(request);
haltIfEntityWithSameIdExists(elasticProfileToCreate);
ClusterProfile associatedClusterProfile = clusterProfilesService.findProfile(elasticProfileToCreate.getClusterProfileId());
haltIfSpecifiedClusterProfileDoesntExists(associatedClusterProfile, elasticProfileToCreate);
final HttpLocalizedOperationResult operationResult = new HttpLocalizedOperationResult();
elasticProfileService.create(currentUsername(), elasticProfileToCreate, operationResult);
return handleCreateOrUpdateResponse(request, response, elasticProfileToCreate, operationResult);
}
use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class ElasticProfileControllerV2 method update.
public String update(Request request, Response response) {
final String profileId = request.params(PROFILE_ID_PARAM);
final ElasticProfile existingElasticProfile = fetchEntityFromConfig(profileId);
final ElasticProfile newElasticProfile = buildEntityFromRequestBody(request);
if (isRenameAttempt(profileId, newElasticProfile.getId())) {
throw haltBecauseRenameOfEntityIsNotSupported("elasticProfile");
}
if (isPutRequestStale(request, existingElasticProfile)) {
throw haltBecauseEtagDoesNotMatch("elasticProfile", existingElasticProfile.getId());
}
ClusterProfile associatedClusterProfile = clusterProfilesService.findProfile(newElasticProfile.getClusterProfileId());
haltIfSpecifiedClusterProfileDoesntExists(associatedClusterProfile, newElasticProfile);
final HttpLocalizedOperationResult operationResult = new HttpLocalizedOperationResult();
elasticProfileService.update(currentUsername(), etagFor(existingElasticProfile), newElasticProfile, operationResult);
return handleCreateOrUpdateResponse(request, response, newElasticProfile, operationResult);
}
Aggregations