Skip to content

Commit d877b00

Browse files
committed
Return summaries from list images
* ListImages returns Image * ListImageSummaries returns ImageSummary * Server has an ImageReference
1 parent 201e932 commit d877b00

11 files changed

Lines changed: 54 additions & 43 deletions

File tree

src/corelib/Compute/v2_1/ComputeApiBuilder.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -576,16 +576,16 @@ protected ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider au
576576
}
577577

578578
/// <summary />
579-
public virtual async Task<TPage> ListImagesAsync<TPage>(IQueryStringBuilder queryString, CancellationToken cancellationToken = default(CancellationToken))
579+
public virtual async Task<TPage> ListImageSummariesAsync<TPage>(IQueryStringBuilder queryString, CancellationToken cancellationToken = default(CancellationToken))
580580
where TPage : IPageBuilder<TPage>, IEnumerable<IServiceResource>
581581
{
582-
Url initialRequestUrl = await BuildListImagesUrlAsync(queryString, cancellationToken);
582+
Url initialRequestUrl = await BuildListImageSummariesRequest(queryString, cancellationToken);
583583
return await Endpoint.GetResourcePageAsync<TPage>(initialRequestUrl, cancellationToken)
584584
.PropogateOwnerToChildren(this);
585585
}
586586

587587
/// <summary />
588-
public virtual async Task<Url> BuildListImagesUrlAsync(IQueryStringBuilder queryString, CancellationToken cancellationToken = default(CancellationToken))
588+
public virtual async Task<Url> BuildListImageSummariesRequest(IQueryStringBuilder queryString, CancellationToken cancellationToken = default(CancellationToken))
589589
{
590590
Url endpoint = await Endpoint.GetEndpoint(cancellationToken).ConfigureAwait(false);
591591

@@ -595,16 +595,16 @@ protected ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider au
595595
}
596596

597597
/// <summary />
598-
public virtual async Task<TPage> ListImageDetailsAsync<TPage>(IQueryStringBuilder queryString, CancellationToken cancellationToken = default(CancellationToken))
598+
public virtual async Task<TPage> ListImagesAsync<TPage>(IQueryStringBuilder queryString, CancellationToken cancellationToken = default(CancellationToken))
599599
where TPage : IPageBuilder<TPage>, IEnumerable<IServiceResource>
600600
{
601-
Url initialRequestUrl = await BuildListImageDetailsUrlAsync(queryString, cancellationToken);
601+
Url initialRequestUrl = await BuildListImagesRequest(queryString, cancellationToken);
602602
return await Endpoint.GetResourcePageAsync<TPage>(initialRequestUrl, cancellationToken)
603603
.PropogateOwnerToChildren(this);
604604
}
605605

