@@ -259,7 +259,7 @@ protected ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider au
259259 }
260260
261261 /// <summary />
262- public virtual async Task < T > CreateSnapshotAsync < T > ( string serverId , object request , CancellationToken cancellationToken = default ( CancellationToken ) )
262+ public virtual async Task < T > SnapshotServerAsync < T > ( string serverId , object request , CancellationToken cancellationToken = default ( CancellationToken ) )
263263 where T : IServiceResource
264264 {
265265 var response = await BuildServerActionAsync ( serverId , request , cancellationToken ) . SendAsync ( ) ;
@@ -1088,6 +1088,25 @@ protected ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider au
10881088 return Endpoint . PrepareGetResourceRequest ( $ "os-volume-types/{ volumeTypeId } ", cancellationToken ) ;
10891089 }
10901090
1091+ /// <summary />
1092+ public virtual async Task < T > GetVolumeSnapshotAsync < T > ( string snapshotId , CancellationToken cancellationToken = default ( CancellationToken ) )
1093+ where T : IServiceResource
1094+ {
1095+ return await BuildGetVolumeSnapshotRequest ( snapshotId , cancellationToken )
1096+ . SendAsync ( )
1097+ . ReceiveJson < T > ( )
1098+ . PropogateOwner ( this ) ;
1099+ }
1100+
1101+ /// <summary />
1102+ public virtual Task < PreparedRequest > BuildGetVolumeSnapshotRequest ( string snapshotId , CancellationToken cancellationToken = default ( CancellationToken ) )
1103+ {
1104+ if ( snapshotId == null )
1105+ throw new ArgumentNullException ( "snapshotId" ) ;
1106+
1107+ return Endpoint . PrepareGetResourceRequest ( $ "os-snapshots/{ snapshotId } ", cancellationToken ) ;
1108+ }
1109+
10911110 /// <summary />
10921111 public virtual async Task < T > CreateVolumeAsync < T > ( object volume , CancellationToken cancellationToken = default ( CancellationToken ) )
10931112 where T : IServiceResource
@@ -1107,6 +1126,25 @@ protected ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider au
11071126 return Endpoint . PrepareCreateResourceRequest ( "os-volumes" , volume , cancellationToken ) ;
11081127 }
11091128
1129+ /// <summary />
1130+ public virtual async Task < T > SnapshotVolumeAsync < T > ( object snapshot , CancellationToken cancellationToken = default ( CancellationToken ) )
1131+ where T : IServiceResource
1132+ {
1133+ return await BuildCreateVolumeSnapshotRequest ( snapshot , cancellationToken )
1134+ . SendAsync ( )
1135+ . ReceiveJson < T > ( )
1136+ . PropogateOwner ( this ) ;
1137+ }
1138+
1139+ /// <summary />
1140+ public virtual async Task < PreparedRequest > BuildCreateVolumeSnapshotRequest ( object snapshot , CancellationToken cancellationToken = default ( CancellationToken ) )
1141+ {
1142+ if ( snapshot == null )
1143+ throw new ArgumentNullException ( "snapshot" ) ;
1144+
1145+ return await Endpoint . PrepareCreateResourceRequest ( "os-snapshots" , snapshot , cancellationToken ) ;
1146+ }
1147+
11101148 /// <summary />
11111149 public virtual async Task < T > ListVolumesAsync < T > ( CancellationToken cancellationToken = default ( CancellationToken ) )
11121150 where T : IEnumerable < IServiceResource >
@@ -1137,6 +1175,22 @@ protected ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider au
11371175 return Endpoint . PrepareGetResourceRequest ( "os-volume-types" , cancellationToken ) ;
11381176 }
11391177
1178+ /// <summary />
1179+ public virtual async Task < T > ListVolumeSnapshotsAsync < T > ( CancellationToken cancellationToken = default ( CancellationToken ) )
1180+ where T : IEnumerable < IServiceResource >
1181+ {
1182+ return await BuildListVolumeSnapshotsRequest ( cancellationToken )
1183+ . SendAsync ( )
1184+ . ReceiveJson < T > ( )
1185+ . PropogateOwnerToChildren ( this ) ;
1186+ }
1187+
1188+ /// <summary />
1189+ public virtual Task < PreparedRequest > BuildListVolumeSnapshotsRequest ( CancellationToken cancellationToken = default ( CancellationToken ) )
1190+ {
1191+ return Endpoint . PrepareGetResourceRequest ( "os-snapshots" , cancellationToken ) ;
1192+ }
1193+
11401194 /// <summary />
11411195 public virtual Task DeleteVolumeAsync ( string volumeId , CancellationToken cancellationToken = default ( CancellationToken ) )
11421196 {
@@ -1152,6 +1206,168 @@ protected ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider au
11521206 return Endpoint . PrepareDeleteResourceRequest ( $ "os-volumes/{ volumeId } ", cancellationToken ) ;
11531207 }
11541208
1209+ /// <summary />
1210+ public virtual Task DeleteVolumeSnapshotAsync ( string snapshotId , CancellationToken cancellationToken = default ( CancellationToken ) )
1211+ {
1212+ return BuildDeleteVolumeSnapshotRequest ( snapshotId , cancellationToken ) . SendAsync ( ) ;
1213+ }
1214+
1215+ /// <summary />
1216+ public virtual Task < PreparedRequest > BuildDeleteVolumeSnapshotRequest ( string snapshotId , CancellationToken cancellationToken = default ( CancellationToken ) )
1217+ {
1218+ if ( snapshotId == null )
1219+ throw new ArgumentNullException ( "snapshotId" ) ;
1220+
1221+ return Endpoint . PrepareDeleteResourceRequest ( $ "os-snapshots/{ snapshotId } ", cancellationToken ) ;
1222+ }
1223+
1224+ /// <summary>
1225+ /// Waits for the volume to reach the specified status.
1226+ /// </summary>
1227+ /// <param name="volumeId">The volume identifier.</param>
1228+ /// <param name="status">The status to wait for.</param>
1229+ /// <param name="refreshDelay">The amount of time to wait between requests.</param>
1230+ /// <param name="timeout">The amount of time to wait before throwing a <see cref="TimeoutException"/>.</param>
1231+ /// <param name="progress">The progress callback.</param>
1232+ /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
1233+ /// <exception cref="TimeoutException">If the <paramref name="timeout"/> value is reached.</exception>
1234+ /// <exception cref="FlurlHttpException">If the API call returns a bad <see cref="HttpStatusCode"/>.</exception>
1235+ public async Task < TVolume > WaitForVolumeStatusAsync < TVolume , TStatus > ( string volumeId , TStatus status , TimeSpan ? refreshDelay = null , TimeSpan ? timeout = null , IProgress < bool > progress = null , CancellationToken cancellationToken = default ( CancellationToken ) )
1236+ where TVolume : IServiceResource
1237+ where TStatus : ResourceStatus
1238+ {
1239+ if ( volumeId == null )
1240+ throw new ArgumentNullException ( "volumeId" ) ;
1241+
1242+ if ( status == null )
1243+ throw new ArgumentNullException ( "status" ) ;
1244+
1245+ Func < Task < TVolume > > getVolume = async ( ) => await GetVolumeAsync < TVolume > ( volumeId , cancellationToken ) ;
1246+ return await Endpoint . WaitForStatusAsync ( volumeId , status , getVolume , refreshDelay , timeout , progress , cancellationToken )
1247+ . PropogateOwner ( this ) ;
1248+ }
1249+
1250+ /// <summary>
1251+ /// Waits for the volume snapshot to reach the specified status.
1252+ /// </summary>
1253+ /// <param name="snapshotId">The snapshot identifier.</param>
1254+ /// <param name="status">The status to wait for.</param>
1255+ /// <param name="refreshDelay">The amount of time to wait between requests.</param>
1256+ /// <param name="timeout">The amount of time to wait before throwing a <see cref="TimeoutException"/>.</param>
1257+ /// <param name="progress">The progress callback.</param>
1258+ /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
1259+ /// <exception cref="TimeoutException">If the <paramref name="timeout"/> value is reached.</exception>
1260+ /// <exception cref="FlurlHttpException">If the API call returns a bad <see cref="HttpStatusCode"/>.</exception>
1261+ public async Task < TSnapshot > WaitForVolumeSnapshotStatusAsync < TSnapshot , TStatus > ( string snapshotId , TStatus status , TimeSpan ? refreshDelay = null , TimeSpan ? timeout = null , IProgress < bool > progress = null , CancellationToken cancellationToken = default ( CancellationToken ) )
1262+ where TSnapshot : IServiceResource
1263+ where TStatus : ResourceStatus
1264+ {
1265+ if ( snapshotId == null )
1266+ throw new ArgumentNullException ( "snapshotId" ) ;
1267+
1268+ if ( status == null )
1269+ throw new ArgumentNullException ( "status" ) ;
1270+
1271+ Func < Task < TSnapshot > > getSnapshot = async ( ) => await GetVolumeSnapshotAsync < TSnapshot > ( snapshotId , cancellationToken ) ;
1272+ return await Endpoint . WaitForStatusAsync ( snapshotId , status , getSnapshot , refreshDelay , timeout , progress , cancellationToken )
1273+ . PropogateOwner ( this ) ;
1274+ }
1275+
1276+ /// <summary>
1277+ /// Waits for the volume to reach the specified status.
1278+ /// </summary>
1279+ /// <param name="volumeId">The volume identifier.</param>
1280+ /// <param name="status">The status to wait for.</param>
1281+ /// <param name="refreshDelay">The amount of time to wait between requests.</param>
1282+ /// <param name="timeout">The amount of time to wait before throwing a <see cref="TimeoutException"/>.</param>
1283+ /// <param name="progress">The progress callback.</param>
1284+ /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
1285+ /// <exception cref="TimeoutException">If the <paramref name="timeout"/> value is reached.</exception>
1286+ /// <exception cref="FlurlHttpException">If the API call returns a bad <see cref="HttpStatusCode"/>.</exception>
1287+ public async Task < TVolume > WaitForVolumeStatusAsync < TVolume , TStatus > ( string volumeId , IEnumerable < TStatus > status , TimeSpan ? refreshDelay = null , TimeSpan ? timeout = null , IProgress < bool > progress = null , CancellationToken cancellationToken = default ( CancellationToken ) )
1288+ where TVolume : IServiceResource
1289+ where TStatus : ResourceStatus
1290+ {
1291+ if ( volumeId == null )
1292+ throw new ArgumentNullException ( "volumeId" ) ;
1293+
1294+ if ( status == null )
1295+ throw new ArgumentNullException ( "status" ) ;
1296+
1297+ Func < Task < TVolume > > getVolume = async ( ) => await GetVolumeAsync < TVolume > ( volumeId , cancellationToken ) ;
1298+ return await Endpoint . WaitForStatusAsync ( volumeId , status , getVolume , refreshDelay , timeout , progress , cancellationToken )
1299+ . PropogateOwner ( this ) ;
1300+ }
1301+
1302+ /// <summary>
1303+ /// Waits for the volume snapshot to reach the specified status.
1304+ /// </summary>
1305+ /// <param name="snapshotId">The snapshot identifier.</param>
1306+ /// <param name="status">The status to wait for.</param>
1307+ /// <param name="refreshDelay">The amount of time to wait between requests.</param>
1308+ /// <param name="timeout">The amount of time to wait before throwing a <see cref="TimeoutException"/>.</param>
1309+ /// <param name="progress">The progress callback.</param>
1310+ /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
1311+ /// <exception cref="TimeoutException">If the <paramref name="timeout"/> value is reached.</exception>
1312+ /// <exception cref="FlurlHttpException">If the API call returns a bad <see cref="HttpStatusCode"/>.</exception>
1313+ public async Task < TSnapshot > WaitForVolumeSnapshotStatusAsync < TSnapshot , TStatus > ( string snapshotId , IEnumerable < TStatus > status , TimeSpan ? refreshDelay = null , TimeSpan ? timeout = null , IProgress < bool > progress = null , CancellationToken cancellationToken = default ( CancellationToken ) )
1314+ where TSnapshot : IServiceResource
1315+ where TStatus : ResourceStatus
1316+ {
1317+ if ( snapshotId == null )
1318+ throw new ArgumentNullException ( "snapshotId" ) ;
1319+
1320+ if ( status == null )
1321+ throw new ArgumentNullException ( "status" ) ;
1322+
1323+ Func < Task < TSnapshot > > getSnapshot = async ( ) => await GetVolumeSnapshotAsync < TSnapshot > ( snapshotId , cancellationToken ) ;
1324+ return await Endpoint . WaitForStatusAsync ( snapshotId , status , getSnapshot , refreshDelay , timeout , progress , cancellationToken )
1325+ . PropogateOwner ( this ) ;
1326+ }
1327+
1328+ /// <summary>
1329+ /// Waits for the volume to be deleted.
1330+ /// <para>Treats a 404 NotFound exception as confirmation that it is deleted.</para>
1331+ /// </summary>
1332+ /// <param name="volumeId">The volume identifier.</param>
1333+ /// <param name="refreshDelay">The amount of time to wait between requests.</param>
1334+ /// <param name="timeout">The amount of time to wait before throwing a <see cref="TimeoutException"/>.</param>
1335+ /// <param name="progress">The progress callback.</param>
1336+ /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
1337+ /// <exception cref="TimeoutException">If the <paramref name="timeout"/> value is reached.</exception>
1338+ /// <exception cref="FlurlHttpException">If the API call returns a bad <see cref="HttpStatusCode"/>.</exception>
1339+ public Task WaitUntilVolumeIsDeletedAsync < TVolume , TStatus > ( string volumeId , TimeSpan ? refreshDelay = null , TimeSpan ? timeout = null , IProgress < bool > progress = null , CancellationToken cancellationToken = default ( CancellationToken ) )
1340+ where TVolume : IServiceResource
1341+ where TStatus : ResourceStatus
1342+ {
1343+ if ( volumeId == null )
1344+ throw new ArgumentNullException ( "volumeId" ) ;
1345+
1346+ Func < Task < dynamic > > getVolume = async ( ) => await GetVolumeAsync < TVolume > ( volumeId , cancellationToken ) ;
1347+ return Endpoint . WaitUntilDeletedAsync < TStatus > ( volumeId , getVolume , refreshDelay , timeout , progress , cancellationToken ) ;
1348+ }
1349+
1350+ /// <summary>
1351+ /// Waits for the volume snapshot to be deleted.
1352+ /// <para>Treats a 404 NotFound exception as confirmation that it is deleted.</para>
1353+ /// </summary>
1354+ /// <param name="snapshotId">The snapshot identifier.</param>
1355+ /// <param name="refreshDelay">The amount of time to wait between requests.</param>
1356+ /// <param name="timeout">The amount of time to wait before throwing a <see cref="TimeoutException"/>.</param>
1357+ /// <param name="progress">The progress callback.</param>
1358+ /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
1359+ /// <exception cref="TimeoutException">If the <paramref name="timeout"/> value is reached.</exception>
1360+ /// <exception cref="FlurlHttpException">If the API call returns a bad <see cref="HttpStatusCode"/>.</exception>
1361+ public Task WaitUntilVolumeSnapshotIsDeletedAsync < TVolume , TStatus > ( string snapshotId , TimeSpan ? refreshDelay = null , TimeSpan ? timeout = null , IProgress < bool > progress = null , CancellationToken cancellationToken = default ( CancellationToken ) )
1362+ where TVolume : IServiceResource
1363+ where TStatus : ResourceStatus
1364+ {
1365+ if ( snapshotId == null )
1366+ throw new ArgumentNullException ( "snapshotId" ) ;
1367+
1368+ Func < Task < dynamic > > getSnapshot = async ( ) => await GetVolumeSnapshotAsync < TVolume > ( snapshotId , cancellationToken ) ;
1369+ return Endpoint . WaitUntilDeletedAsync < TStatus > ( snapshotId , getSnapshot , refreshDelay , timeout , progress , cancellationToken ) ;
1370+ }
11551371 #endregion
11561372
11571373 #region Compute Service
0 commit comments