Search in sources :

Example 1 with ScopeProperty

use of io.pravega.controller.server.rest.generated.model.ScopeProperty in project pravega by pravega.

the class StreamMetadataResourceImpl method listScopes.

/**
 * Implementation of listScopes REST API.
 *
 * @param securityContext     The security for API access.
 * @param asyncResponse       AsyncResponse provides means for asynchronous server side response processing.
 */
@Override
public void listScopes(final SecurityContext securityContext, final AsyncResponse asyncResponse) {
    long traceId = LoggerHelpers.traceEnter(log, "listScopes");
    controllerService.listScopes().thenApply(scopesList -> {
        ScopesList scopes = new ScopesList();
        scopesList.forEach(scope -> scopes.addScopesItem(new ScopeProperty().scopeName(scope)));
        return Response.status(Status.OK).entity(scopes).build();
    }).exceptionally(exception -> {
        log.warn("listScopes failed with exception: " + exception);
        return Response.status(Status.INTERNAL_SERVER_ERROR).build();
    }).thenApply(asyncResponse::resume).thenAccept(x -> LoggerHelpers.traceLeave(log, "listScopes", traceId));
}
Also used : AuthenticationException(io.pravega.common.auth.AuthenticationException) Arrays(java.util.Arrays) ApiV1(io.pravega.controller.server.rest.v1.ApiV1) READ(io.pravega.auth.AuthHandler.Permissions.READ) StreamsList(io.pravega.controller.server.rest.generated.model.StreamsList) AuthHandler(io.pravega.auth.AuthHandler) SecurityContext(javax.ws.rs.core.SecurityContext) ReaderGroupManagerImpl(io.pravega.client.admin.impl.ReaderGroupManagerImpl) ReaderGroup(io.pravega.client.stream.ReaderGroup) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) LocalController(io.pravega.controller.server.eventProcessor.LocalController) StoreException(io.pravega.controller.store.stream.StoreException) ClientFactoryImpl(io.pravega.client.stream.impl.ClientFactoryImpl) ReaderGroupManager(io.pravega.client.admin.ReaderGroupManager) Map(java.util.Map) ReaderGroupProperty(io.pravega.controller.server.rest.generated.model.ReaderGroupProperty) INTERNAL_NAME_PREFIX(io.pravega.shared.NameUtils.INTERNAL_NAME_PREFIX) DeleteScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus) CreateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateStreamStatus) Context(javax.ws.rs.core.Context) AsyncResponse(javax.ws.rs.container.AsyncResponse) CreateScopeRequest(io.pravega.controller.server.rest.generated.model.CreateScopeRequest) Collectors(java.util.stream.Collectors) CreateStreamRequest(io.pravega.controller.server.rest.generated.model.CreateStreamRequest) READER_GROUP_STREAM_PREFIX(io.pravega.shared.NameUtils.READER_GROUP_STREAM_PREFIX) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) HttpHeaders(javax.ws.rs.core.HttpHeaders) StreamState(io.pravega.controller.server.rest.generated.model.StreamState) Response(javax.ws.rs.core.Response) ScopesList(io.pravega.controller.server.rest.generated.model.ScopesList) CreateScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateScopeStatus) CompletableFuture(java.util.concurrent.CompletableFuture) UpdateStreamRequest(io.pravega.controller.server.rest.generated.model.UpdateStreamRequest) ArrayList(java.util.ArrayList) READ_UPDATE(io.pravega.auth.AuthHandler.Permissions.READ_UPDATE) ScaleMetadata(io.pravega.controller.store.stream.ScaleMetadata) DeleteStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteStreamStatus) ConnectionFactory(io.pravega.client.netty.impl.ConnectionFactory) Status(javax.ws.rs.core.Response.Status) LoggerHelpers(io.pravega.common.LoggerHelpers) ControllerService(io.pravega.controller.server.ControllerService) NameUtils(io.pravega.shared.NameUtils) Iterator(java.util.Iterator) ScopeProperty(io.pravega.controller.server.rest.generated.model.ScopeProperty) ModelHelper(io.pravega.controller.server.rest.ModelHelper) ReaderGroupsList(io.pravega.controller.server.rest.generated.model.ReaderGroupsList) PravegaAuthManager(io.pravega.controller.server.rpc.auth.PravegaAuthManager) ReaderGroupsListReaderGroups(io.pravega.controller.server.rest.generated.model.ReaderGroupsListReaderGroups) UpdateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateStreamStatus) InvalidStreamException(io.pravega.client.stream.InvalidStreamException) ScopesList(io.pravega.controller.server.rest.generated.model.ScopesList) ScopeProperty(io.pravega.controller.server.rest.generated.model.ScopeProperty)

Aggregations

AuthHandler (io.pravega.auth.AuthHandler)1 READ (io.pravega.auth.AuthHandler.Permissions.READ)1 READ_UPDATE (io.pravega.auth.AuthHandler.Permissions.READ_UPDATE)1 ReaderGroupManager (io.pravega.client.admin.ReaderGroupManager)1 ReaderGroupManagerImpl (io.pravega.client.admin.impl.ReaderGroupManagerImpl)1 ConnectionFactory (io.pravega.client.netty.impl.ConnectionFactory)1 InvalidStreamException (io.pravega.client.stream.InvalidStreamException)1 ReaderGroup (io.pravega.client.stream.ReaderGroup)1 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)1 ClientFactoryImpl (io.pravega.client.stream.impl.ClientFactoryImpl)1 LoggerHelpers (io.pravega.common.LoggerHelpers)1 AuthenticationException (io.pravega.common.auth.AuthenticationException)1 ControllerService (io.pravega.controller.server.ControllerService)1 LocalController (io.pravega.controller.server.eventProcessor.LocalController)1 ModelHelper (io.pravega.controller.server.rest.ModelHelper)1 CreateScopeRequest (io.pravega.controller.server.rest.generated.model.CreateScopeRequest)1 CreateStreamRequest (io.pravega.controller.server.rest.generated.model.CreateStreamRequest)1 ReaderGroupProperty (io.pravega.controller.server.rest.generated.model.ReaderGroupProperty)1 ReaderGroupsList (io.pravega.controller.server.rest.generated.model.ReaderGroupsList)1 ReaderGroupsListReaderGroups (io.pravega.controller.server.rest.generated.model.ReaderGroupsListReaderGroups)1