/// <inheritdoc />
        public bool CreateVolume(int size, string displayDescription = null, string displayName = null, string snapshotId = null, string volumeType = null, string region = null, CloudIdentity identity = null)
        {
            _cloudBlockStorageValidator.ValidateVolumeSize(size);

            var urlPath     = new Uri(string.Format("{0}/volumes", GetServiceEndpoint(identity, region)));
            var requestBody = new CreateCloudBlockStorageVolumeRequest {
                CreateCloudBlockStorageVolumeDetails = new CreateCloudBlockStorageVolumeDetails {
                    Size = size, DisplayDescription = displayDescription, DisplayName = displayName, SnapshotId = snapshotId, VolumeType = volumeType
                }
            };
            var response = ExecuteRESTRequest(identity, urlPath, HttpMethod.POST, requestBody);

            return(response != null && _validResponseCode.Contains(response.StatusCode));
        }
Пример #2
0
        /// <inheritdoc />
        public Volume CreateVolume(int size, string displayDescription = null, string displayName = null, string snapshotId = null, string volumeType = null, string region = null, CloudIdentity identity = null)
        {
            if (size < 0)
            {
                throw new ArgumentOutOfRangeException("size");
            }
            CheckIdentity(identity);

            _cloudBlockStorageValidator.ValidateVolumeSize(size);

            var urlPath     = new Uri(string.Format("{0}/volumes", GetServiceEndpoint(identity, region)));
            var requestBody = new CreateCloudBlockStorageVolumeRequest(new CreateCloudBlockStorageVolumeDetails(size, displayDescription, displayName, snapshotId, volumeType));
            var response    = ExecuteRESTRequest <GetCloudBlockStorageVolumeResponse>(identity, urlPath, HttpMethod.POST, requestBody);

            if (response == null || response.Data == null)
            {
                return(null);
            }

            return(response.Data.Volume);
        }