private static CreateKeypairResponse CreateKeypair(KpsClient client) { var request = new CreateKeypairRequest { Body = new CreateKeypairRequestBody() { Keypair = new CreateKeypairAction { Name = "KpsTest" } } }; try { var resp = client.CreateKeypair(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); }
private static ListKeypairDetailResponse ListKeypairDetail(KpsClient client) { var request = new ListKeypairDetailRequest { KeypairName = "KpsTest" }; try { var resp = client.ListKeypairDetail(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); }
static void Main1(string[] args) { const string ak = "{your ak string}"; const string sk = "{your sk string}"; const string endpoint = "{your endpoint string}"; const string projectId = "{your projectID string}"; var config = HttpConfig.GetDefaultConfig(); config.IgnoreSslVerification = true; var auth = new BasicCredentials(ak, sk, projectId); var kpsClient = KpsClient.NewBuilder() .WithCredential(auth) .WithEndPoint(endpoint) .WithHttpConfig(config).Build(); ListKeypairs(kpsClient); CreateKeypair(kpsClient); ListKeypairDetail(kpsClient); DeleteKeypair(kpsClient); }