OVHSDK 0.3.32
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package OVHSDK --version 0.3.32
NuGet\Install-Package OVHSDK -Version 0.3.32
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.32" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OVHSDK --version 0.3.32
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: OVHSDK, 0.3.32"
#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.32 // Install OVHSDK as a Cake Tool #tool nuget:?package=OVHSDK&version=0.3.32
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | Versions 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. |
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.33 | 0 | 11/14/2024 |
0.3.32 | 61 | 11/13/2024 |
0.3.31 | 71 | 11/8/2024 |
0.3.30 | 66 | 11/7/2024 |
0.3.29 | 62 | 11/6/2024 |
0.3.28 | 65 | 11/5/2024 |
0.3.27 | 76 | 11/2/2024 |
0.3.26 | 68 | 11/1/2024 |
0.3.25 | 64 | 10/31/2024 |
0.3.24 | 59 | 10/30/2024 |
0.3.23 | 66 | 10/29/2024 |
0.3.22 | 74 | 10/28/2024 |
0.3.21 | 72 | 10/27/2024 |
0.3.20 | 64 | 10/26/2024 |
0.3.19 | 63 | 10/25/2024 |
0.3.18 | 70 | 10/23/2024 |
0.3.17 | 70 | 10/22/2024 |
0.3.16 | 102 | 10/19/2024 |
0.3.15 | 102 | 10/18/2024 |
0.3.14 | 74 | 10/17/2024 |
0.3.13 | 69 | 10/16/2024 |
0.3.12 | 74 | 10/15/2024 |
0.3.11 | 73 | 10/14/2024 |
0.3.10 | 74 | 10/13/2024 |
0.3.9 | 82 | 10/11/2024 |
0.3.8 | 76 | 10/10/2024 |
0.3.7 | 80 | 10/9/2024 |
0.3.6 | 72 | 10/8/2024 |
0.3.5 | 89 | 10/2/2024 |
0.3.4 | 101 | 10/1/2024 |
0.3.3 | 85 | 10/1/2024 |
0.3.2 | 90 | 9/30/2024 |
0.3.1 | 92 | 9/28/2024 |