606606
/// <summary />
607-
public virtual async Task<Url> BuildListImageDetailsUrlAsync(IQueryStringBuilder queryString, CancellationToken cancellationToken = default(CancellationToken))
607+
public virtual async Task<Url> BuildListImagesRequest(IQueryStringBuilder queryString, CancellationToken cancellationToken = default(CancellationToken))
608608
{
609609
Url endpoint = await Endpoint.GetEndpoint(cancellationToken).ConfigureAwait(false);
610610

src/corelib/Compute/v2_1/ComputeService.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,16 @@ public ComputeService(IAuthenticationProvider authenticationProvider, string reg
241241
return _computeApi.CreateImagMetadataAsync(imageId, key, value, cancellationToken);
242242
}
243243

244-
/// <inheritdoc cref="ComputeApiBuilder.ListImagesAsync{TPage}(IQueryStringBuilder,CancellationToken)" />
245-
public async Task<IPage<ImageReference>> ListImagesAsync(ImageListOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
244+
/// <inheritdoc cref="ComputeApiBuilder.ListImageSummariesAsync{TPage}" />
245+
public async Task<IPage<ImageSummary>> ListImageSummariesAsync(ImageListOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
246246
{
247-
return await _computeApi.ListImagesAsync<ImageReferenceCollection>(options, cancellationToken);
247+
return await _computeApi.ListImageSummariesAsync<ImageSummaryCollection>(options, cancellationToken);
248248
}
249249

250-
/// <inheritdoc cref="ComputeApiBuilder.ListImageDetailsAsync{TPage}(IQueryStringBuilder,CancellationToken)" />
251-
public async Task<IPage<Image>> ListImageDetailsAsync(ImageListOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
250+
/// <inheritdoc cref="ComputeApiBuilder.ListImagesAsync{TPage}" />
251+
public async Task<IPage<Image>> ListImagesAsync(ImageListOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
252252
{
253-
return await _computeApi.ListImageDetailsAsync<ImageCollection>(options, cancellationToken);
253+
return await _computeApi.ListImagesAsync<ImageCollection>(options, cancellationToken);
254254
}
255255

256256
/// <inheritdoc cref="ComputeApiBuilder.UpdateImageMetadataAsync{T}" />

src/corelib/Compute/v2_1/ComputeServiceExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,16 @@ public static void CreateImagMetadata(this ComputeService service, Identifier im
220220
service.CreateImagMetadataAsync(imageId, key, value).ForceSynchronous();
221221
}
222222

223-
/// <inheritdoc cref="ComputeService.ListImagesAsync" />
224-
public static IPage<ImageReference> ListImages(this ComputeService service, ImageListOptions options = null)
223+
/// <inheritdoc cref="ComputeService.ListImageSummariesAsync" />
224+
public static IPage<ImageSummary> ListImageSummaries(this ComputeService service, ImageListOptions options = null)
225225
{
226-
return service.ListImagesAsync(options).ForceSynchronous();
226+
return service.ListImageSummariesAsync(options).ForceSynchronous();
227227
}
228228

229-
/// <inheritdoc cref="ComputeService.ListImageDetailsAsync" />
230-
public static IPage<Image> ListImageDetails(this ComputeService service, ImageListOptions options = null)
229+
/// <inheritdoc cref="ComputeService.ListImagesAsync" />
230+
public static IPage<Image> ListImages(this ComputeService service, ImageListOptions options = null)
231231
{
232-
return service.ListImageDetailsAsync(options).ForceSynchronous();
232+
return service.ListImagesAsync(options).ForceSynchronous();
233233
}
234234

235235
/// <inheritdoc cref="ComputeService.UpdateImageMetadataAsync" />

src/corelib/Compute/v2_1/Image.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace OpenStack.Compute.v2_1
1010
{
1111
/// <summary />
1212
[JsonConverterWithConstructor(typeof(RootWrapperConverter), "image")]
13-
public class Image : ImageReference
13+
public class Image : ImageSummary
1414
{
1515
/// <summary>
1616
/// Initializes a new instance of the <see cref="Image"/> class.

src/corelib/Compute/v2_1/ImageReference.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ namespace OpenStack.Compute.v2_1
1212
public class ImageReference : IHaveExtraData, IServiceResource
1313
{
1414
/// <summary />
15+
[JsonProperty("id")]
1516
public virtual Identifier Id { get; set; }
1617

17-
/// <summary />
18-
public string Name { get; set; }
19-
2018
/// <summary />
2119
[JsonExtensionData]
2220
IDictionary<string, JToken> IHaveExtraData.Data { get; set; } = new Dictionary<string, JToken>();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Newtonsoft.Json;
2+
3+
namespace OpenStack.Compute.v2_1
4+
{
5+
/// <summary />
6+
public class ImageSummary : ImageReference
7+
{
8+
/// <summary />
9+
[JsonProperty("name")]
10+
public string Name { get; set; }
11+
12+
}
13+
}

src/corelib/Compute/v2_1/Serialization/ImageCollection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public class ImageCollection<TPage, TItem> : Page<TPage, TItem, PageLink>
2626
}
2727

2828
/// <summary>
29-
/// Represents a collection of references to image resources of the <see cref="ComputeService"/>.
29+
/// Represents a collection of image summary resources of the <see cref="ComputeService"/>.
3030
/// </summary>
3131
/// <exclude />
32-
public class ImageReferenceCollection : ImageCollection<ImageReferenceCollection, ImageReference>
32+
public class ImageSummaryCollection : ImageCollection<ImageSummaryCollection, ImageSummary>
3333
{ }
3434

3535
/// <inheritdoc cref="FlavorCollection{T}" />

src/corelib/OpenStack.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
<Compile Include="Compute\v2_1\ImageListOptions.cs" />
105105
<Compile Include="Compute\v2_1\ImageMetadata.cs" />
106106
<Compile Include="Compute\v2_1\ImageStatus.cs" />
107+
<Compile Include="Compute\v2_1\ImageSummary.cs" />
107108
<Compile Include="Compute\v2_1\ImageType.cs" />
108109
<Compile Include="Compute\v2_1\IPProtocol.cs" />
109110
<Compile Include="Compute\v2_1\KeyPair.cs" />

src/testing/integration/Compute/v2_1/ComputeTestDataManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private async Task<Identifier> GetDefaultImage()
119119
{
120120
if (_defaultImage == null)
121121
{
122-
var images = await _compute.ListImagesAsync(new ImageListOptions {Name = "cirros"});
122+
var images = await _compute.ListImageSummariesAsync(new ImageListOptions {Name = "cirros"});
123123
_defaultImage = images.First().Id;
124124
}
125125
return _defaultImage;

src/testing/integration/Compute/v2_1/ImageTests.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Diagnostics;
33
using System.Linq;
44
using System.Threading.Tasks;
5-
using Flurl.Http;
65
using Xunit;
76
using Xunit.Abstractions;
87

@@ -34,9 +33,9 @@ public void Dispose()
3433
}
3534

3635
[Fact]
37-
public async Task ListImagesTest()
36+
public async Task ListImageSummariesTest()
3837
{
39-
var results = await _compute.ListImagesAsync(new ImageListOptions {PageSize = 1});
38+
var results = await _compute.ListImageSummariesAsync(new ImageListOptions {PageSize = 1});
4039

4140
while (results.Any())
4241
{
@@ -60,16 +59,16 @@ public async Task FindSnapshotsTest()
6059
_testData.Register(snapshot);
6160

6261
Trace.WriteLine("Getting snapshot details...");
63-
var results = await _compute.ListImageDetailsAsync(new ImageListOptions {Type = ImageType.Snapshot});
62+
var results = await _compute.ListImagesAsync(new ImageListOptions {Type = ImageType.Snapshot});
6463
Assert.NotNull(results);
6564
Assert.All(results, x => Assert.Equal(ImageType.Snapshot, x.Type));
6665
Assert.Contains(results, image => image.Id == snapshot.Id);
6766
}
6867

6968
[Fact]
70-
public async Task ListImageDetailsTest()
69+
public async Task ListImagesTest()
7170
{
72-
var results = await _compute.ListImageDetailsAsync(new ImageListOptions { PageSize = 1 });
71+
var results = await _compute.ListImagesAsync(new ImageListOptions { PageSize = 1 });
7372

7473
while (results.Any())
7574
{

0 commit comments

Comments
 (0)