Skip to content

Commit 2fcb4be

Browse files
committed
Fix reference from child back to the parent
1 parent 26ccd15 commit 2fcb4be

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/corelib/Compute/v2_1/ImageMetadata.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,27 @@ protected internal void SetParent(ImageReference parent)
3232

3333
void IChildResource.SetParent(string parentId)
3434
{
35-
SetParent(new Image {Id = parentId});
35+
SetParent(new ImageReference { Id = parentId});
3636
}
3737

3838
void IChildResource.SetParent(object parent)
3939
{
40-
SetParent((Image)parent);
40+
SetParent((ImageReference)parent);
4141
}
4242

4343
/// <summary />
44-
protected void AssertImageIsSet([CallerMemberName]string callerName = "")
44+
protected void AssertParentIsSet([CallerMemberName]string callerName = "")
4545
{
4646
if (Image != null)
4747
return;
4848

49-
throw new InvalidOperationException(string.Format($"{callerName} can only be used on instances which were constructed by the ComputeServer. Use ComputeService.{callerName} instead."));
49+
throw new InvalidOperationException(string.Format($"{callerName} can only be used on instances which were constructed by the ComputeService. Use ComputeService.{callerName} instead."));
5050
}
5151

5252
/// <summary />
5353
public async Task CreateAsync(string key, string value, CancellationToken cancellationToken = default(CancellationToken))
5454
{
55-
AssertImageIsSet();
55+
AssertParentIsSet();
5656
var compute = this.GetOwnerOrThrow<ComputeApi>();
5757
await compute.CreateImagMetadataAsync(Image.Id, key, value, cancellationToken);
5858
this[key] = value;
@@ -61,7 +61,7 @@ protected void AssertImageIsSet([CallerMemberName]string callerName = "")
6161
/// <summary />
6262
public async Task UpdateAsync(bool overwrite = false, CancellationToken cancellationToken = default(CancellationToken))
6363
{
64-
AssertImageIsSet();
64+
AssertParentIsSet();
6565
var compute = this.GetOwnerOrThrow<ComputeApi>();
6666
var results = await compute.UpdateImageMetadataAsync<ImageMetadata>(Image.Id, this, overwrite, cancellationToken);
6767
Clear();
@@ -77,7 +77,7 @@ protected void AssertImageIsSet([CallerMemberName]string callerName = "")
7777
if (!ContainsKey(key))
7878
return;
7979

80-
AssertImageIsSet();
80+
AssertParentIsSet();
8181
var compute = this.GetOwnerOrThrow<ComputeApi>();
8282
await compute.DeleteImageMetadataAsync(Image.Id, key, cancellationToken);
8383
Remove(key);

src/corelib/Compute/v2_1/ServerVolumeReference.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected internal void SetParent(ServerReference parent)
3131

3232
void IChildResource.SetParent(object parent)
3333
{
34-
SetParent((Server)parent);
34+
SetParent((ServerReference)parent);
3535
}
3636

3737
void IChildResource.SetParent(string parentId)
@@ -44,19 +44,19 @@ void IChildResource.SetParent(string parentId)
4444
IDictionary<string, JToken> IHaveExtraData.Data { get; set; } = new Dictionary<string, JToken>();
4545

4646
/// <summary />
47-
protected void AssertServerIsSet([CallerMemberName]string callerName = "")
47+
protected void AssertParentIsSet([CallerMemberName]string callerName = "")
4848
{
4949
if (ServerRef != null)
5050
return;
5151

52-
throw new InvalidOperationException(string.Format($"{callerName} can only be used on instances which were constructed by the ComputeServer. Use ComputeService.{callerName} instead."));
52+
throw new InvalidOperationException(string.Format($"{callerName} can only be used on instances which were constructed by the ComputeService. Use ComputeService.{callerName} instead."));
5353
}
5454

5555
/// <summary />
5656
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
5757
public async Task<ServerVolume> GetServerVolumeAsync(CancellationToken cancellationToken = default(CancellationToken))
5858
{
59-
AssertServerIsSet();
59+
AssertParentIsSet();
6060

6161
var compute = this.GetOwnerOrThrow<ComputeApi>();
6262
var result = await compute.GetServerVolumeAsync<ServerVolume>(ServerRef.Id, Id, cancellationToken);
@@ -68,7 +68,7 @@ protected void AssertServerIsSet([CallerMemberName]string callerName = "")
6868
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
6969
public async Task DetachAsync(CancellationToken cancellationToken = default(CancellationToken))
7070
{
71-
AssertServerIsSet();
71+
AssertParentIsSet();
7272

7373
var compute = this.GetOwnerOrThrow<ComputeApi>();
7474
await compute.DetachVolumeAsync(ServerRef.Id, Id, cancellationToken);

0 commit comments

Comments
 (0)