コード例 #1
0
        /// <inheritdoc />
        public bool CreateSnapshot(string volumeId, bool force = false, string displayName = "None", string displayDescription = "None", string region = null, CloudIdentity identity = null)
        {
            var urlPath     = new Uri(string.Format("{0}/snapshots", GetServiceEndpoint(identity, region)));
            var requestBody = new CreateCloudBlockStorageSnapshotRequest {
                CreateCloudBlockStorageSnapshotDetails = new CreateCloudBlockStorageSnapshotDetails {
                    VolumeId = volumeId, Force = force, DisplayName = displayName, DisplayDescription = displayDescription
                }
            };
            var response = ExecuteRESTRequest(identity, urlPath, HttpMethod.POST, requestBody);

            return(response != null && _validResponseCode.Contains(response.StatusCode));
        }
コード例 #2
0
        /// <inheritdoc />
        public Snapshot CreateSnapshot(string volumeId, bool force = false, string displayName = "None", string displayDescription = "None", string region = null, CloudIdentity identity = null)
        {
            if (volumeId == null)
            {
                throw new ArgumentNullException("volumeId");
            }
            if (string.IsNullOrEmpty(volumeId))
            {
                throw new ArgumentException("volumeId cannot be empty");
            }
            CheckIdentity(identity);

            var urlPath     = new Uri(string.Format("{0}/snapshots", GetServiceEndpoint(identity, region)));
            var requestBody = new CreateCloudBlockStorageSnapshotRequest(new CreateCloudBlockStorageSnapshotDetails(volumeId, force, displayName, displayDescription));
            var response    = ExecuteRESTRequest <GetCloudBlockStorageSnapshotResponse>(identity, urlPath, HttpMethod.POST, requestBody);

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

            return(response.Data.Snapshot);
        }