Skip to content

Commit f973114

Browse files
Harikrishna Patnalakoushik-das
authored andcommitted
CLOUDSTACK-4493: registerSSHKeyPair API doc contains wrong API response (private key) Changing the response object of register and list ssh keypairs APIs
Signed-off-by: Koushik Das <koushik@apache.org>
1 parent 455a9f4 commit f973114

3 files changed

Lines changed: 44 additions & 19 deletions

File tree

‎api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
import org.apache.cloudstack.api.ApiConstants;
2121
import org.apache.cloudstack.api.BaseCmd;
2222
import org.apache.cloudstack.api.Parameter;
23+
import org.apache.cloudstack.api.response.CreateSSHKeyPairResponse;
2324
import org.apache.cloudstack.api.response.DomainResponse;
2425
import org.apache.cloudstack.api.response.ProjectResponse;
25-
import org.apache.cloudstack.api.response.SSHKeyPairResponse;
2626
import org.apache.log4j.Logger;
2727

2828
import com.cloud.user.SSHKeyPair;
2929
import com.cloud.user.UserContext;
3030

31-
@APICommand(name = "createSSHKeyPair", description="Create a new keypair and returns the private key", responseObject=SSHKeyPairResponse.class)
31+
@APICommand(name = "createSSHKeyPair", description="Create a new keypair and returns the private key", responseObject=CreateSSHKeyPairResponse.class)
3232
public class CreateSSHKeyPairCmd extends BaseCmd {
3333
public static final Logger s_logger = Logger.getLogger(CreateSSHKeyPairCmd.class.getName());
3434
private static final String s_name = "createsshkeypairresponse";
@@ -90,7 +90,7 @@ public long getEntityOwnerId() {
9090
@Override
9191
public void execute() {
9292
SSHKeyPair r = _mgr.createSSHKeyPair(this);
93-
SSHKeyPairResponse response = new SSHKeyPairResponse(r.getName(), r.getFingerprint(), r.getPrivateKey());
93+
CreateSSHKeyPairResponse response = new CreateSSHKeyPairResponse(r.getName(), r.getFingerprint(), r.getPrivateKey());
9494
response.setResponseName(getCommandName());
9595
response.setObjectName("keypair");
9696
this.setResponseObject(response);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.api.response;
18+
19+
import com.cloud.serializer.Param;
20+
import com.google.gson.annotations.SerializedName;
21+
22+
public class CreateSSHKeyPairResponse extends SSHKeyPairResponse {
23+
24+
@SerializedName("privatekey") @Param(description="Private key")
25+
private String privateKey;
26+
27+
public CreateSSHKeyPairResponse() {}
28+
29+
public CreateSSHKeyPairResponse(String name, String fingerprint, String privateKey) {
30+
super(name, fingerprint);
31+
this.privateKey = privateKey;
32+
}
33+
34+
public String getPrivateKey() {
35+
return privateKey;
36+
}
37+
38+
public void setPrivateKey(String privateKey) {
39+
this.privateKey = privateKey;
40+
}
41+
}

‎api/src/org/apache/cloudstack/api/response/SSHKeyPairResponse.java‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,11 @@ public class SSHKeyPairResponse extends BaseResponse {
3030
@SerializedName("fingerprint") @Param(description="Fingerprint of the public key")
3131
private String fingerprint;
3232

33-
@SerializedName("privatekey") @Param(description="Private key")
34-
private String privateKey;
35-
3633
public SSHKeyPairResponse() {}
3734

3835
public SSHKeyPairResponse(String name, String fingerprint) {
39-
this(name, fingerprint, null);
40-
}
41-
42-
public SSHKeyPairResponse(String name, String fingerprint, String privateKey) {
4336
this.name = name;
4437
this.fingerprint = fingerprint;
45-
this.privateKey = privateKey;
4638
}
4739

4840
public String getName() {
@@ -61,12 +53,4 @@ public void setFingerprint(String fingerprint) {
6153
this.fingerprint = fingerprint;
6254
}
6355

64-
public String getPrivateKey() {
65-
return privateKey;
66-
}
67-
68-
public void setPrivateKey(String privateKey) {
69-
this.privateKey = privateKey;
70-
}
71-
7256
}

0 commit comments

Comments
 (0)