-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ViewConsole fake command (no API call exists for this!)
- Loading branch information
1 parent
f85fb9e
commit f4d27e3
Showing
10 changed files
with
170 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
[assembly: AssemblyVersion("4.8.0.10")] | ||
[assembly: AssemblyFileVersion("4.8.0.10")] | ||
[assembly: AssemblyInformationalVersion("4.8.0.10")] | ||
[assembly: AssemblyVersion("4.8.0.12")] | ||
[assembly: AssemblyFileVersion("4.8.0.12")] | ||
[assembly: AssemblyInformationalVersion("4.8.0.12")] | ||
|
||
[assembly: CLSCompliant(true)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CloudStack.Net | ||
{ | ||
public abstract class CustomResponse | ||
{ | ||
public abstract void DecodeResponse(string response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
|
||
namespace CloudStack.Net | ||
{ | ||
public class ViewConsoleRequest : APIRequest | ||
{ | ||
// client/console?cmd=access&vm=vmid | ||
|
||
public ViewConsoleRequest() : base("-ViewConsole-") | ||
{ | ||
Parameters.Clear(); | ||
Parameters.Add("cmd", "access"); | ||
} | ||
|
||
/// <summary> | ||
/// the name of the physical network | ||
/// </summary> | ||
public Guid VirtualMachineId | ||
{ | ||
get { return GetParameterValue<Guid>("vm"); } | ||
set { SetParameterValue("vm", value); } | ||
} | ||
|
||
internal override string OverrideEndpoint => "console"; | ||
internal override bool OverrideDecodeResponse => true; | ||
} | ||
|
||
public class ViewConsoleResponse : CustomResponse | ||
{ | ||
private static Regex _rxResponse = new Regex(@"^<html><title>(?<title>.+)</title><frameset><frame src=""(?<url>.*)""></frame></frameset></html>$", RegexOptions.ExplicitCapture | RegexOptions.Compiled); | ||
|
||
public string Name { get; set; } | ||
public string Url { get; set; } | ||
|
||
public override void DecodeResponse(string response) | ||
{ | ||
Match m = _rxResponse.Match(response); | ||
if (!m.Success) | ||
{ | ||
throw new FormatException("Console response was not of the expected format:\n\n" + response); | ||
} | ||
|
||
Name = m.Groups["name"].Value; | ||
Url = m.Groups["url"].Value; | ||
} | ||
} | ||
|
||
public partial interface ICloudStackAPIClient | ||
{ | ||
ViewConsoleResponse ViewConsole(ViewConsoleRequest request); | ||
Task<ViewConsoleResponse> ViewConsoleAsync(ViewConsoleRequest request); | ||
} | ||
|
||
public partial class CloudStackAPIClient : ICloudStackAPIClient | ||
{ | ||
public ViewConsoleResponse ViewConsole(ViewConsoleRequest request) => _proxy.Request<ViewConsoleResponse>(request); | ||
public Task<ViewConsoleResponse> ViewConsoleAsync(ViewConsoleRequest request) => _proxy.RequestAsync<ViewConsoleResponse>(request); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters