-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/0.9.0' into main
- Loading branch information
Showing
210 changed files
with
4,992 additions
and
2,476 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
docs/docs/cli/*.md | ||
docs/docs/cli/reference.md | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.8.1 | ||
0.9.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
backend/api/admin/src/main/java/co/airy/core/api/admin/TemplatesController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package co.airy.core.api.admin; | ||
|
||
import co.airy.avro.communication.Template; | ||
import co.airy.core.api.admin.payload.CreateTemplateRequestPayload; | ||
import co.airy.core.api.admin.payload.DeleteTemplateRequestPayload; | ||
import co.airy.core.api.admin.payload.GetTemplateRequestPayload; | ||
import co.airy.core.api.admin.payload.ListTemplatesRequestPayload; | ||
import co.airy.core.api.admin.payload.TemplatesResponsePayload; | ||
import co.airy.core.api.admin.payload.UpdateTemplateRequestPayload; | ||
import co.airy.model.template.TemplatePayload; | ||
import co.airy.spring.web.payload.EmptyResponsePayload; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import javax.validation.Valid; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
import static java.util.stream.Collectors.toList; | ||
|
||
@RestController | ||
public class TemplatesController { | ||
private final Stores stores; | ||
private final ObjectMapper objectMapper; | ||
|
||
public TemplatesController(Stores stores, ObjectMapper objectMapper) { | ||
this.stores = stores; | ||
this.objectMapper = objectMapper; | ||
} | ||
|
||
@PostMapping("/templates.create") | ||
ResponseEntity<?> createTemplate(@RequestBody @Valid CreateTemplateRequestPayload payload) throws JsonProcessingException { | ||
final Template template = Template.newBuilder() | ||
.setId(UUID.randomUUID().toString()) | ||
.setName(payload.getName()) | ||
.setContent(payload.getContent()) | ||
.setVariables(objectMapper.writeValueAsString(payload.getVariables())) | ||
.build(); | ||
|
||
try { | ||
stores.storeTemplate(template); | ||
} catch (InterruptedException | ExecutionException e) { | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); | ||
} | ||
|
||
return ResponseEntity.status(201).body(TemplatePayload.fromTemplate(template)); | ||
} | ||
|
||
@PostMapping("/templates.info") | ||
ResponseEntity<?> getTemplate(@RequestBody @Valid GetTemplateRequestPayload payload) { | ||
final Template template = stores.getTemplatesStore().get(payload.getId().toString()); | ||
if (template == null) { | ||
return ResponseEntity.notFound().build(); | ||
} | ||
|
||
return ResponseEntity.ok(TemplatePayload.fromTemplate(template)); | ||
} | ||
|
||
@PostMapping("/templates.delete") | ||
ResponseEntity<?> deleteTemplate(@RequestBody @Valid DeleteTemplateRequestPayload payload) { | ||
final Template template = stores.getTemplatesStore().get(payload.getId().toString()); | ||
if (template == null) { | ||
return ResponseEntity.notFound().build(); | ||
} | ||
stores.deleteTemplate(template); | ||
return ResponseEntity.ok(new EmptyResponsePayload()); | ||
} | ||
|
||
@PostMapping("/templates.list") | ||
ResponseEntity<?> listTemplates(@RequestBody @Valid ListTemplatesRequestPayload payload) { | ||
final List<TemplatePayload> response = stores.getTemplates().stream() | ||
.filter(t -> { | ||
if (payload.getName() == null || payload.getName().isEmpty()) { | ||
return true; | ||
} | ||
return t.getName().contains(payload.getName()); | ||
}) | ||
.map(TemplatePayload::fromTemplate) | ||
.collect(toList()); | ||
|
||
return ResponseEntity.ok(new TemplatesResponsePayload(response)); | ||
} | ||
|
||
@PostMapping("/templates.update") | ||
ResponseEntity<?> updateTemplate(@RequestBody @Valid UpdateTemplateRequestPayload payload) throws JsonProcessingException { | ||
final Template template = stores.getTemplate(payload.getName()); | ||
|
||
if (template == null) { | ||
return ResponseEntity.notFound().build(); | ||
} | ||
|
||
template.setContent(payload.getName()); | ||
template.setContent(objectMapper.writeValueAsString(payload.getContent())); | ||
|
||
try { | ||
stores.storeTemplate(template); | ||
} catch (InterruptedException | ExecutionException e) { | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); | ||
} | ||
|
||
return ResponseEntity.ok(TemplatePayload.fromTemplate(template)); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
.../api/admin/src/main/java/co/airy/core/api/admin/payload/CreateTemplateRequestPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package co.airy.core.api.admin.payload; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.validation.Valid; | ||
import javax.validation.constraints.NotNull; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class CreateTemplateRequestPayload { | ||
@NotNull | ||
private String name; | ||
@NotNull | ||
private String content; | ||
@Valid | ||
@NotNull | ||
private JsonNode variables; | ||
} |
16 changes: 16 additions & 0 deletions
16
.../api/admin/src/main/java/co/airy/core/api/admin/payload/DeleteTemplateRequestPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package co.airy.core.api.admin.payload; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.util.UUID; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class DeleteTemplateRequestPayload { | ||
@NotNull | ||
private UUID id; | ||
} |
16 changes: 16 additions & 0 deletions
16
...end/api/admin/src/main/java/co/airy/core/api/admin/payload/GetTemplateRequestPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package co.airy.core.api.admin.payload; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.util.UUID; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class GetTemplateRequestPayload { | ||
@NotNull | ||
private UUID id; | ||
} |
12 changes: 12 additions & 0 deletions
12
...d/api/admin/src/main/java/co/airy/core/api/admin/payload/ListTemplatesRequestPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package co.airy.core.api.admin.payload; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ListTemplatesRequestPayload { | ||
private String name; | ||
} |
15 changes: 15 additions & 0 deletions
15
backend/api/admin/src/main/java/co/airy/core/api/admin/payload/TemplatesResponsePayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package co.airy.core.api.admin.payload; | ||
|
||
import co.airy.model.template.TemplatePayload; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class TemplatesResponsePayload { | ||
private List<TemplatePayload> data; | ||
} |
Oops, something went wrong.