Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 1.44 KB

README.md

File metadata and controls

40 lines (30 loc) · 1.44 KB

C# SDK for vSphere 7.0.3

SDK compatable with .net 6.0 for vSphere 7.0.3 RestAPI engins. It uses RestSharp as the transport and Newtonsoft.Json for JSON handeling.

Modules

All available modules are included:

vSphereClient vsphere = new vSphereClient("vc01.lab.local", "[email protected]", "VMware1!", false);
await vsphere.LoginAsync();

var vms = await vsphere.VcenterSubModule.VMModule.ListAsync();
var testvm = await vsphere.VcenterSubModule.VMModule.GetAsync(vms[0].Vm);

var resourcepools = await vsphere.VcenterSubModule.ResourcePoolModule.ListAsync();
var rpdetails = await vsphere.VcenterSubModule.ResourcePoolModule.GetAsync(resourcepools[0].ResourcePool);

Custom JsonSerializerSettings

You can pass your own serialization settings as part of the client init code

vSphereClient vsphere = new vSphereClient(
    "vc01.lab.local", 
    "[email protected]", 
    "VMware1!", 
    false, 
    new Newtonsoft.Json.JsonSerializerSettings() {  
        Error = (se, ev) => { ev.ErrorContext.Handled = true; },
        DefaultValueHandling = DefaultValueHandling.Include,
        TypeNameHandling = TypeNameHandling.Auto,
        NullValueHandling = NullValueHandling.Ignore,
        Formatting = Formatting.None,
        ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
        Converters = new List<JsonConverter>() { new Newtonsoft.Json.Converters.StringEnumConverter() }
    });