/// <summary> /// Creates new storage container in given location with optionally given name /// </summary> /// <param name="storageLocation">location of storage container</param> /// <param name="containerShortName">container name, optional</param> /// <returns>Error if operation failed, Accepted - when success</returns> public async Task <string> ProvisionContainer(StorageLocations storageLocation, string containerShortName = null) { var uri = $"{_baseProvisioningApiUrl}container"; var containerInput = new ContainerInput { ContainerShortName = containerShortName, MayContainPersonalData = false, StorageLocation = storageLocation.ToString() }; var response = await _httpClient.PostAsync(uri, new StringContent(JsonConvert.SerializeObject(containerInput), Encoding.UTF8, "application/json")); var responseContent = await response.Content.ReadAsStringAsync(); return(response.IsSuccessStatusCode ? response.ReasonPhrase : responseContent); }
/// <summary> /// Creates new storage container in given location with optionally given name /// </summary> /// <param name="storageLocation">location of storage container</param> /// <param name="containerShortName">container name, optional</param> /// <returns>Error if operation failed, Accepted - when success</returns> public async Task <string> ProvisionContainer(StorageLocations storageLocation, string containerShortName = null) { var queryString = HttpUtility.ParseQueryString(string.Empty); if (!string.IsNullOrEmpty(containerShortName)) { queryString["containerShortName"] = containerShortName; } var requestCode = Guid.NewGuid().ToString(); var uri = $"{_baseProvisioningApiUrl}container?storageLocation={storageLocation}&requestCode={requestCode}&{queryString}"; var body = JsonConvert.SerializeObject(new { StorageLocation = storageLocation.ToString(), RequestCode = requestCode, ContainerShortName = containerShortName }); var response = await _httpClient.PostAsync(uri, new StringContent(body, Encoding.UTF8, "application/json")); var responseContent = await response.Content.ReadAsStringAsync(); return(response.IsSuccessStatusCode ? response.ReasonPhrase : responseContent); }