private static DeleteKeypairResponse DeleteKeypair(KpsClient client) { var request = new DeleteKeypairRequest { KeypairName = "KpsTest" }; try { var resp = client.DeleteKeypair(request); Console.WriteLine(resp.ToString()); return(resp); } catch (RequestTimeoutException requestTimeoutException) { Console.WriteLine(requestTimeoutException.ErrorMessage); } catch (ServiceResponseException clientRequestException) { Console.WriteLine(clientRequestException.HttpStatusCode); Console.WriteLine(clientRequestException.ErrorCode); Console.WriteLine(clientRequestException.ErrorMsg); } catch (ConnectionException connectionException) { Console.WriteLine(connectionException.ErrorMessage); } return(null); }
/// <summary> /// 删除SSH密钥对 /// </summary> public async Task <DeleteKeypairResponse> DeleteKeypairAsync(DeleteKeypairRequest deleteKeypairRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("keypair_name", deleteKeypairRequest.KeypairName.ToString()); string urlPath = HttpUtils.AddUrlPath("/v3/{project_id}/keypairs/{keypair_name}", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json", deleteKeypairRequest); HttpResponseMessage response = await DoHttpRequestAsync("DELETE", request); return(JsonUtils.DeSerializeNull <DeleteKeypairResponse>(response)); }