Something will eventually be here! ๐
trmcnvn / digitalocean.api Goto Github PK
View Code? Open in Web Editor NEW:whale2: .NET implementation of the DigitalOcean API
License: MIT License
:whale2: .NET implementation of the DigitalOcean API
License: MIT License
Great project; nicely done.
Recommend better exception handling, by making it all Task based its very hard to figure out what the exceptions mean. Perhaps you can have a way of passing out the exceptions or having some kind of event we can bind to?
Functions client.Droplets.GetAll() and client.Droplets.Get() dont work. :(
var client = new DigitalOceanClient("[API_KEY]");
var task = client.Droplets.GetAll();
task.Wait();
Unable to cast object of type "RestSharp.JsonArray" to type "System.Collections.Generic.IDictionary`2[System.String,System.Object]".
Self explanatory. For more info, you can read DO's blog post
Per the DO developer docs, tag rename (PUT /v2/tags/:name
) will be deprecated on April 26. Please plan accordingly.
New API sections yet to be integrated:
There is also a new Container Registry API, but it is listed as Private Beta.
Update Actions workflow to create and publish a release when a GitHub release is created, rather than a push to the "release" branch.
Error CS8002 Referenced assembly 'DigitalOcean.API, Version=5.2.0.0, Culture=neutral, PublicKeyToken=null' does not have a strong name.
Otherwise it is impossible to to reference it in strong named projects.
Thanks!
Hello, after 3 month of working yesterday client.Droplet.GetAll() stop working with ex.message="Not Found", but curl or doctl.exe returning fine. Please help
Thanks for this library! :)
I use this library in my project, but I have difficulties because the same names for the request and response classes, albeit in different namespaces. Often it is necessary to use the request and response class in the same class.
It turns out 2 options:
All these 2 options impair code reading. Could it be better to use endings in classes?
Task<DigitalOcean.API.Models.Responses.Action>>
and etc
For example:
ActionRq - request
ActionRs - response
OR
ActionRequest
ActionResponse
Package restore manager is the old style of Nuget and not recommended anymore. Best way is to just let VS automatically load them in and not require user interaction. The package restore also messes with project structure.
Here's a guide for converting: http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html
Since you just made the version 3 bump change, I am guessing from the minor API breakage in renaming the TTL
to Ttl
properties, I'd like to start consideration for possible type changes from 2.x. Mostly would like to know if you would be amenable to a detailed audit of all the current Request/Response models in the form of a PR. Possibly also considering any name inconsistencies like the TTL/Ttl thing.
Some of the things I am thinking of:
All ValueTypes properties in Request models should be marked as Nullable if they are not required in the request. I have seem semi-inconsistent notation in some of the Request models, some marking their ints/floats/bools as Nullable and others not. Ones I've already noticed would be the booleans in Models.Requests.Droplet
: backups, ipv6, private_networking, monitoring. Obviously this would cause no "real change", as the defaults for all these when unsent is false and the default value for any boolean is false anyways in C#. But would seem like an appropriate time for a consistency fix.
Changing the types from float to Decimal for PriceMonthly
and PriceHourly
in Models.Responses.Sizes
. As these values are specifically for currencies, Decimal would seem more appropriate in my mind.
I haven't really looked through too many of the classes that closely, but other things might come up.
I would like to know the size in gigabytes of the image/ snapshot
API shows
size_gigabytes | integer | The size of the image in gigabytes.
LoadBalancerClient
is checking the wrong root element (load_balancers
instead of load_balancer
) when deserializing the result of POST for creating a new load balancer.
This results in the LoadBalancer
response object never being populated
This is an issue for all routes that return a single LoadBalancer
Hi, I have tried
[1] Download this project source and open with VS2015, and
[2] Opened a new project and go to NuGet to install "DigitalOcean.API" in my project. (Although I changed my project's Target framework into .NET 2.0 or .NET 4.5.2, still got errors)
But seems all methods are not work for me. I don't know why, I have no ideas. Please advise with thanks!
Please add support for user_data on droplet creation
Could some of database & database cluster namespaces be changed for clarity?
For example, currently
client.Databases.GetAll()
returns a list of database clusters.
client.Databases.GetAllDatabases(string id)
returns a list of actual databases.
Could change to something like:
client.DatabaseClusters.GetAll() client.DatabaseClusters.GetById(string id) client.DatabaseClusters.Add()
for database clusters and let the actual database methods continue to occupy the "Databases" namespace.
The motivation is to have DigitalOcean Api clients for Windows Phone and Windows 8.1.
There are json serializers and Rest clients for portable .Net so it possible to make DigitalOcean.API a portable .Net project. I think of SharpSerializer
(maybe Json supports has been added already, if not there are others) and Microsoft.Net.HTTP
library (https://www.nuget.org/packages/Microsoft.Net.Http
).
When fetching load balancers via Get
or GetAll
, the IpAddress
property of the result does not get populated (despite being in the raw JSON response as ip
). All other properties are populated fine.
Floating IPs is being deprecated in fall 2023. Reserved IPs is then needed to be implemented in this beautiful library. Thanks.
Could you publish the latest code to NuGet?
I see the API supports creating snapshots from a droplet. However, I wish to create a droplet from an old snapshot. Do you know if this is supported?
Thanks
According to DigitalOcean API creating firewall section (https://developers.digitalocean.com/documentation/v2/#create-a-new-firewall) sources
attribute of InboundRule
should be a single object. Providing an array results in an error response as given in title. To be sure I tested following bodies using Postman:
{ "name": "test", "inbound_rules": [ { "protocol": "tcp", "ports": "22", "sources": [ { "addresses": [ "18.0.0.0/8" ] } ] } ] }
Response: { "id": "unprocessable_entity", "message": "You specified an invalid type for one of the sources.", "request_id": "" }
Single object request:
{ "name": "test", "inbound_rules": [ { "protocol": "tcp", "ports": "22", "sources": { "addresses": [ "18.0.0.0/8" ] } } ] }
Response: successfully created firewall
Hi,
At the outset, thank you for such a great client. Clients make interacting with APIs so seamless and quick.
A few days ago, I was using this client in order to do a point in time restore of a managed DB on our account. Here is the API documentation for that particular call.
My request looked like this:
var restoreDBRequest = new DatabaseBackup
{
Name = "db-restored-from-API",
Engine = "pg",
Version = "10",
Size = "db-s-1vcpu-2gb",
Region = "blr1",
NumNodes = 2,
Tags = new List<string>(),
BackupRestore = new DatabaseBackupRestore
{
DatabaseName = "existing-db",
CreatedAt = new DateTime(2021, 02, 20, 16, 45, 0)
}
};
Which constantly threw the error with a status code 422:
{"message":"invalid json body","id":"unprocessable_entity","request_id":"XXXXX"}
Using this information, I contacted digital ocean's support for a resolution and after much back and forth it has been solved. As per them
I made these 2 changes and executed the request:
var restoreDBRequest = new DatabaseBackup
{
- Name = "db-restored-from-API",
+ Name = "db-restored-from-api",
Engine = "pg",
Version = "10",
Size = "db-s-1vcpu-2gb",
Region = "blr1",
NumNodes = 2,
Tags = new List<string>(),
BackupRestore = new DatabaseBackupRestore
{
DatabaseName = "existing-db",
- CreatedAt = new DateTime(2021, 02, 20, 16, 45, 0)
+ CreatedAt = new DateTime(2021, 02, 20, 16, 45, 0, DateTimeKind.Local)
}
};
And I was successfully able to restore my DB to the point in time that I wanted.
.ToLower()
on the DatabaseBackup.Name
field?Kind
property of DatabaseBackupRestore.CreatedAt
is Unspecified
?Unable to create domain records and am getting the Not Found exception. Is this a bug or am I doing something wrong?
Thanks!
// subdomainName and ip are passed into this method
var record = new DomainRecord()
{
Type = "A",
Name = subdomainName,
Data = ip,
};
await _client.DomainRecords.Create($"{subdomainName}", record);
Unhandled Exception: DigitalOcean.API.Exceptions.ApiException: Not Found
at DigitalOcean.API.Extensions.RestSharpExtensions.ThrowIfException(IRestResponse response)
at DigitalOcean.API.Extensions.RestSharpExtensions.ExecuteTask[T](IRestClient client, IRestRequest request)
at DigitalOcean.API.Http.Connection.ExecuteRequest[T](String endpoint, IList`1 parameters, Object data, String expectedRoot, Method method)
at ServerManager.Services.DigitalOceanService.AddDnsRecord(String ip, String subdomainName, String domainName) in C:\Users\chris\code\codestage\ServerManager\Services\DigitalOceanService.cs:line 83
at CodeStageConsole.Commands.CreateWordpressSiteCommand.Execute(IService serverManager, Int32 serverId, String siteName) in C:\Users\chris\code\codestage\CodeStageConsole\Commands\CreateWordpressSiteCommand.cs:line 24
at CodeStageConsole.Program.OnExecute() in C:\Users\chris\code\codestage\CodeStageConsole\Program.cs:line 65
at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.InvokeAsync(MethodInfo method, Object instance, Object[] arguments)
at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context)
at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass142_0.<OnExecute>b__0()
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](CommandLineContext context)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](IConsole console, String[] args)
at CodeStageConsole.Program.Main(String[] args) in C:\Users\chris\code\codestage\CodeStageConsole\Program.cs:line 32
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.