1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * Copyright © 2017 Amdocs
\r
7 * * ===========================================================================
\r
8 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * * you may not use this file except in compliance with the License.
\r
10 * * You may obtain a copy of the License at
\r
12 * * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * * Unless required by applicable law or agreed to in writing, software
\r
15 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * * See the License for the specific language governing permissions and
\r
18 * * limitations under the License.
\r
19 * * ============LICENSE_END====================================================
\r
21 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
23 ******************************************************************************/
\r
24 package com.att.cmd.ns;
\r
26 import com.att.cadi.CadiException;
\r
27 import com.att.cadi.LocatorException;
\r
28 import com.att.cadi.client.Future;
\r
29 import com.att.cadi.client.Rcli;
\r
30 import com.att.cadi.client.Retryable;
\r
31 import com.att.cmd.AAFcli;
\r
32 import com.att.cmd.Cmd;
\r
33 import com.att.cmd.Param;
\r
34 import com.att.cssa.rserv.HttpMethods;
\r
35 import com.att.inno.env.APIException;
\r
37 import aaf.v2_0.NsRequest;
\r
43 public class Create extends Cmd {
\r
44 private static final String COMMA = ",";
\r
46 public Create(NS parent) {
\r
47 super(parent,"create",
\r
48 new Param("name",true),
\r
49 new Param("responsible (id[,id]*)",true),
\r
50 new Param("admin (id[,id]*)",false));
\r
54 public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {
\r
57 final NsRequest nr = new NsRequest();
\r
59 String realm = getOrgRealm();
\r
61 nr.setName(args[idx++]);
\r
62 String[] responsible = args[idx++].split(COMMA);
\r
63 for(String s : responsible) {
\r
64 if (s.indexOf('@') < 0 && realm != null) s += '@' + realm;
\r
65 nr.getResponsible().add(s);
\r
68 if(args.length>idx) {
\r
69 admin = args[idx++].split(COMMA);
\r
71 admin = responsible;
\r
73 for(String s : admin) {
\r
74 if (s.indexOf('@') < 0 && realm != null) s += '@' + realm;
\r
75 nr.getAdmin().add(s);
\r
78 // Set Start/End commands
\r
81 return same(new Retryable<Integer>() {
\r
83 public Integer code(Rcli<?> client) throws CadiException, APIException {
\r
85 setQueryParamsOn(client);
\r
86 Future<NsRequest> fp = client.create(
\r
88 getDF(NsRequest.class),
\r
91 if(fp.get(AAFcli.timeout())) {
\r
92 pw().println("Created Namespace");
\r
94 if(fp.code()==202) {
\r
95 pw().println("Namespace Creation Accepted, but requires Approvals before actualizing");
\r
106 public void detailedHelp(int _indent, StringBuilder sb) {
\r
107 int indent = _indent;
\r
108 detailLine(sb,indent,"Create a Namespace");
\r
110 detailLine(sb,indent,"name - Namespaces are dot-delimited, ex com.att.myapp");
\r
111 detailLine(sb,indent+14,"and must be created with parent credentials.");
\r
112 detailLine(sb,indent+14,"Ex: to create com.att.myapp, you must be admin for com.att");
\r
113 detailLine(sb,indent+14,"or com");
\r
114 detailLine(sb,indent,"responsible - This is the person(s) who receives Notifications and");
\r
115 detailLine(sb,indent+14,"approves Requests regarding this Namespace. Companies have");
\r
116 detailLine(sb,indent+14,"Policies as to who may take on this responsibility");
\r
117 detailLine(sb,indent,"admin - These are the people who are allowed to make changes on");
\r
118 detailLine(sb,indent+14,"the Namespace, including creating Roles, Permissions");
\r
119 detailLine(sb,indent+14,"and Credentials");
\r
121 detailLine(sb,indent,"Namespaces can be created even though there are Roles/Permissions which");
\r
122 detailLine(sb,indent,"start with the requested sub-namespace. They are reassigned to the");
\r
123 detailLine(sb,indent,"Child Namespace");
\r
125 api(sb,indent,HttpMethods.POST,"authz/ns",NsRequest.class,true);
\r