Skip to content

Commit

Permalink
master
Browse files Browse the repository at this point in the history
  • Loading branch information
phspies committed Jun 16, 2022
1 parent 5bc0fef commit ee74d04
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion vSphereSDKTesting/BasicTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class BasicTest
[Fact]
public async void Test1()
{
vSphereClient vsphere = new vSphereClient("vc01.lab.local", "[email protected]", "VMware1!", false);
vSphereClient vsphere = new vSphereClient("vc01.lab.loca1l", "[email protected]", "VMware1!", false);
await vsphere.LoginAsync();
var vms = await vsphere.VcenterSubModule.VMModule.ListAsync();
var templateimage = await vsphere.VcenterSubModule.VMModule.GetAsync(vms.Single(x => x.Name.Equals("ubuntutemplate")).Vm);
Expand Down
2 changes: 1 addition & 1 deletion vspheresdk/Authentication/Login.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static async Task<RestResponse<LoginResponseType>> LoginAsync(RestClient
if (response.StatusCode != HttpStatusCode.OK)
{
var message = "Login operation to " + GetLoginURL.ToString() + " did not complete successfully";
throw new vSphereException(message, (int)response.StatusCode, response.Content, response.Headers, response.ErrorException);
throw new vSphereException(message, (int)response.StatusCode, response.Content ?? response.ErrorMessage, response.Headers, response.ErrorException);
}
return response;
}
Expand Down
31 changes: 15 additions & 16 deletions vspheresdk/vSphereClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ public class vSphereClient
private RestClient tokenRestClient { get; set; }
private RestClient sessionRestClient { get; set; }
private CancellationToken cancellationToken;
private int timeout;
private int retry;
public int Timeout;
public int Retry;
public LoginResponseType LoginResponseDetails;

public vSphereClient(string Host, string Username, string Password, bool? RemoteCertificateValidation = true, JsonSerializerSettings? DefaultSerializationSettings = null, CancellationToken _cancellationToken = default(CancellationToken), int Port = 443, int _timeout = 100, int _retry = 2, string _defaultXAviVerion = null)
{
cancellationToken = _cancellationToken;
timeout = _timeout;
retry = _retry;

Timeout = _timeout;
Retry = _retry;

var tokenUri = new UriBuilder(Host)
{
Expand Down Expand Up @@ -66,7 +65,7 @@ public class vSphereClient
}
public async Task<LoginResponseType> LoginAsync()
{
RestResponse<LoginResponseType> response = await AuthenticationHelper.LoginAsync(sessionRestClient, cancellationToken, timeout, retry);
RestResponse<LoginResponseType> response = await AuthenticationHelper.LoginAsync(sessionRestClient, cancellationToken, Timeout, Retry);
ArgumentNullException.ThrowIfNull(response.Data.Value);

tokenRestClient.AddDefaultHeader("vmware-api-session-id", response.Data.Value);
Expand All @@ -75,20 +74,20 @@ public async Task<LoginResponseType> LoginAsync()
}
public async Task LogoutAsync()
{
await AuthenticationHelper.LogoutAsync(sessionRestClient, cancellationToken, timeout, retry);
await AuthenticationHelper.LogoutAsync(sessionRestClient, cancellationToken, Timeout, Retry);
}
public async Task<string> RetrieveAsync()
{
return await AuthenticationHelper.RetrieveAsync(sessionRestClient, cancellationToken, timeout, retry);
return await AuthenticationHelper.RetrieveAsync(sessionRestClient, cancellationToken, Timeout, Retry);
}
public ApplianceSubModule ApplianceSubModule => new ApplianceSubModule(tokenRestClient, cancellationToken, timeout, retry);
public CisSubModule CisSubModule => new CisSubModule(tokenRestClient, cancellationToken, timeout, retry);
public EsxSubModule EsxSubModule => new EsxSubModule(tokenRestClient, cancellationToken, timeout, retry);
public HvcSubModule HvcSubModule => new HvcSubModule(tokenRestClient, cancellationToken, timeout, retry);
public LibrarySubModule LibrarySubModule => new LibrarySubModule(tokenRestClient, cancellationToken, timeout, retry);
public StatsSubModule StatsSubModule => new StatsSubModule(tokenRestClient, cancellationToken, timeout, retry);
public VapiSubModule VapiSubModule => new VapiSubModule(tokenRestClient, cancellationToken, timeout, retry);
public VcenterSubModule VcenterSubModule => new VcenterSubModule(tokenRestClient, cancellationToken, timeout, retry);
public ApplianceSubModule ApplianceSubModule => new ApplianceSubModule(tokenRestClient, cancellationToken, Timeout, Retry);
public CisSubModule CisSubModule => new CisSubModule(tokenRestClient, cancellationToken, Timeout, Retry);
public EsxSubModule EsxSubModule => new EsxSubModule(tokenRestClient, cancellationToken, Timeout, Retry);
public HvcSubModule HvcSubModule => new HvcSubModule(tokenRestClient, cancellationToken, Timeout, Retry);
public LibrarySubModule LibrarySubModule => new LibrarySubModule(tokenRestClient, cancellationToken, Timeout, Retry);
public StatsSubModule StatsSubModule => new StatsSubModule(tokenRestClient, cancellationToken, Timeout, Retry);
public VapiSubModule VapiSubModule => new VapiSubModule(tokenRestClient, cancellationToken, Timeout, Retry);
public VcenterSubModule VcenterSubModule => new VcenterSubModule(tokenRestClient, cancellationToken, Timeout, Retry);

}
}

0 comments on commit ee74d04

Please sign in to comment.