forked from CZERTAINLY/CZERTAINLY-Interfaces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DiscoveryController.java
113 lines (106 loc) · 4.46 KB
/
DiscoveryController.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package com.czertainly.api.interfaces.connector;
import com.czertainly.api.exception.NotFoundException;
import com.czertainly.api.model.common.ErrorMessageDto;
import com.czertainly.api.model.connector.discovery.DiscoveryDataRequestDto;
import com.czertainly.api.model.connector.discovery.DiscoveryProviderDto;
import com.czertainly.api.model.connector.discovery.DiscoveryRequestDto;
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.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
@RestController
@RequestMapping("/v1/discoveryProvider")
@Tag(
name = "Discovery",
description = "Discovery Provider API. " +
"Used to schedule and establish certificate discovery process. " +
"Once the discovery process is started, the progress and the history " +
"of the certificate discovery can be requested. Discovery provides " +
"information about discovered certificates and meta data that are specific " +
"to implementation of the discovery provider."
)
@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 DiscoveryController {
@PostMapping(
path = "/discover",
consumes = {"application/json"},
produces = {"application/json"}
)
@Operation(
summary = "Initiate certificate Discovery"
)
@ApiResponses(
value = {
@ApiResponse(
responseCode = "200",
description = "Discovery initiated"
),
@ApiResponse(
responseCode = "422",
description = "Unprocessable entity",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)),
examples={@ExampleObject(value="[\"Error Message 1\",\"Error Message 2\"]")})
)
}
)
DiscoveryProviderDto discoverCertificate(@RequestBody DiscoveryRequestDto request) throws IOException, NotFoundException;
@PostMapping(
path = "/discover/{uuid}",
consumes = {"application/json"},
produces = {"application/json"}
)
@Operation(
summary = "Get Discovery status and result"
)
@ApiResponses(
value = {
@ApiResponse(
responseCode = "200",
description = "Discovery details retrieved"
)
}
)
DiscoveryProviderDto getDiscovery(@Parameter(description = "Discovery UUID") @PathVariable String uuid, @RequestBody DiscoveryDataRequestDto request) throws IOException, NotFoundException;
@DeleteMapping(
path = "/discover/{uuid}",
produces = {"application/json"}
)
@Operation(
summary = "Delete Discovery"
)
@ApiResponses(
value = {
@ApiResponse(
responseCode = "204",
description = "Discovery information deleted"
)
}
)
@ResponseStatus(HttpStatus.NO_CONTENT)
void deleteDiscovery(@Parameter(description = "Discovery UUID") @PathVariable String uuid) throws IOException, NotFoundException;
}