OVHSDK 0.3.60

There is a newer version of this package available.
See the version list below for details.
dotnet add package OVHSDK --version 0.3.60                
NuGet\Install-Package OVHSDK -Version 0.3.60                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OVHSDK" Version="0.3.60" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OVHSDK --version 0.3.60                
#r "nuget: OVHSDK, 0.3.60"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install OVHSDK as a Cake Addin
#addin nuget:?package=OVHSDK&version=0.3.60

// Install OVHSDK as a Cake Tool
#tool nuget:?package=OVHSDK&version=0.3.60                

NuGet Version

Authentication

There are three ways to authenticate with OVH:

  • Application key, application secret, and consumer key
  • Client ID and Client Secret
  • Token

There is an authentication implementation for each method:

  • Ovh.Sdk.Net.AuthProviders.Application
  • Ovh.Sdk.Net.AuthProviders.OAuth2
  • Ovh.Sdk.Net.AuthProviders.Token

Refer to the examples for usage.

Samples

SA creation, attach policy and SA login

using _iam_policy;
using _oauth2;
using Ovh.Sdk.Net;
using Ovh.Sdk.Net.AuthProviders;
using Action = _iam_policy.Action;

// Login with an application

// Fetch credentials from environment variables (OVH_APPLICATION_KEY, OVH_APPLICATION_SECRET, OVH_CONSUMER_KEY)
var applicationProvider = new Application();

// Uncomment this line to log all requests and responses
//var handler = new LogHandler(new HttpClientHandler());
var handler = new HttpClientHandler();

var adminClient = new Client(new HttpClient(handler)
{
    BaseAddress = new Uri("https://eu.api.ovh.com"),
}, applicationProvider);

// Create a service account

var serviceAccount = await adminClient.PostV1MeApiOauth2ClientAsync(new clientRequest
{
    Name = "ProjectViewer",
    Description = "Service account to view all projects",
    CallbackUrls = [],
    Flow = ClientFlowEnum.CLIENT_CREDENTIALS,
});
var saInfos = await adminClient.GetV1MeApiOauth2ClientClientIdAsync(serviceAccount.ClientId);

// Upsert the policy for the service account

var activePolicies = await adminClient.GetV2IamPolicyAsync();
var policy = activePolicies.FirstOrDefault(x => x.Name == "OvhSdkNet_Sample");
if (policy == null)
{
    policy = await adminClient.PostV2IamPolicyAsync(new Creation
    {
        Description = "View all projects",
        Identities = [saInfos.Identity],
        Name = "OvhSdkNet_Sample",
        Permissions = new Permissions
        {
            Allow =
            [
                new Action
                {
                    _Action = "publicCloudProject:apiovh:get"
                }
            ]
        },
        Resources = [new Resource { Urn = "urn:v1:eu:resource:publicCloudProject:*" }]
    });
}
else
{
    await adminClient.PutV2IamPolicyPolicyIdAsync(new Update
    {
        Description = "View all projects",
        Identities = [saInfos.Identity],
        Name = "OvhSdkNet_Sample",
        Permissions = new Permissions
        {
            Allow =
            [
                new Action
                {
                    _Action = "publicCloudProject:apiovh:get"
                }
            ]
        },
        Resources = [new Resource { Urn = "urn:v1:eu:resource:publicCloudProject:*" }]
    }, policy.Id);
}

// Login with the service account

var oauthProvider = new OAuth2(serviceAccount.ClientId, serviceAccount._ClientSecret, "https://www.ovh.com/auth/oauth2/token");

var serviceAccountClient = new Client(new HttpClient(handler)
{
    BaseAddress = new Uri("https://eu.api.ovh.com"),
}, oauthProvider);

// Get all projects with our new service account

var projects = await serviceAccountClient.GetV1CloudProjectAsync();
foreach (var project in projects)
{
    var projectInfo = await serviceAccountClient.GetV1CloudProjectServiceNameAsync(project);
    Console.WriteLine($"{project}: {projectInfo.Description}");
}

// Cleanup the service account and policy

await adminClient.DeleteV2IamPolicyPolicyIdAsync(policy.Id);
await adminClient.DeleteV1MeApiOauth2ClientClientIdAsync(serviceAccount.ClientId);
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.77 37 1/25/2025
0.3.76 44 1/24/2025
0.3.75 47 1/23/2025
0.3.74 67 1/22/2025
0.3.73 63 1/21/2025
0.3.72 64 1/18/2025
0.3.71 65 1/17/2025
0.3.70 67 1/16/2025
0.3.69 37 1/15/2025
0.3.68 57 1/14/2025
0.3.67 66 1/12/2025
0.3.66 69 1/11/2025
0.3.65 66 1/10/2025
0.3.64 51 1/9/2025
0.3.63 51 1/8/2025
0.3.62 63 1/7/2025
0.3.61 89 12/29/2024
0.3.60 78 12/28/2024
0.3.59 79 12/25/2024
0.3.58 85 12/23/2024
0.3.57 97 12/22/2024
0.3.56 86 12/21/2024
0.3.55 92 12/20/2024
0.3.54 89 12/19/2024
0.3.53 96 12/18/2024
0.3.52 103 12/15/2024
0.3.51 94 12/14/2024
0.3.50 97 12/13/2024
0.3.49 86 12/12/2024
0.3.48 77 12/11/2024
0.3.47 79 12/10/2024
0.3.46 87 12/9/2024
0.3.45 100 12/6/2024
0.3.44 85 12/4/2024
0.3.43 86 12/3/2024
0.3.42 95 11/28/2024
0.3.41 85 11/27/2024
0.3.40 89 11/26/2024
0.3.39 97 11/23/2024
0.3.38 97 11/22/2024
0.3.37 83 11/21/2024
0.3.36 84 11/20/2024
0.3.35 89 11/19/2024
0.3.34 91 11/16/2024
0.3.33 97 11/14/2024
0.3.32 94 11/13/2024
0.3.31 97 11/8/2024
0.3.30 92 11/7/2024
0.3.29 88 11/6/2024
0.3.28 89 11/5/2024
0.3.27 102 11/2/2024
0.3.26 93 11/1/2024
0.3.25 86 10/31/2024
0.3.24 83 10/30/2024
0.3.23 90 10/29/2024
0.3.22 96 10/28/2024
0.3.21 96 10/27/2024
0.3.20 86 10/26/2024
0.3.19 85 10/25/2024
0.3.18 93 10/23/2024
0.3.17 92 10/22/2024
0.3.16 123 10/19/2024
0.3.15 123 10/18/2024
0.3.14 94 10/17/2024
0.3.13 89 10/16/2024
0.3.12 95 10/15/2024
0.3.11 92 10/14/2024
0.3.10 93 10/13/2024
0.3.9 101 10/11/2024
0.3.8 95 10/10/2024
0.3.7 101 10/9/2024
0.3.6 95 10/8/2024
0.3.5 107 10/2/2024
0.3.4 120 10/1/2024
0.3.3 103 10/1/2024
0.3.2 111 9/30/2024
0.3.1 111 9/28/2024