Skip to content
This repository was archived by the owner on Sep 6, 2025. It is now read-only.

Commit f79c6ec

Browse files
authored
Rename slug fields to match their API fields (#55)
* Rename slug fields to match their API fields * add info to changelog
1 parent 96345e4 commit f79c6ec

10 files changed

Lines changed: 36 additions & 35 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
- RestSharp 106.2.1 -> 106.6.10
2929
- Newtonsoft.Json 10.0.3 -> 12.0.2
3030
- A number of fields and models were changed to make the codebase more consistent with itself and the API.
31+
- `RegionSlug`, `SizeSlug`, `ImageIdOrSlug`, `SshIdsOrFingerprints` were renamed to `Region`, `Size`, `Image`, `SshKeys` to match the API.
3132

3233
### Fixed
3334

DigitalOcean.API.Tests/Clients/DropletActionsClientTest.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace DigitalOcean.API.Tests.Clients {
1111
public class DropletActionsClientTest {
1212
[Fact]
1313
public void CorrectRequestForReboot() {
14-
var factory = Substitute.For<IConnection>();
14+
var factory = Substitute.For<IConnection>();
1515
var client = new DropletActionsClient(factory);
1616

1717
client.Reboot(9001);
@@ -24,7 +24,7 @@ public void CorrectRequestForReboot() {
2424

2525
[Fact]
2626
public void CorrectRequestForPowerCycle() {
27-
var factory = Substitute.For<IConnection>();
27+
var factory = Substitute.For<IConnection>();
2828
var client = new DropletActionsClient(factory);
2929

3030
client.PowerCycle(9001);
@@ -37,7 +37,7 @@ public void CorrectRequestForPowerCycle() {
3737

3838
[Fact]
3939
public void CorrectRequestForShutdown() {
40-
var factory = Substitute.For<IConnection>();
40+
var factory = Substitute.For<IConnection>();
4141
var client = new DropletActionsClient(factory);
4242

4343
client.Shutdown(9001);
@@ -50,7 +50,7 @@ public void CorrectRequestForShutdown() {
5050

5151
[Fact]
5252
public void CorrectRequestForPowerOff() {
53-
var factory = Substitute.For<IConnection>();
53+
var factory = Substitute.For<IConnection>();
5454
var client = new DropletActionsClient(factory);
5555

5656
client.PowerOff(9001);
@@ -63,7 +63,7 @@ public void CorrectRequestForPowerOff() {
6363

6464
[Fact]
6565
public void CorrectRequestForPowerOn() {
66-
var factory = Substitute.For<IConnection>();
66+
var factory = Substitute.For<IConnection>();
6767
var client = new DropletActionsClient(factory);
6868

6969
client.PowerOn(9001);
@@ -76,7 +76,7 @@ public void CorrectRequestForPowerOn() {
7676

7777
[Fact]
7878
public void CorrectRequestForResetPassword() {
79-
var factory = Substitute.For<IConnection>();
79+
var factory = Substitute.For<IConnection>();
8080
var client = new DropletActionsClient(factory);
8181

8282
client.ResetPassword(9001);
@@ -89,46 +89,46 @@ public void CorrectRequestForResetPassword() {
8989

9090
[Fact]
9191
public void CorrectRequestForResize() {
92-
var factory = Substitute.For<IConnection>();
92+
var factory = Substitute.For<IConnection>();
9393
var client = new DropletActionsClient(factory);
9494

9595
client.Resize(9001, "1024mb", true);
9696

9797
var parameters = Arg.Is<List<Parameter>>(list => (int)list[0].Value == 9001);
98-
var body = Arg.Is<DropletAction>(action => action.Type == "resize" && action.SizeSlug == "1024mb" && action.Disk == true);
98+
var body = Arg.Is<DropletAction>(action => action.Type == "resize" && action.Size == "1024mb" && action.Disk == true);
9999
factory.Received().ExecuteRequest<Models.Responses.Action>("droplets/{dropletId}/actions",
100100
parameters, body, "action", Method.POST);
101101
}
102102

103103
[Fact]
104104
public void CorrectRequestForRestore() {
105-
var factory = Substitute.For<IConnection>();
105+
var factory = Substitute.For<IConnection>();
106106
var client = new DropletActionsClient(factory);
107107

108108
client.Restore(9001, 1009);
109109

110110
var parameters = Arg.Is<List<Parameter>>(list => (int)list[0].Value == 9001);
111-
var body = Arg.Is<DropletAction>(action => action.Type == "restore" && (int)action.ImageIdOrSlug == 1009);
111+
var body = Arg.Is<DropletAction>(action => action.Type == "restore" && (int)action.Image == 1009);
112112
factory.Received().ExecuteRequest<Models.Responses.Action>("droplets/{dropletId}/actions",
113113
parameters, body, "action", Method.POST);
114114
}
115115

116116
[Fact]
117117
public void CorrectRequestForRebuild() {
118-
var factory = Substitute.For<IConnection>();
118+
var factory = Substitute.For<IConnection>();
119119
var client = new DropletActionsClient(factory);
120120

121121
client.Rebuild(9001, 1009);
122122

123123
var parameters = Arg.Is<List<Parameter>>(list => (int)list[0].Value == 9001);
124-
var body = Arg.Is<DropletAction>(action => action.Type == "rebuild" && (int)action.ImageIdOrSlug == 1009);
124+
var body = Arg.Is<DropletAction>(action => action.Type == "rebuild" && (int)action.Image == 1009);
125125
factory.Received().ExecuteRequest<Models.Responses.Action>("droplets/{dropletId}/actions",
126126
parameters, body, "action", Method.POST);
127127
}
128128

129129
[Fact]
130130
public void CorrectRequestForRename() {
131-
var factory = Substitute.For<IConnection>();
131+
var factory = Substitute.For<IConnection>();
132132
var client = new DropletActionsClient(factory);
133133

134134
client.Rename(9001, "testing");
@@ -154,7 +154,7 @@ public void CorrectRequestForKernel() {
154154

155155
[Fact]
156156
public void CorrectRequestForIpv6() {
157-
var factory = Substitute.For<IConnection>();
157+
var factory = Substitute.For<IConnection>();
158158
var client = new DropletActionsClient(factory);
159159

160160
client.EnableIpv6(9001);
@@ -180,7 +180,7 @@ public void CorrectRequestForEnableBackups() {
180180

181181
[Fact]
182182
public void CorrectRequestForDisableBackups() {
183-
var factory = Substitute.For<IConnection>();
183+
var factory = Substitute.For<IConnection>();
184184
var client = new DropletActionsClient(factory);
185185

186186
client.DisableBackups(9001);
@@ -193,7 +193,7 @@ public void CorrectRequestForDisableBackups() {
193193

194194
[Fact]
195195
public void CorrectRequestForPrivateNetworking() {
196-
var factory = Substitute.For<IConnection>();
196+
var factory = Substitute.For<IConnection>();
197197
var client = new DropletActionsClient(factory);
198198

199199
client.EnablePrivateNetworking(9001);
@@ -206,7 +206,7 @@ public void CorrectRequestForPrivateNetworking() {
206206

207207
[Fact]
208208
public void CorrectRequestForSnapshot() {
209-
var factory = Substitute.For<IConnection>();
209+
var factory = Substitute.For<IConnection>();
210210
var client = new DropletActionsClient(factory);
211211

212212
client.Snapshot(9001, "testing");
@@ -219,7 +219,7 @@ public void CorrectRequestForSnapshot() {
219219

220220
[Fact]
221221
public void CorrectRequestForGetAction() {
222-
var factory = Substitute.For<IConnection>();
222+
var factory = Substitute.For<IConnection>();
223223
var client = new DropletActionsClient(factory);
224224

225225
client.GetDropletAction(9001, 1009);

DigitalOcean.API.Tests/Clients/ImageActionsClientTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void CorrectRequestForTransfer() {
1616
client.Transfer(9001, "sfo1");
1717

1818
var parameters = Arg.Is<List<Parameter>>(list => (int)list[0].Value == 9001);
19-
var body = Arg.Is<ImageAction>(action => action.Type == "transfer" && action.RegionSlug == "sfo1");
19+
var body = Arg.Is<ImageAction>(action => action.Type == "transfer" && action.Region == "sfo1");
2020
factory.Received().ExecuteRequest<Models.Responses.Action>("images/{imageId}/actions",
2121
parameters, body, "action", Method.POST);
2222
}

DigitalOcean.API/Clients/DropletActionsClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public Task<Action> Resize(int dropletId, string sizeSlug, bool resizeDisk) {
9696
};
9797
var body = new Models.Requests.DropletAction {
9898
Type = "resize",
99-
SizeSlug = sizeSlug,
99+
Size = sizeSlug,
100100
Disk = resizeDisk
101101
};
102102
return _connection.ExecuteRequest<Action>("droplets/{dropletId}/actions", parameters, body,
@@ -114,7 +114,7 @@ public Task<Action> Restore(int dropletId, object imageIdOrSlug) {
114114
};
115115
var body = new Models.Requests.DropletAction {
116116
Type = "restore",
117-
ImageIdOrSlug = imageIdOrSlug
117+
Image = imageIdOrSlug
118118
};
119119
return _connection.ExecuteRequest<Action>("droplets/{dropletId}/actions", parameters, body,
120120
"action", Method.POST);
@@ -129,7 +129,7 @@ public Task<Action> Rebuild(int dropletId, object imageIdOrSlug) {
129129
};
130130
var body = new Models.Requests.DropletAction {
131131
Type = "rebuild",
132-
ImageIdOrSlug = imageIdOrSlug
132+
Image = imageIdOrSlug
133133
};
134134
return _connection.ExecuteRequest<Action>("droplets/{dropletId}/actions", parameters, body,
135135
"action", Method.POST);

DigitalOcean.API/Clients/ImageActionsClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public Task<Action> Transfer(int imageId, string regionSlug) {
2424

2525
var body = new Models.Requests.ImageAction {
2626
Type = "transfer",
27-
RegionSlug = regionSlug
27+
Region = regionSlug
2828
};
2929

3030
return _connection.ExecuteRequest<Action>("images/{imageId}/actions", parameters, body, "action",

DigitalOcean.API/Models/Requests/Droplet.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ public class Droplet {
1515
/// The unique slug identifier for the region that you wish to deploy in.
1616
/// </summary>
1717
[JsonProperty("region")]
18-
public string RegionSlug { get; set; }
18+
public string Region { get; set; }
1919

2020
/// <summary>
2121
/// The unique slug identifier for the size that you wish to select for this Droplet.
2222
/// </summary>
2323
[JsonProperty("size")]
24-
public string SizeSlug { get; set; }
24+
public string Size { get; set; }
2525

2626
/// <summary>
2727
/// The image ID of a public or private image, or the unique slug identifier for a public image. This image will be the
2828
/// base image for your Droplet. Integer (if using an image ID), or String (if using a public image slug).
2929
/// </summary>
3030
[JsonProperty("image")]
31-
public object ImageIdOrSlug { get; set; }
31+
public object Image { get; set; }
3232

3333
/// <summary>
3434
/// An array containing the IDs or fingerprints of the SSH keys that you wish to embed in the Droplet's root account upon
3535
/// creation.
3636
/// </summary>
3737
[JsonProperty("ssh_keys")]
38-
public List<object> SshIdsOrFingerprints { get; set; }
38+
public List<object> SshKeys { get; set; }
3939

4040
/// <summary>
4141
/// A boolean indicating whether automated backups should be enabled for the Droplet. Automated backups can only be enabled

DigitalOcean.API/Models/Requests/DropletAction.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class DropletAction {
1616
/// Resize Droplet action
1717
/// </remarks>
1818
[JsonProperty("size")]
19-
public string SizeSlug { get; set; }
19+
public string Size { get; set; }
2020

2121
/// <summary>
2222
/// Image ID or Slug
@@ -27,7 +27,7 @@ public class DropletAction {
2727
/// Rebuild Droplet action
2828
/// </remarks>
2929
[JsonProperty("image")]
30-
public object ImageIdOrSlug { get; set; }
30+
public object Image { get; set; }
3131

3232
/// <summary>
3333
/// New name

DigitalOcean.API/Models/Requests/Droplets.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ public class Droplets {
1515
/// The unique slug identifier for the region that you wish to deploy in.
1616
/// </summary>
1717
[JsonProperty("region")]
18-
public string RegionSlug { get; set; }
18+
public string Region { get; set; }
1919

2020
/// <summary>
2121
/// The unique slug identifier for the size that you wish to select for this Droplet.
2222
/// </summary>
2323
[JsonProperty("size")]
24-
public string SizeSlug { get; set; }
24+
public string Size { get; set; }
2525

2626
/// <summary>
2727
/// The image ID of a public or private image, or the unique slug identifier for a public image. This image will be the
2828
/// base image for your Droplet. Integer (if using an image ID), or String (if using a public image slug).
2929
/// </summary>
3030
[JsonProperty("image")]
31-
public object ImageIdOrSlug { get; set; }
31+
public object Image { get; set; }
3232

3333
/// <summary>
3434
/// An array containing the IDs or fingerprints of the SSH keys that you wish to embed in the Droplet's root account upon
3535
/// creation.
3636
/// </summary>
3737
[JsonProperty("ssh_keys")]
38-
public List<object> SshIdsOrFingerprints { get; set; }
38+
public List<object> SshKeys { get; set; }
3939

4040
/// <summary>
4141
/// A boolean indicating whether automated backups should be enabled for the Droplet. Automated backups can only be enabled

DigitalOcean.API/Models/Requests/Image.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class Image {
2121
/// The slug identifier for the region where the image will initially be available.
2222
/// </summary>
2323
[JsonProperty("region")]
24-
public string RegionSlug { get; set; }
24+
public string Region { get; set; }
2525

2626
/// <summary>
2727
/// The name of a custom image's distribution.

DigitalOcean.API/Models/Requests/ImageAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public class ImageAction {
1616
/// Transfer Image action
1717
/// </remarks>
1818
[JsonProperty("region")]
19-
public string RegionSlug { get; set; }
19+
public string Region { get; set; }
2020
}
2121
}

0 commit comments

Comments
 (0)