-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathAttributesController.java
92 lines (84 loc) · 3.65 KB
/
AttributesController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package com.czertainly.api.interfaces.connector;
import com.czertainly.api.exception.ValidationException;
import com.czertainly.api.model.client.attribute.RequestAttributeDto;
import com.czertainly.api.model.common.ErrorMessageDto;
import com.czertainly.api.model.common.attribute.v2.BaseAttribute;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/v1/{functionalGroup}/{kind}/attributes")
@Tag(
name = "Connector Attributes",
description = "Connector Attributes API. " +
"Provides information about supported Attributes of the connector. " +
"Attributes are specific to implementation and gives information about the " +
"data that can be exchanged and properly parsed by the connector. " +
"Part of this API is validation of the Attributes."
)
@ApiResponses(
value = {
@ApiResponse(
responseCode = "400",
description = "Bad Request",
content = @Content(schema = @Schema(implementation = ErrorMessageDto.class))
),
@ApiResponse(
responseCode = "404",
description = "Not Found",
content = @Content(schema = @Schema(implementation = ErrorMessageDto.class))
),
@ApiResponse(
responseCode = "500",
description = "Internal Server Error",
content = @Content
)
})
public interface AttributesController {
@GetMapping(
produces = {"application/json"}
)
@Operation(
summary = "List available Attributes"
)
@ApiResponses(
value = {
@ApiResponse(
responseCode = "200",
description = "Attributes retrieved"
)
}
)
List<BaseAttribute> listAttributeDefinitions(@Parameter(description = "Kind") @PathVariable String kind);
@PostMapping(
path = "/validate",
consumes = {"application/json"},
produces = { "application/json" }
)
@Operation(
summary = "Validate Attributes"
)
@ApiResponses(
value = {
@ApiResponse(
responseCode = "200",
description = "Attribute validation completed"
),
@ApiResponse(
responseCode = "422",
description = "Attribute validation failed",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class, example = "Attribute Validation error message")),
examples={@ExampleObject(value="[\"Error Message 1\",\"Error Message 2\"]")})
)
}
)
void validateAttributes(@Parameter(required = true, description = "Kind") @PathVariable String kind, @RequestBody List<RequestAttributeDto> attributes) throws ValidationException;
}