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.ns;
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;
40 public class Delete extends Cmd {
41 public Delete(NS parent) {
42 super(parent,"delete",
43 new Param("ns-name",true));
47 public int _exec(final int idx, final String ... args) throws CadiException, APIException, LocatorException {
48 return same(new Retryable<Integer>() {
50 public Integer code(Rcli<?> client) throws CadiException, APIException {
52 StringBuilder path = new StringBuilder("/authz/ns/");
53 path.append(args[index++]);
55 // Send "Force" if set
56 setQueryParamsOn(client);
57 Future<Void> fp = client.delete(path.toString(),Void.class);
59 if (fp.get(AAFcli.timeout())) {
60 pw().println("Deleted Namespace");
70 public void detailedHelp(int _indent, StringBuilder sb) {
72 detailLine(sb,indent,"Delete a Namespace");
74 detailLine(sb,indent,"Namespaces cannot normally be deleted when there are still credentials,");
75 detailLine(sb,indent,"permissions or roles associated with them. These can be deleted");
76 detailLine(sb,indent,"automatically by setting \"force\" property.");
77 detailLine(sb,indent,"i.e. set force=true or just starting with \"force\"");
78 detailLine(sb,indent," (note force is unset after first use)");
80 detailLine(sb,indent,"If \"set force=move\" is set, credentials are deleted, but ");
81 detailLine(sb,indent,"Permissions and Roles are assigned to the Parent Namespace instead of");
82 detailLine(sb,indent,"being deleted. Similarly, Namespaces can be created even though there");
83 detailLine(sb,indent,"are Roles/Perms whose type starts with the requested sub-namespace.");
84 detailLine(sb,indent,"They are simply reassigned to the Child Namespace");
86 api(sb,indent,HttpMethods.DELETE,"authz/ns/<ns>[?force=true]",Void.class,true);