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.perm;
25 import org.onap.aaf.auth.cmd.AAFcli;
26 import org.onap.aaf.auth.cmd.Cmd;
27 import org.onap.aaf.auth.cmd.Param;
28 import org.onap.aaf.auth.rserv.HttpMethods;
29 import org.onap.aaf.cadi.CadiException;
30 import org.onap.aaf.cadi.LocatorException;
31 import org.onap.aaf.cadi.client.Future;
32 import org.onap.aaf.cadi.client.Rcli;
33 import org.onap.aaf.cadi.client.Retryable;
34 import org.onap.aaf.misc.env.APIException;
36 import aaf.v2_0.PermRequest;
38 public class Rename extends Cmd {
39 public Rename(Perm parent) {
40 super(parent,"rename",
41 new Param("type",true),
42 new Param("instance",true),
43 new Param("action", true),
44 new Param("new type",true),
45 new Param("new instance",true),
46 new Param("new action", true)
51 public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {
52 return same(new Retryable<Integer>() {
54 public Integer code(Rcli<?> client) throws CadiException, APIException {
56 String origType = args[idx++];
57 String origInstance = args[idx++];
58 String origAction = args[idx++];
60 //Create new permission
61 PermRequest pr = new PermRequest();
62 pr.setType(args[idx++]);
63 pr.setInstance(args[idx++]);
64 pr.setAction(args[idx++]);
66 // Set Start/End commands
68 Future<PermRequest> fp = client.update(
69 "/authz/perm/"+origType+"/"+origInstance+"/"+origAction,
70 getDF(PermRequest.class),
74 if (fp.get(AAFcli.timeout())) {
76 pw().println("Updated Permission");
80 pw().println("Permission Update Accepted, but requires Approvals before actualizing");
92 public void detailedHelp(int indent, StringBuilder sb) {
93 detailLine(sb,indent,"Rename a Permission from:");
94 detailLine(sb,indent+2,"<type> <instance> <action>");
95 detailLine(sb,indent,"to:");
96 detailLine(sb,indent+2,"<new type> <new instance> <new action>");
98 detailLine(sb,indent,"Namespace must be the same in <type> and <new type>");
99 detailLine(sb,indent+4,"see Create for definitions of type,instance and action");
100 api(sb,indent,HttpMethods.PUT,"authz/perm/<type>/<instance>/<action>",PermRequest.class,true);