From f9731144cda4d7982cc4be1e60c1e4aa3b3ca2e2 Mon Sep 17 00:00:00 2001 From: Harikrishna Patnala Date: Mon, 21 Oct 2013 10:44:24 +0530 Subject: [PATCH] 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 --- .../command/user/ssh/CreateSSHKeyPairCmd.java | 6 +-- .../response/CreateSSHKeyPairResponse.java | 41 +++++++++++++++++++ .../api/response/SSHKeyPairResponse.java | 16 -------- 3 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 api/src/org/apache/cloudstack/api/response/CreateSSHKeyPairResponse.java diff --git a/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java b/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java index 56bec7eacd7..c47c062e701 100644 --- a/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java @@ -20,15 +20,15 @@ import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.response.CreateSSHKeyPairResponse; import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.ProjectResponse; -import org.apache.cloudstack.api.response.SSHKeyPairResponse; import org.apache.log4j.Logger; import com.cloud.user.SSHKeyPair; import com.cloud.user.UserContext; -@APICommand(name = "createSSHKeyPair", description="Create a new keypair and returns the private key", responseObject=SSHKeyPairResponse.class) +@APICommand(name = "createSSHKeyPair", description="Create a new keypair and returns the private key", responseObject=CreateSSHKeyPairResponse.class) public class CreateSSHKeyPairCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateSSHKeyPairCmd.class.getName()); private static final String s_name = "createsshkeypairresponse"; @@ -90,7 +90,7 @@ public class CreateSSHKeyPairCmd extends BaseCmd { @Override public void execute() { SSHKeyPair r = _mgr.createSSHKeyPair(this); - SSHKeyPairResponse response = new SSHKeyPairResponse(r.getName(), r.getFingerprint(), r.getPrivateKey()); + CreateSSHKeyPairResponse response = new CreateSSHKeyPairResponse(r.getName(), r.getFingerprint(), r.getPrivateKey()); response.setResponseName(getCommandName()); response.setObjectName("keypair"); this.setResponseObject(response); diff --git a/api/src/org/apache/cloudstack/api/response/CreateSSHKeyPairResponse.java b/api/src/org/apache/cloudstack/api/response/CreateSSHKeyPairResponse.java new file mode 100644 index 00000000000..e247fb4dcbc --- /dev/null +++ b/api/src/org/apache/cloudstack/api/response/CreateSSHKeyPairResponse.java @@ -0,0 +1,41 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.api.response; + +import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; + +public class CreateSSHKeyPairResponse extends SSHKeyPairResponse { + + @SerializedName("privatekey") @Param(description="Private key") + private String privateKey; + + public CreateSSHKeyPairResponse() {} + + public CreateSSHKeyPairResponse(String name, String fingerprint, String privateKey) { + super(name, fingerprint); + this.privateKey = privateKey; + } + + public String getPrivateKey() { + return privateKey; + } + + public void setPrivateKey(String privateKey) { + this.privateKey = privateKey; + } +} diff --git a/api/src/org/apache/cloudstack/api/response/SSHKeyPairResponse.java b/api/src/org/apache/cloudstack/api/response/SSHKeyPairResponse.java index 2791853d4a2..e102bab0394 100644 --- a/api/src/org/apache/cloudstack/api/response/SSHKeyPairResponse.java +++ b/api/src/org/apache/cloudstack/api/response/SSHKeyPairResponse.java @@ -30,19 +30,11 @@ public class SSHKeyPairResponse extends BaseResponse { @SerializedName("fingerprint") @Param(description="Fingerprint of the public key") private String fingerprint; - @SerializedName("privatekey") @Param(description="Private key") - private String privateKey; - public SSHKeyPairResponse() {} public SSHKeyPairResponse(String name, String fingerprint) { - this(name, fingerprint, null); - } - - public SSHKeyPairResponse(String name, String fingerprint, String privateKey) { this.name = name; this.fingerprint = fingerprint; - this.privateKey = privateKey; } public String getName() { @@ -61,12 +53,4 @@ public class SSHKeyPairResponse extends BaseResponse { this.fingerprint = fingerprint; } - public String getPrivateKey() { - return privateKey; - } - - public void setPrivateKey(String privateKey) { - this.privateKey = privateKey; - } - }