Commit 340f0796 authored by Matija Obreza's avatar Matija Obreza

API: OAuth client controller docs

parent a3fe3ca4
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
*/ */
package org.gringlobal.api.v1.impl; package org.gringlobal.api.v1.impl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.genesys.blocks.oauth.model.OAuthClient; import org.genesys.blocks.oauth.model.OAuthClient;
import org.genesys.blocks.oauth.service.OAuthClientDetailsService; import org.genesys.blocks.oauth.service.OAuthClientDetailsService;
...@@ -69,6 +70,7 @@ public class OAuthManagementController extends ApiBaseController { ...@@ -69,6 +70,7 @@ public class OAuthManagementController extends ApiBaseController {
* @return the loaded OAuth client * @return the loaded OAuth client
*/ */
@GetMapping(value = ENDPOINT_CLIENT_ID) @GetMapping(value = ENDPOINT_CLIENT_ID)
@Operation(operationId = "getOauthClient", summary = "Get", description = "Get OAuth client by clientId")
public OAuthClient get(@PathVariable(value = "clientId") final String clientId) throws NotFoundElement { public OAuthClient get(@PathVariable(value = "clientId") final String clientId) throws NotFoundElement {
OAuthClient client = clientDetailsService.getClient(clientId); OAuthClient client = clientDetailsService.getClient(clientId);
if (client == null) { if (client == null) {
...@@ -84,6 +86,7 @@ public class OAuthManagementController extends ApiBaseController { ...@@ -84,6 +86,7 @@ public class OAuthManagementController extends ApiBaseController {
* @return the recorded OAuth client * @return the recorded OAuth client
*/ */
@PostMapping(value = "") @PostMapping(value = "")
@Operation(operationId = "addOauthClient", summary = "Create", description = "Add new OAuth client")
public OAuthClient create(@RequestBody OAuthClient source) { public OAuthClient create(@RequestBody OAuthClient source) {
OAuthClient oauthClient = clientDetailsService.addClient(source); OAuthClient oauthClient = clientDetailsService.addClient(source);
LOG.info("Created OAuth client with clientId={}", oauthClient.getClientId()); LOG.info("Created OAuth client with clientId={}", oauthClient.getClientId());
...@@ -97,6 +100,7 @@ public class OAuthManagementController extends ApiBaseController { ...@@ -97,6 +100,7 @@ public class OAuthManagementController extends ApiBaseController {
* @return the updated OAuth client * @return the updated OAuth client
*/ */
@PutMapping(value = "") @PutMapping(value = "")
@Operation(operationId = "updateOauthClient", summary = "Update", description = "Update OAuth client")
public OAuthClient update(@RequestBody OAuthClient source) throws NotFoundElement { public OAuthClient update(@RequestBody OAuthClient source) throws NotFoundElement {
OAuthClient client = get(source.getClientId()); OAuthClient client = get(source.getClientId());
return clientDetailsService.updateClient(client.getId(), source.getVersion(), source); return clientDetailsService.updateClient(client.getId(), source.getVersion(), source);
...@@ -109,6 +113,7 @@ public class OAuthManagementController extends ApiBaseController { ...@@ -109,6 +113,7 @@ public class OAuthManagementController extends ApiBaseController {
* @return the removed client * @return the removed client
*/ */
@DeleteMapping(value = ENDPOINT_CLIENT_ID) @DeleteMapping(value = ENDPOINT_CLIENT_ID)
@Operation(operationId = "removeOauthClient", summary = "Delete", description = "Remove OAuth client")
public OAuthClient remove(@PathVariable("clientId") final String clientId) throws NotFoundElement { public OAuthClient remove(@PathVariable("clientId") final String clientId) throws NotFoundElement {
OAuthClient client = get(clientId); OAuthClient client = get(clientId);
LOG.info("Removing client {}", client.getClientId()); LOG.info("Removing client {}", client.getClientId());
...@@ -122,6 +127,7 @@ public class OAuthManagementController extends ApiBaseController { ...@@ -122,6 +127,7 @@ public class OAuthManagementController extends ApiBaseController {
* @return the secret * @return the secret
*/ */
@PostMapping(value = ENDPOINT_CLIENT_ID + "/secret") @PostMapping(value = ENDPOINT_CLIENT_ID + "/secret")
@Operation(operationId = "generateSecret", summary = "Regenerate secret", description = "Generate a new secret for OAuth client")
public String generateSecret(@PathVariable(value = "clientId") final String clientId) throws NotFoundElement { public String generateSecret(@PathVariable(value = "clientId") final String clientId) throws NotFoundElement {
OAuthClient client = get(clientId); OAuthClient client = get(clientId);
return clientDetailsService.resetSecret(client); return clientDetailsService.resetSecret(client);
...@@ -134,6 +140,7 @@ public class OAuthManagementController extends ApiBaseController { ...@@ -134,6 +140,7 @@ public class OAuthManagementController extends ApiBaseController {
* @return the updated client * @return the updated client
*/ */
@DeleteMapping(value = ENDPOINT_CLIENT_ID + "/secret") @DeleteMapping(value = ENDPOINT_CLIENT_ID + "/secret")
@Operation(operationId = "clearSecret", summary = "Clear secret", description = "Clear the secret for OAuth client")
public OAuthClient removeSecret(@PathVariable(value = "clientId") final String clientId) throws NotFoundElement { public OAuthClient removeSecret(@PathVariable(value = "clientId") final String clientId) throws NotFoundElement {
clientDetailsService.removeSecret(get(clientId)); clientDetailsService.removeSecret(get(clientId));
return get(clientId); return get(clientId);
...@@ -149,6 +156,7 @@ public class OAuthManagementController extends ApiBaseController { ...@@ -149,6 +156,7 @@ public class OAuthManagementController extends ApiBaseController {
* @throws IOException Signals that an I/O exception has occurred. * @throws IOException Signals that an I/O exception has occurred.
*/ */
@PostMapping(value = "/filter") @PostMapping(value = "/filter")
@Operation(operationId = "listClients", summary = "List", description = "List OAuth clients")
public FilteredPage<OAuthClient, OAuthClientFilter> listClients(@RequestParam(name = "f", required = false) String filterCode, final Pagination page, public FilteredPage<OAuthClient, OAuthClientFilter> listClients(@RequestParam(name = "f", required = false) String filterCode, final Pagination page,
@RequestBody(required = false) OAuthClientFilter filter) throws IOException { @RequestBody(required = false) OAuthClientFilter filter) throws IOException {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment