2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.auth.cm.api;
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpServletResponse;
27 import org.eclipse.jetty.http.HttpStatus;
28 import org.onap.aaf.auth.cm.AAF_CM;
29 import org.onap.aaf.auth.cm.mapper.Mapper.API;
30 import org.onap.aaf.auth.cm.service.Code;
31 import org.onap.aaf.auth.env.AuthzTrans;
32 import org.onap.aaf.auth.layer.Result;
33 import org.onap.aaf.auth.rserv.HttpMethods;
36 * API Deployment Artifact Apis.. using Redirect for mechanism
41 public class API_Artifact {
42 private static final String GET_ARTIFACTS = "Get Artifacts";
45 * Normal Init level APIs
51 public static void init(final AAF_CM cmAPI) throws Exception {
52 cmAPI.route(HttpMethods.POST, "/cert/artifacts", API.ARTIFACTS, new Code(cmAPI,"Create Artifacts") {
54 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
55 Result<Void> r = context.createArtifacts(trans, req, resp);
57 resp.setStatus(HttpStatus.CREATED_201);
59 context.error(trans,resp,r);
65 * Use Query Params to get Artifacts by Machine or MechID
67 cmAPI.route(HttpMethods.GET, "/cert/artifacts", API.ARTIFACTS, new Code(cmAPI,GET_ARTIFACTS) {
69 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
70 Result<Void> r = context.readArtifacts(trans, req, resp);
72 resp.setStatus(HttpStatus.OK_200);
74 context.error(trans,resp,r);
80 cmAPI.route(HttpMethods.GET, "/cert/artifacts/:mechid/:machine", API.ARTIFACTS, new Code(cmAPI,GET_ARTIFACTS) {
82 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
84 Result<Void> r = context.readArtifacts(trans, resp, pathParam(req,":mechid"), pathParam(req,":machine"));
86 resp.setStatus(HttpStatus.OK_200);
88 context.error(trans,resp,r);
94 cmAPI.route(HttpMethods.PUT, "/cert/artifacts", API.ARTIFACTS, new Code(cmAPI,"Update Artifacts") {
96 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
97 Result<Void> r = context.updateArtifacts(trans, req, resp);
99 resp.setStatus(HttpStatus.OK_200);
101 context.error(trans,resp,r);
106 cmAPI.route(HttpMethods.DELETE, "/cert/artifacts/:mechid/:machine", API.VOID, new Code(cmAPI,"Delete Artifacts") {
108 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
109 Result<Void> r = context.deleteArtifacts(trans, resp,
110 pathParam(req, ":mechid"), pathParam(req,":machine"));
112 resp.setStatus(HttpStatus.OK_200);
114 context.error(trans,resp,r);
120 cmAPI.route(HttpMethods.DELETE, "/cert/artifacts", API.VOID, new Code(cmAPI,"Delete Artifacts") {
122 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
123 Result<Void> r = context.deleteArtifacts(trans, req, resp);
125 resp.setStatus(HttpStatus.OK_200);
127 context.error(trans,resp,r);