{"id":18446533,"url":"https://github.com/ovh/csharp-ovh","last_synced_at":"2025-04-08T00:31:53.205Z","repository":{"id":8626696,"uuid":"56860664","full_name":"ovh/csharp-ovh","owner":"ovh","description":"Thin wrapper around OVH's APIs. Handles all the hard work including credential creation and requests signing","archived":false,"fork":false,"pushed_at":"2025-02-25T13:56:14.000Z","size":133,"stargazers_count":29,"open_issues_count":3,"forks_count":24,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-03-23T03:11:20.437Z","etag":null,"topics":["api-wrapper","csharp","netcore2","ovh","ovh-api","sdk"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ovh.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-22T14:19:09.000Z","updated_at":"2025-03-07T18:29:37.000Z","dependencies_parsed_at":"2023-01-11T17:26:05.370Z","dependency_job_id":null,"html_url":"https://github.com/ovh/csharp-ovh","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovh%2Fcsharp-ovh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovh%2Fcsharp-ovh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovh%2Fcsharp-ovh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovh%2Fcsharp-ovh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ovh","download_url":"https://codeload.github.com/ovh/csharp-ovh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247755388,"owners_count":20990616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-wrapper","csharp","netcore2","ovh","ovh-api","sdk"],"created_at":"2024-11-06T07:09:37.838Z","updated_at":"2025-04-08T00:31:53.198Z","avatar_url":"https://github.com/ovh.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":".. image:: https://badge.fury.io/nu/csharp-ovh.svg\n    :target: https://www.nuget.org/packages/csharp-ovh\n\nLightweight wrapper around OVH's APIs. Handles all the hard work including\ncredential creation and requests signing.\n\n.. code:: csharp\n\n    using Ovh.Api;\n    using System;\n\n    namespace api_tester\n    {\n        class Program\n        {\n            static async Task Main(string[] args)\n            {\n                // Instantiate. Visit https://api.ovh.com/createToken/index.cgi?GET=/me\n                // to get your credentials\n                Client client = new Client(\"ovh-eu\", \"\u003capplication_key\u003e\", \"\u003capplication_secret\u003e\", \"\u003cconsumer_key\u003e\");\n                PartialMe me = await client.GetAsync\u003cPartialMe\u003e(\"/me\");\n\n                // Print nice welcome message\n                Console.WriteLine(String.Format(\"Hello {0}!\", me.firstname));\n                Console.ReadLine();\n            }\n        }\n\n        class PartialMe\n        {\n            public string firstname { get; set; }\n            public string name { get; set; }\n        }\n    }\n\nInstallation\n============\n\nThe easiest way to get the latest stable release is to grab it from `NuGet\n\u003chttps://www.nuget.org\u003e`_.\n\n.. code:: bash\n\n    nuget install csharp-ovh\n\nExample Usage\n=============\n\nUse the API on behalf of a user\n-------------------------------\n\n1. Create an application\n************************\n\nTo interact with the APIs, the SDK needs to identify itself using an\n``application_key`` and an ``application_secret``. To get them, you need\nto register your application. Depending the API you plan to use, visit:\n\n- `OVH Europe \u003chttps://eu.api.ovh.com/createApp/\u003e`_\n- `OVH US \u003chttps://api.us.ovhcloud.com/createApp/\u003e`_\n- `OVH North-America \u003chttps://ca.api.ovh.com/createApp/\u003e`_\n- `So you Start Europe \u003chttps://eu.api.soyoustart.com/createApp/\u003e`_\n- `So you Start North America \u003chttps://ca.api.soyoustart.com/createApp/\u003e`_\n- `Kimsufi Europe \u003chttps://eu.api.kimsufi.com/createApp/\u003e`_\n- `Kimsufi North America \u003chttps://ca.api.kimsufi.com/createApp/\u003e`_\n- `RunAbove \u003chttps://api.runabove.com/createApp/\u003e`_\n\nOnce created, you will obtain an **application key (AK)** and an **application\nsecret (AS)**.\n\n2. Configure your application\n*****************************\n\nThe easiest and safest way to use your application's credentials is to create a\n``.ovh.conf`` configuration file in application's working directory. Here is how\nit looks like:\n\n.. code:: ini\n\n    [default]\n    ; general configuration: default endpoint\n    endpoint=ovh-eu\n\n    [ovh-eu]\n    ; configuration specific to 'ovh-eu' endpoint\n    application_key=my_app_key\n    application_secret=my_application_secret\n    ; uncomment following line when writing a script application\n    ; with a single consumer key.\n    ;consumer_key=my_consumer_key\n\nDepending on the API you want to use, you may set the ``endpoint`` to:\n\n* ``ovh-eu`` for OVH Europe API\n* ``ovh-us`` for OVH US API\n* ``ovh-ca`` for OVH North-America API\n* ``soyoustart-eu`` for So you Start Europe API\n* ``soyoustart-ca`` for So you Start North America API\n* ``kimsufi-eu`` for Kimsufi Europe API\n* ``kimsufi-ca`` for Kimsufi North America API\n* ``runabove-ca`` for RunAbove API\n\nSee Configuration_ for more information on available configuration mechanisms.\n\n.. note:: When using a versioning system, make sure to add ``.ovh.conf`` to ignored\n          files. It contains confidential/security-sensitive informations!\n\n3. Authorize your application to access a customer account\n**********************************************************\n\nTo allow your application to access a customer account using the API on your\nbehalf, you need a **consumer key (CK)**.\n\nHere is a sample code you can use to allow your application to access a\ncustomer's informations:\n\n.. code:: csharp\n\n    using Ovh.Api;\n    using Ovh.Api.Models;\n    using System;\n    using System.Collections.Generic;\n\n    namespace api_tester\n    {\n        class Program\n        {\n            static async Task Main(string[] args)\n            {\n                Client client = new Client();\n                CredentialRequest requestPayload = new CredentialRequest(\n                    new List\u003cAccessRight\u003e(){\n                        new AccessRight(\"GET\", \"/me\")\n                    },\n                    \"https://redirect.url\" // Change this URL if you don't want to see an unreachable webpage after you validated your consumer key. An unreachable webpage does not mean that the validation has failed.\n                );\n\n                CredentialRequestResult credentialRequestResult =\n                    await client.RequestConsumerKeyAsync(requestPayload);\n                Console.Write(\n                    String.Format(\"Please visit {0} to authenticate \",\n                        credentialRequestResult.ValidationUrl));\n                Console.WriteLine(\"and press enter to continue\");\n                Console.ReadLine();\n\n                client.ConsumerKey = credentialRequestResult.ConsumerKey;\n                PartialMe me = await client.GetAsync\u003cPartialMe\u003e(\"/me\");\n\n                Console.WriteLine(\n                    String.Format(\"Welcome, {0}\", me.firstname));\n                Console.WriteLine(\n                    String.Format(\"Btw, your 'consumerKey' is {0}\",\n                        credentialRequestResult.ConsumerKey));\n                Console.ReadLine();\n            }\n        }\n\n        class PartialMe\n        {\n            public string firstname { get; set; }\n            public string name { get; set; }\n        }\n    }\n\n\n\nReturned ``consumerKey`` should then be kept to avoid re-authenticating your\nend-user on each use.\n\n.. note:: To request full and unlimited access to the API, you may use wildcards:\n\n.. code:: csharp\n\n    new List\u003cAccessRight\u003e(){\n        new AccessRight(\"GET\", \"/*\"),\n        new AccessRight(\"PUT\", \"/*\"),\n        new AccessRight(\"POST\", \"/*\"),\n        new AccessRight(\"DELETE\", \"/*\"),\n    }\n\nInstall a new mail redirection\n------------------------------\n\ne-mail redirections may be freely configured on domains and DNS zones hosted by\nOVH to an arbitrary destination e-mail using API call\n``POST /email/domain/{domain}/redirection``.\n\n.. code:: csharp\n\n    using Ovh.Api;\n    using System;\n    using System.Collections.Generic;\n    using Newtonsoft.Json;\n\n    namespace api_tester\n    {\n        class Program\n        {\n            static void Main(string[] args)\n            {\n                Client client = new Client();\n\n                string domain = \"\u003csomeDomain\u003e\";\n                string source = \"\u003csourceEmail\u003e\";\n                string destination = \"\u003cdestinationEmail\u003e\";\n\n                Dictionary\u003cstring, object\u003e payload = new Dictionary\u003cstring, object\u003e();\n                payload.Add(\"from\", source);\n                payload.Add(\"to\", destination);\n                payload.Add(\"localCopy\", false);\n\n                client.PostAsync(\n                    String.Format(\"/email/domain/{0}/redirection\", domain),\n                    payload\n                ).Wait();\n\n                Console.WriteLine(\n                    String.Format(\"Installed new mail redirection from {0} to {1}\",\n                        source, destination));\n                Console.ReadLine();\n            }\n        }\n    }\n\n\n\nGrab bill list\n--------------\n\nLet's say you want to integrate OVH bills into your own billing system, you\ncould just script around the ``/me/bills`` endpoints and even get the details\nof each bill lines using ``/me/bill/{billId}/details/{billDetailId}``.\n\nThis example assumes an existing Configuration_ with valid ``application_key``,\n``application_secret`` and ``consumer_key``.\n\n.. code:: csharp\n\n    using Ovh.Api;\n    using System;\n    using System.Collections.Generic;\n\n    namespace api_tester\n    {\n        class Program\n        {\n            static async Task Main(string[] args)\n            {\n                Client client = new Client();\n                var billIds = await client.GetAsync\u003cList\u003cstring\u003e\u003e(\"/me/bill\");\n                foreach (var billId in billIds)\n                {\n                    PartialOvhBill details = await client.GetAsync\u003cPartialOvhBill\u003e(\"/me/bill/\" + billId);\n                    Console.WriteLine(\n                        String.Format(\"{0} ({1}): {2} --\u003e {3}\",\n                            billId, details.date, details.priceWithTax.text, details.pdfUrl));\n                }\n                Console.ReadLine();\n            }\n        }\n\n        class PartialOvhBill\n        {\n            public string date { get; set; }\n            public string pdfUrl { get; set; }\n\n            public OvhPrice priceWithTax { get; set; }\n        }\n\n        class OvhPrice\n        {\n            public string currencyCode { get; set; }\n            public double value { get; set; }\n            public string text { get; set; }\n        }\n    }\n\n\nEnable network burst in SBG1\n----------------------------\n\n'Network burst' is a free service but is opt-in. What if you have, say, 10\nservers in ``SBG-1`` datacenter? You certainely don't want to activate it\nmanually for each servers. You could take advantage of a code like this.\n\nThis example assumes an existing Configuration_ with valid ``application_key``,\n``application_secret`` and ``consumer_key``.\n\n.. code:: csharp\n\n    using Ovh.Api;\n    using System;\n    using System.Collections.Generic;\n\n    namespace api_tester\n    {\n        class Program\n        {\n            static async Task Main(string[] args)\n            {\n                Client client = new Client();\n\n                var serverIds = await client.GetAsync\u003cList\u003cstring\u003e\u003e(\"/dedicated/server/\");\n                foreach (var serverId in serverIds)\n                {\n                    string serverUrl = \"/dedicated/server/\" + serverId;\n                    var details = await client.GetAsync\u003cPartialDedicatedServer\u003e(serverUrl);\n                    if (details.datacenter == \"sbg1\")\n                    {\n                        await client.PutStringAsync(serverUrl + \"/burst\", \"{\\\"status\\\":\\\"active\\\"}\");\n                        Console.WriteLine(\"Burst enabled on server \" + serverId);\n                    }\n                }\n                Console.ReadLine();\n            }\n        }\n\n        class PartialDedicatedServer\n        {\n            public string datacenter { get; set; }\n        }\n    }\n\n\nList application authorized to access your account\n--------------------------------------------------\n\nThanks to the application key / consumer key mechanism, it is possible to\nfinely track applications having access to your data and revoke this access.\nThis examples lists validated applications. It could easily be adapted to\nmanage revocation too.\n\nThis example assumes an existing Configuration_ with valid ``application_key``,\n``application_secret`` and ``consumer_key``.\n\n.. code:: csharp\n\n    using Ovh.Api;\n    using System;\n    using System.Collections.Generic;\n    using System.Collections.Specialized;\n    using System.Text;\n\n    namespace api_tester\n    {\n        class Program\n        {\n            static async Task Main(string[] args)\n            {\n                Client client = new Client();\n\n                QueryStringParams qsp = new QueryStringParams();\n                qsp.Add(\"status\", \"validated\");\n\n                var credentialIds = await client.GetAsync\u003cList\u003cstring\u003e\u003e(\"/me/api/credential\", qsp);\n                foreach (var credentialId in credentialIds)\n                {\n                    string credentialUrl = \"/me/api/credential/\" + credentialId;\n                    var credential = await client.GetAsync\u003cPartialCredential\u003e(credentialUrl);\n                    var application = await client.GetAsync\u003cPartialApplication\u003e(credentialUrl + \"/application\");\n\n                    StringBuilder sb = new StringBuilder();\n                    sb.Append(credentialId).Append(\" \").Append(application.status)\n                        .Append(\" \").Append(application.name).Append(\" \")\n                        .Append(application.description).Append(\" \")\n                        .Append(credential.creation).Append(\" \")\n                        .Append(credential.expiration).Append(\" \")\n                        .Append(credential.lastUse);\n                    Console.WriteLine(sb.ToString());\n                }\n                Console.ReadLine();\n            }\n        }\n\n        class PartialCredential\n        {\n            public string creation{ get; set; }\n            public string expiration { get; set; }\n            public string lastUse { get; set; }\n        }\n\n        class PartialApplication\n        {\n            public string name { get; set; }\n            public string description { get; set; }\n            public string status { get; set; }\n        }\n    }\n\nConfiguration\n=============\n\nThe straightforward way to use OVH's API keys is to embed them directly in the\napplication code. While this is very convenient, it lacks of elegance and\nflexibility.\n\nAlternatively it is suggested to use configuration files or environment\nvariables so that the same code may run seamlessly in multiple environments.\nProduction and development for instance.\n\nThis wrapper will first look for direct instanciation parameters then\n``OVH_ENDPOINT``, ``OVH_APPLICATION_KEY``, ``OVH_APPLICATION_SECRET`` and\n``OVH_CONSUMER_KEY`` environment variables. If either of these parameter is not\nprovided, it will look for a configuration file of the form:\n\n.. code:: ini\n\n    [default]\n    ; general configuration: default endpoint\n    endpoint=ovh-eu\n\n    [ovh-eu]\n    ; configuration specific to 'ovh-eu' endpoint\n    application_key=my_app_key\n    application_secret=my_application_secret\n    consumer_key=my_consumer_key\n\nThe client will successively attempt to locate this configuration file in\n\n1. Current working directory: ``./.ovh.conf``\n2. Current user's home directory ``%USERPROFILE%/.ovh.conf``\n\nThis lookup mechanism makes it easy to overload credentials for a specific\nproject or user.\n\nSupported APIs\n==============\n\nOVH Europe\n----------\n\n- **Documentation**: https://eu.api.ovh.com/\n- **Community support**: api-subscribe@ml.ovh.net\n- **Console**: https://eu.api.ovh.com/console\n- **Create application credentials**: https://eu.api.ovh.com/createApp/\n- **Create script credentials** (all keys at once): https://eu.api.ovh.com/createToken/\n\nOVH US\n----------\n\n- **Documentation**: https://api.us.ovhcloud.com/\n- **Community support**: api-subscribe@ml.ovh.net\n- **Console**: https://api.us.ovhcloud.com/console/\n- **Create application credentials**: https://api.us.ovhcloud.com/createApp/\n- **Create script credentials** (all keys at once): https://api.us.ovhcloud.com/createToken/\n\nOVH North America\n-----------------\n\n- **Documentation**: https://ca.api.ovh.com/\n- **Community support**: api-subscribe@ml.ovh.net\n- **Console**: https://ca.api.ovh.com/console\n- **Create application credentials**: https://ca.api.ovh.com/createApp/\n- **Create script credentials** (all keys at once): https://ca.api.ovh.com/createToken/\n\nSo you Start Europe\n-------------------\n\n- **Documentation**: https://eu.api.soyoustart.com/\n- **Community support**: api-subscribe@ml.ovh.net\n- **Console**: https://eu.api.soyoustart.com/console/\n- **Create application credentials**: https://eu.api.soyoustart.com/createApp/\n- **Create script credentials** (all keys at once): https://eu.api.soyoustart.com/createToken/\n\nSo you Start North America\n--------------------------\n\n- **Documentation**: https://ca.api.soyoustart.com/\n- **Community support**: api-subscribe@ml.ovh.net\n- **Console**: https://ca.api.soyoustart.com/console/\n- **Create application credentials**: https://ca.api.soyoustart.com/createApp/\n- **Create script credentials** (all keys at once): https://ca.api.soyoustart.com/createToken/\n\nKimsufi Europe\n--------------\n\n- **Documentation**: https://eu.api.kimsufi.com/\n- **Community support**: api-subscribe@ml.ovh.net\n- **Console**: https://eu.api.kimsufi.com/console/\n- **Create application credentials**: https://eu.api.kimsufi.com/createApp/\n- **Create script credentials** (all keys at once): https://eu.api.kimsufi.com/createToken/\n\nKimsufi North America\n---------------------\n\n- **Documentation**: https://ca.api.kimsufi.com/\n- **Community support**: api-subscribe@ml.ovh.net\n- **Console**: https://ca.api.kimsufi.com/console/\n- **Create application credentials**: https://ca.api.kimsufi.com/createApp/\n- **Create script credentials** (all keys at once): https://ca.api.kimsufi.com/createToken/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovh%2Fcsharp-ovh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fovh%2Fcsharp-ovh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovh%2Fcsharp-ovh/lists"}