Search in sources :

Example 1 with ApiKeyEntity

use of io.gravitee.management.model.ApiKeyEntity in project gravitee-management-rest-api by gravitee-io.

the class ApiKeysResource method updateApiKey.

@PUT
@Path("{key}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Update an API Key", notes = "User must have the MANAGE_API_KEYS permission to use this service")
@ApiResponses({ @ApiResponse(code = 200, message = "API Key successfully updated", response = ApiKeyEntity.class), @ApiResponse(code = 400, message = "Bad plan format"), @ApiResponse(code = 500, message = "Internal server error") })
@Permissions({ @Permission(value = RolePermission.API_SUBSCRIPTION, acls = RolePermissionAction.UPDATE) })
public Response updateApiKey(@PathParam("api") String api, @PathParam("key") String apiKey, @Valid @NotNull ApiKeyEntity apiKeyEntity) {
    if (apiKeyEntity.getKey() != null && !apiKey.equals(apiKeyEntity.getKey())) {
        return Response.status(Response.Status.BAD_REQUEST).entity("'apiKey' parameter does not correspond to the api-key to update").build();
    }
    // Force API Key
    apiKeyEntity.setKey(apiKey);
    ApiKeyEntity keyEntity = apiKeyService.update(apiKeyEntity);
    return Response.ok(keyEntity).build();
}
Also used : ApiKeyEntity(io.gravitee.management.model.ApiKeyEntity) ApiOperation(io.swagger.annotations.ApiOperation) Permissions(io.gravitee.management.rest.security.Permissions) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ApiKeyEntity (io.gravitee.management.model.ApiKeyEntity)1 Permissions (io.gravitee.management.rest.security.Permissions)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1