use of io.cdap.cdap.proto.id.NamespaceId in project cdap by caskdata.
the class ProfileHttpHandler method getProfiles.
/**
* List the profiles in the given namespace. By default the results will not contain profiles in system scope.
*/
@GET
@Path("/namespaces/{namespace-id}/profiles")
public void getProfiles(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @QueryParam("includeSystem") @DefaultValue("false") String includeSystem) throws Exception {
NamespaceId namespace = getValidatedNamespace(namespaceId);
accessEnforcer.enforceOnParent(EntityType.PROFILE, namespace, authenticationContext.getPrincipal(), StandardPermission.LIST);
boolean include = Boolean.valueOf(includeSystem);
if (include) {
accessEnforcer.enforceOnParent(EntityType.PROFILE, NamespaceId.SYSTEM, authenticationContext.getPrincipal(), StandardPermission.LIST);
}
List<Profile> profiles = verifyCpuLabelsProfiles(profileService.getProfiles(namespace, include), namespace);
responder.sendJson(HttpResponseStatus.OK, GSON.toJson(profiles));
}
use of io.cdap.cdap.proto.id.NamespaceId in project cdap by caskdata.
the class ProfileHttpHandler method getSystemProfiles.
@GET
@Path("/profiles")
public void getSystemProfiles(HttpRequest request, HttpResponder responder) throws Exception {
NamespaceId namespaceId = NamespaceId.SYSTEM;
accessEnforcer.enforceOnParent(EntityType.PROFILE, namespaceId, authenticationContext.getPrincipal(), StandardPermission.LIST);
List<Profile> profiles = verifyCpuLabelsProfiles(profileService.getProfiles(namespaceId, true), NamespaceId.SYSTEM);
responder.sendJson(HttpResponseStatus.OK, GSON.toJson(profiles));
}
use of io.cdap.cdap.proto.id.NamespaceId in project cdap by caskdata.
the class AppLifecycleHttpHandlerInternal method getAppDetailForVersion.
/**
* Get {@link ApplicationDetail} for a given application
*
* @param request {@link HttpRequest}
* @param responder {@link HttpResponse}
* @param namespace the namespace to get all application details
* @param application the id of the application to get its {@link ApplicationDetail}
* @throws Exception if either namespace or application doesn't exist, or failed to get {@link ApplicationDetail}
*/
@GET
@Path("/app/{app-id}/versions/{version-id}")
public void getAppDetailForVersion(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") final String namespace, @PathParam("app-id") final String application, @PathParam("version-id") final String version) throws Exception {
NamespaceId namespaceId = new NamespaceId(namespace);
if (!namespaceQueryAdmin.exists(namespaceId)) {
throw new NamespaceNotFoundException(namespaceId);
}
ApplicationId appId = new ApplicationId(namespace, application, version);
responder.sendJson(HttpResponseStatus.OK, GSON.toJson(applicationLifecycleService.getAppDetail(appId)));
}
use of io.cdap.cdap.proto.id.NamespaceId in project cdap by caskdata.
the class AppLifecycleHttpHandlerInternal method getAppDetail.
/**
* Get {@link ApplicationDetail} for a given application
*
* @param request {@link HttpRequest}
* @param responder {@link HttpResponse}
* @param namespace the namespace to get all application details *
* @param application the id of the application to get its {@link ApplicationDetail}
* @throws Exception if either namespace or application doesn't exist, or failed to get {@link ApplicationDetail}
*/
@GET
@Path("/app/{app-id}")
public void getAppDetail(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespace, @PathParam("app-id") String application) throws Exception {
NamespaceId namespaceId = new NamespaceId(namespace);
if (!namespaceQueryAdmin.exists(namespaceId)) {
throw new NamespaceNotFoundException(namespaceId);
}
ApplicationId appId = new ApplicationId(namespace, application);
responder.sendJson(HttpResponseStatus.OK, GSON.toJson(applicationLifecycleService.getAppDetail(appId)));
}
use of io.cdap.cdap.proto.id.NamespaceId in project cdap by caskdata.
the class ArtifactHttpHandlerInternal method getArtifactDetailForVersions.
@GET
@Path("/namespaces/{namespace-id}/artifacts/{artifact-name}/versions")
public void getArtifactDetailForVersions(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespace, @PathParam("artifact-name") String artifactName, @QueryParam("lower") String lower, @QueryParam("upper") String upper, @QueryParam("limit") @DefaultValue("1") int limit, @QueryParam("order") String order, @QueryParam("scope") @DefaultValue("user") String scope) throws Exception {
NamespaceId namespaceId = new NamespaceId(namespace);
if (!namespaceId.equals(NamespaceId.SYSTEM)) {
if (!namespaceQueryAdmin.exists(namespaceId)) {
throw new NamespaceNotFoundException(namespaceId);
}
}
ArtifactRange range = new ArtifactRange(namespaceId.getNamespace(), artifactName, new ArtifactVersionRange(new ArtifactVersion(lower), true, new ArtifactVersion(upper), true));
ArtifactSortOrder sortOrder = ArtifactSortOrder.valueOf(order);
List<ArtifactDetail> artifactDetailList = artifactRepository.getArtifactDetails(range, limit, sortOrder);
responder.sendJson(HttpResponseStatus.OK, GSON.toJson(artifactDetailList, ARTIFACT_DETAIL_LIST_TYPE));
}
Aggregations