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;
35 import aaf.v2_0.NsRequest;
41 public class Create extends Cmd {
42 private static final String COMMA = ",";
44 public Create(NS parent) {
45 super(parent,"create",
46 new Param("ns-name",true),
47 new Param("owner (id[,id]*)",true),
48 new Param("admin (id[,id]*)",false));
52 public int _exec(int _idx, final String ... args) throws CadiException, APIException, LocatorException {
55 final NsRequest nr = new NsRequest();
57 nr.setName(args[idx++]);
58 String[] responsible = args[idx++].split(COMMA);
59 for (String s : responsible) {
60 nr.getResponsible().add(fullID(s));
63 if (args.length>idx) {
64 admin = args[idx++].split(COMMA);
68 for (String s : admin) {
69 nr.getAdmin().add(fullID(s));
72 // Set Start/End commands
75 return same(new Retryable<Integer>() {
77 public Integer code(Rcli<?> client) throws CadiException, APIException {
79 setQueryParamsOn(client);
80 Future<NsRequest> fp = client.create(
82 getDF(NsRequest.class),
85 if (fp.get(AAFcli.timeout())) {
86 pw().println("Created Namespace");
89 pw().println("Namespace Creation Accepted, but requires Approvals before actualizing");
100 public void detailedHelp(int _indent, StringBuilder sb) {
101 int indent = _indent;
102 detailLine(sb,indent,"Create a Namespace");
104 detailLine(sb,indent,"name - Namespaces are dot-delimited, ex com.att.myapp");
105 detailLine(sb,indent+14,"and must be created with parent credentials.");
106 detailLine(sb,indent+14,"Ex: to create com.att.myapp, you must be admin for com.att");
107 detailLine(sb,indent+14,"or com");
108 detailLine(sb,indent,"owner - This is the person(s) who is responsible for the ");
109 detailLine(sb,indent+14,"app. These person or persons receive Notifications and");
110 detailLine(sb,indent+14,"approves Requests regarding this Namespace. Companies have");
111 detailLine(sb,indent+14,"Policies as to who may take on this responsibility");
112 detailLine(sb,indent,"admin - These are the people who are allowed to make changes on");
113 detailLine(sb,indent+14,"the Namespace, including creating Roles, Permissions");
114 detailLine(sb,indent+14,"and Credentials");
116 detailLine(sb,indent,"Namespaces can be created even though there are Roles/Permissions which");
117 detailLine(sb,indent,"start with the requested sub-namespace. They are reassigned to the");
118 detailLine(sb,indent,"Child Namespace");
120 api(sb,indent,HttpMethods.POST,"authz/ns",NsRequest.class,true);