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.cmd.user;
24 import org.onap.aaf.auth.cmd.AAFcli;
25 import org.onap.aaf.auth.cmd.Cmd;
26 import org.onap.aaf.auth.cmd.Param;
27 import org.onap.aaf.auth.rserv.HttpMethods;
28 import org.onap.aaf.cadi.CadiException;
29 import org.onap.aaf.cadi.LocatorException;
30 import org.onap.aaf.cadi.client.Future;
31 import org.onap.aaf.cadi.client.Rcli;
32 import org.onap.aaf.cadi.client.Retryable;
33 import org.onap.aaf.misc.env.APIException;
35 import aaf.v2_0.Approvals;
42 public class ListApprovals extends Cmd {
43 private static final String HEADER = "List Approvals";
44 private static final String[] options = {"user","approver","ticket"};
45 public ListApprovals(List parent) {
46 super(parent,"approvals",
47 new Param(optionsToString(options),true),
48 new Param("value",true));
52 public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {
54 final String type = args[idx++];
55 int option = whichOption(options,type);
56 String value = args[idx];
57 final String fullValue;
59 fullValue = fullID(value);
63 return same(new Retryable<Integer>() {
65 public Integer code(Rcli<?> client) throws CadiException, APIException {
66 Future<Approvals> fp = client.read(
67 "/authz/approval/"+type+'/'+fullValue,
68 getDF(Approvals.class)
70 if (fp.get(AAFcli.timeout())) {
71 ((List)parent).report(fp.value,HEADER + " by " + type,fullValue);
84 public void detailedHelp(int _indent, StringBuilder sb) {
86 detailLine(sb,indent,HEADER);
88 detailLine(sb,indent,"Approvals are used when the Requestor does not have the rights");
89 detailLine(sb,indent,"to perform the action required. Approvers are those listed as");
90 detailLine(sb,indent,"responsible for Namespace associated with the request, and those");
91 detailLine(sb,indent,"required by the Company by Policy. This may be, for instance");
92 detailLine(sb,indent,"the supervisor of the requestor");
94 detailLine(sb,indent,"Delegates can be listed by User, Approver or Ticket.");
96 api(sb,indent,HttpMethods.GET,"authz/approval/user/<value>",Approvals.class,true);
97 api(sb,indent,HttpMethods.GET,"authz/approval/approver/<value>",Approvals.class,false);
98 api(sb,indent,HttpMethods.GET,"authz/approval/ticket/<value>",Approvals.class,false);