Search in sources :

Example 31 with EntityId

use of co.cask.cdap.proto.id.EntityId in project cdap by caskdata.

the class GetMetadataPropertiesCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    EntityId entity = EntityId.fromString(arguments.get(ArgumentName.ENTITY.toString()));
    String scope = arguments.getOptional(ArgumentName.METADATA_SCOPE.toString());
    Map<String, String> properties = scope == null ? client.getProperties(entity) : client.getProperties(entity, MetadataScope.valueOf(scope.toUpperCase()));
    Table table = Table.builder().setHeader("key", "value").setRows(Iterables.transform(properties.entrySet(), new Function<Map.Entry<String, String>, List<String>>() {

        @Nullable
        @Override
        public List<String> apply(@Nullable Map.Entry<String, String> entry) {
            return Lists.newArrayList(entry.getKey(), entry.getValue());
        }
    })).build();
    cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Also used : EntityId(co.cask.cdap.proto.id.EntityId) Table(co.cask.cdap.cli.util.table.Table) List(java.util.List) Map(java.util.Map) Nullable(javax.annotation.Nullable)

Example 32 with EntityId

use of co.cask.cdap.proto.id.EntityId in project cdap by caskdata.

the class RemoveMetadataTagsCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    EntityId entity = EntityId.fromString(arguments.get(ArgumentName.ENTITY.toString()));
    client.removeTags(entity);
    output.println("Successfully removed metadata tags");
}
Also used : EntityId(co.cask.cdap.proto.id.EntityId)

Example 33 with EntityId

use of co.cask.cdap.proto.id.EntityId in project cdap by caskdata.

the class RemotePrivilegesHandler method revoke.

@POST
@Path("/revoke")
public void revoke(FullHttpRequest request, HttpResponder responder) throws Exception {
    Iterator<MethodArgument> arguments = parseArguments(request);
    EntityId entityId = deserializeNext(arguments);
    Principal principal = deserializeNext(arguments);
    Set<Action> actions = deserializeNext(arguments, SET_OF_ACTIONS);
    LOG.trace("Revoking {} on {} from {}", actions, entityId, principal);
    privilegesManager.revoke(Authorizable.fromEntityId(entityId), principal, actions);
    LOG.info("Revoked {} on {} from {} successfully", actions, entityId, principal);
    responder.sendStatus(HttpResponseStatus.OK);
}
Also used : EntityId(co.cask.cdap.proto.id.EntityId) Action(co.cask.cdap.proto.security.Action) MethodArgument(co.cask.cdap.common.internal.remote.MethodArgument) Principal(co.cask.cdap.proto.security.Principal) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 34 with EntityId

use of co.cask.cdap.proto.id.EntityId in project cdap by caskdata.

the class RemotePrivilegesHandler method grant.

@POST
@Path("/grant")
public void grant(FullHttpRequest request, HttpResponder responder) throws Exception {
    Iterator<MethodArgument> arguments = parseArguments(request);
    EntityId entityId = deserializeNext(arguments);
    Principal principal = deserializeNext(arguments);
    Set<Action> actions = deserializeNext(arguments, SET_OF_ACTIONS);
    LOG.trace("Granting {} on {} to {}", actions, entityId, principal);
    privilegesManager.grant(Authorizable.fromEntityId(entityId), principal, actions);
    LOG.info("Granted {} on {} to {} successfully", actions, entityId, principal);
    responder.sendStatus(HttpResponseStatus.OK);
}
Also used : EntityId(co.cask.cdap.proto.id.EntityId) Action(co.cask.cdap.proto.security.Action) MethodArgument(co.cask.cdap.common.internal.remote.MethodArgument) Principal(co.cask.cdap.proto.security.Principal) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 35 with EntityId

use of co.cask.cdap.proto.id.EntityId in project cdap by caskdata.

the class RemotePrivilegesHandler method revokeAll.

@POST
@Path("/revokeAll")
public void revokeAll(FullHttpRequest request, HttpResponder responder) throws Exception {
    Iterator<MethodArgument> arguments = parseArguments(request);
    EntityId entityId = deserializeNext(arguments);
    LOG.trace("Revoking all actions on {}", entityId);
    privilegesManager.revoke(Authorizable.fromEntityId(entityId));
    LOG.info("Revoked all actions on {} successfully", entityId);
    responder.sendStatus(HttpResponseStatus.OK);
}
Also used : EntityId(co.cask.cdap.proto.id.EntityId) MethodArgument(co.cask.cdap.common.internal.remote.MethodArgument) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

EntityId (co.cask.cdap.proto.id.EntityId)62 Principal (co.cask.cdap.proto.security.Principal)21 EnumSet (java.util.EnumSet)18 HashSet (java.util.HashSet)18 Set (java.util.Set)18 PartitionedFileSet (co.cask.cdap.api.dataset.lib.PartitionedFileSet)17 ImmutableSet (com.google.common.collect.ImmutableSet)17 Test (org.junit.Test)17 Action (co.cask.cdap.proto.security.Action)14 UnauthorizedException (co.cask.cdap.security.spi.authorization.UnauthorizedException)13 DatasetId (co.cask.cdap.proto.id.DatasetId)12 ProgramId (co.cask.cdap.proto.id.ProgramId)11 ApplicationManager (co.cask.cdap.test.ApplicationManager)11 ApplicationId (co.cask.cdap.proto.id.ApplicationId)10 StreamId (co.cask.cdap.proto.id.StreamId)9 NamespaceId (co.cask.cdap.proto.id.NamespaceId)8 PrivilegedAction (java.security.PrivilegedAction)8 KeyValueTable (co.cask.cdap.api.dataset.lib.KeyValueTable)7 NamespaceMeta (co.cask.cdap.proto.NamespaceMeta)7 Authorizer (co.cask.cdap.security.spi.authorization.Authorizer)7