/// <summary> /// Create new Api key asynchronously. /// </summary> /// <example> /// This example shows how to use the <see cref="AccountManagementApi.AddApiKeyAsync(ApiKey)"/> method. /// <code> /// try /// { /// var key = new ApiKey /// { /// Name = "example api key", /// }; /// var newKey = await accountApi.AddApiKeyAsync(key); /// return newKey; /// } /// catch (CloudApiException) /// { /// throw; /// } /// </code> /// </example> /// <param name="key"><see cref="ApiKey"/></param> /// <returns><see cref="Task"/> with <see cref="ApiKey"/></returns> /// <exception cref="CloudApiException">CloudApiException</exception> public async Task <ApiKey> AddApiKeyAsync(ApiKey key) { try { var keyBody = key.CreatePostRequest(); return(ApiKey.Map(await DeveloperApi.CreateApiKeyAsync(keyBody))); } catch (iam.Client.ApiException e) { throw new CloudApiException(e.ErrorCode, e.Message, e.ErrorContent); } }