2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2018 IBM.
7 * ===========================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END====================================================
23 package org.onap.aaf.auth.cmd.role;
25 import java.io.UnsupportedEncodingException;
26 import java.net.URLEncoder;
28 import org.onap.aaf.auth.cmd.Cmd;
29 import org.onap.aaf.auth.cmd.Param;
30 import org.onap.aaf.auth.rserv.HttpMethods;
31 import org.onap.aaf.cadi.CadiException;
32 import org.onap.aaf.cadi.LocatorException;
33 import org.onap.aaf.cadi.client.Future;
34 import org.onap.aaf.cadi.client.Rcli;
35 import org.onap.aaf.cadi.config.Config;
36 import org.onap.aaf.misc.env.APIException;
38 import aaf.v2_0.Roles;
46 public class ListByPerm extends Cmd {
47 private static final String HEADER = "List Roles by Perm ";
49 public ListByPerm(List parent) {
51 new Param("type",true),
52 new Param("instance", true),
53 new Param("action", true));
57 public int _exec(int idx0, final String ... args) throws CadiException, APIException, LocatorException {
59 final String type=args[idx];
60 final String instance=args[++idx];
61 final String action = args[++idx];
63 return same(((List)parent).new ListRoles() {
65 public Integer code(Rcli<?> client) throws CadiException, APIException {
67 Future<Roles> fp = client.read(
68 "/authz/roles/perm/"+type+'/' +
69 URLEncoder.encode(instance,Config.UTF_8)+'/'+
73 return list(fp,client, HEADER+type+'|'+instance+'|'+action);
74 } catch (UnsupportedEncodingException e) {
75 throw new CadiException(e);
82 public void detailedHelp(int indent, StringBuilder sb) {
83 detailLine(sb,indent,HEADER);
84 api(sb,indent,HttpMethods.GET,"authz/roles/user/<user>",Roles.class,true);