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.
<PackageVersion Include="OVHSDK" Version="0.3.60" />
                    
Directory.Packages.props
<PackageReference Include="OVHSDK" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version 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.
#addin nuget:?package=OVHSDK&version=0.3.60
                    
Install as a Cake Addin
#tool nuget:?package=OVHSDK&version=0.3.60
                    
Install as a Cake Tool

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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 110 1/25/2025
0.3.76 95 1/24/2025
0.3.75 97 1/23/2025
0.3.74 106 1/22/2025
0.3.73 96 1/21/2025
0.3.72 90 1/18/2025
0.3.71 82 1/17/2025
0.3.70 83 1/16/2025
0.3.69 52 1/15/2025
0.3.68 85 1/14/2025
0.3.67 85 1/12/2025
0.3.66 91 1/11/2025
0.3.65 86 1/10/2025
0.3.64 86 1/9/2025
0.3.63 80 1/8/2025
0.3.62 93 1/7/2025
0.3.61 108 12/29/2024
0.3.60 89 12/28/2024
0.3.59 91 12/25/2024
0.3.58 97 12/23/2024
0.3.57 108 12/22/2024
0.3.56 101 12/21/2024
0.3.55 110 12/20/2024
0.3.54 102 12/19/2024
0.3.53 109 12/18/2024
0.3.52 122 12/15/2024
0.3.51 111 12/14/2024
0.3.50 111 12/13/2024
0.3.49 100 12/12/2024
0.3.48 89 12/11/2024
0.3.47 93 12/10/2024
0.3.46 100 12/9/2024
0.3.45 111 12/6/2024
0.3.44 98 12/4/2024
0.3.43 96 12/3/2024
0.3.42 106 11/28/2024
0.3.41 96 11/27/2024
0.3.40 100 11/26/2024
0.3.39 107 11/23/2024
0.3.38 107 11/22/2024
0.3.37 94 11/21/2024
0.3.36 94 11/20/2024
0.3.35 98 11/19/2024
0.3.34 100 11/16/2024
0.3.33 106 11/14/2024
0.3.32 103 11/13/2024
0.3.31 107 11/8/2024
0.3.30 99 11/7/2024
0.3.29 98 11/6/2024
0.3.28 97 11/5/2024
0.3.27 110 11/2/2024
0.3.26 105 11/1/2024
0.3.25 97 10/31/2024
0.3.24 92 10/30/2024
0.3.23 99 10/29/2024
0.3.22 105 10/28/2024
0.3.21 104 10/27/2024
0.3.20 95 10/26/2024
0.3.19 101 10/25/2024
0.3.18 109 10/23/2024
0.3.17 103 10/22/2024
0.3.16 132 10/19/2024
0.3.15 132 10/18/2024
0.3.14 103 10/17/2024
0.3.13 99 10/16/2024
0.3.12 103 10/15/2024
0.3.11 101 10/14/2024
0.3.10 101 10/13/2024
0.3.9 111 10/11/2024
0.3.8 105 10/10/2024
0.3.7 110 10/9/2024
0.3.6 104 10/8/2024
0.3.5 123 10/2/2024
0.3.4 130 10/1/2024
0.3.3 113 10/1/2024
0.3.2 120 9/30/2024
0.3.1 120 9/28/2024