Skip to content

Commit f622ab9

Browse files
committed
Return summaries from list keypairs
1 parent ddff6b1 commit f622ab9

12 files changed

Lines changed: 74 additions & 74 deletions

File tree

src/corelib/Compute/v2_1/ComputeService.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,9 @@ public ComputeService(IAuthenticationProvider authenticationProvider, string reg
323323
#region Keypairs
324324

325325
/// <inheritdoc cref="ComputeApiBuilder.GetKeyPairAsync{T}" />
326-
public virtual Task<KeyPairDetails> GetKeyPairAsync(string keypairName, CancellationToken cancellationToken = default(CancellationToken))
326+
public virtual Task<KeyPair> GetKeyPairAsync(string keypairName, CancellationToken cancellationToken = default(CancellationToken))
327327
{
328-
return _computeApi.GetKeyPairAsync<KeyPairDetails>(keypairName, cancellationToken);
328+
return _computeApi.GetKeyPairAsync<KeyPair>(keypairName, cancellationToken);
329329
}
330330

331331
/// <inheritdoc cref="ComputeApiBuilder.CreateKeyPairAsync{T}" />
@@ -335,15 +335,15 @@ public ComputeService(IAuthenticationProvider authenticationProvider, string reg
335335
}
336336

337337
/// <summary />
338-
public virtual Task<KeyPair> ImportKeyPairAsync(KeyPairDefinition keypair, CancellationToken cancellationToken = default(CancellationToken))
338+
public virtual Task<KeyPairSummary> ImportKeyPairAsync(KeyPairDefinition keypair, CancellationToken cancellationToken = default(CancellationToken))
339339
{
340-
return _computeApi.CreateKeyPairAsync<KeyPair>(keypair, cancellationToken);
340+
return _computeApi.CreateKeyPairAsync<KeyPairSummary>(keypair, cancellationToken);
341341
}
342342

343343
/// <inheritdoc cref="ComputeApiBuilder.ListKeyPairsAsync{T}" />
344-
public virtual async Task<IEnumerable<KeyPair>> ListKeyPairsAsync(CancellationToken cancellationToken = default(CancellationToken))
344+
public virtual async Task<IEnumerable<KeyPairSummary>> ListKeyPairsAsync(CancellationToken cancellationToken = default(CancellationToken))
345345
{
346-
return await _computeApi.ListKeyPairsAsync<KeyPairCollection>(cancellationToken);
346+
return await _computeApi.ListKeyPairsAsync<KeyPairSummaryCollection>(cancellationToken);
347347
}
348348

349349
/// <summary />

src/corelib/Compute/v2_1/ComputeServiceExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public static void DetachVolume(this ComputeService service, Identifier serverId
301301

302302
#region KeyPairs
303303
/// <inheritdoc cref="ComputeService.GetKeyPairAsync" />
304-
public static KeyPairDetails GetKeyPair(this ComputeService service, string keypairName)
304+
public static KeyPair GetKeyPair(this ComputeService service, string keypairName)
305305
{
306306
return service.GetKeyPairAsync(keypairName).ForceSynchronous();
307307
}
@@ -313,13 +313,13 @@ public static KeyPairResponse CreateKeyPair(this ComputeService service, KeyPair
313313
}
314314

315315
/// <inheritdoc cref="ComputeService.ImportKeyPairAsync" />
316-
public static KeyPair ImportKeyPair(this ComputeService service, KeyPairDefinition keyPair)
316+
public static KeyPairSummary ImportKeyPair(this ComputeService service, KeyPairDefinition keyPair)
317317
{
318318
return service.ImportKeyPairAsync(keyPair).ForceSynchronous();
319319
}
320320

321321
/// <inheritdoc cref="ComputeService.ListKeyPairsAsync" />
322-
public static IEnumerable<KeyPair> ListKeyPairs(this ComputeService service)
322+
public static IEnumerable<KeyPairSummary> ListKeyPairs(this ComputeService service)
323323
{
324324
return service.ListKeyPairsAsync().ForceSynchronous();
325325
}
Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,17 @@
1-
using System.Collections.Generic;
2-
using System.Threading;
3-
using System.Threading.Tasks;
1+
using System;
42
using Newtonsoft.Json;
5-
using Newtonsoft.Json.Linq;
6-
using OpenStack.Compute.v2_1.Serialization;
7-
using OpenStack.Serialization;
83

94
namespace OpenStack.Compute.v2_1
105
{
116
/// <summary />
12-
[JsonConverter(typeof(KeyPairConverter))]
13-
public class KeyPair : IHaveExtraData, IServiceResource
7+
public class KeyPair : KeyPairSummary
148
{
159
/// <summary />
16-
[JsonProperty("name")]
17-
public string Name { get; set; }
10+
[JsonProperty("id")]
11+
public Identifier Id { get; set; }
1812

1913
/// <summary />
20-
[JsonProperty("public_key")]
21-
public string PublicKey { get; set; }
22-
23-
/// <summary />
24-
[JsonProperty("fingerprint")]
25-
public string Fingerprint { get; set; }
26-
27-
/// <summary />
28-
[JsonExtensionData]
29-
IDictionary<string, JToken> IHaveExtraData.Data { get; set; } = new Dictionary<string, JToken>();
30-
31-
object IServiceResource.Owner { get; set; }
32-
33-
/// <inheritdoc cref="ComputeApiBuilder.DeleteKeyPairAsync" />
34-
public Task DeleteAsync(CancellationToken cancellationToken = default(CancellationToken))
35-
{
36-
var compute = this.GetOwnerOrThrow<ComputeApiBuilder>();
37-
return compute.DeleteKeyPairAsync(Name, cancellationToken);
38-
}
14+
[JsonProperty("created_at")]
15+
public DateTimeOffset Created { get; set; }
3916
}
4017
}

src/corelib/Compute/v2_1/KeyPairDetails.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/corelib/Compute/v2_1/KeyPairExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ namespace OpenStack.Synchronous
77
/// <summary />
88
public static class KeypairExtensions_v2_1
99
{
10-
/// <inheritdoc cref="KeyPair.DeleteAsync" />
11-
public static void Delete(this KeyPair keypair)
10+
/// <inheritdoc cref="KeyPairSummary.DeleteAsync" />
11+
public static void Delete(this KeyPairSummary keypair)
1212
{
1313
keypair.DeleteAsync().ForceSynchronous();
1414
}

src/corelib/Compute/v2_1/KeyPairResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace OpenStack.Compute.v2_1
44
{
55
/// <summary />
6-
public class KeyPairResponse : KeyPair
6+
public class KeyPairResponse : KeyPairSummary
77
{
88
/// <summary />
99
[JsonProperty("private_key")]
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.Collections.Generic;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Linq;
6+
using OpenStack.Compute.v2_1.Serialization;
7+
using OpenStack.Serialization;
8+
9+
namespace OpenStack.Compute.v2_1
10+
{
11+
/// <summary />
12+
[JsonConverter(typeof(KeyPairConverter))]
13+
public class KeyPairSummary : IHaveExtraData, IServiceResource
14+
{
15+
/// <summary />
16+
[JsonProperty("name")]
17+
public string Name { get; set; }
18+
19+
/// <summary />
20+
[JsonProperty("public_key")]
21+
public string PublicKey { get; set; }
22+
23+
/// <summary />
24+
[JsonProperty("fingerprint")]
25+
public string Fingerprint { get; set; }
26+
27+
/// <summary />
28+
[JsonExtensionData]
29+
IDictionary<string, JToken> IHaveExtraData.Data { get; set; } = new Dictionary<string, JToken>();
30+
31+
object IServiceResource.Owner { get; set; }
32+
33+
/// <inheritdoc cref="ComputeApiBuilder.DeleteKeyPairAsync" />
34+
public Task DeleteAsync(CancellationToken cancellationToken = default(CancellationToken))
35+
{
36+
var compute = this.GetOwnerOrThrow<ComputeApiBuilder>();
37+
return compute.DeleteKeyPairAsync(Name, cancellationToken);
38+
}
39+
}
40+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public class KeyPairCollection<T> : ResourceCollection<T>
2020

2121
/// <inheritdoc cref="KeyPairCollection{T}" />
2222
/// <exclude />
23-
public class KeyPairCollection : KeyPairCollection<KeyPair>
23+
public class KeyPairSummaryCollection : KeyPairCollection<KeyPairSummary>
2424
{ }
2525
}

src/corelib/Compute/v2_2/KeyPair.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace OpenStack.Compute.v2_2
44
{
55
/// <summary />
6-
public class KeyPair : v2_1.KeyPair
6+
public class KeyPair : v2_1.KeyPairSummary
77
{
88
/// <summary />
99
[JsonProperty("type")]

src/corelib/OpenStack.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
<Compile Include="Compute\v2_1\ImageStatus.cs" />
106106
<Compile Include="Compute\v2_1\ImageType.cs" />
107107
<Compile Include="Compute\v2_1\IPProtocol.cs" />
108-
<Compile Include="Compute\v2_1\KeyPairDetails.cs" />
108+
<Compile Include="Compute\v2_1\KeyPair.cs" />
109109
<Compile Include="Compute\v2_1\KeyPairRequest.cs" />
110110
<Compile Include="Compute\v2_1\KeyPairResponse.cs" />
111111
<Compile Include="Compute\v2_1\NetworkAttachDefinition.cs" />
@@ -152,7 +152,7 @@
152152
<Compile Include="Compute\v2_1\DiskConfiguration.cs" />
153153
<Compile Include="Compute\v2_1\FlavorReference.cs" />
154154
<Compile Include="Compute\v2_1\ImageReference.cs" />
155-
<Compile Include="Compute\v2_1\KeyPair.cs" />
155+
<Compile Include="Compute\v2_1\KeyPairSummary.cs" />
156156
<Compile Include="Compute\v2_1\KeyPairDefinition.cs" />
157157
<Compile Include="Compute\v2_1\ServerListOptions.cs" />
158158
<Compile Include="Compute\v2_1\SecurityGroupReference.cs" />

0 commit comments

Comments
 (0)