1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package org.onap.aaf.cmd.perm;
\r
25 import org.onap.aaf.cmd.AAFcli;
\r
26 import org.onap.aaf.cmd.Cmd;
\r
27 import org.onap.aaf.cmd.Param;
\r
28 import org.onap.aaf.cssa.rserv.HttpMethods;
\r
30 import org.onap.aaf.cadi.CadiException;
\r
31 import org.onap.aaf.cadi.LocatorException;
\r
32 import org.onap.aaf.cadi.client.Future;
\r
33 import org.onap.aaf.cadi.client.Rcli;
\r
34 import org.onap.aaf.cadi.client.Retryable;
\r
35 import org.onap.aaf.inno.env.APIException;
\r
37 import aaf.v2_0.PermRequest;
\r
39 public class Describe extends Cmd {
\r
40 private static final String PERM_PATH = "/authz/perm";
\r
41 public Describe(Perm parent) {
\r
42 super(parent,"describe",
\r
43 new Param("type",true),
\r
44 new Param("instance", true),
\r
45 new Param("action", true),
\r
46 new Param("description",true));
\r
50 public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {
\r
51 return same(new Retryable<Integer>() {
\r
53 public Integer code(Rcli<?> client) throws CadiException, APIException {
\r
55 String type = args[idx++];
\r
56 String instance = args[idx++];
\r
57 String action = args[idx++];
\r
58 StringBuilder desc = new StringBuilder();
\r
59 while (idx < args.length) {
\r
60 desc.append(args[idx++] + ' ');
\r
63 PermRequest pr = new PermRequest();
\r
65 pr.setInstance(instance);
\r
66 pr.setAction(action);
\r
67 pr.setDescription(desc.toString());
\r
69 // Set Start/End commands
\r
72 Future<PermRequest> fp = null;
\r
77 getDF(PermRequest.class),
\r
81 if(fp.get(AAFcli.timeout())) {
\r
83 pw().println("Description added to Permission");
\r
85 if((rv=fp.code())==202) {
\r
86 pw().print("Adding description");
\r
87 pw().println(" Accepted, but requires Approvals before actualizing");
\r
98 public void detailedHelp(int indent, StringBuilder sb) {
\r
99 detailLine(sb,indent,"Add a description to a permission");
\r
100 api(sb,indent,HttpMethods.PUT,"authz/perm",PermRequest.class,true);
\r