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";
43 private static final String CERT_ARTIFACTS = "/cert/artifacts";
45 * Normal Init level APIs
50 public static void init(final AAF_CM cmAPI) throws Exception {
51 cmAPI.route(HttpMethods.POST, CERT_ARTIFACTS, API.ARTIFACTS, new Code(cmAPI,"Create Artifacts") {
53 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
54 Result<Void> r = context.createArtifacts(trans, req, resp);
56 resp.setStatus(HttpStatus.CREATED_201);
58 context.error(trans,resp,r);
64 * Use Query Params to get Artifacts by Machine or MechID
66 cmAPI.route(HttpMethods.GET, CERT_ARTIFACTS, API.ARTIFACTS, new Code(cmAPI,GET_ARTIFACTS) {
68 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
69 Result<Void> r = context.readArtifacts(trans, req, resp);
71 resp.setStatus(HttpStatus.OK_200);
73 context.error(trans,resp,r);
79 cmAPI.route(HttpMethods.GET, "/cert/artifacts/:mechid/:machine", API.ARTIFACTS, new Code(cmAPI,GET_ARTIFACTS) {
81 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
83 Result<Void> r = context.readArtifacts(trans, resp, pathParam(req,":mechid"), pathParam(req,":machine"));
85 resp.setStatus(HttpStatus.OK_200);
87 context.error(trans,resp,r);
93 cmAPI.route(HttpMethods.PUT, CERT_ARTIFACTS, API.ARTIFACTS, new Code(cmAPI,"Update Artifacts") {
95 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
96 Result<Void> r = context.updateArtifacts(trans, req, resp);
98 resp.setStatus(HttpStatus.OK_200);
100 context.error(trans,resp,r);
105 cmAPI.route(HttpMethods.DELETE, "/cert/artifacts/:mechid/:machine", API.VOID, new Code(cmAPI,"Delete Artifacts") {
107 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
108 Result<Void> r = context.deleteArtifacts(trans, resp,
109 pathParam(req, ":mechid"), pathParam(req,":machine"));
111 resp.setStatus(HttpStatus.OK_200);
113 context.error(trans,resp,r);
119 cmAPI.route(HttpMethods.DELETE, CERT_ARTIFACTS, API.VOID, new Code(cmAPI,"Delete Artifacts") {
121 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
122 Result<Void> r = context.deleteArtifacts(trans, req, resp);
124 resp.setStatus(HttpStatus.OK_200);
126 context.error(trans,resp,r);