private async Task And_a_single_apiKey() { using var client = LocalhostRestClient.Create(); _serviceAccountCreateCommand = ServiceAccountCreateCommandFactory.CreateForIntegrationTest(); _serviceAccount = await client.ServiceAccounts.CreateAsync(_serviceAccountCreateCommand); _apiKeyCreate = new ApiKeyCreate() { ServiceAccountId = _serviceAccount.Id, Description = "GetAllScenario" }; _apiKey = await client.ApiKeys.CreateAsync(_apiKeyCreate); }
public async Task <ApiKey> CreateAsync(ApiKeyCreate apiKeyCreate, string clusterId = null) { var payload = JsonConvert.SerializeObject(new { serviceAccountId = apiKeyCreate.ServiceAccountId, description = apiKeyCreate.Description }); var content = new StringContent( payload, Encoding.UTF8, "application/json" ); var response = await _httpClient.PostAsync( new Uri(Utilities.MakeUrl(_clientOptions, APIKEYS_ROUTE, clusterId), UriKind.Absolute), content ); var apiKey = await Utilities.Parse <ApiKey>(response); return(apiKey); }