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