Search in sources :

Example 21 with ProfileId

use of io.cdap.cdap.proto.id.ProfileId in project cdap by caskdata.

the class ProfileHttpHandler method enableSystemProfile.

@POST
@Path("/profiles/{profile-name}/enable")
public void enableSystemProfile(HttpRequest request, HttpResponder responder, @PathParam("profile-name") String profileName) throws Exception {
    ProfileId profileId = getValidatedProfile(NamespaceId.SYSTEM, profileName);
    accessEnforcer.enforce(profileId, authenticationContext.getPrincipal(), StandardPermission.UPDATE);
    profileService.enableProfile(profileId);
    responder.sendStatus(HttpResponseStatus.OK);
}
Also used : ProfileId(io.cdap.cdap.proto.id.ProfileId) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 22 with ProfileId

use of io.cdap.cdap.proto.id.ProfileId in project cdap by caskdata.

the class ProfileHttpHandler method getProfile.

/**
 * Get the information about a specific profile.
 */
@GET
@Path("/namespaces/{namespace-id}/profiles/{profile-name}")
public void getProfile(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("profile-name") String profileName) throws Exception {
    ProfileId profileId = getValidatedProfile(namespaceId, profileName);
    accessEnforcer.enforce(profileId, authenticationContext.getPrincipal(), StandardPermission.GET);
    responder.sendJson(HttpResponseStatus.OK, GSON.toJson(verifyCpuLabelsProfile(profileService.getProfile(profileId), profileId)));
}
Also used : ProfileId(io.cdap.cdap.proto.id.ProfileId) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 23 with ProfileId

use of io.cdap.cdap.proto.id.ProfileId in project cdap by caskdata.

the class ProfileHttpHandler method deleteSystemProfile.

@DELETE
@Path("/profiles/{profile-name}")
public void deleteSystemProfile(HttpRequest request, HttpResponder responder, @PathParam("profile-name") String profileName) throws Exception {
    ProfileId profileId = getValidatedProfile(NamespaceId.SYSTEM, profileName);
    accessEnforcer.enforce(profileId, authenticationContext.getPrincipal(), StandardPermission.DELETE);
    profileService.deleteProfile(getValidatedProfile(NamespaceId.SYSTEM, profileName));
    responder.sendStatus(HttpResponseStatus.OK);
}
Also used : ProfileId(io.cdap.cdap.proto.id.ProfileId) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 24 with ProfileId

use of io.cdap.cdap.proto.id.ProfileId in project cdap by caskdata.

the class ProfileHttpHandler method disableSystemProfile.

@POST
@Path("/profiles/{profile-name}/disable")
public void disableSystemProfile(HttpRequest request, HttpResponder responder, @PathParam("profile-name") String profileName) throws Exception {
    ProfileId profileId = getValidatedProfile(NamespaceId.SYSTEM, profileName);
    accessEnforcer.enforce(profileId, authenticationContext.getPrincipal(), StandardPermission.UPDATE);
    profileService.disableProfile(getValidatedProfile(NamespaceId.SYSTEM, profileName));
    responder.sendStatus(HttpResponseStatus.OK);
}
Also used : ProfileId(io.cdap.cdap.proto.id.ProfileId) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 25 with ProfileId

use of io.cdap.cdap.proto.id.ProfileId in project cdap by caskdata.

the class ProfileHttpHandler method getProfileStatus.

@GET
@Path("/namespaces/{namespace-id}/profiles/{profile-name}/status")
public void getProfileStatus(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("profile-name") String profileName) throws Exception {
    ProfileId profileId = getValidatedProfile(namespaceId, profileName);
    accessEnforcer.enforce(profileId, authenticationContext.getPrincipal(), StandardPermission.GET);
    responder.sendJson(HttpResponseStatus.OK, GSON.toJson(profileService.getProfile(profileId).getStatus()));
}
Also used : ProfileId(io.cdap.cdap.proto.id.ProfileId) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

ProfileId (io.cdap.cdap.proto.id.ProfileId)112 Test (org.junit.Test)68 Profile (io.cdap.cdap.proto.profile.Profile)50 ProgramId (io.cdap.cdap.proto.id.ProgramId)26 ProvisionerInfo (io.cdap.cdap.proto.provisioner.ProvisionerInfo)26 Path (javax.ws.rs.Path)22 ApplicationId (io.cdap.cdap.proto.id.ApplicationId)16 ProgramRunId (io.cdap.cdap.proto.id.ProgramRunId)14 HashMap (java.util.HashMap)14 ProfileConflictException (io.cdap.cdap.common.ProfileConflictException)12 NamespaceId (io.cdap.cdap.proto.id.NamespaceId)12 MetricStore (io.cdap.cdap.api.metrics.MetricStore)10 NotFoundException (io.cdap.cdap.common.NotFoundException)10 ProgramSchedule (io.cdap.cdap.internal.app.runtime.schedule.ProgramSchedule)10 ProfileService (io.cdap.cdap.internal.profile.ProfileService)10 ArrayList (java.util.ArrayList)10 MetricsCollectionService (io.cdap.cdap.api.metrics.MetricsCollectionService)8 ScheduleId (io.cdap.cdap.proto.id.ScheduleId)8 POST (javax.ws.rs.POST)8 Store (io.cdap.cdap.app.store.Store)6