Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
feat(yaml-payload): annotate effected endpoints to accept yaml payload
Browse files Browse the repository at this point in the history
refs: #177
  • Loading branch information
ChrisRousey committed Apr 18, 2023
1 parent 194fc84 commit 1fb2b56
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.datacater.core.config;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.jaxrs.yaml.YAMLMediaTypes;
import io.datacater.core.exceptions.ConfigNotFoundException;
import io.quarkus.security.Authenticated;
import io.smallrye.mutiny.Uni;
Expand All @@ -16,7 +17,7 @@

@Path("/configs")
@Authenticated
@Produces(MediaType.APPLICATION_JSON)
@Produces({MediaType.APPLICATION_JSON, YAMLMediaTypes.APPLICATION_JACKSON_YAML})
@SecurityRequirement(name = "apiToken")
public class ConfigEndpoint {
private static final String UUID_NOT_FOUND_ERROR_MESSAGE = "No config found for uuid %s";
Expand Down Expand Up @@ -51,7 +52,7 @@ public Uni<ConfigEntity> getConfig(@PathParam("uuid") UUID uuid) {

@POST
@RequestBody
@Consumes(MediaType.APPLICATION_JSON)
@Consumes({MediaType.APPLICATION_JSON, YAMLMediaTypes.APPLICATION_JACKSON_YAML})
public Uni<ConfigEntity> createConfig(Config config) throws JsonProcessingException {
ConfigEntity configEntity =
ConfigEntity.from(config.name(), config.kind(), config.metadata(), config.spec());
Expand All @@ -63,7 +64,7 @@ public Uni<ConfigEntity> createConfig(Config config) throws JsonProcessingExcept
@PUT
@Path("{uuid}")
@RequestBody
@Consumes(MediaType.APPLICATION_JSON)
@Consumes({MediaType.APPLICATION_JSON, YAMLMediaTypes.APPLICATION_JACKSON_YAML})
public Uni<ConfigEntity> updateConfig(@PathParam("uuid") UUID uuid, Config config) {
return sf.withTransaction(
((session, transaction) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.jaxrs.yaml.YAMLMediaTypes;
import io.datacater.core.authentication.DataCaterSessionFactory;
import io.datacater.core.config.ConfigEntity;
import io.datacater.core.config.ConfigUtilities;
Expand Down Expand Up @@ -40,7 +41,7 @@

@Path("/deployments")
@Authenticated
@Produces(MediaType.APPLICATION_JSON)
@Produces({MediaType.APPLICATION_JSON, YAMLMediaTypes.APPLICATION_JACKSON_YAML})
@SecurityRequirement(name = "apiToken")
@RequestScoped
public class DeploymentEndpoint {
Expand Down Expand Up @@ -166,7 +167,7 @@ public Uni<List<DeploymentEntity>> getDeployments() {
}

@POST
@Consumes(MediaType.APPLICATION_JSON)
@Consumes({MediaType.APPLICATION_JSON, YAMLMediaTypes.APPLICATION_JACKSON_YAML})
public Uni<DeploymentEntity> createDeployment(DeploymentSpec spec) {
DeploymentEntity de = new DeploymentEntity(spec);

Expand Down Expand Up @@ -252,6 +253,7 @@ public Uni<Response> deleteDeployment(@PathParam("uuid") UUID deploymentId) {

@PUT
@Path("{uuid}")
@Consumes({MediaType.APPLICATION_JSON, YAMLMediaTypes.APPLICATION_JACKSON_YAML})
public Uni<DeploymentEntity> updateDeployment(
@PathParam("uuid") UUID deploymentUuid, DeploymentSpec spec) {
return dsf.withTransaction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.jaxrs.yaml.YAMLMediaTypes;
import io.datacater.core.authentication.DataCaterSessionFactory;
import io.datacater.core.exceptions.DatacaterException;
import io.datacater.core.exceptions.PipelineNotFoundException;
Expand Down Expand Up @@ -42,7 +43,7 @@

@Path("/pipelines")
@Authenticated
@Produces(MediaType.APPLICATION_JSON)
@Produces({MediaType.APPLICATION_JSON, YAMLMediaTypes.APPLICATION_JACKSON_YAML})
@SecurityRequirement(name = "apiToken")
public class PipelineEndpoint {

Expand Down Expand Up @@ -75,7 +76,7 @@ public Uni<PipelineEntity> getPipeline(@PathParam("uuid") UUID uuid) {

@POST
@RequestBody
@Consumes(MediaType.APPLICATION_JSON)
@Consumes({MediaType.APPLICATION_JSON, YAMLMediaTypes.APPLICATION_JACKSON_YAML})
public Uni<PipelineEntity> createPipeline(Pipeline pipeline) throws JsonProcessingException {
PipelineEntity pe =
PipelineEntity.from(
Expand All @@ -88,7 +89,7 @@ public Uni<PipelineEntity> createPipeline(Pipeline pipeline) throws JsonProcessi
@PUT
@Path("{uuid}")
@RequestBody
@Consumes(MediaType.APPLICATION_JSON)
@Consumes({MediaType.APPLICATION_JSON, YAMLMediaTypes.APPLICATION_JACKSON_YAML})
public Uni<PipelineEntity> updatePipeline(@PathParam("uuid") UUID uuid, Pipeline pipeline) {
return dsf.withTransaction(
((session, transaction) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public Uni<Response> createStream(Stream stream) throws JsonProcessingException
@PUT
@Path("{uuid}")
@RequestBody
@Consumes(MediaType.APPLICATION_JSON)
@Consumes({MediaType.APPLICATION_JSON, YAMLMediaTypes.APPLICATION_JACKSON_YAML})
public Uni<StreamEntity> updateStream(@PathParam("uuid") UUID uuid, Stream stream) {

return dsf.withTransaction(
Expand Down

0 comments on commit 1fb2b56

Please sign in to comment.